reapply r3259 (that was reverted) with fix.
authordjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 27 Feb 2012 16:17:59 +0000 (16:17 +0000)
committerdjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 27 Feb 2012 16:17:59 +0000 (16:17 +0000)
The SkASSERT was incorrect and failing on debug runs.
Review URL: https://codereview.appspot.com/5699071

git-svn-id: http://skia.googlecode.com/svn/trunk@3263 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkCanvas.h
src/core/SkCanvas.cpp

index 84d1038..1b9f055 100644 (file)
@@ -429,7 +429,16 @@ public:
         @return true if the horizontal band is completely clipped out (i.e. does
                      not intersect the current clip)
     */
-    bool quickRejectY(SkScalar top, SkScalar bottom, EdgeType et) const;
+    bool quickRejectY(SkScalar top, SkScalar bottom, EdgeType et) const {
+        SkASSERT(SkScalarToCompareType(top) <= SkScalarToCompareType(bottom));
+        const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType(et);
+        // In the case where the clip is empty and we are provided with a
+        // negative top and positive bottom parameter then this test will return
+        // false even though it will be clipped. We have chosen to exclude that
+        // check as it is rare and would result double the comparisons.
+        return SkScalarToCompareType(top) >= clipR.fBottom
+            || SkScalarToCompareType(bottom) <= clipR.fTop;
+    }
 
     /** Return the bounds of the current clip (in local coordinates) in the
         bounds parameter, and return true if it is non-empty. This can be useful
index 5f97d68..aa92dd0 100644 (file)
@@ -1197,30 +1197,6 @@ bool SkCanvas::quickReject(const SkPath& path, EdgeType et) const {
     return path.isEmpty() || this->quickReject(path.getBounds(), et);
 }
 
-bool SkCanvas::quickRejectY(SkScalar top, SkScalar bottom, EdgeType et) const {
-    /*  current impl ignores edgetype, and relies on
-        getLocalClipBoundsCompareType(), which always returns a value assuming
-        antialiasing (worst case)
-     */
-
-    if (fMCRec->fRasterClip->isEmpty()) {
-        return true;
-    }
-
-    SkScalarCompareType userT = SkScalarToCompareType(top);
-    SkScalarCompareType userB = SkScalarToCompareType(bottom);
-
-    // check for invalid user Y coordinates (i.e. empty)
-    // reed: why do we need to do this check, since it slows us down?
-    if (userT >= userB) {
-        return true;
-    }
-
-    // check if we are above or below the local clip bounds
-    const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType();
-    return userT >= clipR.fBottom || userB <= clipR.fTop;
-}
-
 static inline int pinIntForScalar(int x) {
 #ifdef SK_SCALAR_IS_FIXED
     if (x < SK_MinS16) {