diff options
author | ericrk <ericrk@chromium.org> | 2015-03-21 00:48:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-21 07:48:54 +0000 |
commit | db214180d73e6516d8b2de4f87b8a1ae01bdd45f (patch) | |
tree | 28304a8c062a0819a5cbd77de066f0fd559e0582 /cc/output/software_renderer.cc | |
parent | c5056857280ce8822b0eaa0d761bab5d8a7967ff (diff) | |
download | chromium_src-db214180d73e6516d8b2de4f87b8a1ae01bdd45f.zip chromium_src-db214180d73e6516d8b2de4f87b8a1ae01bdd45f.tar.gz chromium_src-db214180d73e6516d8b2de4f87b8a1ae01bdd45f.tar.bz2 |
Refactor discard/clear behavior in DirectRenderer
This CL tries to simplify the logic around per-pass scissor set-up.
- For a given pass, we calculate the intersection of the viewport rect,
the clip rect and any scissor rect.
- We check whether this intersection contains the entire output surface
for the pass - if not, we consider the pass "clipped"
- If the pass is clipped we disable GL discard and restrict clear to
the clipped region. We also clip all quads to the clipped region
(as before).
- If the pass is not clipped, we perform a discard/clear and render
all quads as normal (no clipping).
This flow seems more straightforward, as we don't need to track as
many booleans/values and treat things more uniformly. It does result
in slightly different behavior which required a few unit test changes
(not pixel tests, but tests that expected certain patterns of
scissors/etc...):
- If we are using the scissor optimization, but the scissor rect
contains the entire output surface, we proceed as though we aren't
using the scissor optimization (previously we would apply
full-output-surface clips).
- If both device and scissor clips are applied, we use the intersection
of these to restrict clear (before we would just use the device clip).
- If the viewport does not contain the full output surface, the clear is
restricted to the viewport (before it would clear the entire surface).
BUG=468845
Review URL: https://codereview.chromium.org/1018423002
Cr-Commit-Position: refs/heads/master@{#321697}
Diffstat (limited to 'cc/output/software_renderer.cc')
-rw-r--r-- | cc/output/software_renderer.cc | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc index cecd633..bd99d0b1 100644 --- a/cc/output/software_renderer.cc +++ b/cc/output/software_renderer.cc @@ -172,10 +172,6 @@ bool SoftwareRenderer::BindFramebufferToTexture( current_framebuffer_canvas_ = skia::AdoptRef(new SkCanvas(current_framebuffer_lock_->sk_bitmap())); current_canvas_ = current_framebuffer_canvas_.get(); - InitializeViewport(frame, - target_rect, - gfx::Rect(target_rect.size()), - target_rect.size()); return true; } @@ -202,11 +198,7 @@ void SoftwareRenderer::ClearCanvas(SkColor color) { current_canvas_->clear(color); } -void SoftwareRenderer::DiscardPixels(bool has_external_stencil_test, - bool draw_rect_covers_full_surface) {} - -void SoftwareRenderer::ClearFramebuffer(DrawingFrame* frame, - bool has_external_stencil_test) { +void SoftwareRenderer::ClearFramebuffer(DrawingFrame* frame) { if (frame->current_render_pass->has_transparent_background) { ClearCanvas(SkColorSetARGB(0, 0, 0, 0)); } else { @@ -218,6 +210,25 @@ void SoftwareRenderer::ClearFramebuffer(DrawingFrame* frame, } } +void SoftwareRenderer::PrepareSurfaceForPass( + DrawingFrame* frame, + SurfaceInitializationMode initialization_mode, + const gfx::Rect& render_pass_scissor) { + switch (initialization_mode) { + case SURFACE_INITIALIZATION_MODE_PRESERVE: + EnsureScissorTestDisabled(); + return; + case SURFACE_INITIALIZATION_MODE_FULL_SURFACE_CLEAR: + EnsureScissorTestDisabled(); + ClearFramebuffer(frame); + break; + case SURFACE_INITIALIZATION_MODE_SCISSORED_CLEAR: + SetScissorTestRect(render_pass_scissor); + ClearFramebuffer(frame); + break; + } +} + void SoftwareRenderer::SetDrawViewport( const gfx::Rect& window_space_viewport) {} |