aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-23 15:27:41 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-23 15:27:41 +0000
commit4fdbb229649caf74e5c1b55a1823926df903af34 (patch)
tree5f822b5335b213ce7f9857cac288e79e4f3cc8f9 /tests
parent672222e400ec10024106a394512ce864d5b839ea (diff)
turn off debugging printfs
fix pathops issues 1417, 1418 be more rigorous about pulling intersections of lines to end points rewrite cubic/line and quad/line intersections to share style BUG= Review URL: https://codereview.chromium.org/19543005 git-svn-id: http://skia.googlecode.com/svn/trunk@10270 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/PathOpsAngleTest.cpp12
-rw-r--r--tests/PathOpsCubicIntersectionTest.cpp154
-rw-r--r--tests/PathOpsCubicLineIntersectionTest.cpp12
-rw-r--r--tests/PathOpsCubicQuadIntersectionTest.cpp4
-rw-r--r--tests/PathOpsDLineTest.cpp2
-rw-r--r--tests/PathOpsLineIntersectionTest.cpp21
-rw-r--r--tests/PathOpsOpTest.cpp311
-rw-r--r--tests/PathOpsQuadIntersectionTest.cpp83
-rw-r--r--tests/PathOpsQuadLineIntersectionTest.cpp8
-rw-r--r--tests/PathOpsQuadLineIntersectionThreadedTest.cpp6
-rw-r--r--tests/PathOpsSimplifyTest.cpp4
-rw-r--r--tests/PathOpsSkpClipTest.cpp7
12 files changed, 351 insertions, 273 deletions
diff --git a/tests/PathOpsAngleTest.cpp b/tests/PathOpsAngleTest.cpp
index 4c362b6276..f7507a0f97 100644
--- a/tests/PathOpsAngleTest.cpp
+++ b/tests/PathOpsAngleTest.cpp
@@ -257,8 +257,8 @@ static void setup(const SortSet* set, const size_t idx,
if (useIntersectPt) {
break;
}
- start = dLine.xyAtT(set[idx].tStart).asSkPoint();
- end = dLine.xyAtT(set[idx].tEnd).asSkPoint();
+ start = dLine.ptAtT(set[idx].tStart).asSkPoint();
+ end = dLine.ptAtT(set[idx].tEnd).asSkPoint();
} break;
case 3: {
SkASSERT(ValidPoints(data, 3));
@@ -269,8 +269,8 @@ static void setup(const SortSet* set, const size_t idx,
if (useIntersectPt) {
break;
}
- start = dQuad.xyAtT(set[idx].tStart).asSkPoint();
- end = dQuad.xyAtT(set[idx].tEnd).asSkPoint();
+ start = dQuad.ptAtT(set[idx].tStart).asSkPoint();
+ end = dQuad.ptAtT(set[idx].tEnd).asSkPoint();
} break;
case 4: {
SkASSERT(ValidPoints(data, 4));
@@ -281,8 +281,8 @@ static void setup(const SortSet* set, const size_t idx,
if (useIntersectPt) {
break;
}
- start = dCubic.xyAtT(set[idx].tStart).asSkPoint();
- end = dCubic.xyAtT(set[idx].tEnd).asSkPoint();
+ start = dCubic.ptAtT(set[idx].tStart).asSkPoint();
+ end = dCubic.ptAtT(set[idx].tEnd).asSkPoint();
} break;
}
double tStart = set[idx].tStart;
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index c4915e99c9..a0f2846984 100644
--- a/tests/PathOpsCubicIntersectionTest.cpp
+++ b/tests/PathOpsCubicIntersectionTest.cpp
@@ -52,9 +52,9 @@ static void standardTestCases(skiatest::Reporter* reporter) {
}
for (int pt = 0; pt < tIntersections.used(); ++pt) {
double tt1 = tIntersections[0][pt];
- SkDPoint xy1 = cubic1.xyAtT(tt1);
+ SkDPoint xy1 = cubic1.ptAtT(tt1);
double tt2 = tIntersections[1][pt];
- SkDPoint xy2 = cubic2.xyAtT(tt2);
+ SkDPoint xy2 = cubic2.ptAtT(tt2);
if (!xy1.approximatelyEqual(xy2)) {
SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
__FUNCTION__, (int)index, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
@@ -163,6 +163,19 @@ static const SkDCubic testSet[] = {
const size_t testSetCount = SK_ARRAY_COUNT(testSet);
static const SkDCubic newTestSet[] = {
+{{{3, 4}, {1, 5}, {4, 3}, {6, 4}}},
+{{{3, 4}, {4, 6}, {4, 3}, {5, 1}}},
+
+{{{130.04275512695312, 11417.413085937500 },
+ {130.23312377929687, 11418.319335937500 },
+ {131.03707885742187, 11419.000000000000 },
+ {132.00000000000000, 11419.000000000000 }}},
+
+{{{132.00000000000000, 11419.000000000000 },
+ {130.89543151855469, 11419.000000000000 },
+ {130.00000000000000, 11418.104492187500 },
+ {130.00000000000000, 11417.000000000000 }}},
+
{{{1.0516976506771041, 2.9684399028541346 },
{1.0604363140895228, 2.9633503074444141 },
{1.0692548215065762, 2.9580354426587459 },
@@ -305,9 +318,9 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
SkDPoint xy1, xy2;
for (int pt3 = 0; pt3 < intersections.used(); ++pt3) {
tt1 = intersections[0][pt3];
- xy1 = cubic1.xyAtT(tt1);
+ xy1 = cubic1.ptAtT(tt1);
tt2 = intersections[1][pt3];
- xy2 = cubic2.xyAtT(tt2);
+ xy2 = cubic2.ptAtT(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",
@@ -391,9 +404,9 @@ static void CubicIntersection_RandTest(skiatest::Reporter* reporter) {
}
for (int pt = 0; pt < intersections2.used(); ++pt) {
double tt1 = intersections2[0][pt];
- SkDPoint xy1 = cubic1.xyAtT(tt1);
+ SkDPoint xy1 = cubic1.ptAtT(tt1);
double tt2 = intersections2[1][pt];
- SkDPoint xy2 = cubic2.xyAtT(tt2);
+ SkDPoint xy2 = cubic2.ptAtT(tt2);
REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
}
}
@@ -406,12 +419,12 @@ static void intersectionFinder(int index0, int index1, double t1Seed, double t2S
SkDPoint t1[3], t2[3];
bool toggle = true;
do {
- t1[0] = cubic1.xyAtT(t1Seed - t1Step);
- t1[1] = cubic1.xyAtT(t1Seed);
- t1[2] = cubic1.xyAtT(t1Seed + t1Step);
- t2[0] = cubic2.xyAtT(t2Seed - t2Step);
- t2[1] = cubic2.xyAtT(t2Seed);
- t2[2] = cubic2.xyAtT(t2Seed + t2Step);
+ t1[0] = cubic1.ptAtT(t1Seed - t1Step);
+ t1[1] = cubic1.ptAtT(t1Seed);
+ t1[2] = cubic1.ptAtT(t1Seed + t1Step);
+ t2[0] = cubic2.ptAtT(t2Seed - t2Step);
+ t2[1] = cubic2.ptAtT(t2Seed);
+ t2[2] = cubic2.ptAtT(t2Seed + t2Step);
double dist[3][3];
dist[1][1] = t1[1].distance(t2[1]);
int best_i = 1, best_j = 1;
@@ -452,38 +465,38 @@ static void intersectionFinder(int index0, int index1, double t1Seed, double t2S
double t22 = t2Seed + t2Step * 2;
SkDPoint test;
while (!approximately_zero(t1Step)) {
- test = cubic1.xyAtT(t10);
+ test = cubic1.ptAtT(t10);
t10 += t1[1].approximatelyEqual(test) ? -t1Step : t1Step;
t1Step /= 2;
}
t1Step = 0.1;
while (!approximately_zero(t1Step)) {
- test = cubic1.xyAtT(t12);
+ test = cubic1.ptAtT(t12);
t12 -= t1[1].approximatelyEqual(test) ? -t1Step : t1Step;
t1Step /= 2;
}
while (!approximately_zero(t2Step)) {
- test = cubic2.xyAtT(t20);
+ test = cubic2.ptAtT(t20);
t20 += t2[1].approximatelyEqual(test) ? -t2Step : t2Step;
t2Step /= 2;
}
t2Step = 0.1;
while (!approximately_zero(t2Step)) {
- test = cubic2.xyAtT(t22);
+ test = cubic2.ptAtT(t22);
t22 -= t2[1].approximatelyEqual(test) ? -t2Step : t2Step;
t2Step /= 2;
}
#if ONE_OFF_DEBUG
SkDebugf("%s t1=(%1.9g<%1.9g<%1.9g) t2=(%1.9g<%1.9g<%1.9g)\n", __FUNCTION__,
t10, t1Seed, t12, t20, t2Seed, t22);
- SkDPoint p10 = cubic1.xyAtT(t10);
- SkDPoint p1Seed = cubic1.xyAtT(t1Seed);
- SkDPoint p12 = cubic1.xyAtT(t12);
+ SkDPoint p10 = cubic1.ptAtT(t10);
+ SkDPoint p1Seed = cubic1.ptAtT(t1Seed);
+ SkDPoint p12 = cubic1.ptAtT(t12);
SkDebugf("%s p1=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__,
p10.fX, p10.fY, p1Seed.fX, p1Seed.fY, p12.fX, p12.fY);
- SkDPoint p20 = cubic2.xyAtT(t20);
- SkDPoint p2Seed = cubic2.xyAtT(t2Seed);
- SkDPoint p22 = cubic2.xyAtT(t22);
+ SkDPoint p20 = cubic2.ptAtT(t20);
+ SkDPoint p2Seed = cubic2.ptAtT(t2Seed);
+ SkDPoint p22 = cubic2.ptAtT(t22);
SkDebugf("%s p2=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__,
p20.fX, p20.fY, p2Seed.fX, p2Seed.fY, p22.fX, p22.fY);
#endif
@@ -499,54 +512,65 @@ static void CubicIntersection_IntersectionFinder() {
intersectionFinder(0, 1, 0.865213351, 0.865208087, t1Step, t2Step);
}
+static const SkDCubic selfSet[] = {
+ {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
+ {{{3, 6}, {2, 3}, {4, 0}, {3, 2}}},
+ {{{0, 2}, {2, 3}, {5, 1}, {3, 2}}},
+ {{{0, 2}, {3, 5}, {5, 0}, {4, 2}}},
+ {{{3.34, 8.98}, {1.95, 10.27}, {3.76, 7.65}, {4.96, 10.64}}},
+ {{{3.13, 2.74}, {1.08, 4.62}, {3.71, 0.94}, {2.01, 3.81}}},
+ {{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}},
+ {{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}},
+};
+size_t selfSetCount = SK_ARRAY_COUNT(selfSet);
+
+static void selfOneOff(skiatest::Reporter* reporter, int index) {
+ const SkDCubic& cubic = selfSet[index];
+#if ONE_OFF_DEBUG
+ int idx2;
+ double max[3];
+ int ts = cubic.findMaxCurvature(max);
+ for (idx2 = 0; idx2 < ts; ++idx2) {
+ SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2,
+ max[idx2], cubic.ptAtT(max[idx2]).fX, cubic.ptAtT(max[idx2]).fY);
+ }
+ SkTArray<double, true> ts1;
+ SkTArray<SkDQuad, true> quads1;
+ cubic.toQuadraticTs(cubic.calcPrecision(), &ts1);
+ for (idx2 = 0; idx2 < ts1.count(); ++idx2) {
+ SkDebugf("%s t[%d]=%1.9g\n", __FUNCTION__, idx2, ts1[idx2]);
+ }
+ CubicToQuads(cubic, cubic.calcPrecision(), quads1);
+ for (idx2 = 0; idx2 < quads1.count(); ++idx2) {
+ const SkDQuad& q = quads1[idx2];
+ 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);
+ }
+ SkDebugf("\n");
+#endif
+ SkIntersections i;
+ int result = i.intersect(cubic);
+ REPORTER_ASSERT(reporter, result == 1);
+ REPORTER_ASSERT(reporter, i.used() == 1);
+ REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0]));
+ SkDPoint pt1 = cubic.ptAtT(i[0][0]);
+ SkDPoint pt2 = cubic.ptAtT(i[1][0]);
+ REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
+}
+
static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) {
- const SkDCubic selfSet[] = {
- {{{0, 2}, {2, 3}, {5, 1}, {3, 2}}},
- {{{0, 2}, {3, 5}, {5, 0}, {4, 2}}},
- {{{3.34, 8.98}, {1.95, 10.27}, {3.76, 7.65}, {4.96, 10.64}}},
- {{{3.13, 2.74}, {1.08, 4.62}, {3.71, 0.94}, {2.01, 3.81}}},
- {{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}},
- {{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}},
- };
- size_t selfSetCount = SK_ARRAY_COUNT(selfSet);
- size_t firstFail = 1;
+ size_t firstFail = 0;
for (size_t index = firstFail; index < selfSetCount; ++index) {
- const SkDCubic& cubic = selfSet[index];
- #if ONE_OFF_DEBUG
- int idx2;
- double max[3];
- int ts = cubic.findMaxCurvature(max);
- for (idx2 = 0; idx2 < ts; ++idx2) {
- SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2,
- max[idx2], cubic.xyAtT(max[idx2]).fX, cubic.xyAtT(max[idx2]).fY);
- }
- SkTArray<double, true> ts1;
- SkTArray<SkDQuad, true> quads1;
- cubic.toQuadraticTs(cubic.calcPrecision(), &ts1);
- for (idx2 = 0; idx2 < ts1.count(); ++idx2) {
- SkDebugf("%s t[%d]=%1.9g\n", __FUNCTION__, idx2, ts1[idx2]);
- }
- CubicToQuads(cubic, cubic.calcPrecision(), quads1);
- for (idx2 = 0; idx2 < quads1.count(); ++idx2) {
- const SkDQuad& q = quads1[idx2];
- 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);
- }
- SkDebugf("\n");
- #endif
- SkIntersections i;
- int result = i.intersect(cubic);
- REPORTER_ASSERT(reporter, result == 1);
- REPORTER_ASSERT(reporter, i.used() == 1);
- REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0]));
- SkDPoint pt1 = cubic.xyAtT(i[0][0]);
- SkDPoint pt2 = cubic.xyAtT(i[1][0]);
- REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
+ selfOneOff(reporter, index);
}
}
static void PathOpsCubicIntersectionOneOffTest(skiatest::Reporter* reporter) {
- newOneOff(reporter, 6, 7);
+ newOneOff(reporter, 0, 1);
+}
+
+static void PathOpsCubicSelfOneOffTest(skiatest::Reporter* reporter) {
+ selfOneOff(reporter, 0);
}
static void PathOpsCubicIntersectionTest(skiatest::Reporter* reporter) {
@@ -561,3 +585,5 @@ static void PathOpsCubicIntersectionTest(skiatest::Reporter* reporter) {
DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest)
DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionOneOffTest)
+
+DEFINE_TESTCLASS_SHORT(PathOpsCubicSelfOneOffTest)
diff --git a/tests/PathOpsCubicLineIntersectionTest.cpp b/tests/PathOpsCubicLineIntersectionTest.cpp
index 2f52b3b1f2..866acb34fd 100644
--- a/tests/PathOpsCubicLineIntersectionTest.cpp
+++ b/tests/PathOpsCubicLineIntersectionTest.cpp
@@ -54,9 +54,9 @@ static void testOne(skiatest::Reporter* reporter, int iIndex) {
int roots = i.intersect(cubic, line);
for (int pt = 0; pt < roots; ++pt) {
double tt1 = i[0][pt];
- SkDPoint xy1 = cubic.xyAtT(tt1);
+ SkDPoint xy1 = cubic.ptAtT(tt1);
double tt2 = i[1][pt];
- SkDPoint xy2 = line.xyAtT(tt2);
+ SkDPoint xy2 = line.ptAtT(tt2);
if (!xy1.approximatelyEqual(xy2)) {
SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
__FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
@@ -84,15 +84,15 @@ static void PathOpsCubicLineIntersectionOneOffTest(skiatest::Reporter* reporter)
SkASSERT(i.used() == 1);
#if ONE_OFF_DEBUG
double cubicT = i[0][0];
- SkDPoint prev = cubic.xyAtT(cubicT * 2 - 1);
- SkDPoint sect = cubic.xyAtT(cubicT);
+ 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.xyAtT(i[1][0] - 0.0000007);
+ 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.xyAtT(i[1][0] + 0.0000007);
+ 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));
diff --git a/tests/PathOpsCubicQuadIntersectionTest.cpp b/tests/PathOpsCubicQuadIntersectionTest.cpp
index 42a5d33cb1..76ecd01a47 100644
--- a/tests/PathOpsCubicQuadIntersectionTest.cpp
+++ b/tests/PathOpsCubicQuadIntersectionTest.cpp
@@ -52,9 +52,9 @@ static void PathOpsCubicQuadIntersectionTest(skiatest::Reporter* reporter) {
SkASSERT(roots == quadCubicTests[index].answerCount);
for (int pt = 0; pt < roots; ++pt) {
double tt1 = i[0][pt];
- SkDPoint xy1 = cubic.xyAtT(tt1);
+ SkDPoint xy1 = cubic.ptAtT(tt1);
double tt2 = i[1][pt];
- SkDPoint xy2 = quad.xyAtT(tt2);
+ SkDPoint xy2 = quad.ptAtT(tt2);
if (!xy1.approximatelyEqual(xy2)) {
SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
__FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
diff --git a/tests/PathOpsDLineTest.cpp b/tests/PathOpsDLineTest.cpp
index feab21d466..ea816c5b8f 100644
--- a/tests/PathOpsDLineTest.cpp
+++ b/tests/PathOpsDLineTest.cpp
@@ -47,7 +47,7 @@ static void PathOpsLineUtilitiesTest(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, line[0] == line2[1] && line[1] == line2[0]);
line2 = SkDLine::SubDivide(pts, 1, 0);
REPORTER_ASSERT(reporter, line[0] == line2[1] && line[1] == line2[0]);
- SkDPoint mid = line.xyAtT(.5);
+ SkDPoint mid = line.ptAtT(.5);
REPORTER_ASSERT(reporter, approximately_equal((line[0].fX + line[1].fX) / 2, mid.fX));
REPORTER_ASSERT(reporter, approximately_equal((line[0].fY + line[1].fY) / 2, mid.fY));
}
diff --git a/tests/PathOpsLineIntersectionTest.cpp b/tests/PathOpsLineIntersectionTest.cpp
index f2bef912eb..57b42ec3c0 100644
--- a/tests/PathOpsLineIntersectionTest.cpp
+++ b/tests/PathOpsLineIntersectionTest.cpp
@@ -11,6 +11,8 @@
// FIXME: add tests for intersecting, non-intersecting, degenerate, coincident
static const SkDLine tests[][2] = {
+ {{{{181.1764678955078125f, 120}, {186.3661956787109375f, 134.7042236328125f}}},
+ {{{175.8309783935546875f, 141.5211334228515625f}, {187.8782806396484375f, 133.7258148193359375f}}}},
#if 0 // FIXME: these fail because one line is too short and appears quasi-coincident
{{{{158.000000, 926.000000}, {1108.00000, 926.000000}}},
{{{1108.00000, 926.000000}, {1108.00000, 925.999634}}}},
@@ -41,8 +43,11 @@ static const SkDLine noIntersect[][2] = {
static const size_t noIntersect_count = SK_ARRAY_COUNT(noIntersect);
static const SkDLine coincidentTests[][2] = {
+ {{{{186.3661956787109375f, 134.7042236328125f}, {187.8782806396484375f, 133.7258148193359375f}}},
+ {{{175.8309783935546875f, 141.5211334228515625f}, {187.8782806396484375f, 133.7258148193359375f}}}},
+
{{{{235.681549, 531.000000}, {280.318420, 321.000000}}},
- {{{286.695129, 291.000000}, {229.304855, 561.000000}}}},
+ {{{286.695129, 291.000000}, {229.304855, 561.000000}}}},
};
static const size_t coincidentTests_count = SK_ARRAY_COUNT(coincidentTests);
@@ -50,11 +55,11 @@ 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) {
for (int i = 0; i < ts.used(); ++i) {
- SkDPoint result1 = line1.xyAtT(ts[0][i]);
- SkDPoint result2 = line2.xyAtT(ts[1][i]);
+ SkDPoint result1 = line1.ptAtT(ts[0][i]);
+ SkDPoint result2 = line2.ptAtT(ts[1][i]);
if (!result1.approximatelyEqual(result2)) {
REPORTER_ASSERT(reporter, ts.used() != 1);
- result2 = line2.xyAtT(ts[1][i ^ 1]);
+ result2 = line2.ptAtT(ts[1][i ^ 1]);
REPORTER_ASSERT(reporter, result1.approximatelyEqual(result2));
REPORTER_ASSERT(reporter, result1.approximatelyEqual(ts.pt(i).asSkPoint()));
}
@@ -146,7 +151,7 @@ static void PathOpsLineIntersectionTest(skiatest::Reporter* reporter) {
}
}
-static void PathOpsLineIntersectionTestOne(skiatest::Reporter* reporter) {
+static void PathOpsLineIntersectionOneOffTest(skiatest::Reporter* reporter) {
int index = 0;
SkASSERT(index < (int) tests_count);
const SkDLine& line1 = tests[index][0];
@@ -154,7 +159,7 @@ static void PathOpsLineIntersectionTestOne(skiatest::Reporter* reporter) {
testOne(reporter, line1, line2);
}
-static void PathOpsLineIntersectionTestOneCoincident(skiatest::Reporter* reporter) {
+static void PathOpsLineIntersectionOneCoincidentTest(skiatest::Reporter* reporter) {
int index = 0;
SkASSERT(index < (int) coincidentTests_count);
const SkDLine& line1 = coincidentTests[index][0];
@@ -165,6 +170,6 @@ static void PathOpsLineIntersectionTestOneCoincident(skiatest::Reporter* reporte
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTest)
-DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTestOne)
+DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionOneOffTest)
-DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTestOneCoincident)
+DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionOneCoincidentTest)
diff --git a/tests/PathOpsOpTest.cpp b/tests/PathOpsOpTest.cpp
index c81f1dc025..a85c435f98 100644
--- a/tests/PathOpsOpTest.cpp
+++ b/tests/PathOpsOpTest.cpp
@@ -1803,7 +1803,6 @@ static void cubicOp85d(skiatest::Reporter* reporter) {
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
-#if 0 // FIXME
// this fails because the pair of nearly coincident cubics intersect at the ends
// but the line connected to one of the cubics at the same point does not intersect
// the other
@@ -1834,158 +1833,194 @@ static void skpkkiste_to98(skiatest::Reporter* reporter) {
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
-#endif
-#if 0 // https://code.google.com/p/skia/issues/detail?id=1417
+#if 01
static void issue1417(skiatest::Reporter* reporter) {
- SkPath path1;
- path1.moveTo(122.589f, 82.2836f);
- path1.quadTo(129.822f, 80, 138, 80);
- path1.quadTo(147.157f, 80, 155.128f, 82.8628f);
- path1.lineTo(161.176f, 100);
- path1.lineTo(161.176f, 100);
- path1.lineTo(115.294f, 100);
- path1.lineTo(115.294f, 100);
- path1.lineTo(122.589f, 82.2836f);
- path1.lineTo(122.589f, 82.2836f);
- path1.close();
- path1.moveTo(98.6819f, 140.344f);
- path1.lineTo(115.294f, 100);
- path1.lineTo(115.294f, 100);
- path1.lineTo(97.9338f, 100);
- path1.lineTo(97.9338f, 100);
- path1.quadTo(88, 112.943f, 88, 130);
- path1.quadTo(88, 131.545f, 88.0815f, 133.056f);
- path1.lineTo(98.6819f, 140.344f);
- path1.lineTo(98.6819f, 140.344f);
- path1.close();
- path1.moveTo(136.97f, 166.667f);
- path1.lineTo(98.6819f, 140.344f);
- path1.lineTo(98.6819f, 140.344f);
- path1.lineTo(93.4589f, 153.028f);
- path1.lineTo(93.4589f, 153.028f);
- path1.quadTo(96.9412f, 159.652f, 102.645f, 165.355f);
- path1.quadTo(110.792f, 173.503f, 120.818f, 177.118f);
- path1.lineTo(136.97f, 166.667f);
- path1.lineTo(136.97f, 166.667f);
- path1.close();
- path1.moveTo(175.831f, 141.521f);
- path1.lineTo(136.97f, 166.667f);
- path1.lineTo(136.97f, 166.667f);
- path1.lineTo(153.157f, 177.796f);
- path1.lineTo(153.157f, 177.796f);
- path1.quadTo(164.392f, 174.318f, 173.355f, 165.355f);
- path1.quadTo(177.806f, 160.905f, 180.904f, 155.894f);
- path1.lineTo(175.831f, 141.521f);
- path1.lineTo(175.831f, 141.521f);
- path1.close();
- path1.moveTo(175.831f, 141.521f);
- path1.lineTo(187.878f, 133.726f);
- path1.lineTo(187.878f, 133.726f);
- path1.quadTo(188, 131.888f, 188, 130);
- path1.quadTo(188, 112.943f, 178.066f, 100);
- path1.lineTo(161.176f, 100);
- path1.lineTo(161.176f, 100);
- path1.lineTo(175.831f, 141.521f);
- path1.lineTo(175.831f, 141.521f);
- path1.close();
-
- SkPath path2;
- path2.moveTo(174.118f, 100);
- path2.lineTo(161.176f, 100);
- path2.lineTo(161.176f, 100);
- path2.lineTo(155.128f, 82.8628f);
- path2.lineTo(155.128f, 82.8628f);
- path2.quadTo(153.15f, 82.1523f, 151.098f, 81.6181f);
- path2.lineTo(143.529f, 100);
- path2.lineTo(143.529f, 100);
- path2.lineTo(161.176f, 100);
- path2.lineTo(161.176f, 100);
- path2.lineTo(168.235f, 120);
- path2.lineTo(168.235f, 120);
- path2.lineTo(181.176f, 120);
- path2.lineTo(181.176f, 120);
- path2.lineTo(186.366f, 134.704f);
- path2.lineTo(186.366f, 134.704f);
- path2.lineTo(187.878f, 133.726f);
- path2.lineTo(187.878f, 133.726f);
- path2.quadTo(188, 131.888f, 188, 130);
- path2.quadTo(188, 124.809f, 187.08f, 120);
- path2.lineTo(181.176f, 120);
- path2.lineTo(181.176f, 120);
- path2.lineTo(174.118f, 100);
- path2.lineTo(174.118f, 100);
- path2.close();
- path2.moveTo(88.9198f, 120);
- path2.lineTo(107.059f, 120);
- path2.lineTo(107.059f, 120);
- path2.lineTo(98.6819f, 140.344f);
- path2.lineTo(98.6819f, 140.344f);
- path2.lineTo(88.0815f, 133.056f);
- path2.lineTo(88.0815f, 133.056f);
- path2.quadTo(88, 131.545f, 88, 130);
- path2.quadTo(88, 124.81f, 88.9198f, 120);
- path2.close();
- path2.moveTo(96.6762f, 145.215f);
- path2.lineTo(98.6819f, 140.344f);
- path2.lineTo(98.6819f, 140.344f);
- path2.lineTo(120.688f, 155.473f);
- path2.lineTo(120.688f, 155.473f);
- path2.lineTo(118.682f, 160.344f);
- path2.lineTo(118.682f, 160.344f);
- path2.lineTo(96.6762f, 145.215f);
- path2.lineTo(96.6762f, 145.215f);
- path2.close();
- path2.moveTo(113.232f, 173.579f);
- path2.quadTo(116.88f, 175.698f, 120.818f, 177.118f);
- path2.lineTo(132.286f, 169.697f);
- path2.lineTo(132.286f, 169.697f);
- path2.lineTo(118.682f, 160.344f);
- path2.lineTo(118.682f, 160.344f);
- path2.lineTo(113.232f, 173.579f);
- path2.lineTo(113.232f, 173.579f);
- path2.close();
+ SkPath path1;
+ path1.moveTo(122.58908843994140625f, 82.2836456298828125f);
+ path1.quadTo(129.8215789794921875f, 80, 138, 80);
+ path1.quadTo(147.15692138671875f, 80, 155.1280364990234375f, 82.86279296875f);
+ path1.lineTo(161.1764678955078125f, 100);
+ path1.lineTo(161.1764678955078125f, 100);
+ path1.lineTo(115.29412078857421875f, 100);
+ path1.lineTo(115.29412078857421875f, 100);
+ path1.lineTo(122.58908843994140625f, 82.2836456298828125f);
+ path1.lineTo(122.58908843994140625f, 82.2836456298828125f);
+ path1.close();
+ path1.moveTo(98.68194580078125f, 140.343841552734375f);
+ path1.lineTo(115.29412078857421875f, 100);
+ path1.lineTo(115.29412078857421875f, 100);
+ path1.lineTo(97.9337615966796875f, 100);
+ path1.lineTo(97.9337615966796875f, 100);
+ path1.quadTo(88, 112.94264984130859375f, 88, 130);
+ path1.quadTo(88, 131.544830322265625f, 88.08148956298828125f, 133.0560302734375f);
+ path1.lineTo(98.68194580078125f, 140.343841552734375f);
+ path1.lineTo(98.68194580078125f, 140.343841552734375f);
+ path1.close();
+ path1.moveTo(136.969696044921875f, 166.6666717529296875f);
+ path1.lineTo(98.68194580078125f, 140.343841552734375f);
+ path1.lineTo(98.68194580078125f, 140.343841552734375f);
+ path1.lineTo(93.45894622802734375f, 153.02825927734375f);
+ path1.lineTo(93.45894622802734375f, 153.02825927734375f);
+ path1.quadTo(96.94116973876953125f, 159.65185546875f, 102.64466094970703125f, 165.3553466796875f);
+ path1.quadTo(110.7924652099609375f, 173.503143310546875f, 120.8179779052734375f, 177.1177825927734375f);
+ path1.lineTo(136.969696044921875f, 166.6666717529296875f);
+ path1.lineTo(136.969696044921875f, 166.6666717529296875f);
+ path1.close();
+ path1.moveTo(175.8309783935546875f, 141.5211334228515625f);
+ path1.lineTo(136.969696044921875f, 166.6666717529296875f);
+ path1.lineTo(136.969696044921875f, 166.6666717529296875f);
+ path1.lineTo(153.15728759765625f, 177.7956390380859375f);
+ path1.lineTo(153.15728759765625f, 177.7956390380859375f);
+ path1.quadTo(164.392425537109375f, 174.318267822265625f, 173.3553466796875f, 165.3553466796875f);
+ path1.quadTo(177.805816650390625f, 160.9048614501953125f, 180.90380859375f, 155.8941650390625f);
+ path1.lineTo(175.8309783935546875f, 141.5211334228515625f);
+ path1.lineTo(175.8309783935546875f, 141.5211334228515625f);
+ path1.close();
+ path1.moveTo(175.8309783935546875f, 141.5211334228515625f);
+ path1.lineTo(187.8782806396484375f, 133.7258148193359375f);
+ path1.lineTo(187.8782806396484375f, 133.7258148193359375f);
+ path1.quadTo(188, 131.8880615234375f, 188, 130);
+ path1.quadTo(188, 112.942657470703125f, 178.0662384033203125f, 100);
+ path1.lineTo(161.1764678955078125f, 100);
+ path1.lineTo(161.1764678955078125f, 100);
+ path1.lineTo(175.8309783935546875f, 141.5211334228515625f);
+ path1.lineTo(175.8309783935546875f, 141.5211334228515625f);
+ path1.close();
+
+ SkPath path2;
+ path2.moveTo(174.117645263671875f, 100);
+ path2.lineTo(161.1764678955078125f, 100);
+ path2.lineTo(161.1764678955078125f, 100);
+ path2.lineTo(155.1280364990234375f, 82.86279296875f);
+ path2.lineTo(155.1280364990234375f, 82.86279296875f);
+ path2.quadTo(153.14971923828125f, 82.15229034423828125f, 151.098419189453125f, 81.618133544921875f);
+ path2.lineTo(143.5294189453125f, 100);
+ path2.lineTo(143.5294189453125f, 100);
+ path2.lineTo(161.1764678955078125f, 100);
+ path2.lineTo(161.1764678955078125f, 100);
+ path2.lineTo(168.23529052734375f, 120);
+ path2.lineTo(168.23529052734375f, 120);
+ path2.lineTo(181.1764678955078125f, 120);
+ path2.lineTo(181.1764678955078125f, 120);
+ path2.lineTo(186.3661956787109375f, 134.7042236328125f);
+ path2.lineTo(186.3661956787109375f, 134.7042236328125f);
+ path2.lineTo(187.8782806396484375f, 133.7258148193359375f);
+ path2.lineTo(187.8782806396484375f, 133.7258148193359375f);
+ path2.quadTo(188, 131.8880615234375f, 188, 130);
+ path2.quadTo(188, 124.80947113037109375f, 187.080169677734375f, 120);
+ path2.lineTo(181.1764678955078125f, 120);
+ path2.lineTo(181.1764678955078125f, 120);
+ path2.lineTo(174.117645263671875f, 100);
+ path2.lineTo(174.117645263671875f, 100);
+ path2.close();
+ path2.moveTo(88.91983795166015625f, 120);
+ path2.lineTo(107.0588226318359375f, 120);
+ path2.lineTo(107.0588226318359375f, 120);
+ path2.lineTo(98.68194580078125f, 140.343841552734375f);
+ path2.lineTo(98.68194580078125f, 140.343841552734375f);
+ path2.lineTo(88.08148956298828125f, 133.0560302734375f);
+ path2.lineTo(88.08148956298828125f, 133.0560302734375f);
+ path2.quadTo(88, 131.544830322265625f, 88, 130);
+ path2.quadTo(88, 124.80951690673828125f, 88.91983795166015625f, 120);
+ path2.close();
+ path2.moveTo(96.67621612548828125f, 145.21490478515625f);
+ path2.lineTo(98.68194580078125f, 140.343841552734375f);
+ path2.lineTo(98.68194580078125f, 140.343841552734375f);
+ path2.lineTo(120.68767547607421875f, 155.4727783203125f);
+ path2.lineTo(120.68767547607421875f, 155.4727783203125f);
+ path2.lineTo(118.68194580078125f, 160.343841552734375f);
+ path2.lineTo(118.68194580078125f, 160.343841552734375f);
+ path2.lineTo(96.67621612548828125f, 145.21490478515625f);
+ path2.lineTo(96.67621612548828125f, 145.21490478515625f);
+ path2.close();
+ path2.moveTo(113.232177734375f, 173.5789947509765625f);
+ path2.quadTo(116.8802642822265625f, 175.69805908203125f, 120.8179779052734375f, 177.1177825927734375f);
+ path2.lineTo(132.2864990234375f, 169.6969757080078125f);
+ path2.lineTo(132.2864990234375f, 169.6969757080078125f);
+ path2.lineTo(118.68194580078125f, 160.343841552734375f);
+ path2.lineTo(118.68194580078125f, 160.343841552734375f);
+ path2.lineTo(113.232177734375f, 173.5789947509765625f);
+ path2.lineTo(113.232177734375f, 173.5789947509765625f);
+ path2.close();
testPathOp(reporter, path1, path2, kUnion_PathOp);
}
#endif
-#if 0 // https://code.google.com/p/skia/issues/detail?id=1418
static void issue1418(skiatest::Reporter* reporter) {
- SkPath path1;
- path1.moveTo(0, 0);
- path1.lineTo(1, 0);
- path1.lineTo(1, 0);
- path1.lineTo(1, 1);
- path1.lineTo(1, 1);
- path1.lineTo(0, 1);
- path1.lineTo(0, 1);
- path1.lineTo(0, 0);
- path1.lineTo(0, 0);
- path1.close();
-
- SkPath path2;
- path2.moveTo(0.646447f, -0.353553f);
- path2.quadTo(0.792893f, -0.5f, 1, -0.5f);
- path2.quadTo(1.20711f, -0.5f, 1.35355f, -0.353553f);
- path2.quadTo(1.5f, -0.207107f, 1.5f, 0);
- path2.quadTo(1.5f, 0.207107f, 1.35355f, 0.353553f);
- path2.quadTo(1.20711f, 0.5f, 1, 0.5f);
- path2.quadTo(0.792893f, 0.5f, 0.646447f, 0.353553f);
- path2.quadTo(0.5f, 0.207107f, 0.5f, 0);
- path2.quadTo(0.5f, -0.207107f, 0.646447f, -0.353553f);
- path2.close();
-
+ SkPath path1;
+ path1.moveTo(0, 0);
+ path1.lineTo(1, 0);
+ path1.lineTo(1, 0);
+ path1.lineTo(1, 1);
+ path1.lineTo(1, 1);
+ path1.lineTo(0, 1);
+ path1.lineTo(0, 1);
+ path1.lineTo(0, 0);
+ path1.lineTo(0, 0);
+ path1.close();
+
+ SkPath path2;
+ path2.moveTo(0.64644664525985717773f, -0.35355341434478759766f);
+ path2.quadTo(0.79289329051971435547f, -0.50000005960464477539f, 1.0000001192092895508f, -0.50000005960464477539f);
+ path2.quadTo(1.2071068286895751953f, -0.50000005960464477539f, 1.3535535335540771484f, -0.35355341434478759766f);
+ path2.quadTo(1.5000001192092895508f, -0.20710679888725280762f, 1.5000001192092895508f, 0);
+ path2.quadTo(1.5000001192092895508f, 0.20710679888725280762f, 1.3535535335540771484f, 0.35355341434478759766f);
+ path2.quadTo(1.2071068286895751953f, 0.50000005960464477539f, 1.0000001192092895508f, 0.50000005960464477539f);
+ path2.quadTo(0.79289329051971435547f, 0.50000005960464477539f, 0.64644664525985717773f, 0.35355341434478759766f);
+ path2.quadTo(0.50000005960464477539f, 0.20710679888725280762f, 0.50000005960464477539f, 0);
+ path2.quadTo(0.50000005960464477539f, -0.20710679888725280762f, 0.64644664525985717773f, -0.35355341434478759766f);
testPathOp(reporter, path1, path2, kIntersect_PathOp);
}
+
+static void cubicOp85i(skiatest::Reporter* reporter) {
+ SkPath path, pathB;
+ path.setFillType(SkPath::kWinding_FillType);
+ path.moveTo(3, 4);
+ path.cubicTo(1, 5, 4, 3, 6, 4);
+ path.close();
+ pathB.setFillType(SkPath::kWinding_FillType);
+ pathB.moveTo(3, 4);
+ pathB.cubicTo(4, 6, 4, 3, 5, 1);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kIntersect_PathOp);
+}
+
+#if 0
+static void skpkkiste_to716(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ path.moveTo(1173, 284);
+ path.cubicTo(1173, 285.125824f, 1173.37207f, 286.164734f, 1174, 287.000488f);
+ path.lineTo(1174, 123.999496f);
+ path.cubicTo(1173.37207f, 124.835243f, 1173, 125.874168f, 1173, 127);
+ path.lineTo(1173, 284);
+ path.close();
+ SkPath pathB;
+ pathB.setFillType(SkPath::kWinding_FillType);
+ pathB.moveTo(1340, 122);
+ pathB.cubicTo(1342.76147f, 122, 1345, 124.238579f, 1345, 127);
+ pathB.lineTo(1345, 284);
+ pathB.cubicTo(1345, 286.761414f, 1342.76147f, 289, 1340, 289);
+ pathB.lineTo(1178, 289);
+ pathB.cubicTo(1175.23853f, 289, 1173, 286.761414f, 1173, 284);
+ pathB.lineTo(1173, 127);
+ pathB.cubicTo(1173, 124.238579f, 1175.23853f, 122, 1178, 122);
+ pathB.lineTo(1340, 122);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kIntersect_PathOp);
+}
#endif
static void (*firstTest)(skiatest::Reporter* ) = 0;
static struct TestDesc tests[] = {
-// TEST(issue1418),
-// TEST(issue1417),
-// TEST(skpkkiste_to98),
+ // TEST(skpkkiste_to716),
+ TEST(cubicOp85i),
+ TEST(issue1417),
+ TEST(issue1418),
+ TEST(skpkkiste_to98),
TEST(skpahrefs_com29),
TEST(cubicOp85d),
TEST(skpahrefs_com88),
diff --git a/tests/PathOpsQuadIntersectionTest.cpp b/tests/PathOpsQuadIntersectionTest.cpp
index ee2e8de8a1..2d72b41d2d 100644
--- a/tests/PathOpsQuadIntersectionTest.cpp
+++ b/tests/PathOpsQuadIntersectionTest.cpp
@@ -37,9 +37,9 @@ static void standardTestCases(skiatest::Reporter* reporter) {
if (intersections.used() > 0) {
for (int pt = 0; pt < intersections.used(); ++pt) {
double tt1 = intersections[0][pt];
- SkDPoint xy1 = quad1.xyAtT(tt1);
+ SkDPoint xy1 = quad1.ptAtT(tt1);
double tt2 = intersections[1][pt];
- SkDPoint xy2 = quad2.xyAtT(tt2);
+ SkDPoint xy2 = quad2.ptAtT(tt2);
if (!xy1.approximatelyEqual(xy2)) {
SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
__FUNCTION__, static_cast<int>(index), pt, tt1, xy1.fX, xy1.fY,
@@ -256,9 +256,9 @@ static void oneOffTest1(skiatest::Reporter* reporter, size_t outer, size_t inner
intersections2.intersect(quad1, quad2);
for (int pt = 0; pt < intersections2.used(); ++pt) {
double tt1 = intersections2[0][pt];
- SkDPoint xy1 = quad1.xyAtT(tt1);
+ SkDPoint xy1 = quad1.ptAtT(tt1);
double tt2 = intersections2[1][pt];
- SkDPoint xy2 = quad2.xyAtT(tt2);
+ SkDPoint xy2 = quad2.ptAtT(tt2);
if (!xy1.approximatelyEqual(xy2)) {
SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
__FUNCTION__, static_cast<int>(outer), static_cast<int>(inner),
@@ -285,6 +285,8 @@ static void oneOffTests(skiatest::Reporter* reporter) {
}
static const SkDQuad coincidentTestSet[] = {
+ {{{97.9337615966796875,100}, {88,112.94264984130859375}, {88,130}}},
+ {{{88,130}, {88,124.80951690673828125}, {88.91983795166015625,120}}},
{{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287}}},
{{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287}}},
{{{8, 8}, {10, 10}, {8, -10}}},
@@ -293,25 +295,34 @@ static const SkDQuad coincidentTestSet[] = {
const size_t coincidentTestSetCount = SK_ARRAY_COUNT(coincidentTestSet);
+static void coincidentTestOne(skiatest::Reporter* reporter, int test1, int test2) {
+ const SkDQuad& quad1 = coincidentTestSet[test1];
+ SkASSERT(ValidQuad(quad1));
+ const SkDQuad& quad2 = coincidentTestSet[test2];
+ SkASSERT(ValidQuad(quad2));
+ SkIntersections intersections2;
+ intersections2.intersect(quad1, quad2);
+ REPORTER_ASSERT(reporter, intersections2.coincidentUsed() == 2);
+ REPORTER_ASSERT(reporter, intersections2.used() == 2);
+ for (int pt = 0; pt < intersections2.coincidentUsed(); ++pt) {
+ double tt1 = intersections2[0][pt];
+ double tt2 = intersections2[1][pt];
+ SkDPoint pt1 = quad1.ptAtT(tt1);
+ SkDPoint pt2 = quad2.ptAtT(tt2);
+ REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
+ }
+}
+
static void coincidentTest(skiatest::Reporter* reporter) {
for (size_t testIndex = 0; testIndex < coincidentTestSetCount - 1; testIndex += 2) {
- const SkDQuad& quad1 = coincidentTestSet[testIndex];
- SkASSERT(ValidQuad(quad1));
- const SkDQuad& quad2 = coincidentTestSet[testIndex + 1];
- SkASSERT(ValidQuad(quad2));
- SkIntersections intersections2;
- intersections2.intersect(quad1, quad2);
- REPORTER_ASSERT(reporter, intersections2.coincidentUsed() == 2);
- REPORTER_ASSERT(reporter, intersections2.used() == 2);
- for (int pt = 0; pt < intersections2.coincidentUsed(); ++pt) {
- double tt1 = intersections2[0][pt];
- double tt2 = intersections2[1][pt];
- REPORTER_ASSERT(reporter, approximately_equal(1, tt1) || approximately_zero(tt1));
- REPORTER_ASSERT(reporter, approximately_equal(1, tt2) || approximately_zero(tt2));
- }
+ coincidentTestOne(reporter, testIndex, testIndex + 1);
}
}
+static void PathOpsQuadIntersectionCoincidenceOneOffTest(skiatest::Reporter* reporter) {
+ coincidentTestOne(reporter, 0, 1);
+}
+
static int floatSign(double x) {
return x < 0 ? -1 : x > 0 ? 1 : 0;
}
@@ -338,7 +349,7 @@ static const SkDQuad pointFinderTestSet[] = {
static void pointFinder(const SkDQuad& q1, const SkDQuad& q2) {
for (int index = 0; index < 3; ++index) {
double t = q1.nearestT(q2[index]);
- SkDPoint onQuad = q1.xyAtT(t);
+ SkDPoint onQuad = q1.ptAtT(t);
SkDebugf("%s t=%1.9g (%1.9g,%1.9g) dist=%1.9g\n", __FUNCTION__, t, onQuad.fX, onQuad.fY,
onQuad.distance(q2[index]));
double left[3];
@@ -388,12 +399,12 @@ static void intersectionFinder(int test1, int test2) {
SkDPoint t1[3], t2[3];
bool toggle = true;
do {
- t1[0] = quad1.xyAtT(t1Seed - t1Step);
- t1[1] = quad1.xyAtT(t1Seed);
- t1[2] = quad1.xyAtT(t1Seed + t1Step);
- t2[0] = quad2.xyAtT(t2Seed - t2Step);
- t2[1] = quad2.xyAtT(t2Seed);
- t2[2] = quad2.xyAtT(t2Seed + t2Step);
+ t1[0] = quad1.ptAtT(t1Seed - t1Step);
+ t1[1] = quad1.ptAtT(t1Seed);
+ t1[2] = quad1.ptAtT(t1Seed + t1Step);
+ t2[0] = quad2.ptAtT(t2Seed - t2Step);
+ t2[1] = quad2.ptAtT(t2Seed);
+ t2[2] = quad2.ptAtT(t2Seed + t2Step);
double dist[3][3];
dist[1][1] = t1[1].distance(t2[1]);
int best_i = 1, best_j = 1;
@@ -434,38 +445,38 @@ static void intersectionFinder(int test1, int test2) {
double t22 = t2Seed + t2Step * 2;
SkDPoint test;
while (!approximately_zero(t1Step)) {
- test = quad1.xyAtT(t10);
+ test = quad1.ptAtT(t10);
t10 += t1[1].approximatelyEqual(test) ? -t1Step : t1Step;
t1Step /= 2;
}
t1Step = 0.1;
while (!approximately_zero(t1Step)) {
- test = quad1.xyAtT(t12);
+ test = quad1.ptAtT(t12);
t12 -= t1[1].approximatelyEqual(test) ? -t1Step : t1Step;
t1Step /= 2;
}
while (!approximately_zero(t2Step)) {
- test = quad2.xyAtT(t20);
+ test = quad2.ptAtT(t20);
t20 += t2[1].approximatelyEqual(test) ? -t2Step : t2Step;
t2Step /= 2;
}
t2Step = 0.1;
while (!approximately_zero(t2Step)) {
- test = quad2.xyAtT(t22);
+ test = quad2.ptAtT(t22);
t22 -= t2[1].approximatelyEqual(test) ? -t2Step : t2Step;
t2Step /= 2;
}
#if ONE_OFF_DEBUG
SkDebugf("%s t1=(%1.9g<%1.9g<%1.9g) t2=(%1.9g<%1.9g<%1.9g)\n", __FUNCTION__,
t10, t1Seed, t12, t20, t2Seed, t22);
- SkDPoint p10 = quad1.xyAtT(t10);
- SkDPoint p1Seed = quad1.xyAtT(t1Seed);
- SkDPoint p12 = quad1.xyAtT(t12);
+ SkDPoint p10 = quad1.ptAtT(t10);
+ SkDPoint p1Seed = quad1.ptAtT(t1Seed);
+ SkDPoint p12 = quad1.ptAtT(t12);
SkDebugf("%s p1=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__,
p10.fX, p10.fY, p1Seed.fX, p1Seed.fY, p12.fX, p12.fY);
- SkDPoint p20 = quad2.xyAtT(t20);
- SkDPoint p2Seed = quad2.xyAtT(t2Seed);
- SkDPoint p22 = quad2.xyAtT(t22);
+ SkDPoint p20 = quad2.ptAtT(t20);
+ SkDPoint p2Seed = quad2.ptAtT(t2Seed);
+ SkDPoint p22 = quad2.ptAtT(t22);
SkDebugf("%s p2=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__,
p20.fX, p20.fY, p2Seed.fX, p2Seed.fY, p22.fX, p22.fY);
#endif
@@ -488,3 +499,5 @@ static void PathOpsQuadIntersectionTest(skiatest::Reporter* reporter) {
DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionTest)
DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionOneOffTest)
+
+DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionCoincidenceOneOffTest)
diff --git a/tests/PathOpsQuadLineIntersectionTest.cpp b/tests/PathOpsQuadLineIntersectionTest.cpp
index 02c925cad2..555a90ce70 100644
--- a/tests/PathOpsQuadLineIntersectionTest.cpp
+++ b/tests/PathOpsQuadLineIntersectionTest.cpp
@@ -80,9 +80,9 @@ static void testOneOffs(skiatest::Reporter* reporter) {
int result = doIntersect(intersections, quad, line, flipped);
for (int inner = 0; inner < result; ++inner) {
double quadT = intersections[0][inner];
- SkDPoint quadXY = quad.xyAtT(quadT);
+ SkDPoint quadXY = quad.ptAtT(quadT);
double lineT = intersections[1][inner];
- SkDPoint lineXY = line.xyAtT(lineT);
+ SkDPoint lineXY = line.ptAtT(lineT);
REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY));
}
}
@@ -120,10 +120,10 @@ static void PathOpsQuadLineIntersectionTest(skiatest::Reporter* reporter) {
for (int pt = 0; pt < result; ++pt) {
double tt1 = intersections[0][pt];
REPORTER_ASSERT(reporter, tt1 >= 0 && tt1 <= 1);
- SkDPoint t1 = quad.xyAtT(tt1);
+ SkDPoint t1 = quad.ptAtT(tt1);
double tt2 = intersections[1][pt];
REPORTER_ASSERT(reporter, tt2 >= 0 && tt2 <= 1);
- SkDPoint t2 = line.xyAtT(tt2);
+ SkDPoint t2 = line.ptAtT(tt2);
if (!t1.approximatelyEqual(t2)) {
SkDebugf("%s [%d,%d] x!= t1=%1.9g (%1.9g,%1.9g) t2=%1.9g (%1.9g,%1.9g)\n",
__FUNCTION__, iIndex, pt, tt1, t1.fX, t1.fY, tt2, t2.fX, t2.fY);
diff --git a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
index 7d1b133fac..63f9447edf 100644
--- a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
+++ b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
@@ -55,9 +55,9 @@ static void testLineIntersect(skiatest::Reporter* reporter, const SkDQuad& quad,
bool found = false;
for (int index = 0; index < result; ++index) {
double quadT = intersections[0][index];
- SkDPoint quadXY = quad.xyAtT(quadT);
+ SkDPoint quadXY = quad.ptAtT(quadT);
double lineT = intersections[1][index];
- SkDPoint lineXY = line.xyAtT(lineT);
+ SkDPoint lineXY = line.ptAtT(lineT);
if (quadXY.approximatelyEqual(lineXY)) {
found = true;
}
@@ -89,7 +89,7 @@ static void testQuadLineIntersectMain(PathOpsThreadState* data)
return;
}
for (int tIndex = 0; tIndex <= 4; ++tIndex) {
- SkDPoint xy = quad.xyAtT(tIndex / 4.0);
+ SkDPoint xy = quad.ptAtT(tIndex / 4.0);
for (int h = -2; h <= 2; ++h) {
for (int v = -2; v <= 2; ++v) {
if (h == v && abs(h) != 1) {
diff --git a/tests/PathOpsSimplifyTest.cpp b/tests/PathOpsSimplifyTest.cpp
index 5f61812b1f..954435fc92 100644
--- a/tests/PathOpsSimplifyTest.cpp
+++ b/tests/PathOpsSimplifyTest.cpp
@@ -3828,7 +3828,7 @@ static void skphealth_com76(skiatest::Reporter* reporter) {
testSimplify(reporter, path);
}
-static void (*firstTest)(skiatest::Reporter* ) = testLine24a;
+static void (*firstTest)(skiatest::Reporter* ) = testQuad6;
static TestDesc tests[] = {
TEST(skphealth_com76),
@@ -4194,7 +4194,7 @@ static const size_t subTestCount = SK_ARRAY_COUNT(subTests);
static void (*firstSubTest)(skiatest::Reporter* ) = 0;
static bool runSubTestsFirst = false;
-static bool runReverse = true;
+static bool runReverse = false;
static void (*stopTest)(skiatest::Reporter* ) = 0;
static void PathOpsSimplifyTest(skiatest::Reporter* reporter) {
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index f9d33e16f8..146c42ade7 100644
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -58,9 +58,8 @@ static void testOne(const SkString& filename) {
if (!stream.isValid()) {
return;
}
- bool success;
- SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &SkImageDecoder::DecodeMemory));
- if (!success) {
+ SkPicture* pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory);
+ if (!pic) {
SkDebugf("unable to decode %s\n", filename.c_str());
return;
}
@@ -68,7 +67,7 @@ static void testOne(const SkString& filename) {
int height = pic->height();
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- success = bitmap.allocPixels();
+ bool success = bitmap.allocPixels();
if (!success) {
SkDebugf("unable to allocate bitmap for %s\n", filename.c_str());
return;