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); |
} |