Refactor Texture::setImage and subImage to use gl::Error objects.
BUG=angle:520
Change-Id: Ib43ace0fbdab59086ae4314cce139636d9045e65
Reviewed-on: https://chromium-review.googlesource.com/216644
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index b8d51a6..25eb3bd 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -4145,43 +4145,78 @@
case GL_TEXTURE_2D:
{
gl::Texture2D *texture = context->getTexture2D();
- texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
- texture->setImagePosX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImagePosX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
- texture->setImageNegX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImageNegX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
- texture->setImagePosY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImagePosY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
- texture->setImageNegY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImageNegY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
- texture->setImagePosZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImagePosZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
- texture->setImageNegZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImageNegZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
default: UNREACHABLE();
@@ -4372,7 +4407,12 @@
case GL_TEXTURE_2D:
{
gl::Texture2D *texture = context->getTexture2D();
- texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
@@ -4384,7 +4424,12 @@
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
- texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
@@ -5015,14 +5060,24 @@
case GL_TEXTURE_3D:
{
gl::Texture3D *texture = context->getTexture3D();
- texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
case GL_TEXTURE_2D_ARRAY:
{
gl::Texture2DArray *texture = context->getTexture2DArray();
- texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
@@ -5068,14 +5123,24 @@
case GL_TEXTURE_3D:
{
gl::Texture3D *texture = context->getTexture3D();
- texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;
case GL_TEXTURE_2D_ARRAY:
{
gl::Texture2DArray *texture = context->getTexture2DArray();
- texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
+ gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
break;