Use double precision when iterating in SkDashPathEffect::filterPath()
Extremely large path_length/dash_length ratios may cause us to loop
indefinitely otherwise.
R=reed@google.com
BUG=
Review URL: https://codereview.appspot.com/6926051
git-svn-id: http://skia.googlecode.com/svn/trunk@6773 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index e2d3648..f2e36cc 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -186,8 +186,10 @@
}
}
- SkScalar distance = 0;
- SkScalar dlen = SkScalarMul(fInitialDashLength, scale);
+ // Using double precision to avoid looping indefinitely due to single precision rounding
+ // (for extreme path_length/dash_length ratios). See test_infinite_dash() unittest.
+ double distance = 0;
+ double dlen = SkScalarMul(fInitialDashLength, scale);
while (distance < length) {
SkASSERT(dlen >= 0);