Chromium Code Reviews| 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; |
| } |
| } |