Index: cc/output/gl_renderer.cc |
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
index f365e36cd9108281b19cb2830c13c14e0a0f228c..f4b1e575d3920391c6e667c5bc230b1f0496730a 100644 |
--- a/cc/output/gl_renderer.cc |
+++ b/cc/output/gl_renderer.cc |
@@ -290,25 +290,29 @@ void GLRenderer::ViewportChanged() { |
ReinitializeGrCanvas(); |
} |
-void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { |
+void GLRenderer::DiscardPixels(bool has_external_stencil_test, |
+ bool draw_rect_covers_full_surface) { |
+ if (has_external_stencil_test || !draw_rect_covers_full_surface || |
+ !capabilities_.using_discard_framebuffer) |
+ return; |
+ bool using_default_framebuffer = |
+ !current_framebuffer_lock_ && |
+ output_surface_->capabilities().uses_default_gl_framebuffer; |
+ GLenum attachments[] = {static_cast<GLenum>( |
+ using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)}; |
+ context_->discardFramebufferEXT( |
+ GL_FRAMEBUFFER, arraysize(attachments), attachments); |
+} |
+ |
+void GLRenderer::ClearFramebuffer(DrawingFrame* frame, |
+ bool has_external_stencil_test) { |
// It's unsafe to clear when we have a stencil test because glClear ignores |
// stencil. |
- if (output_surface_->HasExternalStencilTest() && |
- frame->current_render_pass == frame->root_render_pass) { |
+ if (has_external_stencil_test) { |
DCHECK(!frame->current_render_pass->has_transparent_background); |
return; |
} |
- if (capabilities_.using_discard_framebuffer) { |
- bool using_default_framebuffer = |
- !current_framebuffer_lock_ && |
- output_surface_->capabilities().uses_default_gl_framebuffer; |
- GLenum attachments[] = {static_cast<GLenum>( |
- using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)}; |
- context_->discardFramebufferEXT( |
- GL_FRAMEBUFFER, arraysize(attachments), attachments); |
- } |
- |
// On DEBUG builds, opaque render passes are cleared to blue to easily see |
// regions that were not drawn on the screen. |
if (frame->current_render_pass->has_transparent_background) |