Refactor internal format pixel math methods.
This removes the use of the ErrorOrResult class from these methods.
This will enable more performant Error handling. Also cleans up the
ANGLE_TRY_CHECKED_MATH macro to be more general.
Bug: angleproject:2713
Change-Id: I349947d320907839ca88ec1f9251e6ddc3858a08
Reviewed-on: https://chromium-review.googlesource.com/1128920
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 30ff34d..8422216 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -975,18 +975,16 @@
const auto &unpack = context->getGLState().getUnpackState();
bool targetIs3D = texType == TextureType::_3D || texType == TextureType::_2DArray;
- auto endByteOrErr = formatInfo.computePackUnpackEndByte(type, size, unpack, targetIs3D);
- if (endByteOrErr.isError())
+ GLuint endByte = 0;
+ if (!formatInfo.computePackUnpackEndByte(type, size, unpack, targetIs3D, &endByte))
{
- context->handleError(endByteOrErr.getError());
+ ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false;
}
- GLuint endByte = endByteOrErr.getResult();
-
if (pixelUnpackBuffer)
{
- CheckedNumeric<size_t> checkedEndByte(endByteOrErr.getResult());
+ CheckedNumeric<size_t> checkedEndByte(endByte);
CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(pixels));
checkedEndByte += checkedOffset;
@@ -994,7 +992,7 @@
(checkedEndByte.ValueOrDie() > static_cast<size_t>(pixelUnpackBuffer->getSize())))
{
// Overflow past the end of the buffer
- context->handleError(InvalidOperation());
+ ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false;
}
if (context->getExtensions().webglCompatibility &&
@@ -5781,14 +5779,13 @@
const gl::Extents size(width, height, 1);
const auto &pack = context->getGLState().getPackState();
- auto endByteOrErr = formatInfo.computePackUnpackEndByte(type, size, pack, false);
- if (endByteOrErr.isError())
+ GLuint endByte = 0;
+ if (!formatInfo.computePackUnpackEndByte(type, size, pack, false, &endByte))
{
- context->handleError(endByteOrErr.getError());
+ ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false;
}
- size_t endByte = endByteOrErr.getResult();
if (bufSize >= 0)
{
if (pixelPackBuffer == nullptr && static_cast<size_t>(bufSize) < endByte)