move call to nothingToDraw into our iterator, so it sees the results of filters and loopers
before making its decision.



git-svn-id: http://skia.googlecode.com/svn/trunk@2417 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 70b53fe..f563cd1 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -53,13 +53,6 @@
             SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType;
 }
 
-#if 0
-    #define CHECK_NOTHING_TO_DRAW(paint)    \
-        do { if ((paint).nothingToDraw()) return; } while (0)
-#else
-    #define CHECK_NOTHING_TO_DRAW(paint)    do {} while (0)
-#endif
-
 ///////////////////////////////////////////////////////////////////////////////
 
 /*  This is the record we keep for each SkDevice that the user installs.
@@ -317,30 +310,35 @@
 };
 
 bool AutoDrawLooper::next(SkDrawFilter::Type drawType) {
+    fPaint = NULL;
     if (fDone) {
-        fPaint = NULL;
         return false;
     }
-    if (!fLooper && !fFilter) {
-        fDone = true;
-        fPaint = &fOrigPaint;
-        return true;
-    }
 
-    SkPaint* paint = fLazyPaint.set(fOrigPaint);
-    if (fLooper && !fLooper->next(fCanvas, paint)) {
+    if (fLooper || fFilter) {
+        SkPaint* paint = fLazyPaint.set(fOrigPaint);
+        if (fLooper && !fLooper->next(fCanvas, paint)) {
+            fDone = true;
+            return false;
+        }
+        if (fFilter) {
+            fFilter->filter(paint, drawType);
+            if (NULL == fLooper) {
+                // no looper means we only draw once
+                fDone = true;
+            }
+        }
+        fPaint = paint;
+    } else {
         fDone = true;
+        fPaint = &fOrigPaint;
+    }
+
+    // call this after any possible paint modifiers
+    if (fPaint->nothingToDraw()) {
         fPaint = NULL;
         return false;
     }
-    if (fFilter) {
-        fFilter->filter(paint, drawType);
-        if (NULL == fLooper) {
-            // no looper means we only draw once
-            fDone = true;
-        }
-    }
-    fPaint = paint;
     return true;
 }
 
@@ -829,10 +827,6 @@
 
 void SkCanvas::drawDevice(SkDevice* device, int x, int y,
                           const SkPaint* paint) {
-    if (paint) {
-        CHECK_NOTHING_TO_DRAW(*paint);
-    }
-
     SkPaint tmp;
     if (NULL == paint) {
         tmp.setDither(true);
@@ -1221,8 +1215,6 @@
 }
 
 void SkCanvas::internalDrawPaint(const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     LOOPER_BEGIN(paint, SkDrawFilter::kPaint_Type)
 
     while (iter.next()) {
@@ -1234,7 +1226,6 @@
 
 void SkCanvas::drawPoints(PointMode mode, size_t count, const SkPoint pts[],
                           const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
     if ((long)count <= 0) {
         return;
     }
@@ -1251,8 +1242,6 @@
 }
 
 void SkCanvas::drawRect(const SkRect& r, const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     if (paint.canComputeFastBounds()) {
         SkRect storage;
         if (this->quickReject(paint.computeFastBounds(r, &storage),
@@ -1271,8 +1260,6 @@
 }
 
 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     if (!path.isInverseFillType() && paint.canComputeFastBounds()) {
         SkRect storage;
         const SkRect& bounds = path.getBounds();
@@ -1301,10 +1288,6 @@
                           const SkPaint* paint) {
     SkDEBUGCODE(bitmap.validate();)
 
-    if (paint) {
-        CHECK_NOTHING_TO_DRAW(*paint);
-    }
-
     if (NULL == paint || (paint->getMaskFilter() == NULL)) {
         SkRect fastBounds;
         fastBounds.set(x, y,
@@ -1370,17 +1353,11 @@
 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
                               const SkRect& dst, const SkPaint* paint) {
     SkDEBUGCODE(bitmap.validate();)
-    if (paint) {
-        CHECK_NOTHING_TO_DRAW(*paint);
-    }
     this->internalDrawBitmapRect(bitmap, src, dst, paint);
 }
 
 void SkCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
                                 const SkPaint* paint) {
-    if (paint) {
-        CHECK_NOTHING_TO_DRAW(*paint);
-    }
     SkDEBUGCODE(bitmap.validate();)
     this->internalDrawBitmap(bitmap, NULL, matrix, paint);
 }
@@ -1451,9 +1428,6 @@
 
 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
                               const SkRect& dst, const SkPaint* paint) {
-    if (paint) {
-        CHECK_NOTHING_TO_DRAW(*paint);
-    }
     SkDEBUGCODE(bitmap.validate();)
 
     // Need a device entry-point, so gpu can use a mesh
@@ -1462,9 +1436,6 @@
 
 void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
                           const SkPaint* paint) {
-    if (paint) {
-        CHECK_NOTHING_TO_DRAW(*paint);
-    }
     SkDEBUGCODE(bitmap.validate();)
 
     if (reject_bitmap(bitmap)) {
@@ -1580,8 +1551,6 @@
 
 void SkCanvas::drawText(const void* text, size_t byteLength,
                         SkScalar x, SkScalar y, const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     LOOPER_BEGIN(paint, SkDrawFilter::kText_Type)
 
     while (iter.next()) {
@@ -1596,8 +1565,6 @@
 
 void SkCanvas::drawPosText(const void* text, size_t byteLength,
                            const SkPoint pos[], const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     LOOPER_BEGIN(paint, SkDrawFilter::kText_Type)
 
     while (iter.next()) {
@@ -1612,8 +1579,6 @@
 void SkCanvas::drawPosTextH(const void* text, size_t byteLength,
                             const SkScalar xpos[], SkScalar constY,
                             const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     LOOPER_BEGIN(paint, SkDrawFilter::kText_Type)
 
     while (iter.next()) {
@@ -1628,8 +1593,6 @@
 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength,
                               const SkPath& path, const SkMatrix* matrix,
                               const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     LOOPER_BEGIN(paint, SkDrawFilter::kText_Type)
 
     while (iter.next()) {
@@ -1644,8 +1607,6 @@
 void SkCanvas::drawPosTextOnPath(const void* text, size_t byteLength,
                                  const SkPoint pos[], const SkPaint& paint,
                                  const SkPath& path, const SkMatrix* matrix) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     LOOPER_BEGIN(paint, SkDrawFilter::kText_Type)
 
     while (iter.next()) {
@@ -1662,8 +1623,6 @@
                             const SkColor colors[], SkXfermode* xmode,
                             const uint16_t indices[], int indexCount,
                             const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type)
 
     while (iter.next()) {
@@ -1741,8 +1700,6 @@
 
 void SkCanvas::drawCircle(SkScalar cx, SkScalar cy, SkScalar radius,
                           const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     if (radius < 0) {
         radius = 0;
     }
@@ -1765,8 +1722,6 @@
 
 void SkCanvas::drawRoundRect(const SkRect& r, SkScalar rx, SkScalar ry,
                              const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     if (rx > 0 && ry > 0) {
         if (paint.canComputeFastBounds()) {
             SkRect storage;
@@ -1785,8 +1740,6 @@
 }
 
 void SkCanvas::drawOval(const SkRect& oval, const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     if (paint.canComputeFastBounds()) {
         SkRect storage;
         if (this->quickReject(paint.computeFastBounds(oval, &storage),
@@ -1803,8 +1756,6 @@
 void SkCanvas::drawArc(const SkRect& oval, SkScalar startAngle,
                        SkScalar sweepAngle, bool useCenter,
                        const SkPaint& paint) {
-    CHECK_NOTHING_TO_DRAW(paint);
-
     if (SkScalarAbs(sweepAngle) >= SkIntToScalar(360)) {
         this->drawOval(oval, paint);
     } else {