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

Unified Diff: skia/ext/analysis_canvas.cc

Issue 2449583002: Support rrect clips in analysis canvas (Closed)
Patch Set: Address reviewer feedback. Created 4 years, 2 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 | skia/ext/analysis_canvas_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/analysis_canvas.cc
diff --git a/skia/ext/analysis_canvas.cc b/skia/ext/analysis_canvas.cc
index 2caa73d00dd2cbad35493532d6de1b9ade8cd84d..1819c0e834a9a2943d8cce1daa6898d2ade6d573 100644
--- a/skia/ext/analysis_canvas.cc
+++ b/skia/ext/analysis_canvas.cc
@@ -410,9 +410,37 @@ void AnalysisCanvas::onClipPath(const SkPath& path,
INHERITED::onClipRect(path.getBounds(), op, edge_style);
}
+bool doesCoverCanvas(const SkRRect& rr,
+ const SkMatrix& total_matrix,
+ const SkIRect& clip_device_bounds) {
+ const SkRect& bounding_rect = rr.rect();
+
+ // We cannot handle non axis aligned rectangles at the moment.
+ if (!total_matrix.isScaleTranslate()) {
+ return false;
+ }
+
+ SkMatrix inverse;
+ if (!total_matrix.invert(&inverse)) {
+ return false;
+ }
+
+ SkRect clip_rect = SkRect::Make(clip_device_bounds);
+ inverse.mapRectScaleTranslate(&clip_rect, clip_rect);
+ return rr.contains(clip_rect);
+}
+
void AnalysisCanvas::onClipRRect(const SkRRect& rrect,
SkRegion::Op op,
ClipEdgeStyle edge_style) {
+ SkIRect clip_device_bounds;
+ if (getClipDeviceBounds(&clip_device_bounds) &&
+ doesCoverCanvas(rrect, getTotalMatrix(), clip_device_bounds)) {
+ // If the canvas is fully contained within the clip, it is as if we weren't
+ // clipped at all, so bail early.
+ return;
+ }
+
OnComplexClip();
INHERITED::onClipRect(rrect.getBounds(), op, edge_style);
}
« no previous file with comments | « no previous file | skia/ext/analysis_canvas_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698