aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/DrawPathTest.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-06 14:58:35 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-06 14:58:35 +0000
commitd9ee348720f933d8a23547ee36693880296810c5 (patch)
treef69c3ac71aa10a182360c9c5b514e26da4e63da1 /tests/DrawPathTest.cpp
parent157d94465a47a57e30e5cf49cd57dccd903e27e2 (diff)
If we lose precision computing sum of the dash intervals, then we can have the
same error when we subtract-in-a-loop with the phase. The result is that we can read past the end of the array. To fix this, we just pin the loop counter, and if we exhaust our intervals, we just treat the phase as 0. Not precisely the exact answer, but we aren't going to draw this dash correctly anyway, since it contains massive interval values that will be imprecise given our current float implementation. Fixes http://code.google.com/p/chromium/issues/detail?id=140642 Review URL: https://codereview.appspot.com/6458088 git-svn-id: http://skia.googlecode.com/svn/trunk@4959 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/DrawPathTest.cpp')
-rw-r--r--tests/DrawPathTest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index 947bf88029..f421ee87b6 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -137,6 +137,28 @@ static void test_bug533(skiatest::Reporter* reporter) {
#endif
}
+static void test_crbug_140642(skiatest::Reporter* reporter) {
+ /*
+ * We used to see this construct, and due to rounding as we accumulated
+ * our length, the loop where we apply the phase would run off the end of
+ * the array, since it relied on just -= each interval value, which did not
+ * behave as "expected". Now the code explicitly checks for walking off the
+ * end of that array.
+
+ * A different (better) fix might be to rewrite dashing to do all of its
+ * length/phase/measure math using double, but this may need to be
+ * coordinated with SkPathMeasure, to be consistent between the two.
+
+ <path stroke="mintcream" stroke-dasharray="27734 35660 2157846850 247"
+ stroke-dashoffset="-248.135982067">
+ */
+
+#ifdef SK_SCALAR_IS_FLOAT
+ const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 };
+ SkDashPathEffect dontAssert(vals, 4, -248.135982067f);
+#endif
+}
+
static void test_crbug_124652(skiatest::Reporter* reporter) {
#ifdef SK_SCALAR_IS_FLOAT
/*
@@ -185,6 +207,7 @@ static void TestDrawPath(skiatest::Reporter* reporter) {
test_bug533(reporter);
test_bigcubic(reporter);
test_crbug_124652(reporter);
+ test_crbug_140642(reporter);
test_inversepathwithclip(reporter);
// test_crbug131181(reporter);
}