Mike R: please sanity check SkPostConfig.h
Mike K: please sanity check Test.cpp and skia_test.cpp
Feel free to look at the rest, but I don't expect any in depth review of path ops innards.
Path Ops first iteration used QuickSort to order segments radiating from an intersection to compute the winding rule.
This revision uses a circular sort instead. Breaking out the circular sort into its own long-lived structure (SkOpAngle) allows doing less work and provides a home for caching additional sorting data.
The circle sort is more stable than the former sort, has a robust ordering and fewer exceptions. It finds unsortable ordering less often. It is less reliant on the initial curve tangent, using convex hulls instead whenever it can.
Additional debug validation makes sure that the computed structures are self-consistent. A new visualization tool helps verify that the angle ordering is correct.
The 70+M tests pass with this change on Windows, Mac, Linux 32 and Linux 64 in debug and release.
R=mtklein@google.com, reed@google.com
Author: caryclark@google.com
Review URL: https://codereview.chromium.org/131103009
git-svn-id: http://skia.googlecode.com/svn/trunk@14183 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PathOpsCubicLineIntersectionTest.cpp b/tests/PathOpsCubicLineIntersectionTest.cpp
index 3f9e9ff..8ded198 100644
--- a/tests/PathOpsCubicLineIntersectionTest.cpp
+++ b/tests/PathOpsCubicLineIntersectionTest.cpp
@@ -15,6 +15,12 @@
SkDCubic cubic;
SkDLine line;
} lineCubicTests[] = {
+ {{{{421, 378}, {421, 380.209137f}, {418.761414f, 382}, {416, 382}}},
+ {{{320, 378}, {421, 378.000031f}}}},
+
+ {{{{416, 383}, {418.761414f, 383}, {421, 380.761414f}, {421, 378}}},
+ {{{320, 378}, {421, 378.000031f}}}},
+
{{{{154,715}, {151.238571,715}, {149,712.761414}, {149,710}}},
{{{149,675}, {149,710.001465}}}},
@@ -73,6 +79,21 @@
}
REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
}
+#if ONE_OFF_DEBUG
+ double cubicT = i[0][0];
+ SkDPoint prev = cubic.ptAtT(cubicT * 2 - 1);
+ SkDPoint sect = cubic.ptAtT(cubicT);
+ double left[3] = { line.isLeft(prev), line.isLeft(sect), line.isLeft(cubic[3]) };
+ SkDebugf("cubic=(%1.9g, %1.9g, %1.9g)\n", left[0], left[1], left[2]);
+ SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prev.fX, prev.fY, sect.fX, sect.fY);
+ SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", sect.fX, sect.fY, cubic[3].fX, cubic[3].fY);
+ SkDPoint prevL = line.ptAtT(i[1][0] - 0.0000007);
+ SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prevL.fX, prevL.fY, i.pt(0).fX, i.pt(0).fY);
+ SkDPoint nextL = line.ptAtT(i[1][0] + 0.0000007);
+ SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", i.pt(0).fX, i.pt(0).fY, nextL.fX, nextL.fY);
+ SkDebugf("prevD=%1.9g dist=%1.9g nextD=%1.9g\n", prev.distance(nextL),
+ sect.distance(i.pt(0)), cubic[3].distance(prevL));
+#endif
}
}
@@ -92,19 +113,4 @@
SkIntersections i;
i.intersect(cubic, line);
SkASSERT(i.used() == 1);
-#if ONE_OFF_DEBUG
- double cubicT = i[0][0];
- SkDPoint prev = cubic.ptAtT(cubicT * 2 - 1);
- SkDPoint sect = cubic.ptAtT(cubicT);
- double left[3] = { line.isLeft(prev), line.isLeft(sect), line.isLeft(cubic[3]) };
- SkDebugf("cubic=(%1.9g, %1.9g, %1.9g)\n", left[0], left[1], left[2]);
- SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prev.fX, prev.fY, sect.fX, sect.fY);
- SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", sect.fX, sect.fY, cubic[3].fX, cubic[3].fY);
- SkDPoint prevL = line.ptAtT(i[1][0] - 0.0000007);
- SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prevL.fX, prevL.fY, i.pt(0).fX, i.pt(0).fY);
- SkDPoint nextL = line.ptAtT(i[1][0] + 0.0000007);
- SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", i.pt(0).fX, i.pt(0).fY, nextL.fX, nextL.fY);
- SkDebugf("prevD=%1.9g dist=%1.9g nextD=%1.9g\n", prev.distance(nextL),
- sect.distance(i.pt(0)), cubic[3].distance(prevL));
-#endif
}