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

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..c6c1802a4da1946cb7b3bd46203c19b8d10e5970 100644
--- a/skia/ext/analysis_canvas.cc
+++ b/skia/ext/analysis_canvas.cc
@@ -410,9 +410,41 @@ 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::MakeFromIRect(clip_device_bounds);
f(malita) 2016/10/26 12:24:24 nit: MakeFromIRect is deprecated, you can use Make
Ian Vollick 2016/10/26 13:57:04 Done.
+ inverse.mapRectScaleTranslate(&clip_rect, clip_rect);
+ if (!clip_rect.isFinite()) {
f(malita) 2016/10/26 12:24:24 nit: Is this check needed? I think the contains t
Ian Vollick 2016/10/26 13:57:04 Nope, not necessary. Removed.
+ return false;
+ }
+
+ 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