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

Unified Diff: src/core/SkCanvas.cpp

Issue 1458913005: option to quick-accept clipRect calls (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: shared call into maprect Created 5 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 7d71ffb13bdd573ea0b014e66975e4c81de9393b..28e642e59cfc01882b4ffca7d5b41a2e2496fc9c 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1498,24 +1498,44 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
}
#endif
- AutoValidateClip avc(this);
-
- fDeviceCMDirty = true;
- fCachedLocalClipBoundsDirty = true;
if (!fAllowSoftClip) {
edgeStyle = kHard_ClipEdgeStyle;
}
- if (fMCRec->fMatrix.rectStaysRect()) {
- // for these simpler matrices, we can stay a rect even after applying
- // the matrix. This means we don't have to a) make a path, and b) tell
- // the region code to scan-convert the path, only to discover that it
- // is really just a rect.
- SkRect r;
+ const bool rectStaysRect = fMCRec->fMatrix.rectStaysRect();
+ SkRect devR;
+ if (rectStaysRect) {
+ fMCRec->fMatrix.mapRect(&devR, rect);
+ }
+
+ // Check if we can quick-accept the clip call (and do nothing)
+ //
+ // TODO: investigate if a (conservative) version of this could be done in ::clipRect,
+ // so that subclasses (like PictureRecording) didn't see unnecessary clips, which in turn
+ // might allow lazy save/restores to eliminate entire save/restore blocks.
+ //
+ if (SkRegion::kIntersect_Op == op &&
+ kHard_ClipEdgeStyle == edgeStyle
+ && rectStaysRect)
+ {
+ if (devR.round().contains(fMCRec->fRasterClip.getBounds())) {
+#if 0
+ SkDebugf("------- ignored clipRect [%g %g %g %g]\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom());
+#endif
+ return;
+ }
+ }
+
+ AutoValidateClip avc(this);
+
+ fDeviceCMDirty = true;
+ fCachedLocalClipBoundsDirty = true;
- fMCRec->fMatrix.mapRect(&r, rect);
- fClipStack->clipDevRect(r, op, kSoft_ClipEdgeStyle == edgeStyle);
- fMCRec->fRasterClip.op(r, this->getBaseLayerSize(), op, kSoft_ClipEdgeStyle == edgeStyle);
+ if (rectStaysRect) {
+ const bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
+ fClipStack->clipDevRect(devR, op, isAA);
+ fMCRec->fRasterClip.op(devR, this->getBaseLayerSize(), op, isAA);
} else {
// since we're rotated or some such thing, we convert the rect to a path
// and clip against that, since it can handle any matrix. However, to
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698