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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 stats.backbufferRequested = !is_backbuffer_discarded_; | 283 stats.backbufferRequested = !is_backbuffer_discarded_; |
284 context_->sendManagedMemoryStatsCHROMIUM(&stats); | 284 context_->sendManagedMemoryStatsCHROMIUM(&stats); |
285 } | 285 } |
286 | 286 |
287 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } | 287 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } |
288 | 288 |
289 void GLRenderer::ViewportChanged() { | 289 void GLRenderer::ViewportChanged() { |
290 ReinitializeGrCanvas(); | 290 ReinitializeGrCanvas(); |
291 } | 291 } |
292 | 292 |
293 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { | 293 void GLRenderer::DiscardPixels(bool has_external_stencil_test, |
| 294 bool redraw_rect_covers_full_surface) { |
| 295 if (has_external_stencil_test || |
| 296 !redraw_rect_covers_full_surface || |
| 297 !capabilities_.using_discard_framebuffer) |
| 298 return; |
| 299 bool using_default_framebuffer = |
| 300 !current_framebuffer_lock_ && |
| 301 output_surface_->capabilities().uses_default_gl_framebuffer; |
| 302 GLenum attachments[] = {static_cast<GLenum>( |
| 303 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)}; |
| 304 context_->discardFramebufferEXT( |
| 305 GL_FRAMEBUFFER, arraysize(attachments), attachments); |
| 306 } |
| 307 |
| 308 void GLRenderer::ClearFramebuffer(DrawingFrame* frame, |
| 309 bool has_external_stencil_test) { |
294 // It's unsafe to clear when we have a stencil test because glClear ignores | 310 // It's unsafe to clear when we have a stencil test because glClear ignores |
295 // stencil. | 311 // stencil. |
296 if (output_surface_->HasExternalStencilTest() && | 312 if (has_external_stencil_test) { |
297 frame->current_render_pass == frame->root_render_pass) { | |
298 DCHECK(!frame->current_render_pass->has_transparent_background); | 313 DCHECK(!frame->current_render_pass->has_transparent_background); |
299 return; | 314 return; |
300 } | 315 } |
301 | 316 |
302 if (capabilities_.using_discard_framebuffer) { | |
303 bool using_default_framebuffer = | |
304 !current_framebuffer_lock_ && | |
305 output_surface_->capabilities().uses_default_gl_framebuffer; | |
306 GLenum attachments[] = {static_cast<GLenum>( | |
307 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)}; | |
308 context_->discardFramebufferEXT( | |
309 GL_FRAMEBUFFER, arraysize(attachments), attachments); | |
310 } | |
311 | |
312 // On DEBUG builds, opaque render passes are cleared to blue to easily see | 317 // On DEBUG builds, opaque render passes are cleared to blue to easily see |
313 // regions that were not drawn on the screen. | 318 // regions that were not drawn on the screen. |
314 if (frame->current_render_pass->has_transparent_background) | 319 if (frame->current_render_pass->has_transparent_background) |
315 GLC(context_, context_->clearColor(0, 0, 0, 0)); | 320 GLC(context_, context_->clearColor(0, 0, 0, 0)); |
316 else | 321 else |
317 GLC(context_, context_->clearColor(0, 0, 1, 1)); | 322 GLC(context_, context_->clearColor(0, 0, 1, 1)); |
318 | 323 |
319 bool always_clear = false; | 324 bool always_clear = false; |
320 #ifndef NDEBUG | 325 #ifndef NDEBUG |
321 always_clear = true; | 326 always_clear = true; |
(...skipping 2806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3128 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 3133 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
3129 // implementation. | 3134 // implementation. |
3130 return gr_context_ && context_->getContextAttributes().stencil; | 3135 return gr_context_ && context_->getContextAttributes().stencil; |
3131 } | 3136 } |
3132 | 3137 |
3133 bool GLRenderer::IsContextLost() { | 3138 bool GLRenderer::IsContextLost() { |
3134 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 3139 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
3135 } | 3140 } |
3136 | 3141 |
3137 } // namespace cc | 3142 } // namespace cc |
OLD | NEW |