Apply fix from #3739 to quads and cubics as well
Fixes http://code.google.com/p/chromium/issues/detail?id=125249
Review URL: https://codereview.appspot.com/6137046
git-svn-id: http://skia.googlecode.com/svn/trunk@3786 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PathMeasureTest.cpp b/tests/PathMeasureTest.cpp
index e636ff3..453cdeb 100644
--- a/tests/PathMeasureTest.cpp
+++ b/tests/PathMeasureTest.cpp
@@ -8,6 +8,43 @@
#include "Test.h"
#include "SkPathMeasure.h"
+static void test_small_segment3(skiatest::Reporter* reporter) {
+#ifdef SK_SCALAR_IS_FLOAT
+ SkPath path;
+ const SkPoint pts[] = {
+ { 0, 0 },
+ { 100000000000.0f, 100000000000.0f }, { 0, 0 }, { 10, 10 },
+ { 10, 10 }, { 0, 0 }, { 10, 10 }
+ };
+
+ path.moveTo(pts[0]);
+ for (size_t i = 1; i < SK_ARRAY_COUNT(pts); i += 2) {
+ path.cubicTo(pts[i], pts[i + 1], pts[i + 2]);
+ }
+
+ SkPathMeasure meas(path, false);
+ meas.getLength();
+#endif
+}
+
+static void test_small_segment2(skiatest::Reporter* reporter) {
+#ifdef SK_SCALAR_IS_FLOAT
+ SkPath path;
+ const SkPoint pts[] = {
+ { 0, 0 },
+ { 100000000000.0f, 100000000000.0f }, { 0, 0 },
+ { 10, 10 }, { 0, 0 },
+ };
+
+ path.moveTo(pts[0]);
+ for (size_t i = 1; i < SK_ARRAY_COUNT(pts); i += 2) {
+ path.quadTo(pts[i], pts[i + 1]);
+ }
+ SkPathMeasure meas(path, false);
+ meas.getLength();
+#endif
+}
+
static void test_small_segment(skiatest::Reporter* reporter) {
#ifdef SK_SCALAR_IS_FLOAT
SkPath path;
@@ -18,7 +55,7 @@
// 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]);
@@ -31,7 +68,7 @@
d = distance(pts[0], pts[1]);
distance += d;
seg->fDistance = distance;
-
+
SkASSERT(d > 0); // TRUE
SkASSERT(seg->fDistance > prevSeg->fDistance); // FALSE
@@ -167,6 +204,8 @@
REPORTER_ASSERT(reporter, tangent.fY == 0);
test_small_segment(reporter);
+ test_small_segment2(reporter);
+ test_small_segment3(reporter);
}
#include "TestClassDef.h"