Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 24239006: cc: Don't discard framebuffer when using partial swaps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 draw_rect_covers_full_surface) {
295 if (has_external_stencil_test || !draw_rect_covers_full_surface ||
296 !capabilities_.using_discard_framebuffer)
297 return;
298 bool using_default_framebuffer =
299 !current_framebuffer_lock_ &&
300 output_surface_->capabilities().uses_default_gl_framebuffer;
301 GLenum attachments[] = {static_cast<GLenum>(
302 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)};
303 context_->discardFramebufferEXT(
304 GL_FRAMEBUFFER, arraysize(attachments), attachments);
305 }
306
307 void GLRenderer::ClearFramebuffer(DrawingFrame* frame,
308 bool has_external_stencil_test) {
294 // It's unsafe to clear when we have a stencil test because glClear ignores 309 // It's unsafe to clear when we have a stencil test because glClear ignores
295 // stencil. 310 // stencil.
296 if (output_surface_->HasExternalStencilTest() && 311 if (has_external_stencil_test) {
297 frame->current_render_pass == frame->root_render_pass) {
298 DCHECK(!frame->current_render_pass->has_transparent_background); 312 DCHECK(!frame->current_render_pass->has_transparent_background);
299 return; 313 return;
300 } 314 }
301 315
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 316 // On DEBUG builds, opaque render passes are cleared to blue to easily see
313 // regions that were not drawn on the screen. 317 // regions that were not drawn on the screen.
314 if (frame->current_render_pass->has_transparent_background) 318 if (frame->current_render_pass->has_transparent_background)
315 GLC(context_, context_->clearColor(0, 0, 0, 0)); 319 GLC(context_, context_->clearColor(0, 0, 0, 0));
316 else 320 else
317 GLC(context_, context_->clearColor(0, 0, 1, 1)); 321 GLC(context_, context_->clearColor(0, 0, 1, 1));
318 322
319 bool always_clear = false; 323 bool always_clear = false;
320 #ifndef NDEBUG 324 #ifndef NDEBUG
321 always_clear = true; 325 always_clear = true;
(...skipping 2806 matching lines...) Expand 10 before | Expand all | Expand 10 after
3128 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas 3132 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas
3129 // implementation. 3133 // implementation.
3130 return gr_context_ && context_->getContextAttributes().stencil; 3134 return gr_context_ && context_->getContextAttributes().stencil;
3131 } 3135 }
3132 3136
3133 bool GLRenderer::IsContextLost() { 3137 bool GLRenderer::IsContextLost() {
3134 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); 3138 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR);
3135 } 3139 }
3136 3140
3137 } // namespace cc 3141 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698