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 39e0a2954c987119b03744e8848c02faffce1ff9..c7d6687d3b245ce6d46ebde7932cfffffad2e008 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -13027,34 +13027,19 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
Texture* dest_texture = dest_texture_ref->texture(); |
int source_width = 0; |
int source_height = 0; |
- gl::GLImage* image = |
- source_texture->GetLevelImage(source_texture->target(), 0); |
- if (image) { |
- gfx::Size size = image->GetSize(); |
dshwang
2015/11/07 15:53:03
As SetSize hack just update size of GLImage, this
|
- source_width = size.width(); |
- source_height = size.height(); |
- if (source_width <= 0 || source_height <= 0) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_VALUE, |
- "glCopyTextureChromium", "invalid image size"); |
- return; |
- } |
- } else { |
- if (!source_texture->GetLevelSize(source_texture->target(), 0, |
- &source_width, &source_height, nullptr)) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
- "glCopyTextureChromium", |
- "source texture has no level 0"); |
- return; |
- } |
+ if (!source_texture->GetLevelSize(source_texture->target(), 0, &source_width, |
+ &source_height, nullptr)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTextureChromium", |
+ "source texture has no level 0"); |
+ return; |
+ } |
- // Check that this type of texture is allowed. |
- if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
- source_width, source_height, 1)) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions"); |
- return; |
- } |
+ // Check that this type of texture is allowed. |
+ if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
+ source_width, source_height, 1)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTextureCHROMIUM", |
+ "Bad dimensions"); |
+ return; |
} |
GLenum source_type = 0; |
@@ -13131,6 +13116,8 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
} |
// Try using GLImage::CopyTexImage when possible. |
+ gl::GLImage* image = |
+ source_texture->GetLevelImage(source_texture->target(), 0); |
bool unpack_premultiply_alpha_change = |
(unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
@@ -13185,32 +13172,19 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
Texture* dest_texture = dest_texture_ref->texture(); |
int source_width = 0; |
int source_height = 0; |
- gl::GLImage* image = |
- source_texture->GetLevelImage(source_texture->target(), 0); |
- if (image) { |
- gfx::Size size = image->GetSize(); |
- source_width = size.width(); |
- source_height = size.height(); |
- if (source_width <= 0 || source_height <= 0) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
- "invalid image size"); |
- return; |
- } |
- } else { |
- if (!source_texture->GetLevelSize(source_texture->target(), 0, |
- &source_width, &source_height, nullptr)) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
- "source texture has no level 0"); |
- return; |
- } |
+ if (!source_texture->GetLevelSize(source_texture->target(), 0, &source_width, |
+ &source_height, nullptr)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
+ "source texture has no level 0"); |
+ return; |
+ } |
- // Check that this type of texture is allowed. |
- if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
- source_width, source_height, 1)) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
- "source texture bad dimensions"); |
- return; |
- } |
+ // Check that this type of texture is allowed. |
+ if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
+ source_width, source_height, 1)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
+ "source texture bad dimensions"); |
+ return; |
} |
GLenum source_type = 0; |
@@ -13295,6 +13269,8 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
} |
// Try using GLImage::CopyTexSubImage when possible. |
+ gl::GLImage* image = |
+ source_texture->GetLevelImage(source_texture->target(), 0); |
bool unpack_premultiply_alpha_change = |
(unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
@@ -13331,35 +13307,19 @@ void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, |
Texture* dest_texture = dest_texture_ref->texture(); |
int source_width = 0; |
int source_height = 0; |
- gl::GLImage* image = |
- source_texture->GetLevelImage(source_texture->target(), 0); |
- if (image) { |
- gfx::Size size = image->GetSize(); |
- source_width = size.width(); |
- source_height = size.height(); |
- if (source_width <= 0 || source_height <= 0) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_VALUE, |
- "glCompressedCopyTextureCHROMIUM", "invalid image size"); |
- return; |
- } |
- } else { |
- if (!source_texture->GetLevelSize(source_texture->target(), 0, |
- &source_width, &source_height, nullptr)) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
- "glCompressedCopyTextureCHROMIUM", |
- "source texture has no level 0"); |
- return; |
- } |
+ if (!source_texture->GetLevelSize(source_texture->target(), 0, &source_width, |
+ &source_height, nullptr)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopyTextureCHROMIUM", |
+ "source texture has no level 0"); |
+ return; |
+ } |
- // Check that this type of texture is allowed. |
- if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
- source_width, source_height, 1)) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_VALUE, "glCompressedCopyTextureCHROMIUM", |
- "Bad dimensions"); |
- return; |
- } |
+ // Check that this type of texture is allowed. |
+ if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
+ source_width, source_height, 1)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopyTextureCHROMIUM", |
+ "Bad dimensions"); |
+ return; |
} |
GLenum source_type = 0; |
@@ -13404,6 +13364,8 @@ void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, |
&state_, dest_texture->service_id(), GL_TEXTURE_2D); |
// Try using GLImage::CopyTexImage when possible. |
+ gl::GLImage* image = |
+ source_texture->GetLevelImage(source_texture->target(), 0); |
if (image) { |
GLenum dest_type = 0; |
GLenum dest_internal_format = 0; |
@@ -13507,32 +13469,19 @@ void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, |
Texture* dest_texture = dest_texture_ref->texture(); |
int source_width = 0; |
int source_height = 0; |
- gl::GLImage* image = |
- source_texture->GetLevelImage(source_texture->target(), 0); |
- if (image) { |
- gfx::Size size = image->GetSize(); |
- source_width = size.width(); |
- source_height = size.height(); |
- if (source_width <= 0 || source_height <= 0) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", |
- "invalid image size"); |
- return; |
- } |
- } else { |
- if (!source_texture->GetLevelSize(source_texture->target(), 0, |
- &source_width, &source_height, nullptr)) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", |
- "source texture has no level 0"); |
- return; |
- } |
+ if (!source_texture->GetLevelSize(source_texture->target(), 0, &source_width, |
+ &source_height, nullptr)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", |
+ "source texture has no level 0"); |
+ return; |
+ } |
- // Check that this type of texture is allowed. |
- if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
- source_width, source_height, 1)) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", |
- "source texture bad dimensions"); |
- return; |
- } |
+ // Check that this type of texture is allowed. |
+ if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
+ source_width, source_height, 1)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", |
+ "source texture bad dimensions"); |
+ return; |
} |
GLenum source_type = 0; |
@@ -13637,6 +13586,8 @@ void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, |
&state_, dest_texture->service_id(), GL_TEXTURE_2D); |
// Try using GLImage::CopyTexSubImage when possible. |
+ gl::GLImage* image = |
+ source_texture->GetLevelImage(source_texture->target(), 0); |
if (image && |
image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset), |
gfx::Rect(x, y, width, height))) { |