| 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 46dc8961d05d4aeb10b72cdd9b1fe1e984276946..4214263ee409f037c2f3836cbd85dbb20324eef0 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| @@ -707,6 +707,7 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
|
| // Workarounds
|
| void OnFboChanged() const;
|
| void OnUseFramebuffer() const;
|
| + void UpdateFramebufferSRGB(Framebuffer* framebuffer);
|
|
|
| error::ContextLostReason GetContextLostReasonFromResetStatus(
|
| GLenum reset_status) const;
|
| @@ -3458,6 +3459,7 @@ bool GLES2DecoderImpl::Initialize(
|
| DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
| DoBindFramebuffer(GL_FRAMEBUFFER, 0);
|
| DoBindRenderbuffer(GL_RENDERBUFFER, 0);
|
| + UpdateFramebufferSRGB(nullptr);
|
|
|
| bool call_gl_clear = !surfaceless_ && !offscreen;
|
| #if defined(OS_ANDROID)
|
| @@ -4295,21 +4297,28 @@ bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) {
|
| Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
|
| bool valid = CheckFramebufferValid(
|
| framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
|
| - if (valid && !features().chromium_framebuffer_multisample)
|
| + if (!valid)
|
| + return false;
|
| +
|
| + if (!features().chromium_framebuffer_multisample)
|
| OnUseFramebuffer();
|
| - if (valid && feature_info_->feature_flags().desktop_srgb_support) {
|
| - // If framebuffer contains sRGB images, then enable FRAMEBUFFER_SRGB.
|
| - // Otherwise, disable FRAMEBUFFER_SRGB. Assume default fbo does not have
|
| - // sRGB image.
|
| - // In theory, we can just leave FRAMEBUFFER_SRGB on. However, many drivers
|
| - // behave incorrectly when all images are linear encoding, they still apply
|
| - // the sRGB conversion, but when at least one image is sRGB, then they
|
| - // behave correctly.
|
| +
|
| + UpdateFramebufferSRGB(framebuffer);
|
| + return true;
|
| +}
|
| +
|
| +void GLES2DecoderImpl::UpdateFramebufferSRGB(Framebuffer* framebuffer) {
|
| + // 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) {
|
| + // Assume that the default fbo does not have an sRGB image.
|
| bool enable_framebuffer_srgb =
|
| framebuffer && framebuffer->HasSRGBAttachments();
|
| state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
|
| }
|
| - return valid;
|
| }
|
|
|
| bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(
|
|
|