aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathMeasureTest.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-20 15:10:32 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-20 15:10:32 +0000
commitfab1ddd3a8893db58b2ce0afd28ecc73412ee871 (patch)
tree7a3dfc4e59baf0e3e51507d3f48bc1cebfd71ca2 /tests/PathMeasureTest.cpp
parentd6195f956fdccef865224520a624e3fd968573d0 (diff)
only add pathmeasure segment if the accumulated length was actually changed,
and not based on if the local length was > 0. This is necessary since assert(delta > 0); // true prevDistance = distance; distance += delta; assert(distance > prevDistance); // not always true Fixes https://bugs.webkit.org/show_bug.cgi?id=78979 git-svn-id: http://skia.googlecode.com/svn/trunk@3739 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PathMeasureTest.cpp')
-rw-r--r--tests/PathMeasureTest.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/PathMeasureTest.cpp b/tests/PathMeasureTest.cpp
index 3855a0019d..e636ff38fc 100644
--- a/tests/PathMeasureTest.cpp
+++ b/tests/PathMeasureTest.cpp
@@ -8,6 +8,40 @@
#include "Test.h"
#include "SkPathMeasure.h"
+static void test_small_segment(skiatest::Reporter* reporter) {
+#ifdef SK_SCALAR_IS_FLOAT
+ SkPath path;
+ const SkPoint pts[] = {
+ { 100000, 100000},
+ // big jump between these points, makes a big segment
+ { 1.0005, 0.9999 },
+ // tiny (non-zero) jump between these points
+ { 1, 1 },
+ };
+
+ path.moveTo(pts[0]);
+ for (size_t i = 1; i < SK_ARRAY_COUNT(pts); ++i) {
+ path.lineTo(pts[i]);
+ }
+ SkPathMeasure meas(path, false);
+
+ /* this would assert (before a fix) because we added a segment with
+ the same length as the prev segment, due to the follow (bad) pattern
+
+ d = distance(pts[0], pts[1]);
+ distance += d;
+ seg->fDistance = distance;
+
+ SkASSERT(d > 0); // TRUE
+ SkASSERT(seg->fDistance > prevSeg->fDistance); // FALSE
+
+ This 2nd assert failes because (distance += d) didn't affect distance
+ because distance >>> d.
+ */
+ meas.getLength();
+#endif
+}
+
static void TestPathMeasure(skiatest::Reporter* reporter) {
SkPath path;
@@ -131,6 +165,8 @@ static void TestPathMeasure(skiatest::Reporter* reporter) {
SkFloatToScalar(0.0001f)));
REPORTER_ASSERT(reporter, tangent.fX == -SK_Scalar1);
REPORTER_ASSERT(reporter, tangent.fY == 0);
+
+ test_small_segment(reporter);
}
#include "TestClassDef.h"