aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar fmalita@google.com <fmalita@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-12 22:13:58 +0000
committerGravatar fmalita@google.com <fmalita@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-12 22:13:58 +0000
commitbfa0401ab60b83abf30c7cca4c326282360948fe (patch)
tree5962fc1ff2b5d1c1fae133edd2a001f78516786b /src
parentb79103a954952f3562ed92f02062808a3fb605f6 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/effects/SkDashPathEffect.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index e2d3648ac1..f2e36cc347 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -186,8 +186,10 @@ bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
}
}
- 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);