aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsCubicIntersectionTest.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-06-04 17:59:42 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-06-04 17:59:42 +0000
commitcffbcc3b9665f2c928544b6fc6b8a0e22a4210fb (patch)
treeed16b540c395c4e1c91733d9198575c2352efc06 /tests/PathOpsCubicIntersectionTest.cpp
parent4075fd485101eea80cc67c396e6839e555ab948a (diff)
path ops -- rewrite angle sort
This is a major change resulting from a minor tweak. In the old code, the intersection point of two curves was shared between them, but the intersection points and end points of sorted edges was computed directly from the intersection T value. In this CL, both intersection points and sorted points are the same, and intermediate control points are computed to preserve their slope. The sort itself has been completely rewritten to be more robust and remove 'magic' checks, conditions that empirically worked but couldn't be rationalized. This CL was triggered by errors generated computing the clips of SKP files. At this point, all 73M standard tests work and at least the first troublesome SKPs work. Review URL: https://codereview.chromium.org/15338003 git-svn-id: http://skia.googlecode.com/svn/trunk@9432 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PathOpsCubicIntersectionTest.cpp')
-rw-r--r--tests/PathOpsCubicIntersectionTest.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index 58d7d98024..b0d6bd881b 100644
--- a/tests/PathOpsCubicIntersectionTest.cpp
+++ b/tests/PathOpsCubicIntersectionTest.cpp
@@ -163,6 +163,12 @@ static const SkDCubic testSet[] = {
const size_t testSetCount = SK_ARRAY_COUNT(testSet);
static const SkDCubic newTestSet[] = {
+{{{134,11414}, {131.990234375,11414}, {130.32666015625,11415.482421875}, {130.04275512695312,11417.4130859375}}},
+{{{132,11419}, {130.89543151855469,11419}, {130,11418.1044921875}, {130,11417}}},
+
+{{{132,11419}, {130.89543151855469,11419}, {130,11418.1044921875}, {130,11417}}},
+{{{130.04275512695312,11417.4130859375}, {130.23312377929687,11418.3193359375}, {131.03707885742187,11419}, {132,11419}}},
+
{{{0, 1}, {2, 3}, {5, 1}, {4, 3}}},
{{{1, 5}, {3, 4}, {1, 0}, {3, 2}}},
@@ -231,10 +237,10 @@ const size_t newTestSetCount = SK_ARRAY_COUNT(newTestSet);
static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const SkDCubic& cubic2) {
#if ONE_OFF_DEBUG
SkDebugf("computed quadratics given\n");
- SkDebugf(" {{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}},\n",
+ SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n",
cubic1[0].fX, cubic1[0].fY, cubic1[1].fX, cubic1[1].fY,
cubic1[2].fX, cubic1[2].fY, cubic1[3].fX, cubic1[3].fY);
- SkDebugf(" {{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}},\n",
+ SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n",
cubic2[0].fX, cubic2[0].fY, cubic2[1].fX, cubic2[1].fY,
cubic2[2].fX, cubic2[2].fY, cubic2[3].fX, cubic2[3].fY);
#endif
@@ -244,7 +250,7 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
SkDebugf("computed quadratics set 1\n");
for (int index = 0; index < quads1.count(); ++index) {
const SkDQuad& q = quads1[index];
- SkDebugf(" {{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}},\n", q[0].fX, q[0].fY,
+ SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].fX, q[0].fY,
q[1].fX, q[1].fY, q[2].fX, q[2].fY);
}
#endif
@@ -254,7 +260,7 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
SkDebugf("computed quadratics set 2\n");
for (int index = 0; index < quads2.count(); ++index) {
const SkDQuad& q = quads2[index];
- SkDebugf(" {{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}},\n", q[0].fX, q[0].fY,
+ SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].fX, q[0].fY,
q[1].fX, q[1].fY, q[2].fX, q[2].fY);
}
#endif
@@ -267,12 +273,15 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
xy1 = cubic1.xyAtT(tt1);
tt2 = intersections[1][pt3];
xy2 = cubic2.xyAtT(tt2);
+ const SkDPoint& iPt = intersections.pt(pt3);
#if ONE_OFF_DEBUG
SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g) (%1.9g, %1.9g) t2=%1.9g\n",
- __FUNCTION__, tt1, xy1.fX, xy1.fY, intersections.pt(pt3).fX,
- intersections.pt(pt3).fY, xy2.fX, xy2.fY, tt2);
+ __FUNCTION__, tt1, xy1.fX, xy1.fY, iPt.fX,
+ iPt.fY, xy2.fX, xy2.fY, tt2);
#endif
- REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
+ REPORTER_ASSERT(reporter, xy1.approximatelyEqual(iPt));
+ REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt));
+ REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
}
}