| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 ResourceProvider* resource_provider, | 373 ResourceProvider* resource_provider, |
| 374 TextureMailboxDeleter* texture_mailbox_deleter, | 374 TextureMailboxDeleter* texture_mailbox_deleter, |
| 375 int highp_threshold_min) | 375 int highp_threshold_min) |
| 376 : DirectRenderer(settings, output_surface, resource_provider), | 376 : DirectRenderer(settings, output_surface, resource_provider), |
| 377 offscreen_framebuffer_id_(0), | 377 offscreen_framebuffer_id_(0), |
| 378 shared_geometry_quad_(QuadVertexRect()), | 378 shared_geometry_quad_(QuadVertexRect()), |
| 379 gl_(output_surface->context_provider()->ContextGL()), | 379 gl_(output_surface->context_provider()->ContextGL()), |
| 380 context_support_(output_surface->context_provider()->ContextSupport()), | 380 context_support_(output_surface->context_provider()->ContextSupport()), |
| 381 texture_mailbox_deleter_(texture_mailbox_deleter), | 381 texture_mailbox_deleter_(texture_mailbox_deleter), |
| 382 is_scissor_enabled_(false), | 382 is_scissor_enabled_(false), |
| 383 scissor_rect_needs_reset_(true), | |
| 384 stencil_shadow_(false), | 383 stencil_shadow_(false), |
| 385 blend_shadow_(false), | 384 blend_shadow_(false), |
| 386 highp_threshold_min_(highp_threshold_min), | 385 highp_threshold_min_(highp_threshold_min), |
| 387 highp_threshold_cache_(0), | 386 highp_threshold_cache_(0), |
| 388 use_sync_query_(false), | 387 use_sync_query_(false), |
| 389 gl_composited_texture_quad_border_( | 388 gl_composited_texture_quad_border_( |
| 390 settings->gl_composited_texture_quad_border), | 389 settings->gl_composited_texture_quad_border), |
| 391 bound_geometry_(NO_BINDING), | 390 bound_geometry_(NO_BINDING), |
| 392 color_lut_cache_(gl_) { | 391 color_lut_cache_(gl_) { |
| 393 DCHECK(gl_); | 392 DCHECK(gl_); |
| (...skipping 2823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 GL_FRAMEBUFFER_COMPLETE || | 3216 GL_FRAMEBUFFER_COMPLETE || |
| 3218 IsContextLost()); | 3217 IsContextLost()); |
| 3219 return true; | 3218 return true; |
| 3220 } | 3219 } |
| 3221 | 3220 |
| 3222 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { | 3221 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { |
| 3223 EnsureScissorTestEnabled(); | 3222 EnsureScissorTestEnabled(); |
| 3224 | 3223 |
| 3225 // Don't unnecessarily ask the context to change the scissor, because it | 3224 // Don't unnecessarily ask the context to change the scissor, because it |
| 3226 // may cause undesired GPU pipeline flushes. | 3225 // may cause undesired GPU pipeline flushes. |
| 3227 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) | 3226 if (scissor_rect == scissor_rect_) { |
| 3227 #if DCHECK_IS_ON() |
| 3228 // GetIntegerv doesn't modify the output array when GL context is lost or |
| 3229 // in test mock. Also our GL wrapper requires output to be initialized with |
| 3230 // 0 or -1. Assuming lost context if the output is still -1. |
| 3231 GLint actual_scissor[4] = {-1}; |
| 3232 gl_->GetIntegerv(GL_SCISSOR_BOX, actual_scissor); |
| 3233 if (actual_scissor[0] == -1) |
| 3234 return; |
| 3235 DCHECK(scissor_rect.x() == actual_scissor[0] && |
| 3236 scissor_rect.y() == actual_scissor[1] && |
| 3237 scissor_rect.width() == actual_scissor[2] && |
| 3238 scissor_rect.height() == actual_scissor[3]); |
| 3239 #endif |
| 3228 return; | 3240 return; |
| 3241 } |
| 3229 | 3242 |
| 3230 scissor_rect_ = scissor_rect; | 3243 scissor_rect_ = scissor_rect; |
| 3231 FlushTextureQuadCache(SHARED_BINDING); | 3244 FlushTextureQuadCache(SHARED_BINDING); |
| 3232 gl_->Scissor(scissor_rect.x(), scissor_rect.y(), scissor_rect.width(), | 3245 gl_->Scissor(scissor_rect.x(), scissor_rect.y(), scissor_rect.width(), |
| 3233 scissor_rect.height()); | 3246 scissor_rect.height()); |
| 3234 | |
| 3235 scissor_rect_needs_reset_ = false; | |
| 3236 } | 3247 } |
| 3237 | 3248 |
| 3238 void GLRenderer::SetViewport() { | 3249 void GLRenderer::SetViewport() { |
| 3239 gl_->Viewport(current_window_space_viewport_.x(), | 3250 gl_->Viewport(current_window_space_viewport_.x(), |
| 3240 current_window_space_viewport_.y(), | 3251 current_window_space_viewport_.y(), |
| 3241 current_window_space_viewport_.width(), | 3252 current_window_space_viewport_.width(), |
| 3242 current_window_space_viewport_.height()); | 3253 current_window_space_viewport_.height()); |
| 3243 } | 3254 } |
| 3244 | 3255 |
| 3245 void GLRenderer::InitializeSharedObjects() { | 3256 void GLRenderer::InitializeSharedObjects() { |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3717 solid_color_program_aa_.Cleanup(gl_); | 3728 solid_color_program_aa_.Cleanup(gl_); |
| 3718 | 3729 |
| 3719 if (offscreen_framebuffer_id_) | 3730 if (offscreen_framebuffer_id_) |
| 3720 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_); | 3731 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_); |
| 3721 | 3732 |
| 3722 ReleaseRenderPassTextures(); | 3733 ReleaseRenderPassTextures(); |
| 3723 } | 3734 } |
| 3724 | 3735 |
| 3725 void GLRenderer::ReinitializeGLState() { | 3736 void GLRenderer::ReinitializeGLState() { |
| 3726 is_scissor_enabled_ = false; | 3737 is_scissor_enabled_ = false; |
| 3727 scissor_rect_needs_reset_ = true; | 3738 scissor_rect_ = gfx::Rect(); |
| 3728 stencil_shadow_ = false; | 3739 stencil_shadow_ = false; |
| 3729 blend_shadow_ = true; | 3740 blend_shadow_ = true; |
| 3730 program_shadow_ = 0; | 3741 program_shadow_ = 0; |
| 3731 | 3742 |
| 3732 RestoreGLState(); | 3743 RestoreGLState(); |
| 3733 } | 3744 } |
| 3734 | 3745 |
| 3735 void GLRenderer::RestoreGLState() { | 3746 void GLRenderer::RestoreGLState() { |
| 3736 // This restores the current GLRenderer state to the GL context. | 3747 // This restores the current GLRenderer state to the GL context. |
| 3737 bound_geometry_ = NO_BINDING; | 3748 bound_geometry_ = NO_BINDING; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3749 if (stencil_shadow_) | 3760 if (stencil_shadow_) |
| 3750 gl_->Enable(GL_STENCIL_TEST); | 3761 gl_->Enable(GL_STENCIL_TEST); |
| 3751 else | 3762 else |
| 3752 gl_->Disable(GL_STENCIL_TEST); | 3763 gl_->Disable(GL_STENCIL_TEST); |
| 3753 | 3764 |
| 3754 if (blend_shadow_) | 3765 if (blend_shadow_) |
| 3755 gl_->Enable(GL_BLEND); | 3766 gl_->Enable(GL_BLEND); |
| 3756 else | 3767 else |
| 3757 gl_->Disable(GL_BLEND); | 3768 gl_->Disable(GL_BLEND); |
| 3758 | 3769 |
| 3759 if (is_scissor_enabled_) { | 3770 if (is_scissor_enabled_) |
| 3760 gl_->Enable(GL_SCISSOR_TEST); | 3771 gl_->Enable(GL_SCISSOR_TEST); |
| 3761 gl_->Scissor(scissor_rect_.x(), scissor_rect_.y(), scissor_rect_.width(), | 3772 else |
| 3762 scissor_rect_.height()); | |
| 3763 } else { | |
| 3764 gl_->Disable(GL_SCISSOR_TEST); | 3773 gl_->Disable(GL_SCISSOR_TEST); |
| 3765 } | 3774 |
| 3775 gl_->Scissor(scissor_rect_.x(), scissor_rect_.y(), scissor_rect_.width(), |
| 3776 scissor_rect_.height()); |
| 3766 } | 3777 } |
| 3767 | 3778 |
| 3768 bool GLRenderer::IsContextLost() { | 3779 bool GLRenderer::IsContextLost() { |
| 3769 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 3780 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
| 3770 } | 3781 } |
| 3771 | 3782 |
| 3772 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { | 3783 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { |
| 3773 if (overlay_resource_pool_) { | 3784 if (overlay_resource_pool_) { |
| 3774 overlay_resource_pool_->CheckBusyResources(); | 3785 overlay_resource_pool_->CheckBusyResources(); |
| 3775 } | 3786 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4045 // The alpha has already been applied when copying the RPDQ to an IOSurface. | 4056 // The alpha has already been applied when copying the RPDQ to an IOSurface. |
| 4046 GLfloat alpha = 1; | 4057 GLfloat alpha = 1; |
| 4047 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, | 4058 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, |
| 4048 sorting_context_id, gl_transform); | 4059 sorting_context_id, gl_transform); |
| 4049 gl_->ScheduleCALayerCHROMIUM( | 4060 gl_->ScheduleCALayerCHROMIUM( |
| 4050 texture_id, contents_rect, ca_layer_overlay->background_color, | 4061 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4051 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4062 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4052 } | 4063 } |
| 4053 | 4064 |
| 4054 } // namespace cc | 4065 } // namespace cc |
| OLD | NEW |