| 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 baa2852131694f5e10ee3f33f89c325cd318370c..c0922abd1456f60a607a1595acb3e18f7fc9fcaa 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| @@ -1461,6 +1461,10 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
|
|
|
| // Wrapper for glClear*()
|
| error::Error DoClear(GLbitfield mask);
|
| + void DoClearColor(GLclampf red,
|
| + GLclampf green,
|
| + GLclampf blue,
|
| + GLclampf alpha);
|
| void DoClearBufferiv(GLenum buffer,
|
| GLint drawbuffer,
|
| const volatile GLint* value);
|
| @@ -2608,7 +2612,7 @@ ScopedResolvedFramebufferBinder::ScopedResolvedFramebufferBinder(
|
| decoder_->offscreen_target_frame_buffer_->id());
|
| decoder_->state_.SetDeviceColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
| decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
|
| - glClearColor(0, 0, 0, 1);
|
| + decoder_->DoClearColor(0, 0, 0, 1);
|
| glClear(GL_COLOR_BUFFER_BIT);
|
| decoder_->RestoreClearState();
|
| }
|
| @@ -2860,7 +2864,7 @@ bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size,
|
| ScopedFramebufferBinder binder(decoder_, fbo);
|
| glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, Target(),
|
| id(), 0);
|
| - glClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor());
|
| + decoder_->DoClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor());
|
| decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
| decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
|
| glClear(GL_COLOR_BUFFER_BIT);
|
| @@ -2953,7 +2957,7 @@ bool BackRenderbuffer::AllocateStorage(const gfx::Size& size,
|
| ScopedFramebufferBinder binder(decoder_, fbo);
|
| glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
| GL_RENDERBUFFER, id_);
|
| - glClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor());
|
| + decoder_->DoClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor());
|
| decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
| decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
|
| glClear(GL_COLOR_BUFFER_BIT);
|
| @@ -3603,7 +3607,7 @@ bool GLES2DecoderImpl::Initialize(
|
| // alpha, clear the surface alpha to 1.0 to be correct on ReadPixels/etc.
|
| bool clear_alpha = back_buffer_color_format_ == GL_RGB && alpha_bits > 0;
|
| if (clear_alpha) {
|
| - glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
| + DoClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
| }
|
|
|
| // Clear the backbuffer.
|
| @@ -3611,7 +3615,7 @@ bool GLES2DecoderImpl::Initialize(
|
|
|
| // Restore alpha clear value if we changed it.
|
| if (clear_alpha) {
|
| - glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
| + DoClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
| }
|
| }
|
|
|
| @@ -4360,7 +4364,7 @@ bool GLES2DecoderImpl::CheckFramebufferValid(
|
| if (surfaceless_)
|
| return false;
|
| if (backbuffer_needs_clear_bits_) {
|
| - glClearColor(0, 0, 0, BackBufferAlphaClearColor());
|
| + DoClearColor(0, 0, 0, BackBufferAlphaClearColor());
|
| state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
| glClearStencil(0);
|
| state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
|
| @@ -5108,7 +5112,7 @@ bool GLES2DecoderImpl::ResizeOffscreenFramebuffer(const gfx::Size& size) {
|
| // Clear the target frame buffer.
|
| {
|
| ScopedFramebufferBinder binder(this, offscreen_target_frame_buffer_->id());
|
| - glClearColor(0, 0, 0, BackBufferAlphaClearColor());
|
| + DoClearColor(0, 0, 0, BackBufferAlphaClearColor());
|
| state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
| glClearStencil(0);
|
| state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
|
| @@ -7379,6 +7383,21 @@ error::Error GLES2DecoderImpl::DoClear(GLbitfield mask) {
|
| return error::kNoError;
|
| }
|
|
|
| +void GLES2DecoderImpl::DoClearColor(GLclampf red,
|
| + GLclampf green,
|
| + GLclampf blue,
|
| + GLclampf alpha) {
|
| + if (workarounds().clear_to_boundary_values_is_broken &&
|
| + (1 == red || 0 == red) && (1 == green || 0 == green) &&
|
| + (1 == blue || 0 == blue) && (1 == alpha || 0 == alpha)) {
|
| + if (1 == alpha)
|
| + alpha = 2;
|
| + else
|
| + alpha = -1;
|
| + }
|
| + glClearColor(red, green, blue, alpha);
|
| +}
|
| +
|
| void GLES2DecoderImpl::DoClearBufferiv(GLenum buffer,
|
| GLint drawbuffer,
|
| const volatile GLint* value) {
|
| @@ -7617,7 +7636,7 @@ void GLES2DecoderImpl::ClearUnclearedAttachments(
|
| // We should always use alpha == 0 here, because 1) some draw buffers may
|
| // have alpha and some may not; 2) we won't have the same situation as the
|
| // back buffer where alpha channel exists but is not requested.
|
| - glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
| + DoClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
| state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
| clear_bits |= GL_COLOR_BUFFER_BIT;
|
|
|
| @@ -7672,9 +7691,8 @@ void GLES2DecoderImpl::ClearUnclearedAttachments(
|
|
|
| void GLES2DecoderImpl::RestoreClearState() {
|
| framebuffer_state_.clear_state_dirty = true;
|
| - glClearColor(
|
| - state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue,
|
| - state_.color_clear_alpha);
|
| + DoClearColor(state_.color_clear_red, state_.color_clear_green,
|
| + state_.color_clear_blue, state_.color_clear_alpha);
|
| glClearStencil(state_.stencil_clear);
|
| glClearDepth(state_.depth_clear);
|
| state_.SetDeviceCapabilityState(GL_SCISSOR_TEST,
|
| @@ -8633,7 +8651,7 @@ bool GLES2DecoderImpl::VerifyMultisampleRenderbufferIntegrity(
|
|
|
| GLfloat clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
| glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color);
|
| - glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
|
| + DoClearColor(1.0f, 0.0f, 1.0f, 1.0f);
|
|
|
| // Clear the buffer to the desired key color.
|
| glClear(GL_COLOR_BUFFER_BIT);
|
| @@ -8662,7 +8680,7 @@ bool GLES2DecoderImpl::VerifyMultisampleRenderbufferIntegrity(
|
|
|
| state_.SetDeviceColorMask(
|
| color_mask[0], color_mask[1], color_mask[2], color_mask[3]);
|
| - glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
|
| + DoClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
|
| glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, draw_framebuffer);
|
| glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_framebuffer);
|
|
|
| @@ -15565,7 +15583,7 @@ void GLES2DecoderImpl::DoSwapBuffers() {
|
| {
|
| ScopedFramebufferBinder binder(this,
|
| offscreen_saved_frame_buffer_->id());
|
| - glClearColor(0, 0, 0, BackBufferAlphaClearColor());
|
| + DoClearColor(0, 0, 0, BackBufferAlphaClearColor());
|
| state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
| state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
|
| glClear(GL_COLOR_BUFFER_BIT);
|
|
|