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

Unified Diff: src/core/SkCanvas.cpp

Issue 2113443002: add SK_SUPPORT_PRECHECK_CLIPRECT experiment for clipRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 | 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 0313ed16113ae2c6d9c538f7412cd2eadd843f43..e96658ef2f09a33c987ccd683fc1d392125c15f2 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -46,6 +46,8 @@
#define RETURN_ON_NULL(ptr) do { if (nullptr == (ptr)) return; } while (0)
+//#define SK_SUPPORT_PRECHECK_CLIPRECT
+
/*
* Return true if the drawing this rect would hit every pixels in the canvas.
*
@@ -1522,6 +1524,34 @@ void SkCanvas::resetMatrix() {
//////////////////////////////////////////////////////////////////////////////
void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
+ if (!fAllowSoftClip) {
+ doAA = false;
+ }
+
+#ifdef SK_SUPPORT_PRECHECK_CLIPRECT
+ const bool rectStaysRect = fMCRec->fMatrix.rectStaysRect();
+ SkRect devR;
+ if (rectStaysRect) {
+ fMCRec->fMatrix.mapRect(&devR, rect);
f(malita) 2016/06/29 20:55:52 Can we move all this under the top-level condition
reed1 2016/06/29 21:07:17 Done.
+ }
+
+ // 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,
f(malita) 2016/06/29 20:55:52 Nit: TODO solved :)
reed1 2016/06/29 21:07:18 Done.
+ // 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 && !doAA && rectStaysRect) {
+ if (devR.round().contains(fMCRec->fRasterClip.getBounds())) {
f(malita) 2016/06/29 20:55:52 Maybe add a comment about round() vs. unknown reso
reed1 2016/06/29 21:07:17 Done.
+#if 0
+ SkDebugf("ignored clipRect [%g %g %g %g]\n",
+ rect.left(), rect.top(), rect.right(), rect.bottom());
+#endif
+ return;
+ }
+ }
+#endif
+
this->checkForDeferredSave();
ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
this->onClipRect(rect, op, edgeStyle);
@@ -1531,7 +1561,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
#ifdef SK_ENABLE_CLIP_QUICKREJECT
if (SkRegion::kIntersect_Op == op) {
if (fMCRec->fRasterClip.isEmpty()) {
- return false;
+ return;
}
if (this->quickReject(rect)) {
@@ -1539,27 +1569,19 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
fCachedLocalClipBoundsDirty = true;
fClipStack->clipEmpty();
- return fMCRec->fRasterClip.setEmpty();
+ (void)fMCRec->fRasterClip.setEmpty();
+ return;
}
}
#endif
- if (!fAllowSoftClip) {
- edgeStyle = kHard_ClipEdgeStyle;
- }
-
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.
- //
+#ifndef SK_SUPPORT_PRECHECK_CLIPRECT
if (SkRegion::kIntersect_Op == op &&
kHard_ClipEdgeStyle == edgeStyle
&& rectStaysRect)
@@ -1572,6 +1594,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
return;
}
}
+#endif
AutoValidateClip avc(this);
@@ -1657,7 +1680,7 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg
#ifdef SK_ENABLE_CLIP_QUICKREJECT
if (SkRegion::kIntersect_Op == op && !path.isInverseFillType()) {
if (fMCRec->fRasterClip.isEmpty()) {
- return false;
+ return;
}
if (this->quickReject(path.getBounds())) {
@@ -1665,7 +1688,8 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg
fCachedLocalClipBoundsDirty = true;
fClipStack->clipEmpty();
- return fMCRec->fRasterClip.setEmpty();
+ (void)fMCRec->fRasterClip.setEmpty();
+ return;
}
}
#endif
« 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