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 793606f951a86dcf5642eb26107a2f41db725984..7b87e09e55a7e47cec2376e99929dc9a49e16202 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -3073,7 +3073,20 @@ bool GLES2DecoderImpl::CheckFramebufferValid( |
glClearDepth(1.0f); |
state_.SetDeviceDepthMask(GL_TRUE); |
state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
+ bool reset_draw_buffer = false; |
+ if ((backbuffer_needs_clear_bits_ | GL_COLOR_BUFFER_BIT) != 0 && |
+ group_->draw_buffer() == GL_NONE) { |
+ reset_draw_buffer = true; |
+ GLenum buf = GL_BACK; |
+ if (GetBackbufferServiceId() != 0) // emulated backbuffer |
+ buf = GL_COLOR_ATTACHMENT0; |
+ glDrawBuffersARB(1, &buf); |
+ } |
glClear(backbuffer_needs_clear_bits_); |
+ if (reset_draw_buffer) { |
+ GLenum buf = GL_NONE; |
+ glDrawBuffersARB(1, &buf); |
+ } |
backbuffer_needs_clear_bits_ = 0; |
RestoreClearState(); |
} |
@@ -5019,7 +5032,7 @@ void GLES2DecoderImpl::ClearUnclearedAttachments( |
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, framebuffer->service_id()); |
} |
GLbitfield clear_bits = 0; |
- if (framebuffer->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { |
+ if (framebuffer->HasUnclearedColorAttachments()) { |
glClearColor( |
0.0f, 0.0f, 0.0f, |
(GLES2Util::GetChannelsForFormat( |
@@ -5027,6 +5040,7 @@ void GLES2DecoderImpl::ClearUnclearedAttachments( |
1.0f); |
state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
clear_bits |= GL_COLOR_BUFFER_BIT; |
+ framebuffer->PrepareDrawBuffersForClear(); |
} |
if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || |
@@ -5046,6 +5060,9 @@ void GLES2DecoderImpl::ClearUnclearedAttachments( |
state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
glClear(clear_bits); |
+ if ((clear_bits | GL_COLOR_BUFFER_BIT) != 0) |
+ framebuffer->RestoreDrawBuffersAfterClear(); |
+ |
framebuffer_manager()->MarkAttachmentsAsCleared( |
framebuffer, renderbuffer_manager(), texture_manager()); |