| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 int highp_threshold_min) | 175 int highp_threshold_min) |
| 176 : DirectRenderer(client, settings, output_surface, resource_provider), | 176 : DirectRenderer(client, settings, output_surface, resource_provider), |
| 177 offscreen_framebuffer_id_(0), | 177 offscreen_framebuffer_id_(0), |
| 178 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), | 178 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), |
| 179 context_(output_surface->context_provider()->Context3d()), | 179 context_(output_surface->context_provider()->Context3d()), |
| 180 context_support_(output_surface->context_provider()->ContextSupport()), | 180 context_support_(output_surface->context_provider()->ContextSupport()), |
| 181 texture_mailbox_deleter_(texture_mailbox_deleter), | 181 texture_mailbox_deleter_(texture_mailbox_deleter), |
| 182 is_backbuffer_discarded_(false), | 182 is_backbuffer_discarded_(false), |
| 183 visible_(true), | 183 visible_(true), |
| 184 is_scissor_enabled_(false), | 184 is_scissor_enabled_(false), |
| 185 scissor_rect_needs_reset_(true), |
| 185 stencil_shadow_(false), | 186 stencil_shadow_(false), |
| 186 blend_shadow_(false), | 187 blend_shadow_(false), |
| 187 highp_threshold_min_(highp_threshold_min), | 188 highp_threshold_min_(highp_threshold_min), |
| 188 highp_threshold_cache_(0), | 189 highp_threshold_cache_(0), |
| 189 on_demand_tile_raster_resource_id_(0) { | 190 on_demand_tile_raster_resource_id_(0) { |
| 190 DCHECK(context_); | 191 DCHECK(context_); |
| 191 DCHECK(context_support_); | 192 DCHECK(context_support_); |
| 192 } | 193 } |
| 193 | 194 |
| 194 bool GLRenderer::Initialize() { | 195 bool GLRenderer::Initialize() { |
| (...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2512 gfx::Rect(target_rect.size()), | 2513 gfx::Rect(target_rect.size()), |
| 2513 target_rect.size()); | 2514 target_rect.size()); |
| 2514 return true; | 2515 return true; |
| 2515 } | 2516 } |
| 2516 | 2517 |
| 2517 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { | 2518 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { |
| 2518 EnsureScissorTestEnabled(); | 2519 EnsureScissorTestEnabled(); |
| 2519 | 2520 |
| 2520 // Don't unnecessarily ask the context to change the scissor, because it | 2521 // Don't unnecessarily ask the context to change the scissor, because it |
| 2521 // may cause undesired GPU pipeline flushes. | 2522 // may cause undesired GPU pipeline flushes. |
| 2522 if (scissor_rect == scissor_rect_) | 2523 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) |
| 2523 return; | 2524 return; |
| 2524 | 2525 |
| 2525 scissor_rect_ = scissor_rect; | 2526 scissor_rect_ = scissor_rect; |
| 2526 FlushTextureQuadCache(); | 2527 FlushTextureQuadCache(); |
| 2527 GLC(context_, | 2528 GLC(context_, |
| 2528 context_->scissor(scissor_rect.x(), | 2529 context_->scissor(scissor_rect.x(), |
| 2529 scissor_rect.y(), | 2530 scissor_rect.y(), |
| 2530 scissor_rect.width(), | 2531 scissor_rect.width(), |
| 2531 scissor_rect.height())); | 2532 scissor_rect.height())); |
| 2533 |
| 2534 scissor_rect_needs_reset_ = false; |
| 2532 } | 2535 } |
| 2533 | 2536 |
| 2534 void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) { | 2537 void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) { |
| 2535 viewport_ = window_space_viewport; | 2538 viewport_ = window_space_viewport; |
| 2536 GLC(context_, context_->viewport(window_space_viewport.x(), | 2539 GLC(context_, context_->viewport(window_space_viewport.x(), |
| 2537 window_space_viewport.y(), | 2540 window_space_viewport.y(), |
| 2538 window_space_viewport.width(), | 2541 window_space_viewport.width(), |
| 2539 window_space_viewport.height())); | 2542 window_space_viewport.height())); |
| 2540 } | 2543 } |
| 2541 | 2544 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2998 stencil_shadow_ = false; | 3001 stencil_shadow_ = false; |
| 2999 GLC(context_, context_->enable(GL_BLEND)); | 3002 GLC(context_, context_->enable(GL_BLEND)); |
| 3000 blend_shadow_ = true; | 3003 blend_shadow_ = true; |
| 3001 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 3004 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
| 3002 GLC(context_, context_->activeTexture(GL_TEXTURE0)); | 3005 GLC(context_, context_->activeTexture(GL_TEXTURE0)); |
| 3003 program_shadow_ = 0; | 3006 program_shadow_ = 0; |
| 3004 | 3007 |
| 3005 // Make sure scissoring starts as disabled. | 3008 // Make sure scissoring starts as disabled. |
| 3006 is_scissor_enabled_ = false; | 3009 is_scissor_enabled_ = false; |
| 3007 GLC(context_, context_->disable(GL_SCISSOR_TEST)); | 3010 GLC(context_, context_->disable(GL_SCISSOR_TEST)); |
| 3011 scissor_rect_needs_reset_ = true; |
| 3008 } | 3012 } |
| 3009 | 3013 |
| 3010 bool GLRenderer::CanUseSkiaGPUBackend() const { | 3014 bool GLRenderer::CanUseSkiaGPUBackend() const { |
| 3011 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 3015 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
| 3012 // implementation. | 3016 // implementation. |
| 3013 return gr_context_ && context_->getContextAttributes().stencil; | 3017 return gr_context_ && context_->getContextAttributes().stencil; |
| 3014 } | 3018 } |
| 3015 | 3019 |
| 3016 bool GLRenderer::IsContextLost() { | 3020 bool GLRenderer::IsContextLost() { |
| 3017 return output_surface_->context_provider()->IsContextLost(); | 3021 return output_surface_->context_provider()->IsContextLost(); |
| 3018 } | 3022 } |
| 3019 | 3023 |
| 3020 } // namespace cc | 3024 } // namespace cc |
| OLD | NEW |