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 c23ea5f7b5bae4cd35f54ebc115af1997583b34b..986dbba7e3603d696fabe1ac235414e38671b435 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -890,10 +890,6 @@ |
const void* data, |
ContextState::Dimension dimension); |
- bool ValidateCopyTexFormatHelper(GLenum internal_format, |
- GLenum read_format, |
- GLenum read_type, |
- std::string* output_error_msg); |
// Validate if |format| is valid for CopyTex{Sub}Image functions. |
// If not, generate a GL error and return false. |
bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format, |
@@ -2007,7 +2003,7 @@ |
bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, |
TextureRef* source_texture_ref, |
TextureRef* dest_texture_ref); |
- CopyTextureMethod ValidateCopyTextureCHROMIUMInternalFormats( |
+ bool ValidateCopyTextureCHROMIUMInternalFormats( |
const char* function_name, |
TextureRef* source_texture_ref, |
GLenum dest_internal_format); |
@@ -13808,14 +13804,12 @@ |
return error::kNoError; |
} |
-bool GLES2DecoderImpl::ValidateCopyTexFormatHelper( |
- GLenum internal_format, |
- GLenum read_format, |
- GLenum read_type, |
- std::string* output_error_msg) { |
- DCHECK(output_error_msg); |
+bool GLES2DecoderImpl::ValidateCopyTexFormat( |
+ const char* func_name, GLenum internal_format, |
+ GLenum read_format, GLenum read_type) { |
if (read_format == 0) { |
- *output_error_msg = std::string("no valid color image"); |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, func_name, "no valid color image"); |
return false; |
} |
// Check we have compatible formats. |
@@ -13823,7 +13817,8 @@ |
uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); |
if (!channels_needed || |
(channels_needed & channels_exist) != channels_needed) { |
- *output_error_msg = std::string("incompatible format"); |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, func_name, "incompatible format"); |
return false; |
} |
if (feature_info_->IsWebGL2OrES3Context()) { |
@@ -13838,13 +13833,15 @@ |
GLES2Util::IsSignedIntegerFormat(read_format)) || |
(GLES2Util::IsUnsignedIntegerFormat(internal_format) != |
GLES2Util::IsUnsignedIntegerFormat(read_format))) { |
- *output_error_msg = std::string("incompatible format"); |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, func_name, "incompatible format"); |
return false; |
} |
} |
if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { |
- *output_error_msg = |
- std::string("can not be used with depth or stencil textures"); |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, |
+ func_name, "can not be used with depth or stencil textures"); |
return false; |
} |
if (feature_info_->IsWebGL2OrES3Context()) { |
@@ -13861,24 +13858,12 @@ |
(dg > 0 && sg != dg) || |
(db > 0 && sb != db) || |
(da > 0 && sa != da)) { |
- *output_error_msg = std::string("incompatible color component sizes"); |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, |
+ func_name, "incompatible color component sizes"); |
return false; |
} |
} |
- } |
- return true; |
-} |
- |
-bool GLES2DecoderImpl::ValidateCopyTexFormat(const char* func_name, |
- GLenum internal_format, |
- GLenum read_format, |
- GLenum read_type) { |
- std::string output_error_msg; |
- if (!ValidateCopyTexFormatHelper(internal_format, read_format, read_type, |
- &output_error_msg)) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
- output_error_msg.c_str()); |
- return false; |
} |
return true; |
} |
@@ -16087,7 +16072,7 @@ |
return true; |
} |
-CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( |
+bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( |
const char* function_name, |
TextureRef* source_texture_ref, |
GLenum dest_internal_format) { |
@@ -16097,59 +16082,14 @@ |
source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
&source_internal_format); |
- bool valid_dest_format = false; |
- // TODO(qiankun.miao@intel.com): ALPHA, LUMINANCE and LUMINANCE_ALPHA formats |
- // are not supported on GL core profile. See crbug.com/577144. Enable the |
- // workaround for glCopyTexImage and glCopyTexSubImage in |
- // gles2_cmd_copy_tex_image.cc for glCopyTextureCHROMIUM implementation. |
- switch (dest_internal_format) { |
- case GL_RGB: |
- case GL_RGBA: |
- case GL_RGB8: |
- case GL_RGBA8: |
- valid_dest_format = true; |
- break; |
- case GL_BGRA_EXT: |
- case GL_BGRA8_EXT: |
- valid_dest_format = |
- feature_info_->feature_flags().ext_texture_format_bgra8888; |
- break; |
- case GL_SRGB_EXT: |
- case GL_SRGB_ALPHA_EXT: |
- valid_dest_format = feature_info_->feature_flags().ext_srgb; |
- break; |
- case GL_R8: |
- case GL_R8UI: |
- case GL_RG8: |
- case GL_RG8UI: |
- case GL_SRGB8: |
- case GL_RGB565: |
- case GL_RGB8UI: |
- case GL_SRGB8_ALPHA8: |
- case GL_RGB5_A1: |
- case GL_RGBA4: |
- case GL_RGBA8UI: |
- valid_dest_format = feature_info_->IsWebGL2OrES3Context(); |
- break; |
- case GL_RGB9_E5: |
- valid_dest_format = !gl_version_info().is_es; |
- break; |
- case GL_R16F: |
- case GL_R32F: |
- case GL_RG16F: |
- case GL_RG32F: |
- case GL_RGB16F: |
- case GL_RGB32F: |
- case GL_RGBA16F: |
- case GL_RGBA32F: |
- case GL_R11F_G11F_B10F: |
- valid_dest_format = feature_info_->ext_color_buffer_float_available(); |
- break; |
- default: |
- valid_dest_format = false; |
- break; |
- } |
- |
+ // 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 = |
+ dest_internal_format == GL_RGB || dest_internal_format == GL_RGBA || |
+ dest_internal_format == GL_RGB8 || dest_internal_format == GL_RGBA8 || |
+ dest_internal_format == GL_BGRA_EXT || |
+ dest_internal_format == GL_BGRA8_EXT; |
bool valid_source_format = |
source_internal_format == GL_RED || source_internal_format == GL_ALPHA || |
source_internal_format == GL_RGB || source_internal_format == GL_RGBA || |
@@ -16165,38 +16105,16 @@ |
GLES2Util::GetStringEnum(source_internal_format); |
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
msg.c_str()); |
- return NOT_COPYABLE; |
+ return false; |
} |
if (!valid_dest_format) { |
std::string msg = "invalid dest internal format " + |
GLES2Util::GetStringEnum(dest_internal_format); |
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
msg.c_str()); |
- return NOT_COPYABLE; |
- } |
- |
- bool source_format_color_renderable = |
- Texture::ColorRenderable(GetFeatureInfo(), source_internal_format, false); |
- bool dest_format_color_renderable = |
- Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format, false); |
- std::string output_error_msg; |
- |
- // CopyTexImage* should not allow internalformat of GL_BGRA_EXT and |
- // GL_BGRA8_EXT. crbug.com/663086. |
- bool copy_tex_image_format_valid = |
- source_internal_format != GL_BGRA_EXT && |
- dest_internal_format != GL_BGRA_EXT && |
- source_internal_format != GL_BGRA8_EXT && |
- dest_internal_format != GL_BGRA8_EXT && |
- ValidateCopyTexFormatHelper(dest_internal_format, source_internal_format, |
- source_type, &output_error_msg); |
- if (source_format_color_renderable && copy_tex_image_format_valid) |
- return DIRECT_COPY; |
- |
- if (dest_format_color_renderable) |
- return DIRECT_DRAW; |
- |
- return DRAW_AND_COPY; |
+ return false; |
+ } |
+ return true; |
} |
bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( |
@@ -16260,8 +16178,18 @@ |
TextureRef* source_texture_ref = GetTexture(source_id); |
TextureRef* dest_texture_ref = GetTexture(dest_id); |
+ if (!texture_manager()->ValidateTextureParameters( |
+ GetErrorState(), kFunctionName, true, internal_format, dest_type, |
+ internal_format, 0)) |
+ return; |
+ |
if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref, |
dest_texture_ref)) { |
+ return; |
+ } |
+ |
+ if (!ValidateCopyTextureCHROMIUMInternalFormats( |
+ kFunctionName, source_texture_ref, internal_format)) { |
return; |
} |
@@ -16269,34 +16197,6 @@ |
Texture* dest_texture = dest_texture_ref->texture(); |
GLenum source_target = source_texture->target(); |
GLenum dest_target = dest_texture->target(); |
- |
- GLenum source_type = 0; |
- GLenum source_internal_format = 0; |
- source_texture->GetLevelType(source_target, 0, &source_type, |
- &source_internal_format); |
- GLenum format = |
- TextureManager::ExtractFormatFromStorageFormat(internal_format); |
- if (!texture_manager()->ValidateTextureParameters( |
- GetErrorState(), kFunctionName, true, format, dest_type, |
- internal_format, 0)) { |
- return; |
- } |
- |
- CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats( |
- kFunctionName, source_texture_ref, internal_format); |
- // INVALID_OPERATION is already generated by |
- // ValidateCopyTextureCHROMIUMInternalFormats. |
- if (NOT_COPYABLE == method) { |
- return; |
- } |
- |
- if (feature_info_->feature_flags().desktop_srgb_support) { |
- bool enable_framebuffer_srgb = |
- GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB || |
- GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; |
- state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
- } |
- |
int source_width = 0; |
int source_height = 0; |
gl::GLImage* image = |
@@ -16328,6 +16228,11 @@ |
} |
} |
+ GLenum source_type = 0; |
+ GLenum source_internal_format = 0; |
+ source_texture->GetLevelType(source_target, 0, &source_type, |
+ &source_internal_format); |
+ |
if (dest_texture->IsImmutable()) { |
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
"texture is immutable"); |
@@ -16364,24 +16269,26 @@ |
// Ensure that the glTexImage2D succeeds. |
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); |
glBindTexture(dest_target, dest_texture->service_id()); |
- glTexImage2D(dest_target, 0, TextureManager::AdjustTexInternalFormat( |
- feature_info_.get(), internal_format), |
- source_width, source_height, 0, |
- TextureManager::AdjustTexFormat(feature_info_.get(), format), |
- dest_type, NULL); |
+ glTexImage2D( |
+ dest_target, 0, TextureManager::AdjustTexInternalFormat( |
+ feature_info_.get(), internal_format), |
+ source_width, source_height, 0, |
+ TextureManager::AdjustTexFormat(feature_info_.get(), internal_format), |
+ dest_type, NULL); |
GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); |
if (error != GL_NO_ERROR) { |
RestoreCurrentTextureBindings(&state_, dest_target); |
return; |
} |
- texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, 0, |
- internal_format, source_width, |
- source_height, 1, 0, format, dest_type, |
- gfx::Rect(source_width, source_height)); |
+ texture_manager()->SetLevelInfo( |
+ dest_texture_ref, dest_target, 0, internal_format, source_width, |
+ source_height, 1, 0, internal_format, dest_type, |
+ gfx::Rect(source_width, source_height)); |
dest_texture->ApplyFormatWorkarounds(feature_info_.get()); |
} else { |
- texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, true); |
+ texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, |
+ true); |
} |
// Try using GLImage::CopyTexImage when possible. |
@@ -16404,21 +16311,18 @@ |
GLfloat transform_matrix[16]; |
image->GetTextureMatrix(transform_matrix); |
copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
- this, source_target, source_texture->service_id(), |
- source_internal_format, dest_target, dest_texture->service_id(), |
- internal_format, source_width, source_height, |
+ this, source_target, source_texture->service_id(), dest_target, |
+ dest_texture->service_id(), source_width, source_height, |
unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
return; |
} |
} |
- |
copy_texture_CHROMIUM_->DoCopyTexture( |
this, source_target, source_texture->service_id(), source_internal_format, |
dest_target, dest_texture->service_id(), internal_format, source_width, |
source_height, unpack_flip_y == GL_TRUE, |
- unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, |
- method); |
+ unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); |
} |
void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
@@ -16520,19 +16424,9 @@ |
return; |
} |
- CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats( |
- kFunctionName, source_texture_ref, dest_internal_format); |
- // INVALID_OPERATION is already generated by |
- // ValidateCopyTextureCHROMIUMInternalFormats. |
- if (NOT_COPYABLE == method) { |
- return; |
- } |
- |
- if (feature_info_->feature_flags().desktop_srgb_support) { |
- bool enable_framebuffer_srgb = |
- GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB || |
- GetColorEncodingFromInternalFormat(dest_internal_format) == GL_SRGB; |
- state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
+ if (!ValidateCopyTextureCHROMIUMInternalFormats( |
+ kFunctionName, source_texture_ref, dest_internal_format)) { |
+ return; |
} |
// Clear the source texture if necessary. |
@@ -16613,8 +16507,7 @@ |
dest_target, dest_texture->service_id(), dest_internal_format, xoffset, |
yoffset, x, y, width, height, dest_width, dest_height, source_width, |
source_height, unpack_flip_y == GL_TRUE, |
- unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, |
- method); |
+ unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); |
} |
bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( |
@@ -16789,7 +16682,7 @@ |
this, source_texture->target(), source_texture->service_id(), |
source_internal_format, dest_texture->target(), |
dest_texture->service_id(), GL_RGBA, source_width, source_height, false, |
- false, false, DIRECT_DRAW); |
+ false, false); |
} |
void GLES2DecoderImpl::TexStorageImpl(GLenum target, |