| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 int highp_threshold_min) | 161 int highp_threshold_min) |
| 162 : DirectRenderer(client, settings, output_surface, resource_provider), | 162 : DirectRenderer(client, settings, output_surface, resource_provider), |
| 163 offscreen_framebuffer_id_(0), | 163 offscreen_framebuffer_id_(0), |
| 164 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), | 164 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), |
| 165 context_(output_surface->context_provider()->Context3d()), | 165 context_(output_surface->context_provider()->Context3d()), |
| 166 context_support_(output_surface->context_provider()->ContextSupport()), | 166 context_support_(output_surface->context_provider()->ContextSupport()), |
| 167 texture_mailbox_deleter_(texture_mailbox_deleter), | 167 texture_mailbox_deleter_(texture_mailbox_deleter), |
| 168 is_backbuffer_discarded_(false), | 168 is_backbuffer_discarded_(false), |
| 169 visible_(true), | 169 visible_(true), |
| 170 is_scissor_enabled_(false), | 170 is_scissor_enabled_(false), |
| 171 scissor_rect_needs_reset_(true), |
| 171 stencil_shadow_(false), | 172 stencil_shadow_(false), |
| 172 blend_shadow_(false), | 173 blend_shadow_(false), |
| 173 highp_threshold_min_(highp_threshold_min), | 174 highp_threshold_min_(highp_threshold_min), |
| 174 highp_threshold_cache_(0), | 175 highp_threshold_cache_(0), |
| 175 on_demand_tile_raster_resource_id_(0) { | 176 on_demand_tile_raster_resource_id_(0) { |
| 176 DCHECK(context_); | 177 DCHECK(context_); |
| 177 DCHECK(context_support_); | 178 DCHECK(context_support_); |
| 178 } | 179 } |
| 179 | 180 |
| 180 bool GLRenderer::Initialize() { | 181 bool GLRenderer::Initialize() { |
| (...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 gfx::Rect(target_rect.size()), | 2480 gfx::Rect(target_rect.size()), |
| 2480 target_rect.size()); | 2481 target_rect.size()); |
| 2481 return true; | 2482 return true; |
| 2482 } | 2483 } |
| 2483 | 2484 |
| 2484 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { | 2485 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { |
| 2485 EnsureScissorTestEnabled(); | 2486 EnsureScissorTestEnabled(); |
| 2486 | 2487 |
| 2487 // Don't unnecessarily ask the context to change the scissor, because it | 2488 // Don't unnecessarily ask the context to change the scissor, because it |
| 2488 // may cause undesired GPU pipeline flushes. | 2489 // may cause undesired GPU pipeline flushes. |
| 2489 if (scissor_rect == scissor_rect_) | 2490 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) |
| 2490 return; | 2491 return; |
| 2491 | 2492 |
| 2492 scissor_rect_ = scissor_rect; | 2493 scissor_rect_ = scissor_rect; |
| 2493 FlushTextureQuadCache(); | 2494 FlushTextureQuadCache(); |
| 2494 GLC(context_, | 2495 GLC(context_, |
| 2495 context_->scissor(scissor_rect.x(), | 2496 context_->scissor(scissor_rect.x(), |
| 2496 scissor_rect.y(), | 2497 scissor_rect.y(), |
| 2497 scissor_rect.width(), | 2498 scissor_rect.width(), |
| 2498 scissor_rect.height())); | 2499 scissor_rect.height())); |
| 2500 |
| 2501 scissor_rect_needs_reset_ = false; |
| 2499 } | 2502 } |
| 2500 | 2503 |
| 2501 void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) { | 2504 void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) { |
| 2502 viewport_ = window_space_viewport; | 2505 viewport_ = window_space_viewport; |
| 2503 GLC(context_, context_->viewport(window_space_viewport.x(), | 2506 GLC(context_, context_->viewport(window_space_viewport.x(), |
| 2504 window_space_viewport.y(), | 2507 window_space_viewport.y(), |
| 2505 window_space_viewport.width(), | 2508 window_space_viewport.width(), |
| 2506 window_space_viewport.height())); | 2509 window_space_viewport.height())); |
| 2507 } | 2510 } |
| 2508 | 2511 |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2939 stencil_shadow_ = false; | 2942 stencil_shadow_ = false; |
| 2940 GLC(context_, context_->enable(GL_BLEND)); | 2943 GLC(context_, context_->enable(GL_BLEND)); |
| 2941 blend_shadow_ = true; | 2944 blend_shadow_ = true; |
| 2942 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 2945 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
| 2943 GLC(context_, context_->activeTexture(GL_TEXTURE0)); | 2946 GLC(context_, context_->activeTexture(GL_TEXTURE0)); |
| 2944 program_shadow_ = 0; | 2947 program_shadow_ = 0; |
| 2945 | 2948 |
| 2946 // Make sure scissoring starts as disabled. | 2949 // Make sure scissoring starts as disabled. |
| 2947 is_scissor_enabled_ = false; | 2950 is_scissor_enabled_ = false; |
| 2948 GLC(context_, context_->disable(GL_SCISSOR_TEST)); | 2951 GLC(context_, context_->disable(GL_SCISSOR_TEST)); |
| 2952 scissor_rect_needs_reset_ = true; |
| 2949 } | 2953 } |
| 2950 | 2954 |
| 2951 bool GLRenderer::CanUseSkiaGPUBackend() const { | 2955 bool GLRenderer::CanUseSkiaGPUBackend() const { |
| 2952 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 2956 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
| 2953 // implementation. | 2957 // implementation. |
| 2954 return gr_context_ && context_->getContextAttributes().stencil; | 2958 return gr_context_ && context_->getContextAttributes().stencil; |
| 2955 } | 2959 } |
| 2956 | 2960 |
| 2957 bool GLRenderer::IsContextLost() { | 2961 bool GLRenderer::IsContextLost() { |
| 2958 return output_surface_->context_provider()->IsContextLost(); | 2962 return output_surface_->context_provider()->IsContextLost(); |
| 2959 } | 2963 } |
| 2960 | 2964 |
| 2961 } // namespace cc | 2965 } // namespace cc |
| OLD | NEW |