| 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 4f93174e1a1c68ed35e465a914d6c639e59d9f89..289898a358cfa5a322251c1ae3c7bee18093f495 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| @@ -4308,17 +4308,26 @@ bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) {
|
| }
|
|
|
| void GLES2DecoderImpl::UpdateFramebufferSRGB(Framebuffer* framebuffer) {
|
| + // Manually set the value of FRAMEBUFFER_SRGB based on the state that was set
|
| + // by the client.
|
| + bool needs_enable_disable_framebuffer_srgb = false;
|
| + bool enable_framebuffer_srgb = true;
|
| + if (feature_info_->feature_flags().ext_srgb_write_control) {
|
| + needs_enable_disable_framebuffer_srgb = true;
|
| + enable_framebuffer_srgb &= state_.GetEnabled(GL_FRAMEBUFFER_SRGB);
|
| + }
|
| // On desktop, enable FRAMEBUFFER_SRGB only if the framebuffer contains sRGB
|
| // attachments. In theory, we can just leave FRAMEBUFFER_SRGB enabled,
|
| // however,
|
| // many drivers behave incorrectly when no attachments are sRGB. When at
|
| // least one attachment is sRGB, then they behave correctly.
|
| if (feature_info_->feature_flags().desktop_srgb_support) {
|
| + needs_enable_disable_framebuffer_srgb = true;
|
| // Assume that the default fbo does not have an sRGB image.
|
| - bool enable_framebuffer_srgb =
|
| - framebuffer && framebuffer->HasSRGBAttachments();
|
| - state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
|
| + enable_framebuffer_srgb &= framebuffer && framebuffer->HasSRGBAttachments();
|
| }
|
| + if (needs_enable_disable_framebuffer_srgb)
|
| + state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
|
| }
|
|
|
| bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(
|
| @@ -7433,6 +7442,11 @@ void GLES2DecoderImpl::DoDisable(GLenum cap) {
|
| // DrawElements* for old desktop GL.
|
| return;
|
| }
|
| + if (cap == GL_FRAMEBUFFER_SRGB) {
|
| + // Enable and Disable GL_FRAMEBUFFER_SRGB is done manually in
|
| + // CheckBoundDrawFramebufferValid.
|
| + return;
|
| + }
|
| glDisable(cap);
|
| }
|
| }
|
| @@ -7445,6 +7459,11 @@ void GLES2DecoderImpl::DoEnable(GLenum cap) {
|
| // DrawElements* for old desktop GL.
|
| return;
|
| }
|
| + if (cap == GL_FRAMEBUFFER_SRGB) {
|
| + // Enable and Disable GL_FRAMEBUFFER_SRGB is done manually in
|
| + // CheckBoundDrawFramebufferValid.
|
| + return;
|
| + }
|
| glEnable(cap);
|
| }
|
| }
|
|
|