Fix handling of nan when clamping number of pts in quads/cubics

Review URL: http://codereview.appspot.com/4646044/



git-svn-id: http://skia.googlecode.com/svn/trunk@1642 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrPathUtils.cpp b/gpu/src/GrPathUtils.cpp
index b93c8a9..aebdf1d 100644
--- a/gpu/src/GrPathUtils.cpp
+++ b/gpu/src/GrPathUtils.cpp
@@ -32,7 +32,14 @@
         // points.
         // 2^(log4(x)) = sqrt(x);
         int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol)));
-        return GrMin(GrNextPow2(temp), MAX_POINTS_PER_CURVE);
+        int pow2 = GrNextPow2(temp);
+        // Because of NaNs & INFs we can wind up with a degenerate temp
+        // such that pow2 comes out negative. Also, our point generator
+        // will always output at least one pt.
+        if (pow2 < 1) {
+            pow2 = 1;
+        }
+        return GrMin(pow2, MAX_POINTS_PER_CURVE);
     }
 }
 
@@ -70,7 +77,14 @@
         return 1;
     } else {
         int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol)));
-        return GrMin(GrNextPow2(temp), MAX_POINTS_PER_CURVE);
+        int pow2 = GrNextPow2(temp);
+        // Because of NaNs & INFs we can wind up with a degenerate temp
+        // such that pow2 comes out negative. Also, our point generator
+        // will always output at least one pt.
+        if (pow2 < 1) {
+            pow2 = 1;
+        }
+        return GrMin(pow2, MAX_POINTS_PER_CURVE);
     }
 }