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..a5d69b0f8be98d6d8eedaec67ac2cb39593a52bc 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -1567,6 +1567,13 @@ class GLES2DecoderImpl : public GLES2Decoder, |
| // attached. Generates GL error if not. |
| bool CheckBoundReadFramebufferColorAttachment(const char* func_name); |
| + // Infer color encoding from internalformat |
| + GLint GetColorEncodingFromInternalFormat(GLenum internalformat); |
|
Zhenyao Mo
2015/10/13 17:00:23
Make it static.
qiankun
2015/10/13 23:54:07
Done.
|
| + |
| + // 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 +4026,29 @@ bool GLES2DecoderImpl::CheckBoundReadFramebufferColorAttachment( |
| return true; |
| } |
| +GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( |
| + GLenum internalformat) { |
| + switch (internalformat) { |
| + case GL_SRGB_EXT: |
| + case GL_SRGB_ALPHA_EXT: |
| + case GL_SRGB8: |
| + case GL_SRGB8_ALPHA8: |
| + return GL_SRGB; |
| + default: |
| + return GL_LINEAR; |
| + } |
| +} |
| + |
| +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 +11033,20 @@ void GLES2DecoderImpl::DoCopyTexImage2D( |
| return; |
| } |
| + if (feature_info_->IsES3Enabled()) { |
| + GLint color_encoding = GetReadFramebufferAttachmentColorEncoding(); |
|
Zhenyao Mo
2015/10/13 17:00:24
Here you don't need the GetReadFramebufferAttachme
qiankun
2015/10/13 23:54:07
Done.
Zhenyao Mo
2015/10/14 18:39:20
Then please get rid of the GetReadFramebufferAttac
|
| + if (color_encoding != GetColorEncodingFromInternalFormat(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, |