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 5e26477a6d6b2a6823ef80c3ef78545a47c47b18..e7c0445c49ec49a69a0bd1c37d70ab44f22390dd 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -10047,6 +10047,26 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
return; |
} |
+ GLenum source_type = 0; |
+ GLenum source_internal_format = 0; |
+ source_texture->GetLevelType( |
+ source_texture->target(), 0, &source_type, &source_internal_format); |
+ |
+ // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, |
+ // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not |
+ // renderable on some platforms. |
+ bool valid_dest_format = |
+ internal_format == GL_RGB || internal_format == GL_RGBA; |
+ // The source format can be GL_BGRA_EXT. |
+ bool valid_source_format = (source_internal_format >= GL_ALPHA && |
no sievers
2014/08/22 18:07:19
nit: mind making this comparison more explicit? i.
dshwang
2014/08/22 19:07:54
Done.
|
+ source_internal_format <= GL_LUMINANCE_ALPHA) || |
+ source_internal_format == GL_BGRA_EXT; |
+ if (!valid_source_format || !valid_dest_format) { |
no sievers
2014/08/22 18:07:19
Should we make it GL_INVALID_OPERATION if !valid_s
dshwang
2014/08/22 19:07:55
Yes! GL_INVALID_OPERATION is right.
|
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid internal format"); |
+ return; |
+ } |
+ |
// Defer initializing the CopyTextureCHROMIUMResourceManager until it is |
// needed because it takes 10s of milliseconds to initialize. |
if (!copy_texture_CHROMIUM_.get()) { |
@@ -10058,11 +10078,6 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
return; |
} |
- GLenum source_type = 0; |
- GLenum source_internal_format = 0; |
- source_texture->GetLevelType( |
- source_texture->target(), 0, &source_type, &source_internal_format); |
- |
GLenum dest_type_previous = dest_type; |
GLenum dest_internal_format = internal_format; |
bool dest_level_defined = dest_texture->GetLevelSize( |
@@ -10073,20 +10088,6 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
&dest_internal_format); |
} |
- // The destination format should be GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, |
- // or GL_LUMINANCE_ALPHA. |
- bool valid_dest_format = dest_internal_format >= GL_ALPHA && |
- dest_internal_format <= GL_LUMINANCE_ALPHA; |
- // The source format can be GL_BGRA_EXT. |
- bool valid_source_format = (source_internal_format >= GL_ALPHA && |
- source_internal_format <= GL_LUMINANCE_ALPHA) || |
- source_internal_format == GL_BGRA_EXT; |
- if (!valid_source_format || !valid_dest_format) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid internal format"); |
- return; |
- } |
- |
// Resize the destination texture to the dimensions of the source texture. |
if (!dest_level_defined || dest_width != source_width || |
dest_height != source_height || |