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

Unified Diff: cc/output/software_renderer.cc

Issue 2867913002: Avoid using SkClipOp::kReplace_deprecated in software renderer (Closed)
Patch Set: feedback Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/output/software_renderer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/software_renderer.cc
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc
index bb8010847ef60fe50b26629dd0f52dc6f1d7c20e..34eda97f5d477b5b878000184fd1a0346eaa9fb2 100644
--- a/cc/output/software_renderer.cc
+++ b/cc/output/software_renderer.cc
@@ -99,19 +99,10 @@ bool SoftwareRenderer::FlippedFramebuffer() const {
void SoftwareRenderer::EnsureScissorTestEnabled() {
is_scissor_enabled_ = true;
- SetClipRect(scissor_rect_);
}
void SoftwareRenderer::EnsureScissorTestDisabled() {
- // There is no explicit notion of enabling/disabling scissoring in software
- // rendering, but the underlying effect we want is to clear any existing
- // clipRect on the current SkCanvas. This is done by setting clipRect to
- // the viewport's dimensions.
- if (!current_canvas_)
- return;
is_scissor_enabled_ = false;
- SkISize size = current_canvas_->getBaseLayerSize();
- SetClipRect(gfx::Rect(size.width(), size.height()));
}
void SoftwareRenderer::BindFramebufferToOutputSurface() {
@@ -140,7 +131,6 @@ bool SoftwareRenderer::BindFramebufferToTexture(
void SoftwareRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
is_scissor_enabled_ = true;
scissor_rect_ = scissor_rect;
- SetClipRect(scissor_rect);
}
void SoftwareRenderer::SetClipRect(const gfx::Rect& rect) {
@@ -149,9 +139,13 @@ void SoftwareRenderer::SetClipRect(const gfx::Rect& rect) {
// Skia applies the current matrix to clip rects so we reset it temporary.
SkMatrix current_matrix = current_canvas_->getTotalMatrix();
current_canvas_->resetMatrix();
- // TODO(fmalita) stop using kReplace (see crbug.com/673851)
- current_canvas_->clipRect(gfx::RectToSkRect(rect),
- SkClipOp::kReplace_deprecated);
+ // SetClipRect is assumed to be applied temporarily, on an
+ // otherwise-unclipped canvas.
+ DCHECK_EQ(current_canvas_->getDeviceClipBounds().width(),
+ current_canvas_->imageInfo().width());
+ DCHECK_EQ(current_canvas_->getDeviceClipBounds().height(),
+ current_canvas_->imageInfo().height());
+ current_canvas_->clipRect(gfx::RectToSkRect(rect));
current_canvas_->setMatrix(current_matrix);
}
@@ -208,11 +202,14 @@ void SoftwareRenderer::DoDrawQuad(const DrawQuad* quad,
const gfx::QuadF* draw_region) {
if (!current_canvas_)
return;
- if (draw_region) {
- current_canvas_->save();
- }
TRACE_EVENT0("cc", "SoftwareRenderer::DoDrawQuad");
+ bool do_save = draw_region || is_scissor_enabled_;
+ SkAutoCanvasRestore canvas_restore(current_canvas_, do_save);
+ if (is_scissor_enabled_) {
+ SetClipRect(scissor_rect_);
+ }
+
gfx::Transform quad_rect_matrix;
QuadRectTransform(&quad_rect_matrix,
quad->shared_quad_state->quad_to_target_transform,
@@ -298,9 +295,6 @@ void SoftwareRenderer::DoDrawQuad(const DrawQuad* quad,
}
current_canvas_->resetMatrix();
- if (draw_region) {
- current_canvas_->restore();
- }
}
void SoftwareRenderer::DrawDebugBorderQuad(const DebugBorderDrawQuad* quad) {
« no previous file with comments | « no previous file | cc/output/software_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698