work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@3443 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/EdgeWalkerPolygons_Test.cpp b/experimental/Intersection/EdgeWalkerPolygons_Test.cpp
index 07ce6c8..9a740e9 100644
--- a/experimental/Intersection/EdgeWalkerPolygons_Test.cpp
+++ b/experimental/Intersection/EdgeWalkerPolygons_Test.cpp
@@ -12,8 +12,8 @@
path.lineTo(10,30); // /_|
path.lineTo(20,30);
path.close();
- simplify(path, true, out); // expect |\/|
- comparePaths(path, out); // |__|
+ testSimplify(path, true, out); // expect |\/|
+ // |__|
}
static void testSimplifyTriangle3() {
@@ -26,8 +26,7 @@
path.lineTo(1, 0);
path.lineTo(3, 1);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle4() {
@@ -40,8 +39,7 @@
path.lineTo(1, 0);
path.lineTo(2, 1);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle5() {
@@ -54,8 +52,7 @@
path.lineTo(1, 1);
path.lineTo(2, 1);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle6() {
@@ -70,8 +67,7 @@
path.lineTo(3, 1);
path.lineTo(0, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle7() {
@@ -86,8 +82,7 @@
path.lineTo(0, 2);
path.lineTo(0, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle8() {
@@ -102,8 +97,7 @@
path.lineTo(1, 3);
path.lineTo(0, 1);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle9() {
@@ -118,8 +112,7 @@
path.lineTo(2, 1);
path.lineTo(0, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle10() {
@@ -134,8 +127,7 @@
path.lineTo(0, 1);
path.lineTo(0, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle11() {
@@ -150,8 +142,7 @@
path.lineTo(2, 2);
path.lineTo(0, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle12() {
@@ -166,8 +157,7 @@
path.lineTo(1, 1);
path.lineTo(2, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle13() {
@@ -182,8 +172,7 @@
path.lineTo(1, 1);
path.lineTo(3, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle14() {
@@ -198,8 +187,7 @@
path.lineTo(0, 1);
path.lineTo(0, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle15() {
@@ -213,8 +201,7 @@
path.lineTo(0, 1);
path.lineTo(2, 2);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle16() {
@@ -227,8 +214,7 @@
path.lineTo(0, 1);
path.lineTo(1, 3);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle17() {
@@ -241,8 +227,7 @@
path.lineTo(1, 3);
path.lineTo(0, 1);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle18() {
@@ -255,8 +240,7 @@
path.lineTo(0, 1);
path.lineTo(0, 3);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle19() {
@@ -270,8 +254,7 @@
path.lineTo(1, 1);
path.lineTo(2, 1);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle20() {
@@ -284,8 +267,7 @@
path.lineTo(3, 2);
path.lineTo(0, 3);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyTriangle21() {
@@ -298,8 +280,7 @@
path.lineTo(2, 1);
path.lineTo(0, 3);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyDegenerateTriangle1() {
@@ -312,8 +293,7 @@
path.lineTo(0, 0);
path.lineTo(0, 0);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyDegenerateTriangle2() {
@@ -326,8 +306,7 @@
path.lineTo(2, 2);
path.lineTo(3, 3);
path.close();
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
static void testSimplifyWindingParallelogram() {
@@ -343,9 +322,9 @@
path.lineTo(20,30); // /_/
path.lineTo(30,10);
path.close();
- simplify(path, true, out); // expect _
- comparePaths(path, out); // / \ .
-} // /___\ .
+ testSimplify(path, true, out); // expect _
+ // / \ .
+} // /___\ .
static void testSimplifyXorParallelogram() {
SkPath path, out;
@@ -360,9 +339,8 @@
path.lineTo(20,30); // /_/
path.lineTo(30,10);
path.close();
- simplify(path, true, out); // expect _
- comparePaths(path, out); // \ /
-} //
+ testSimplify(path, true, out); // expect _
+} // \ /
static void testSimplifyTriangle2() {
SkPath path, out;
@@ -374,10 +352,9 @@
path.moveTo(10,10); // triangle _
path.lineTo(20,10); // \ |
path.lineTo(20,30); // \|
- path.close(); // _
- simplify(path, true, out); // expect | |
- comparePaths(path, out); // |_|
-}
+ path.close(); // _
+ testSimplify(path, true, out); // expect | |
+} // |_|
static void testSimplifyNondegenerate4x4Triangles() {
char pathStr[1024];
@@ -433,11 +410,9 @@
str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
str += sprintf(str, " path.close();");
}
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
path.setFillType(SkPath::kEvenOdd_FillType);
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
}
}
@@ -494,11 +469,9 @@
str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
str += sprintf(str, " path.close();");
}
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
path.setFillType(SkPath::kEvenOdd_FillType);
- simplify(path, true, out);
- comparePaths(path, out);
+ testSimplify(path, true, out);
}
}
}
@@ -527,7 +500,165 @@
}
}
+static void testSimplifySkinnyTriangle1() {
+ for (int x = 1; x < 255; ++x) {
+ SkPath path, out;
+ path.moveTo((x * 101) % 10, 0);
+ path.lineTo((x * 91) % 10, 1000);
+ path.lineTo((x * 71) % 10, 2000);
+ path.lineTo((x * 51) % 10, 3000);
+ path.close();
+ path.moveTo((x * 101) % 20, 0);
+ path.lineTo((x * 91) % 20, 1000);
+ path.lineTo((x * 71) % 20, 2000);
+ path.lineTo((x * 51) % 20, 3000);
+ path.close();
+ path.moveTo((x * 101) % 30, 0);
+ path.lineTo((x * 91) % 30, 1000);
+ path.lineTo((x * 71) % 30, 2000);
+ path.lineTo((x * 51) % 30, 3000);
+ path.close();
+ testSimplify(path, true, out);
+ }
+}
+
+static void testSimplifySkinnyTriangle2() {
+ SkPath path, out;
+#if 01
+path.moveTo(591.091064, 627.534851);
+path.lineTo(541.088135, 560.707642);
+path.lineTo(491.085175, 493.880310);
+path.lineTo(441.082214, 427.053101);
+//path.lineTo(591.091064, 627.534851);
+path.close();
+#endif
+path.moveTo(317.093445, 592.013306);
+path.lineTo(366.316162, 542.986572);
+path.lineTo(416.051514, 486.978577);
+path.lineTo(465.786865, 430.970581);
+//path.lineTo(317.093445, 592.013306);
+path.close();
+#if 0
+path.moveTo(289.392517, 517.138489);
+path.lineTo(249.886078, 508.598022);
+path.lineTo(217.110916, 450.916443);
+path.lineTo(196.621033, 394.917633);
+//path.lineTo(289.392517, 517.138489);
+path.close();
+#endif
+ testSimplify(path, true, out);
+}
+
+static void testSimplifySkinnyTriangle3() {
+ SkPath path, out;
+ path.moveTo(591, 627.534851);
+ path.lineTo(541, 560.707642);
+ path.lineTo(491, 493.880310);
+ path.lineTo(441, 427.053101);
+ path.close();
+ path.moveTo(317, 592.013306);
+ path.lineTo(366, 542.986572);
+ path.lineTo(416, 486.978577);
+ path.lineTo(465, 430.970581);
+ path.close();
+ testSimplify(path, true, out);
+}
+
+static void testSimplifySkinnyTriangle4() {
+ SkPath path, out;
+path.moveTo(572.655212, 614.959961);
+path.lineTo(524.618896, 549.339600);
+path.lineTo(476.582581, 483.719269);
+path.lineTo(428.546265, 418.098938);
+path.lineTo(572.655212, 614.959961);
+path.close();
+path.moveTo(312.166382, 583.723083);
+path.lineTo(361.047791, 529.824219);
+path.lineTo(409.929230, 475.925354);
+path.lineTo(458.810669, 422.026520);
+path.lineTo(312.166382, 583.723083);
+path.close();
+path.moveTo(278.742737, 508.065643);
+path.lineTo(241.475800, 493.465118);
+path.lineTo(210.344177, 437.315125);
+path.lineTo(197.019455, 383.794556);
+path.lineTo(278.742737, 508.065643);
+path.close();
+ testSimplify(path, true, out);
+}
+
+static void testSimplifySkinnyTriangle5() {
+ SkPath path, out;
+path.moveTo(554.690613, 602.286072);
+path.lineTo(508.590057, 537.906250);
+path.lineTo(462.489441, 473.526520);
+path.lineTo(416.388855, 409.146729);
+path.lineTo(554.690613, 602.286072);
+path.close();
+path.moveTo(307.216949, 575.189270);
+path.lineTo(355.826965, 516.804688);
+path.lineTo(403.815918, 464.990753);
+path.lineTo(451.804871, 413.176819);
+path.lineTo(307.216949, 575.189270);
+path.close();
+path.moveTo(271.998901, 521.301025);
+path.lineTo(234.619705, 499.687683);
+path.lineTo(203.059692, 441.332336);
+path.lineTo(195.994370, 386.856506);
+path.lineTo(271.998901, 521.301025);
+path.close();
+ testSimplify(path, true, out);
+}
+
+
+static void testSimplifyTriangle22() {
+ SkPath path, out;
+ path.moveTo(0, 0);
+ path.lineTo(1, 0);
+ path.lineTo(0, 2);
+ path.close();
+ path.moveTo(1, 0);
+ path.lineTo(0, 2);
+ path.lineTo(0, 1);
+ path.close();
+ testSimplify(path, true, out);
+}
+
+static void testSimplifyTriangle23() {
+ SkPath path, out;
+ path.moveTo(0, 0);
+ path.lineTo(0, 0);
+ path.lineTo(0, 0);
+ path.close();
+ path.moveTo(0, 0);
+ path.lineTo(0, 1);
+ path.lineTo(1, 2);
+ path.close();
+ testSimplify(path, true, out);
+}
+
+static void testSimplifyTriangle24() {
+ SkPath path, out;
+ path.moveTo(0, 0);
+ path.lineTo(0, 0);
+ path.lineTo(0, 1);
+ path.close();
+ path.moveTo(0, 0);
+ path.lineTo(1, 0);
+ path.lineTo(0, 1);
+ path.close();
+ testSimplify(path, true, out);
+}
+
static void (*simplifyTests[])() = {
+ testSimplifySkinnyTriangle5,
+ testSimplifySkinnyTriangle4,
+ testSimplifySkinnyTriangle3,
+ testSimplifySkinnyTriangle2,
+ testSimplifySkinnyTriangle1,
+ testSimplifyTriangle24,
+ testSimplifyTriangle23,
+ testSimplifyTriangle22,
testSimplifyDegenerateTriangle2,
testSimplifyDegenerateTriangle1,
testSimplifyTriangle21,
@@ -560,7 +691,7 @@
static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]);
-static void (*firstTest)() = 0;
+static void (*firstTest)() = testSimplifySkinnyTriangle4;
void SimplifyPolygonPaths_Test() {
size_t index = 0;
@@ -569,8 +700,10 @@
++index;
}
}
+ bool firstTestComplete = false;
for ( ; index < simplifyTestsCount; ++index) {
(*simplifyTests[index])();
+ firstTestComplete = true;
}
}