Fix handling of infinite bounds during "fast transforms".

http://codereview.appspot.com/6449125/



git-svn-id: http://skia.googlecode.com/svn/trunk@5042 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 4483388..1127e95 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1341,13 +1341,30 @@
         dst->swap(tmp);
         matrix.mapPoints(dst->fPts.begin(), dst->fPts.count());
     } else {
-        // remember that dst might == this, so be sure to check
-        // fBoundsIsDirty before we set it
+        /*
+         *  If we're not in perspective, we can transform all of the points at
+         *  once.
+         *
+         *  Here we also want to optimize bounds, by noting if the bounds are
+         *  already known, and if so, we just transform those as well and mark
+         *  them as "known", rather than force the transformed path to have to
+         *  recompute them.
+         *
+         *  Special gotchas if the path is effectively empty (<= 1 point) or
+         *  if it is non-finite. In those cases bounds need to stay empty,
+         *  regardless of the matrix.
+         */
         if (!fBoundsIsDirty && matrix.rectStaysRect() && fPts.count() > 1) {
-            // if we're empty, fastbounds should not be mapped
-            matrix.mapRect(&dst->fBounds, fBounds);
             dst->fBoundsIsDirty = false;
-            dst->fIsFinite = dst->fBounds.isFinite();
+            if (fIsFinite) {
+                matrix.mapRect(&dst->fBounds, fBounds);
+                if (!(dst->fIsFinite = dst->fBounds.isFinite())) {
+                    dst->fBounds.setEmpty();
+                }
+            } else {
+                dst->fIsFinite = false;
+                dst->fBounds.setEmpty();
+            }
         } else {
             GEN_ID_PTR_INC(dst);
             dst->fBoundsIsDirty = true;
@@ -1795,7 +1812,10 @@
 
     if (!fBoundsIsDirty) {
         SkRect bounds;
-        compute_pt_bounds(&bounds, fPts);
+
+        bool isFinite = compute_pt_bounds(&bounds, fPts);
+        SkASSERT(fIsFinite == isFinite);
+
         if (fPts.count() <= 1) {
             // if we're empty, fBounds may be empty but translated, so we can't
             // necessarily compare to bounds directly