Index: gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc |
diff --git a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc |
index 00f510db2832f23462cd1217cb7763a4477f778c..33ecbd662e9ceb846107ae77d1df7434e8a08032 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc |
@@ -7,6 +7,7 @@ |
#include <algorithm> |
#include "base/basictypes.h" |
+#include "gpu/command_buffer/common/gles2_cmd_utils.h" |
#include "gpu/command_buffer/service/gl_utils.h" |
#include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
@@ -362,18 +363,25 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture( |
bool premultiply_alpha, |
bool unpremultiply_alpha) { |
bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; |
+ uint32_t source_channels = gles2::GLES2Util::GetChannelsForFormat( |
+ source_internal_format); |
+ uint32_t dest_channels = gles2::GLES2Util::GetChannelsForFormat( |
+ dest_internal_format); |
// GL_INVALID_OPERATION is generated if the currently bound framebuffer's |
// format does not contain a superset of the components required by the base |
// format of internalformat. |
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml |
bool source_format_contain_superset_of_dest_format = |
- (source_internal_format == dest_internal_format && |
- source_internal_format != GL_BGRA_EXT) || |
- (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); |
- // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, |
- // so restrict this to GL_TEXTURE_2D. |
- if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && |
- source_format_contain_superset_of_dest_format) { |
+ (source_channels & dest_channels) == dest_channels; |
+ // Note: GL_TEXTURE_RECTANGLE_ARB is only available if supported on FBOs. |
+ bool valid_source_target = source_target == GL_TEXTURE_2D || |
+ source_target == GL_TEXTURE_RECTANGLE_ARB; |
+ bool valid_dest_internal_format = dest_internal_format == GL_ALPHA || |
+ dest_internal_format == GL_RGB || |
+ dest_internal_format == GL_RGBA; |
+ if (valid_source_target && !flip_y && !premultiply_alpha_change && |
+ source_format_contain_superset_of_dest_format && |
+ valid_dest_internal_format) { |
DoCopyTexImage2D(decoder, |
source_target, |
source_id, |
@@ -412,18 +420,25 @@ void CopyTextureCHROMIUMResourceManager::DoCopySubTexture( |
bool premultiply_alpha, |
bool unpremultiply_alpha) { |
bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; |
+ uint32_t source_channels = gles2::GLES2Util::GetChannelsForFormat( |
+ source_internal_format); |
+ uint32_t dest_channels = gles2::GLES2Util::GetChannelsForFormat( |
+ dest_internal_format); |
// GL_INVALID_OPERATION is generated if the currently bound framebuffer's |
// format does not contain a superset of the components required by the base |
// format of internalformat. |
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml |
bool source_format_contain_superset_of_dest_format = |
- (source_internal_format == dest_internal_format && |
- source_internal_format != GL_BGRA_EXT) || |
- (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); |
- // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, |
- // so restrict this to GL_TEXTURE_2D. |
- if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && |
- source_format_contain_superset_of_dest_format) { |
+ (source_channels & dest_channels) == dest_channels; |
+ // Note: GL_TEXTURE_RECTANGLE_ARB is only available if supported on FBOs. |
+ bool valid_source_target = source_target == GL_TEXTURE_2D || |
+ source_target == GL_TEXTURE_RECTANGLE_ARB; |
+ bool valid_dest_internal_format = dest_internal_format == GL_ALPHA || |
+ dest_internal_format == GL_RGB || |
+ dest_internal_format == GL_RGBA; |
+ if (valid_source_target && !flip_y && !premultiply_alpha_change && |
+ source_format_contain_superset_of_dest_format && |
+ valid_dest_internal_format) { |
DoCopyTexSubImage2D(decoder, source_target, source_id, dest_id, xoffset, |
yoffset, x, y, width, height, framebuffer_); |
return; |