Chromium Code Reviews| 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 a555557a96e6859dde37b5d94e1558de7b50f297..c56d28f9d45c9201b6c1339afffe8476c991f145 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -1567,6 +1567,10 @@ class GLES2DecoderImpl : public GLES2Decoder, |
| // attached. Generates GL error if not. |
| bool CheckBoundReadFramebufferColorAttachment(const char* func_name); |
| + // Get the value of GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the |
| + // framebuffer attachment corresponding to the read buffer. |
| + GLint GetReadFramebufferAttachmentColorEncoding(); |
| + |
| // Check that the currently bound read framebuffer's color image |
| // isn't the target texture of the glCopyTex{Sub}Image2D. |
| bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); |
| @@ -4019,6 +4023,16 @@ bool GLES2DecoderImpl::CheckBoundReadFramebufferColorAttachment( |
| return true; |
| } |
| +GLint GLES2DecoderImpl::GetReadFramebufferAttachmentColorEncoding() { |
| + GLenum target = features().chromium_framebuffer_multisample ? |
| + GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER_EXT; |
| + GLint v = GL_NONE; |
| + glGetFramebufferAttachmentParameterivEXT( |
| + target, GL_COLOR_ATTACHMENT0, |
| + GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &v); |
| + return v; |
| +} |
| + |
| bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( |
| TextureRef* texture, GLint level) { |
| Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? |
| @@ -11003,6 +11017,23 @@ void GLES2DecoderImpl::DoCopyTexImage2D( |
| return; |
| } |
| + if (feature_info_->IsES3Enabled()) { |
| + GLint color_encoding = GetReadFramebufferAttachmentColorEncoding(); |
| + if ((GL_LINEAR == color_encoding && |
| + GLES2Util::IsSRGBFormat(internal_format)) || |
|
Zhenyao Mo
2015/10/13 01:22:49
One optimization is, instead of asking IsSRGBForma
qiankun
2015/10/13 14:28:01
Thanks for this suggestion! I implemented this opt
|
| + (GL_SRGB == color_encoding && |
| + !GLES2Util::IsSRGBFormat(internal_format)) || |
| + GLES2Util::IsFloatFormat(internal_format) || |
| + (GLES2Util::IsSignedIntegerFormat(internal_format) != |
| + GLES2Util::IsSignedIntegerFormat(read_format)) || |
| + (GLES2Util::IsUnsignedIntegerFormat(internal_format) != |
| + GLES2Util::IsUnsignedIntegerFormat(read_format))) { |
| + LOCAL_SET_GL_ERROR( |
| + GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format"); |
| + return; |
| + } |
| + } |
| + |
| if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { |
| LOCAL_SET_GL_ERROR( |
| GL_INVALID_OPERATION, |