| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| index af0a62f7e1654040e449fcf73891d4a2a83cee72..d0c8614df87fb556febb2e27d39ae4cdaaca45c9 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| @@ -1782,6 +1782,11 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
|
| GLenum target,
|
| TextureRef* source_texture_ref,
|
| TextureRef* dest_texture_ref);
|
| + bool ValidateCompressedCopySubTextureDimensions(
|
| + const char* function_name,
|
| + GLenum target, GLint xoffset, GLint yoffset,
|
| + GLsizei width, GLsizei height, GLenum format,
|
| + Texture* texture);
|
|
|
| void RenderWarning(const char* filename, int line, const std::string& msg);
|
| void PerformanceWarning(
|
| @@ -12732,6 +12737,47 @@ bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM(
|
| return true;
|
| }
|
|
|
| +bool GLES2DecoderImpl::ValidateCompressedCopySubTextureDimensions(
|
| + const char* function_name,
|
| + GLenum target, GLint xoffset, GLint yoffset,
|
| + GLsizei width, GLsizei height, GLenum format,
|
| + Texture* texture) {
|
| + if (xoffset < 0 || yoffset < 0) {
|
| + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "x/y offset < 0");
|
| + return false;
|
| + }
|
| +
|
| + switch (format) {
|
| + case GL_ATC_RGB_AMD:
|
| + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
|
| + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
| + case GL_ETC1_RGB8_OES: {
|
| + const int kBlockWidth = 4;
|
| + const int kBlockHeight = 4;
|
| + if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) {
|
| + LOCAL_SET_GL_ERROR(
|
| + GL_INVALID_OPERATION, function_name,
|
| + "xoffset or yoffset not multiple of 4");
|
| + return false;
|
| + }
|
| + GLsizei tex_width = 0;
|
| + GLsizei tex_height = 0;
|
| + if (!texture->GetLevelSize(target, 0, &tex_width, &tex_height, nullptr) ||
|
| + width - xoffset > tex_width ||
|
| + height - yoffset > tex_height) {
|
| + LOCAL_SET_GL_ERROR(
|
| + GL_INVALID_OPERATION, function_name, "dimensions out of range");
|
| + return false;
|
| + }
|
| + return ValidateCompressedTexDimensions(
|
| + function_name, target, 0, width, height, 1, format);
|
| + }
|
| + default:
|
| + return false;
|
| + }
|
| +}
|
| +
|
| void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
|
| GLenum target,
|
| GLuint source_id,
|
| @@ -13291,16 +13337,18 @@ void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target,
|
| return;
|
| }
|
|
|
| - if (!ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM",
|
| - source_texture->target(), 0, x, y, 0,
|
| - width, height, 1,
|
| - source_internal_format,
|
| - source_texture) ||
|
| - !ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM",
|
| - dest_texture->target(), 0,
|
| - xoffset, yoffset, 0, width, height, 1,
|
| - dest_internal_format,
|
| - dest_texture)) {
|
| + if (!ValidateCompressedCopySubTextureDimensions(
|
| + "glCompressedCopySubTextureCHROMIUM",
|
| + source_texture->target(), x, y,
|
| + width, height,
|
| + source_internal_format,
|
| + source_texture) ||
|
| + !ValidateCompressedCopySubTextureDimensions(
|
| + "glCompressedCopySubTextureCHROMIUM",
|
| + dest_texture->target(),
|
| + xoffset, yoffset, width, height,
|
| + dest_internal_format,
|
| + dest_texture)) {
|
| return;
|
| }
|
|
|
|
|