From 39f0538178bcb182346fbbb1c746eb5a1c2925fd Mon Sep 17 00:00:00 2001 From: robertphillips Date: Tue, 24 Nov 2015 09:30:12 -0800 Subject: [PATCH] Add sniff for rect, oval & rrect to SkCanvas::clipPath Review URL: https://codereview.chromium.org/1466303004 --- src/core/SkCanvas.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index e4fe63992c..1e49fe272d 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1600,12 +1600,26 @@ void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle void SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { this->checkForDeferredSave(); ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; - SkRect r; - if (!path.isInverseFillType() && path.isRect(&r)) { - this->onClipRect(r, op, edgeStyle); - } else { - this->onClipPath(path, op, edgeStyle); + + if (!path.isInverseFillType() && fMCRec->fMatrix.rectStaysRect()) { + SkRect r; + if (path.isRect(&r)) { + this->onClipRect(r, op, edgeStyle); + return; + } + SkRRect rrect; + if (path.isOval(&r)) { + rrect.setOval(r); + this->onClipRRect(rrect, op, edgeStyle); + return; + } + if (path.isRRect(&rrect)) { + this->onClipRRect(rrect, op, edgeStyle); + return; + } } + + this->onClipPath(path, op, edgeStyle); } void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {