| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2130 if (offscreen_target_frame_buffer_.get()) { | 2130 if (offscreen_target_frame_buffer_.get()) { |
| 2131 return offscreen_buffer_should_have_alpha_; | 2131 return offscreen_buffer_should_have_alpha_; |
| 2132 } | 2132 } |
| 2133 return (back_buffer_color_format_ == GL_RGBA || | 2133 return (back_buffer_color_format_ == GL_RGBA || |
| 2134 back_buffer_color_format_ == GL_RGBA8); | 2134 back_buffer_color_format_ == GL_RGBA8); |
| 2135 } | 2135 } |
| 2136 | 2136 |
| 2137 // If the back buffer has a non-emulated alpha channel, the clear color should | 2137 // If the back buffer has a non-emulated alpha channel, the clear color should |
| 2138 // be 0. Otherwise, the clear color should be 1. | 2138 // be 0. Otherwise, the clear color should be 1. |
| 2139 GLfloat BackBufferAlphaClearColor() const { | 2139 GLfloat BackBufferAlphaClearColor() const { |
| 2140 return offscreen_buffer_should_have_alpha_ ? 0.f : 1.f; | 2140 return offscreen_buffer_should_have_alpha_ ? 0.f : 1.001f; |
| 2141 } | 2141 } |
| 2142 | 2142 |
| 2143 // Set remaining commands to process to 0 to force DoCommands to return | 2143 // Set remaining commands to process to 0 to force DoCommands to return |
| 2144 // and allow context preemption and GPU watchdog checks in CommandExecutor(). | 2144 // and allow context preemption and GPU watchdog checks in CommandExecutor(). |
| 2145 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } | 2145 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } |
| 2146 | 2146 |
| 2147 void ProcessPendingReadPixels(bool did_finish); | 2147 void ProcessPendingReadPixels(bool did_finish); |
| 2148 void FinishReadPixels(GLsizei width, | 2148 void FinishReadPixels(GLsizei width, |
| 2149 GLsizei height, | 2149 GLsizei height, |
| 2150 GLsizei format, | 2150 GLsizei format, |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2606 decoder_->should_use_native_gmb_for_backbuffer_ && | 2606 decoder_->should_use_native_gmb_for_backbuffer_ && |
| 2607 !decoder_->offscreen_buffer_should_have_alpha_ && | 2607 !decoder_->offscreen_buffer_should_have_alpha_ && |
| 2608 decoder_->ChromiumImageNeedsRGBEmulation() && | 2608 decoder_->ChromiumImageNeedsRGBEmulation() && |
| 2609 decoder_->workarounds() | 2609 decoder_->workarounds() |
| 2610 .disable_multisampling_color_mask_usage; | 2610 .disable_multisampling_color_mask_usage; |
| 2611 if (alpha_channel_needs_clear) { | 2611 if (alpha_channel_needs_clear) { |
| 2612 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, | 2612 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, |
| 2613 decoder_->offscreen_target_frame_buffer_->id()); | 2613 decoder_->offscreen_target_frame_buffer_->id()); |
| 2614 decoder_->state_.SetDeviceColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); | 2614 decoder_->state_.SetDeviceColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); |
| 2615 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 2615 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
| 2616 glClearColor(0, 0, 0, 1); | 2616 glClearColor(0, 0, 0, 1.001); |
| 2617 glClear(GL_COLOR_BUFFER_BIT); | 2617 glClear(GL_COLOR_BUFFER_BIT); |
| 2618 decoder_->RestoreClearState(); | 2618 decoder_->RestoreClearState(); |
| 2619 } | 2619 } |
| 2620 | 2620 |
| 2621 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, | 2621 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, |
| 2622 decoder_->offscreen_target_frame_buffer_->id()); | 2622 decoder_->offscreen_target_frame_buffer_->id()); |
| 2623 GLuint targetid; | 2623 GLuint targetid; |
| 2624 if (internal) { | 2624 if (internal) { |
| 2625 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { | 2625 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { |
| 2626 decoder_->offscreen_resolved_frame_buffer_.reset( | 2626 decoder_->offscreen_resolved_frame_buffer_.reset( |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3580 // because the system already clears the buffer before each draw. Proper | 3580 // because the system already clears the buffer before each draw. Proper |
| 3581 // fix might be setting the scissor clip properly before initialize. See | 3581 // fix might be setting the scissor clip properly before initialize. See |
| 3582 // crbug.com/259023 for details. | 3582 // crbug.com/259023 for details. |
| 3583 call_gl_clear = surface_->GetHandle(); | 3583 call_gl_clear = surface_->GetHandle(); |
| 3584 #endif | 3584 #endif |
| 3585 if (call_gl_clear) { | 3585 if (call_gl_clear) { |
| 3586 // On configs where we report no alpha, if the underlying surface has | 3586 // On configs where we report no alpha, if the underlying surface has |
| 3587 // alpha, clear the surface alpha to 1.0 to be correct on ReadPixels/etc. | 3587 // alpha, clear the surface alpha to 1.0 to be correct on ReadPixels/etc. |
| 3588 bool clear_alpha = back_buffer_color_format_ == GL_RGB && alpha_bits > 0; | 3588 bool clear_alpha = back_buffer_color_format_ == GL_RGB && alpha_bits > 0; |
| 3589 if (clear_alpha) { | 3589 if (clear_alpha) { |
| 3590 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); | 3590 glClearColor(0.0f, 0.0f, 0.0f, 1.001f); |
| 3591 } | 3591 } |
| 3592 | 3592 |
| 3593 // Clear the backbuffer. | 3593 // Clear the backbuffer. |
| 3594 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 3594 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 3595 | 3595 |
| 3596 // Restore alpha clear value if we changed it. | 3596 // Restore alpha clear value if we changed it. |
| 3597 if (clear_alpha) { | 3597 if (clear_alpha) { |
| 3598 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | 3598 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 3599 } | 3599 } |
| 3600 } | 3600 } |
| (...skipping 4109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7710 } | 7710 } |
| 7711 | 7711 |
| 7712 framebuffer_manager()->MarkAttachmentsAsCleared( | 7712 framebuffer_manager()->MarkAttachmentsAsCleared( |
| 7713 framebuffer, renderbuffer_manager(), texture_manager()); | 7713 framebuffer, renderbuffer_manager(), texture_manager()); |
| 7714 } | 7714 } |
| 7715 | 7715 |
| 7716 void GLES2DecoderImpl::RestoreClearState() { | 7716 void GLES2DecoderImpl::RestoreClearState() { |
| 7717 framebuffer_state_.clear_state_dirty = true; | 7717 framebuffer_state_.clear_state_dirty = true; |
| 7718 glClearColor( | 7718 glClearColor( |
| 7719 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, | 7719 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, |
| 7720 state_.color_clear_alpha); | 7720 state_.color_clear_alpha + 0.001); |
| 7721 glClearStencil(state_.stencil_clear); | 7721 glClearStencil(state_.stencil_clear); |
| 7722 glClearDepth(state_.depth_clear); | 7722 glClearDepth(state_.depth_clear); |
| 7723 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | 7723 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, |
| 7724 state_.enable_flags.scissor_test); | 7724 state_.enable_flags.scissor_test); |
| 7725 gfx::Vector2d scissor_offset = GetBoundFramebufferDrawOffset(); | 7725 gfx::Vector2d scissor_offset = GetBoundFramebufferDrawOffset(); |
| 7726 glScissor(state_.scissor_x + scissor_offset.x(), | 7726 glScissor(state_.scissor_x + scissor_offset.x(), |
| 7727 state_.scissor_y + scissor_offset.y(), state_.scissor_width, | 7727 state_.scissor_y + scissor_offset.y(), state_.scissor_width, |
| 7728 state_.scissor_height); | 7728 state_.scissor_height); |
| 7729 } | 7729 } |
| 7730 | 7730 |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8645 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); | 8645 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); |
| 8646 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 8646 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 8647 GL_RENDERBUFFER, 0); | 8647 GL_RENDERBUFFER, 0); |
| 8648 | 8648 |
| 8649 // Restore cached state. | 8649 // Restore cached state. |
| 8650 if (scissor_enabled) | 8650 if (scissor_enabled) |
| 8651 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); | 8651 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); |
| 8652 | 8652 |
| 8653 state_.SetDeviceColorMask( | 8653 state_.SetDeviceColorMask( |
| 8654 color_mask[0], color_mask[1], color_mask[2], color_mask[3]); | 8654 color_mask[0], color_mask[1], color_mask[2], color_mask[3]); |
| 8655 glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); | 8655 glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3] +
0.001); |
| 8656 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, draw_framebuffer); | 8656 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, draw_framebuffer); |
| 8657 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_framebuffer); | 8657 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_framebuffer); |
| 8658 | 8658 |
| 8659 // Return true if the pixel matched the desired key color. | 8659 // Return true if the pixel matched the desired key color. |
| 8660 return (pixel[0] == 0xFF && | 8660 return (pixel[0] == 0xFF && |
| 8661 pixel[1] == 0x00 && | 8661 pixel[1] == 0x00 && |
| 8662 pixel[2] == 0xFF); | 8662 pixel[2] == 0xFF); |
| 8663 } | 8663 } |
| 8664 | 8664 |
| 8665 void GLES2DecoderImpl::DoRenderbufferStorage( | 8665 void GLES2DecoderImpl::DoRenderbufferStorage( |
| (...skipping 10994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19660 } | 19660 } |
| 19661 | 19661 |
| 19662 // Include the auto-generated part of this file. We split this because it means | 19662 // Include the auto-generated part of this file. We split this because it means |
| 19663 // we can easily edit the non-auto generated parts right here in this file | 19663 // we can easily edit the non-auto generated parts right here in this file |
| 19664 // instead of having to edit some template or the code generator. | 19664 // instead of having to edit some template or the code generator. |
| 19665 #include "base/macros.h" | 19665 #include "base/macros.h" |
| 19666 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19666 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19667 | 19667 |
| 19668 } // namespace gles2 | 19668 } // namespace gles2 |
| 19669 } // namespace gpu | 19669 } // namespace gpu |
| OLD | NEW |