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

Unified Diff: src/core/SkCanvas.cpp

Issue 12545009: Adding option in SkPicture to record device-space bounds of draw commands. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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
Index: src/core/SkCanvas.cpp
===================================================================
--- src/core/SkCanvas.cpp (revision 9110)
+++ src/core/SkCanvas.cpp (working copy)
@@ -513,6 +513,7 @@
fDeviceCMDirty = false;
fSaveLayerCount = 0;
fMetaData = NULL;
+ fQuickRejectEnabled = true;
fMCRec = (MCRec*)fMCStack.push_back();
new (fMCRec) MCRec(NULL, 0);
@@ -1370,34 +1371,45 @@
}
bool SkCanvas::quickReject(const SkRect& rect) const {
+ if (fQuickRejectEnabled) {
+ if (!rect.isFinite())
+ return true;
- if (!rect.isFinite())
- return true;
+ if (fMCRec->fRasterClip->isEmpty()) {
+ return true;
+ }
- if (fMCRec->fRasterClip->isEmpty()) {
- return true;
- }
+ if (fMCRec->fMatrix->hasPerspective()) {
+ SkRect dst;
+ fMCRec->fMatrix->mapRect(&dst, rect);
+ SkIRect idst;
+ dst.roundOut(&idst);
+ return !SkIRect::Intersects(idst, fMCRec->fRasterClip->getBounds());
+ } else {
+ const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType();
- if (fMCRec->fMatrix->hasPerspective()) {
- SkRect dst;
- fMCRec->fMatrix->mapRect(&dst, rect);
- SkIRect idst;
- dst.roundOut(&idst);
- return !SkIRect::Intersects(idst, fMCRec->fRasterClip->getBounds());
+ // for speed, do the most likely reject compares first
+ SkScalarCompareType userT = SkScalarToCompareType(rect.fTop);
+ SkScalarCompareType userB = SkScalarToCompareType(rect.fBottom);
+ if (userT >= clipR.fBottom || userB <= clipR.fTop) {
+ return true;
+ }
+ SkScalarCompareType userL = SkScalarToCompareType(rect.fLeft);
+ SkScalarCompareType userR = SkScalarToCompareType(rect.fRight);
+ if (userL >= clipR.fRight || userR <= clipR.fLeft) {
+ return true;
+ }
+ return false;
+ }
} else {
- const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType();
-
- // for speed, do the most likely reject compares first
- SkScalarCompareType userT = SkScalarToCompareType(rect.fTop);
- SkScalarCompareType userB = SkScalarToCompareType(rect.fBottom);
- if (userT >= clipR.fBottom || userB <= clipR.fTop) {
- return true;
- }
- SkScalarCompareType userL = SkScalarToCompareType(rect.fLeft);
- SkScalarCompareType userR = SkScalarToCompareType(rect.fRight);
- if (userL >= clipR.fRight || userR <= clipR.fLeft) {
- return true;
- }
+#ifdef SK_DEBUG
reed1 2013/05/14 13:31:11 Hmmm, not sure we always want to assert this. Seem
+ // Validate that the decision to skip the test is well founded by
+ // verifying that the test would have returned false.
+ SkCanvas* nonConstThis = const_cast<SkCanvas*>(this);
+ nonConstThis->fQuickRejectEnabled = true;
+ SkASSERT(false == quickReject(rect));
+ nonConstThis->fQuickRejectEnabled = false;
+#endif
return false;
}
}

Powered by Google App Engine
This is Rietveld 408576698