Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tests/PathOpsLineIntersectionTest.cpp

Issue 1002693002: pathops version two (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix arm 64 inspired coincident handling Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/PathOpsFuzz763Test.cpp ('k') | tests/PathOpsOpCubicThreadedTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathOpsLineIntersectionTest.cpp
diff --git a/tests/PathOpsLineIntersectionTest.cpp b/tests/PathOpsLineIntersectionTest.cpp
index 105187be64c8f72b1685262f278b21416250b8ee..bc0259c9c9f8c37acd36edfa0fd26dee5c236428 100644
--- a/tests/PathOpsLineIntersectionTest.cpp
+++ b/tests/PathOpsLineIntersectionTest.cpp
@@ -11,6 +11,9 @@
// FIXME: add tests for intersecting, non-intersecting, degenerate, coincident
static const SkDLine tests[][2] = {
+{{{{0.00010360032320022583, 1.0172703415155411}, {0.00014114845544099808, 1.0200891587883234}}},
+ {{{0.00010259449481964111, 1.017270140349865}, {0.00018215179443359375, 1.022890567779541}}}},
+
#if 0
// these do intersect at a pair of points, but not close enough for check results liking
{{{{365.848175,5081.15186}, {368,5103}}}, {{{367.967712,5102.61084}, {368.278717,5105.71045}}}},
@@ -82,10 +85,13 @@ static const SkDLine coincidentTests[][2] = {
static const size_t coincidentTests_count = SK_ARRAY_COUNT(coincidentTests);
static void check_results(skiatest::Reporter* reporter, const SkDLine& line1, const SkDLine& line2,
- const SkIntersections& ts) {
+ const SkIntersections& ts, bool nearAllowed) {
for (int i = 0; i < ts.used(); ++i) {
SkDPoint result1 = line1.ptAtT(ts[0][i]);
SkDPoint result2 = line2.ptAtT(ts[1][i]);
+ if (nearAllowed && result1.roughlyEqual(result2)) {
+ continue;
+ }
if (!result1.approximatelyEqual(result2) && !ts.nearlySame(i)) {
REPORTER_ASSERT(reporter, ts.used() != 1);
result2 = line2.ptAtT(ts[1][i ^ 1]);
@@ -98,14 +104,16 @@ static void check_results(skiatest::Reporter* reporter, const SkDLine& line1, co
}
}
-static void testOne(skiatest::Reporter* reporter, const SkDLine& line1, const SkDLine& line2) {
+static void testOne(skiatest::Reporter* reporter, const SkDLine& line1, const SkDLine& line2,
+ bool nearAllowed) {
SkASSERT(ValidLine(line1));
SkASSERT(ValidLine(line2));
SkIntersections i;
+ i.allowNear(nearAllowed);
int pts = i.intersect(line1, line2);
REPORTER_ASSERT(reporter, pts);
REPORTER_ASSERT(reporter, pts == i.used());
- check_results(reporter, line1, line2, i);
+ check_results(reporter, line1, line2, i, nearAllowed);
if (line1[0] == line1[1] || line2[0] == line2[1]) {
return;
}
@@ -114,28 +122,28 @@ static void testOne(skiatest::Reporter* reporter, const SkDLine& line1, const Sk
double right = SkTMax(line1[0].fX, line1[1].fX);
SkIntersections ts;
ts.horizontal(line2, left, right, line1[0].fY, line1[0].fX != left);
- check_results(reporter, line2, line1, ts);
+ check_results(reporter, line2, line1, ts, nearAllowed);
}
if (line2[0].fY == line2[1].fY) {
double left = SkTMin(line2[0].fX, line2[1].fX);
double right = SkTMax(line2[0].fX, line2[1].fX);
SkIntersections ts;
ts.horizontal(line1, left, right, line2[0].fY, line2[0].fX != left);
- check_results(reporter, line1, line2, ts);
+ check_results(reporter, line1, line2, ts, nearAllowed);
}
if (line1[0].fX == line1[1].fX) {
double top = SkTMin(line1[0].fY, line1[1].fY);
double bottom = SkTMax(line1[0].fY, line1[1].fY);
SkIntersections ts;
ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top);
- check_results(reporter, line2, line1, ts);
+ check_results(reporter, line2, line1, ts, nearAllowed);
}
if (line2[0].fX == line2[1].fX) {
double top = SkTMin(line2[0].fY, line2[1].fY);
double bottom = SkTMax(line2[0].fY, line2[1].fY);
SkIntersections ts;
ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top);
- check_results(reporter, line1, line2, ts);
+ check_results(reporter, line1, line2, ts, nearAllowed);
}
reporter->bumpTestCount();
}
@@ -148,7 +156,7 @@ static void testOneCoincident(skiatest::Reporter* reporter, const SkDLine& line1
int pts = ts.intersect(line1, line2);
REPORTER_ASSERT(reporter, pts == 2);
REPORTER_ASSERT(reporter, pts == ts.used());
- check_results(reporter, line1, line2, ts);
+ check_results(reporter, line1, line2, ts, false);
if (line1[0] == line1[1] || line2[0] == line2[1]) {
return;
}
@@ -159,7 +167,7 @@ static void testOneCoincident(skiatest::Reporter* reporter, const SkDLine& line1
ts.horizontal(line2, left, right, line1[0].fY, line1[0].fX != left);
REPORTER_ASSERT(reporter, pts == 2);
REPORTER_ASSERT(reporter, pts == ts.used());
- check_results(reporter, line2, line1, ts);
+ check_results(reporter, line2, line1, ts, false);
}
if (line2[0].fY == line2[1].fY) {
double left = SkTMin(line2[0].fX, line2[1].fX);
@@ -168,7 +176,7 @@ static void testOneCoincident(skiatest::Reporter* reporter, const SkDLine& line1
ts.horizontal(line1, left, right, line2[0].fY, line2[0].fX != left);
REPORTER_ASSERT(reporter, pts == 2);
REPORTER_ASSERT(reporter, pts == ts.used());
- check_results(reporter, line1, line2, ts);
+ check_results(reporter, line1, line2, ts, false);
}
if (line1[0].fX == line1[1].fX) {
double top = SkTMin(line1[0].fY, line1[1].fY);
@@ -177,7 +185,7 @@ static void testOneCoincident(skiatest::Reporter* reporter, const SkDLine& line1
ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top);
REPORTER_ASSERT(reporter, pts == 2);
REPORTER_ASSERT(reporter, pts == ts.used());
- check_results(reporter, line2, line1, ts);
+ check_results(reporter, line2, line1, ts, false);
}
if (line2[0].fX == line2[1].fX) {
double top = SkTMin(line2[0].fY, line2[1].fY);
@@ -186,7 +194,7 @@ static void testOneCoincident(skiatest::Reporter* reporter, const SkDLine& line1
ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top);
REPORTER_ASSERT(reporter, pts == 2);
REPORTER_ASSERT(reporter, pts == ts.used());
- check_results(reporter, line1, line2, ts);
+ check_results(reporter, line1, line2, ts, false);
}
reporter->bumpTestCount();
}
@@ -201,7 +209,7 @@ DEF_TEST(PathOpsLineIntersection, reporter) {
for (index = 0; index < tests_count; ++index) {
const SkDLine& line1 = tests[index][0];
const SkDLine& line2 = tests[index][1];
- testOne(reporter, line1, line2);
+ testOne(reporter, line1, line2, true);
}
for (index = 0; index < noIntersect_count; ++index) {
const SkDLine& line1 = noIntersect[index][0];
@@ -217,8 +225,13 @@ DEF_TEST(PathOpsLineIntersection, reporter) {
DEF_TEST(PathOpsLineIntersectionOneOff, reporter) {
int index = 0;
SkASSERT(index < (int) tests_count);
- testOne(reporter, tests[index][0], tests[index][1]);
- testOne(reporter, tests[1][0], tests[1][1]);
+ testOne(reporter, tests[index][0], tests[index][1], true);
+}
+
+DEF_TEST(PathOpsLineIntersectionExactOneOff, reporter) {
+ int index = 0;
+ SkASSERT(index < (int) tests_count);
+ testOne(reporter, tests[index][0], tests[index][1], false);
}
DEF_TEST(PathOpsLineIntersectionOneCoincident, reporter) {
« no previous file with comments | « tests/PathOpsFuzz763Test.cpp ('k') | tests/PathOpsOpCubicThreadedTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698