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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ResourceProvider* resource_provider, | 159 ResourceProvider* resource_provider, |
160 TextureMailboxDeleter* texture_mailbox_deleter, | 160 TextureMailboxDeleter* texture_mailbox_deleter, |
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 discard_backbuffer_when_not_visible_(false), | |
170 is_using_bind_uniform_(false), | 169 is_using_bind_uniform_(false), |
171 visible_(true), | 170 visible_(true), |
172 is_scissor_enabled_(false), | 171 is_scissor_enabled_(false), |
173 stencil_shadow_(false), | 172 stencil_shadow_(false), |
174 blend_shadow_(false), | 173 blend_shadow_(false), |
175 highp_threshold_min_(highp_threshold_min), | 174 highp_threshold_min_(highp_threshold_min), |
176 highp_threshold_cache_(0), | 175 highp_threshold_cache_(0), |
177 on_demand_tile_raster_resource_id_(0) { | 176 on_demand_tile_raster_resource_id_(0) { |
178 DCHECK(context_); | 177 DCHECK(context_); |
179 DCHECK(context_support_); | 178 DCHECK(context_support_); |
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 | 2095 |
2097 // We don't have real fences, so we mark read fences as passed | 2096 // We don't have real fences, so we mark read fences as passed |
2098 // assuming a double-buffered GPU pipeline. A texture can be | 2097 // assuming a double-buffered GPU pipeline. A texture can be |
2099 // written to after one full frame has past since it was last read. | 2098 // written to after one full frame has past since it was last read. |
2100 if (last_swap_fence_.get()) | 2099 if (last_swap_fence_.get()) |
2101 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); | 2100 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); |
2102 last_swap_fence_ = resource_provider_->GetReadLockFence(); | 2101 last_swap_fence_ = resource_provider_->GetReadLockFence(); |
2103 resource_provider_->SetReadLockFence(new SimpleSwapFence()); | 2102 resource_provider_->SetReadLockFence(new SimpleSwapFence()); |
2104 } | 2103 } |
2105 | 2104 |
2106 void GLRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { | |
2107 discard_backbuffer_when_not_visible_ = discard; | |
2108 EnforceMemoryPolicy(); | |
2109 } | |
2110 | |
2111 void GLRenderer::EnforceMemoryPolicy() { | 2105 void GLRenderer::EnforceMemoryPolicy() { |
2112 if (!visible_) { | 2106 if (!visible_) { |
2113 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources"); | 2107 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources"); |
2114 ReleaseRenderPassTextures(); | 2108 ReleaseRenderPassTextures(); |
2115 if (discard_backbuffer_when_not_visible_) | 2109 DiscardBackbuffer(); |
2116 DiscardBackbuffer(); | |
2117 resource_provider_->ReleaseCachedData(); | 2110 resource_provider_->ReleaseCachedData(); |
2118 GLC(context_, context_->flush()); | 2111 GLC(context_, context_->flush()); |
2119 } | 2112 } |
2120 } | 2113 } |
2121 | 2114 |
2122 void GLRenderer::DiscardBackbuffer() { | 2115 void GLRenderer::DiscardBackbuffer() { |
2123 if (is_backbuffer_discarded_) | 2116 if (is_backbuffer_discarded_) |
2124 return; | 2117 return; |
2125 | 2118 |
2126 output_surface_->DiscardBackbuffer(); | 2119 output_surface_->DiscardBackbuffer(); |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3089 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 3082 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
3090 // implementation. | 3083 // implementation. |
3091 return gr_context_ && context_->getContextAttributes().stencil; | 3084 return gr_context_ && context_->getContextAttributes().stencil; |
3092 } | 3085 } |
3093 | 3086 |
3094 bool GLRenderer::IsContextLost() { | 3087 bool GLRenderer::IsContextLost() { |
3095 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 3088 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
3096 } | 3089 } |
3097 | 3090 |
3098 } // namespace cc | 3091 } // namespace cc |
OLD | NEW |