aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-10-20 08:32:18 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-20 08:32:18 -0700
commita35ab3e6e024d0b548ded26a2e3b8ecd838ead93 (patch)
treec009069f86b1129fcf5037ffc8e8fbf1b9ba010f /tests
parent65820db5e15201a3f30968420232d36c0ca89cd8 (diff)
fix fuzzers
Many old pathops-related fuzz failures have built up while the codebase was under a state a flux. Now that the code is stable, address these failures. Most of the CL plumbs the debug global state to downstream routines so that, if the data is not trusted (ala fuzzed) the function can safely exit without asserting. TBR=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2426173002 Review-Url: https://chromiumcodereview.appspot.com/2426173002
Diffstat (limited to 'tests')
-rwxr-xr-xtests/PathOpsAngleIdeas.cpp65
-rw-r--r--tests/PathOpsAngleTest.cpp8
-rw-r--r--tests/PathOpsConicIntersectionTest.cpp11
-rw-r--r--tests/PathOpsConicLineIntersectionTest.cpp12
-rw-r--r--tests/PathOpsConicQuadIntersectionTest.cpp12
-rw-r--r--tests/PathOpsCubicConicIntersectionTest.cpp12
-rw-r--r--tests/PathOpsCubicIntersectionTest.cpp122
-rw-r--r--tests/PathOpsCubicIntersectionTestData.cpp16
-rw-r--r--tests/PathOpsCubicIntersectionTestData.h20
-rw-r--r--tests/PathOpsCubicLineIntersectionIdeas.cpp10
-rw-r--r--tests/PathOpsCubicLineIntersectionTest.cpp14
-rw-r--r--tests/PathOpsCubicQuadIntersectionTest.cpp12
-rw-r--r--tests/PathOpsCubicReduceOrderTest.cpp40
-rw-r--r--tests/PathOpsDCubicTest.cpp6
-rw-r--r--tests/PathOpsDRectTest.cpp12
-rw-r--r--tests/PathOpsLineParametetersTest.cpp6
-rw-r--r--tests/PathOpsOpTest.cpp7
-rw-r--r--tests/PathOpsQuadIntersectionTest.cpp51
-rw-r--r--tests/PathOpsQuadIntersectionTestData.cpp8
-rw-r--r--tests/PathOpsQuadIntersectionTestData.h10
-rw-r--r--tests/PathOpsQuadLineIntersectionTest.cpp12
-rw-r--r--tests/PathOpsQuadLineIntersectionThreadedTest.cpp5
-rw-r--r--tests/PathOpsQuadReduceOrderTest.cpp14
-rw-r--r--tests/PathOpsTestCommon.h15
-rw-r--r--tests/PathOpsThreeWayTest.cpp16
-rwxr-xr-xtests/StrokerTest.cpp25
26 files changed, 349 insertions, 192 deletions
diff --git a/tests/PathOpsAngleIdeas.cpp b/tests/PathOpsAngleIdeas.cpp
index 9d1b5994b2..a408a3c3b1 100755
--- a/tests/PathOpsAngleIdeas.cpp
+++ b/tests/PathOpsAngleIdeas.cpp
@@ -77,7 +77,7 @@ static void orderQuads(skiatest::Reporter* reporter, const SkDQuad& quad, double
double s = r * SK_ScalarTanPIOver8;
double m = r * SK_ScalarRoot2Over2;
// construct circle from quads
- const SkDQuad circle[8] = {{{{ r, 0}, { r, -s}, { m, -m}}},
+ const QuadPts circle[8] = {{{{ r, 0}, { r, -s}, { m, -m}}},
{{{ m, -m}, { s, -r}, { 0, -r}}},
{{{ 0, -r}, {-s, -r}, {-m, -m}}},
{{{-m, -m}, {-r, -s}, {-r, 0}}},
@@ -86,7 +86,9 @@ static void orderQuads(skiatest::Reporter* reporter, const SkDQuad& quad, double
{{{ 0, r}, { s, r}, { m, m}}},
{{{ m, m}, { r, s}, { r, 0}}}};
for (int octant = 0; octant < 8; ++octant) {
- double t = testArc(reporter, quad, circle[octant], octant);
+ SkDQuad cQuad;
+ cQuad.debugSet(circle[octant].fPts);
+ double t = testArc(reporter, quad, cQuad, octant);
if (t < 0) {
continue;
}
@@ -332,6 +334,9 @@ static bool bruteMinT(skiatest::Reporter* reporter, const SkDQuad& quad1, const
rStep /= 2;
} while (rStep > FLT_EPSILON);
if (bestCCW < 0) {
+ if (bestR >= maxRadius) {
+ SkDebugf("");
+ }
REPORTER_ASSERT(reporter, bestR < maxRadius);
return false;
}
@@ -555,12 +560,15 @@ static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, c
DEF_TEST(PathOpsAngleOverlapHullsOne, reporter) {
SkChunkAlloc allocator(4096);
// gPathOpsAngleIdeasVerbose = true;
- const SkDQuad quads[] = {
+ const QuadPts quads[] = {
{{{939.4808349609375, 914.355224609375}, {-357.7921142578125, 590.842529296875}, {736.8936767578125, -350.717529296875}}},
{{{939.4808349609375, 914.355224609375}, {-182.85418701171875, 634.4552001953125}, {-509.62615966796875, 576.1182861328125}}}
};
for (int index = 0; index < (int) SK_ARRAY_COUNT(quads); index += 2) {
- testQuadAngles(reporter, quads[index], quads[index + 1], 0, &allocator);
+ SkDQuad quad0, quad1;
+ quad0.debugSet(quads[index].fPts);
+ quad1.debugSet(quads[index + 1].fPts);
+ testQuadAngles(reporter, quad0, quad1, 0, &allocator);
}
}
@@ -573,23 +581,26 @@ DEF_TEST(PathOpsAngleOverlapHulls, reporter) {
for (int index = 0; index < 100000; ++index) {
if (index % 1000 == 999) SkDebugf(".");
SkDPoint origin = {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)};
- SkDQuad quad1 = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
+ QuadPts quad1 = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
{ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)}}};
- if (quad1[0] == quad1[2]) {
+ if (quad1.fPts[0] == quad1.fPts[2]) {
continue;
}
- SkDQuad quad2 = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
+ QuadPts quad2 = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
{ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)}}};
- if (quad2[0] == quad2[2]) {
+ if (quad2.fPts[0] == quad2.fPts[2]) {
continue;
}
SkIntersections i;
- i.intersect(quad1, quad2);
+ SkDQuad q1, q2;
+ q1.debugSet(quad1.fPts);
+ q2.debugSet(quad2.fPts);
+ i.intersect(q1, q2);
REPORTER_ASSERT(reporter, i.used() >= 1);
if (i.used() > 1) {
continue;
}
- testQuadAngles(reporter, quad1, quad2, index, &allocator);
+ testQuadAngles(reporter, q1, q2, index, &allocator);
}
}
@@ -603,29 +614,32 @@ DEF_TEST(PathOpsAngleBruteT, reporter) {
SkDEBUGCODE(int smallIndex);
for (int index = 0; index < 100000; ++index) {
SkDPoint origin = {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)};
- SkDQuad quad1 = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
+ QuadPts quad1 = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
{ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)}}};
- if (quad1[0] == quad1[2]) {
+ if (quad1.fPts[0] == quad1.fPts[2]) {
continue;
}
- SkDQuad quad2 = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
+ QuadPts quad2 = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
{ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)}}};
- if (quad2[0] == quad2[2]) {
+ if (quad2.fPts[0] == quad2.fPts[2]) {
continue;
}
+ SkDQuad q1, q2;
+ q1.debugSet(quad1.fPts);
+ q2.debugSet(quad2.fPts);
SkIntersections i;
- i.intersect(quad1, quad2);
+ i.intersect(q1, q2);
REPORTER_ASSERT(reporter, i.used() >= 1);
if (i.used() > 1) {
continue;
}
TRange lowerRange, upperRange;
- bool result = bruteMinT(reporter, quad1, quad2, &lowerRange, &upperRange);
+ bool result = bruteMinT(reporter, q1, q2, &lowerRange, &upperRange);
REPORTER_ASSERT(reporter, result);
double min = SkTMin(upperRange.t1, upperRange.t2);
if (smaller > min) {
- small[0] = quad1;
- small[1] = quad2;
+ small[0] = q1;
+ small[1] = q2;
SkDEBUGCODE(smallIndex = index);
smaller = min;
}
@@ -637,7 +651,7 @@ DEF_TEST(PathOpsAngleBruteT, reporter) {
DEF_TEST(PathOpsAngleBruteTOne, reporter) {
// gPathOpsAngleIdeasVerbose = true;
- const SkDQuad quads[] = {
+ const QuadPts qPts[] = {
{{{-770.8492431640625, 948.2369384765625}, {-853.37066650390625, 972.0301513671875}, {-200.62042236328125, -26.7174072265625}}},
{{{-770.8492431640625, 948.2369384765625}, {513.602783203125, 578.8681640625}, {960.641357421875, -813.69757080078125}}},
{{{563.8267822265625, -107.4566650390625}, {-44.67724609375, -136.57452392578125}, {492.3856201171875, -268.79644775390625}}},
@@ -646,6 +660,10 @@ DEF_TEST(PathOpsAngleBruteTOne, reporter) {
{{{598.857421875, 846.345458984375}, {715.7142333984375, 955.3599853515625}, {-919.9478759765625, 691.611328125}}},
};
TRange lowerRange, upperRange;
+ SkDQuad quads[SK_ARRAY_COUNT(qPts)];
+ for (int index = 0; index < (int) SK_ARRAY_COUNT(qPts); ++index) {
+ quads[index].debugSet(qPts[index].fPts);
+ }
bruteMinT(reporter, quads[0], quads[1], &lowerRange, &upperRange);
bruteMinT(reporter, quads[2], quads[3], &lowerRange, &upperRange);
bruteMinT(reporter, quads[4], quads[5], &lowerRange, &upperRange);
@@ -666,7 +684,7 @@ We need to determine how short is extremely short. Move the control point a set
the largest length to determine how stable the curve is vis-a-vis the initial tangent.
*/
-static const SkDQuad extremeTests[][2] = {
+static const QuadPts extremeTests[][2] = {
{
{{{-708.0077926931004,-154.61669472244046},
{-707.9234268635319,-154.30459999551294},
@@ -793,8 +811,11 @@ DEF_TEST(PathOpsAngleExtreme, reporter) {
}
double maxR = SK_ScalarMax;
for (int index = 0; index < (int) SK_ARRAY_COUNT(extremeTests); ++index) {
- const SkDQuad& quad1 = extremeTests[index][0];
- const SkDQuad& quad2 = extremeTests[index][1];
+ const QuadPts& qu1 = extremeTests[index][0];
+ const QuadPts& qu2 = extremeTests[index][1];
+ SkDQuad quad1, quad2;
+ quad1.debugSet(qu1.fPts);
+ quad2.debugSet(qu2.fPts);
if (gPathOpsAngleIdeasVerbose) {
SkDebugf("%s %d\n", __FUNCTION__, index);
}
diff --git a/tests/PathOpsAngleTest.cpp b/tests/PathOpsAngleTest.cpp
index fe39d40b9c..d5285c8fbc 100644
--- a/tests/PathOpsAngleTest.cpp
+++ b/tests/PathOpsAngleTest.cpp
@@ -81,7 +81,9 @@ DEF_TEST(PathOpsAngleFindQuadEpsilon, reporter) {
SkDPoint qPt2 = line.ptAtT(t3);
qPt.fX += qPt2.fY;
qPt.fY -= qPt2.fX;
- SkDQuad quad = {{line[0], dPt, qPt}};
+ QuadPts q = {{line[0], dPt, qPt}};
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
// binary search for maximum movement of quad[1] towards test that still has 1 intersection
double moveT = 0.5f;
double deltaT = moveT / 2;
@@ -223,7 +225,7 @@ public:
};
struct CircleData {
- const SkDCubic fPts;
+ const CubicPts fPts;
const int fPtCount;
SkPoint fShortPts[4];
};
@@ -266,7 +268,7 @@ DEF_TEST(PathOpsAngleCircle, reporter) {
}
struct IntersectData {
- const SkDCubic fPts;
+ const CubicPts fPts;
const int fPtCount;
double fTStart;
double fTEnd;
diff --git a/tests/PathOpsConicIntersectionTest.cpp b/tests/PathOpsConicIntersectionTest.cpp
index e22ad6bff1..41c0acb9fd 100644
--- a/tests/PathOpsConicIntersectionTest.cpp
+++ b/tests/PathOpsConicIntersectionTest.cpp
@@ -16,7 +16,7 @@ manually compute the intersection of a pair of circles and see if the conic inte
*/
-static const SkDConic testSet[] = {
+static const ConicPts testSet[] = {
{{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}}, 0.707107008f},
{{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}, 0.707107008f},
@@ -295,11 +295,14 @@ static void writeFrames() {
}
#endif
-static void oneOff(skiatest::Reporter* reporter, const SkDConic& c1, const SkDConic& c2,
+static void oneOff(skiatest::Reporter* reporter, const ConicPts& conic1, const ConicPts& conic2,
bool coin) {
#if DEBUG_VISUALIZE_CONICS
writeFrames();
#endif
+ SkDConic c1, c2;
+ c1.debugSet(conic1.fPts.fPts, conic1.fWeight);
+ c2.debugSet(conic2.fPts.fPts, conic2.fWeight);
chopBothWays(c1, 0.5, "c1");
chopBothWays(c2, 0.5, "c2");
#if DEBUG_VISUALIZE_CONICS
@@ -330,8 +333,8 @@ static void oneOff(skiatest::Reporter* reporter, const SkDConic& c1, const SkDCo
}
static void oneOff(skiatest::Reporter* reporter, int outer, int inner) {
- const SkDConic& c1 = testSet[outer];
- const SkDConic& c2 = testSet[inner];
+ const ConicPts& c1 = testSet[outer];
+ const ConicPts& c2 = testSet[inner];
oneOff(reporter, c1, c2, false);
}
diff --git a/tests/PathOpsConicLineIntersectionTest.cpp b/tests/PathOpsConicLineIntersectionTest.cpp
index ecc4a47f17..c3d4a2afe3 100644
--- a/tests/PathOpsConicLineIntersectionTest.cpp
+++ b/tests/PathOpsConicLineIntersectionTest.cpp
@@ -14,7 +14,7 @@
#include "Test.h"
static struct lineConic {
- SkDConic conic;
+ ConicPts conic;
SkDLine line;
int result;
SkDPoint expected[2];
@@ -57,7 +57,7 @@ static int doIntersect(SkIntersections& intersections, const SkDConic& conic, co
}
static struct oneLineConic {
- SkDConic conic;
+ ConicPts conic;
SkDLine line;
} oneOffs[] = {
{{{{{30.6499996,25.6499996}, {30.6499996,20.6499996}, {25.6499996,20.6499996}}}, 0.707107008f},
@@ -69,7 +69,9 @@ static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs);
static void testOneOffs(skiatest::Reporter* reporter) {
bool flipped = false;
for (size_t index = 0; index < oneOffs_count; ++index) {
- const SkDConic& conic = oneOffs[index].conic;
+ const ConicPts& c = oneOffs[index].conic;
+ SkDConic conic;
+ conic.debugSet(c.fPts.fPts, c.fWeight);
SkASSERT(ValidConic(conic));
const SkDLine& line = oneOffs[index].line;
SkASSERT(ValidLine(line));
@@ -96,7 +98,9 @@ DEF_TEST(PathOpsConicLineIntersectionOneOff, reporter) {
DEF_TEST(PathOpsConicLineIntersection, reporter) {
for (size_t index = 0; index < lineConicTests_count; ++index) {
int iIndex = static_cast<int>(index);
- const SkDConic& conic = lineConicTests[index].conic;
+ const ConicPts& c = lineConicTests[index].conic;
+ SkDConic conic;
+ conic.debugSet(c.fPts.fPts, c.fWeight);
SkASSERT(ValidConic(conic));
const SkDLine& line = lineConicTests[index].line;
SkASSERT(ValidLine(line));
diff --git a/tests/PathOpsConicQuadIntersectionTest.cpp b/tests/PathOpsConicQuadIntersectionTest.cpp
index 5996cf804c..99411dc98c 100644
--- a/tests/PathOpsConicQuadIntersectionTest.cpp
+++ b/tests/PathOpsConicQuadIntersectionTest.cpp
@@ -12,8 +12,8 @@
#include "Test.h"
static struct conicQuad {
- SkDConic conic;
- SkDQuad quad;
+ ConicPts conic;
+ QuadPts quad;
} conicQuadTests[] = {
{{{{{494.348663,224.583771}, {494.365143,224.633194}, {494.376404,224.684067}}}, 0.998645842f},
{{{494.30481,224.474213}, {494.334961,224.538284}, {494.355774,224.605927}}}},
@@ -25,9 +25,13 @@ static struct conicQuad {
static const int conicQuadTests_count = (int) SK_ARRAY_COUNT(conicQuadTests);
static void conicQuadIntersection(skiatest::Reporter* reporter, int index) {
- const SkDConic& conic = conicQuadTests[index].conic;
+ const ConicPts& c = conicQuadTests[index].conic;
+ SkDConic conic;
+ conic.debugSet(c.fPts.fPts, c.fWeight);
SkASSERT(ValidConic(conic));
- const SkDQuad& quad = conicQuadTests[index].quad;
+ const QuadPts& q = conicQuadTests[index].quad;
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
SkReduceOrder reduce1;
SkReduceOrder reduce2;
diff --git a/tests/PathOpsCubicConicIntersectionTest.cpp b/tests/PathOpsCubicConicIntersectionTest.cpp
index fae1233a55..d7924634b2 100644
--- a/tests/PathOpsCubicConicIntersectionTest.cpp
+++ b/tests/PathOpsCubicConicIntersectionTest.cpp
@@ -12,8 +12,8 @@
#include "Test.h"
static struct cubicConic {
- SkDCubic cubic;
- SkDConic conic;
+ CubicPts cubic;
+ ConicPts conic;
} cubicConicTests[] = {
{{{{188.60000610351562, 2041.5999755859375}, {188.60000610351562, 2065.39990234375},
{208, 2084.800048828125}, {231.80000305175781, 2084.800048828125}}},
@@ -29,9 +29,13 @@ static struct cubicConic {
static const int cubicConicTests_count = (int) SK_ARRAY_COUNT(cubicConicTests);
static void cubicConicIntersection(skiatest::Reporter* reporter, int index) {
- const SkDCubic& cubic = cubicConicTests[index].cubic;
+ const CubicPts& cu = cubicConicTests[index].cubic;
+ SkDCubic cubic;
+ cubic.debugSet(cu.fPts);
SkASSERT(ValidCubic(cubic));
- const SkDConic& conic = cubicConicTests[index].conic;
+ const ConicPts& co = cubicConicTests[index].conic;
+ SkDConic conic;
+ conic.debugSet(co.fPts.fPts, co.fWeight);
SkASSERT(ValidConic(conic));
SkReduceOrder reduce1;
SkReduceOrder reduce2;
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index 07852bca9a..e69aff86a5 100644
--- a/tests/PathOpsCubicIntersectionTest.cpp
+++ b/tests/PathOpsCubicIntersectionTest.cpp
@@ -19,11 +19,14 @@ const int firstCubicIntersectionTest = 9;
static void standardTestCases(skiatest::Reporter* reporter) {
for (size_t index = firstCubicIntersectionTest; index < tests_count; ++index) {
int iIndex = static_cast<int>(index);
- const SkDCubic& cubic1 = tests[index][0];
- const SkDCubic& cubic2 = tests[index][1];
+ const CubicPts& cubic1 = tests[index][0];
+ const CubicPts& cubic2 = tests[index][1];
+ SkDCubic c1, c2;
+ c1.debugSet(cubic1.fPts);
+ c2.debugSet(cubic2.fPts);
SkReduceOrder reduce1, reduce2;
- int order1 = reduce1.reduce(cubic1, SkReduceOrder::kNo_Quadratics);
- int order2 = reduce2.reduce(cubic2, SkReduceOrder::kNo_Quadratics);
+ int order1 = reduce1.reduce(c1, SkReduceOrder::kNo_Quadratics);
+ int order2 = reduce2.reduce(c2, SkReduceOrder::kNo_Quadratics);
const bool showSkipped = false;
if (order1 < 4) {
if (showSkipped) {
@@ -38,7 +41,7 @@ static void standardTestCases(skiatest::Reporter* reporter) {
continue;
}
SkIntersections tIntersections;
- tIntersections.intersect(cubic1, cubic2);
+ tIntersections.intersect(c1, c2);
if (!tIntersections.used()) {
if (showSkipped) {
SkDebugf("%s [%d] no intersection\n", __FUNCTION__, iIndex);
@@ -53,9 +56,9 @@ static void standardTestCases(skiatest::Reporter* reporter) {
}
for (int pt = 0; pt < tIntersections.used(); ++pt) {
double tt1 = tIntersections[0][pt];
- SkDPoint xy1 = cubic1.ptAtT(tt1);
+ SkDPoint xy1 = c1.ptAtT(tt1);
double tt2 = tIntersections[1][pt];
- SkDPoint xy2 = cubic2.ptAtT(tt2);
+ SkDPoint xy2 = c2.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);
@@ -66,7 +69,7 @@ static void standardTestCases(skiatest::Reporter* reporter) {
}
}
-static const SkDCubic testSet[] = {
+static const CubicPts testSet[] = {
// FIXME: uncommenting these two will cause this to fail
// this results in two curves very nearly but not exactly coincident
#if 0
@@ -164,7 +167,7 @@ static const SkDCubic testSet[] = {
const int testSetCount = (int) SK_ARRAY_COUNT(testSet);
-static const SkDCubic newTestSet[] = {
+static const CubicPts newTestSet[] = {
{ { { 130.0427549999999997, 11417.41309999999976 },{ 130.2331240000000037, 11418.3192999999992 },{ 131.0370790000000056, 11419 },{ 132, 11419 } } },
{ { { 132, 11419 },{ 130.8954319999999996, 11419 },{ 130, 11418.10449999999946 },{ 130, 11417 } } },
@@ -381,10 +384,13 @@ static const SkDCubic newTestSet[] = {
};
const int newTestSetCount = (int) SK_ARRAY_COUNT(newTestSet);
-static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const SkDCubic& cubic2,
+static void oneOff(skiatest::Reporter* reporter, const CubicPts& cubic1, const CubicPts& cubic2,
bool coin) {
- SkASSERT(ValidCubic(cubic1));
- SkASSERT(ValidCubic(cubic2));
+ SkDCubic c1, c2;
+ c1.debugSet(cubic1.fPts);
+ c2.debugSet(cubic2.fPts);
+ SkASSERT(ValidCubic(c1));
+ SkASSERT(ValidCubic(c2));
#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",
@@ -395,7 +401,7 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
cubic2[2].fX, cubic2[2].fY, cubic2[3].fX, cubic2[3].fY);
#endif
SkIntersections intersections;
- intersections.intersect(cubic1, cubic2);
+ intersections.intersect(c1, c2);
#if DEBUG_T_SECT_DUMP == 3
SkDebugf("</div>\n\n");
SkDebugf("<script type=\"text/javascript\">\n\n");
@@ -412,9 +418,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.ptAtT(tt1);
+ xy1 = c1.ptAtT(tt1);
tt2 = intersections[1][pt3];
- xy2 = cubic2.ptAtT(tt2);
+ xy2 = c2.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",
@@ -429,20 +435,20 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
}
static void oneOff(skiatest::Reporter* reporter, int outer, int inner) {
- const SkDCubic& cubic1 = testSet[outer];
- const SkDCubic& cubic2 = testSet[inner];
+ const CubicPts& cubic1 = testSet[outer];
+ const CubicPts& cubic2 = testSet[inner];
oneOff(reporter, cubic1, cubic2, false);
}
static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) {
- const SkDCubic& cubic1 = newTestSet[outer];
- const SkDCubic& cubic2 = newTestSet[inner];
+ const CubicPts& cubic1 = newTestSet[outer];
+ const CubicPts& cubic2 = newTestSet[inner];
oneOff(reporter, cubic1, cubic2, false);
}
static void testsOneOff(skiatest::Reporter* reporter, int index) {
- const SkDCubic& cubic1 = tests[index][0];
- const SkDCubic& cubic2 = tests[index][1];
+ const CubicPts& cubic1 = tests[index][0];
+ const CubicPts& cubic2 = tests[index][1];
oneOff(reporter, cubic1, cubic2, false);
}
@@ -468,12 +474,12 @@ static void CubicIntersection_RandTest(skiatest::Reporter* reporter) {
unsigned seed = 0;
#endif
for (int test = 0; test < tests; ++test) {
- SkDCubic cubic1, cubic2;
+ CubicPts cubic1, cubic2;
for (int i = 0; i < 4; ++i) {
- cubic1[i].fX = static_cast<double>(SK_RAND(seed)) / RAND_MAX * 100;
- cubic1[i].fY = static_cast<double>(SK_RAND(seed)) / RAND_MAX * 100;
- cubic2[i].fX = static_cast<double>(SK_RAND(seed)) / RAND_MAX * 100;
- cubic2[i].fY = static_cast<double>(SK_RAND(seed)) / RAND_MAX * 100;
+ cubic1.fPts[i].fX = static_cast<double>(SK_RAND(seed)) / RAND_MAX * 100;
+ cubic1.fPts[i].fY = static_cast<double>(SK_RAND(seed)) / RAND_MAX * 100;
+ cubic2.fPts[i].fX = static_cast<double>(SK_RAND(seed)) / RAND_MAX * 100;
+ cubic2.fPts[i].fY = static_cast<double>(SK_RAND(seed)) / RAND_MAX * 100;
}
#if DEBUG_CRASH
char str[1024];
@@ -486,15 +492,18 @@ static void CubicIntersection_RandTest(skiatest::Reporter* reporter) {
cubic2[3].fX, cubic2[3].fY);
#endif
SkDRect rect1, rect2;
- rect1.setBounds(cubic1);
- rect2.setBounds(cubic2);
+ SkDCubic c1, c2;
+ c1.debugSet(cubic1.fPts);
+ c2.debugSet(cubic2.fPts);
+ rect1.setBounds(c1);
+ rect2.setBounds(c2);
bool boundsIntersect = rect1.fLeft <= rect2.fRight && rect2.fLeft <= rect2.fRight
&& rect1.fTop <= rect2.fBottom && rect2.fTop <= rect1.fBottom;
if (test == -1) {
SkDebugf("ready...\n");
}
SkIntersections intersections2;
- int newIntersects = intersections2.intersect(cubic1, cubic2);
+ int newIntersects = intersections2.intersect(c1, c2);
if (!boundsIntersect && newIntersects) {
#if DEBUG_CRASH
SkDebugf("%s %d unexpected intersection boundsIntersect=%d "
@@ -505,9 +514,9 @@ static void CubicIntersection_RandTest(skiatest::Reporter* reporter) {
}
for (int pt = 0; pt < intersections2.used(); ++pt) {
double tt1 = intersections2[0][pt];
- SkDPoint xy1 = cubic1.ptAtT(tt1);
+ SkDPoint xy1 = c1.ptAtT(tt1);
double tt2 = intersections2[1][pt];
- SkDPoint xy2 = cubic2.ptAtT(tt2);
+ SkDPoint xy2 = c2.ptAtT(tt2);
REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
}
reporter->bumpTestCount();
@@ -516,17 +525,20 @@ static void CubicIntersection_RandTest(skiatest::Reporter* reporter) {
static void intersectionFinder(int index0, int index1, double t1Seed, double t2Seed,
double t1Step, double t2Step) {
- const SkDCubic& cubic1 = newTestSet[index0];
- const SkDCubic& cubic2 = newTestSet[index1];
+ const CubicPts& cubic1 = newTestSet[index0];
+ const CubicPts& cubic2 = newTestSet[index1];
SkDPoint t1[3], t2[3];
bool toggle = true;
+ SkDCubic c1, c2;
+ c1.debugSet(cubic1.fPts);
+ c2.debugSet(cubic2.fPts);
do {
- 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);
+ t1[0] = c1.ptAtT(t1Seed - t1Step);
+ t1[1] = c1.ptAtT(t1Seed);
+ t1[2] = c1.ptAtT(t1Seed + t1Step);
+ t2[0] = c2.ptAtT(t2Seed - t2Step);
+ t2[1] = c2.ptAtT(t2Seed);
+ t2[2] = c2.ptAtT(t2Seed + t2Step);
double dist[3][3];
dist[1][1] = t1[1].distance(t2[1]);
int best_i = 1, best_j = 1;
@@ -567,38 +579,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.ptAtT(t10);
+ test = c1.ptAtT(t10);
t10 += t1[1].approximatelyEqual(test) ? -t1Step : t1Step;
t1Step /= 2;
}
t1Step = 0.1;
while (!approximately_zero(t1Step)) {
- test = cubic1.ptAtT(t12);
+ test = c1.ptAtT(t12);
t12 -= t1[1].approximatelyEqual(test) ? -t1Step : t1Step;
t1Step /= 2;
}
while (!approximately_zero(t2Step)) {
- test = cubic2.ptAtT(t20);
+ test = c2.ptAtT(t20);
t20 += t2[1].approximatelyEqual(test) ? -t2Step : t2Step;
t2Step /= 2;
}
t2Step = 0.1;
while (!approximately_zero(t2Step)) {
- test = cubic2.ptAtT(t22);
+ test = c2.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.ptAtT(t10);
- SkDPoint p1Seed = cubic1.ptAtT(t1Seed);
- SkDPoint p12 = cubic1.ptAtT(t12);
+ SkDPoint p10 = c1.ptAtT(t10);
+ SkDPoint p1Seed = c1.ptAtT(t1Seed);
+ SkDPoint p12 = c1.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.ptAtT(t20);
- SkDPoint p2Seed = cubic2.ptAtT(t2Seed);
- SkDPoint p22 = cubic2.ptAtT(t22);
+ SkDPoint p20 = c2.ptAtT(t20);
+ SkDPoint p2Seed = c2.ptAtT(t2Seed);
+ SkDPoint p22 = c2.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
@@ -614,7 +626,7 @@ static void CubicIntersection_IntersectionFinder() {
intersectionFinder(0, 1, 0.865213351, 0.865208087, t1Step, t2Step);
}
-static const SkDCubic selfSet[] = {
+static const CubicPts 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}}},
@@ -628,10 +640,10 @@ static const SkDCubic selfSet[] = {
int selfSetCount = (int) SK_ARRAY_COUNT(selfSet);
static void selfOneOff(skiatest::Reporter* reporter, int index) {
- const SkDCubic& cubic = selfSet[index];
+ const CubicPts& cubic = selfSet[index];
SkPoint c[4];
for (int i = 0; i < 4; ++i) {
- c[i] = cubic[i].asSkPoint();
+ c[i] = cubic.fPts[i].asSkPoint();
}
SkScalar loopT;
SkScalar d[3];
@@ -662,7 +674,7 @@ static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) {
}
}
-static const SkDCubic coinSet[] = {
+static const CubicPts coinSet[] = {
{{{72.350448608398438, 27.966041564941406}, {72.58441162109375, 27.861515045166016},
{72.818222045898437, 27.756658554077148}, {73.394996643066406, 27.49799919128418}}},
{{{73.394996643066406, 27.49799919128418}, {72.818222045898437, 27.756658554077148},
@@ -684,8 +696,8 @@ static const SkDCubic coinSet[] = {
static int coinSetCount = (int) SK_ARRAY_COUNT(coinSet);
static void coinOneOff(skiatest::Reporter* reporter, int index) {
- const SkDCubic& cubic1 = coinSet[index];
- const SkDCubic& cubic2 = coinSet[index + 1];
+ const CubicPts& cubic1 = coinSet[index];
+ const CubicPts& cubic2 = coinSet[index + 1];
oneOff(reporter, cubic1, cubic2, true);
}
diff --git a/tests/PathOpsCubicIntersectionTestData.cpp b/tests/PathOpsCubicIntersectionTestData.cpp
index 7f725ef9fd..58dbfde3d1 100644
--- a/tests/PathOpsCubicIntersectionTestData.cpp
+++ b/tests/PathOpsCubicIntersectionTestData.cpp
@@ -14,7 +14,7 @@ static const double G = FLT_EPSILON / 3;
static const double N = -FLT_EPSILON / 2;
static const double M = -FLT_EPSILON / 3;
-const SkDCubic pointDegenerates[] = {
+const CubicPts pointDegenerates[] = {
{{{0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{{{1, 1}, {1, 1}, {1, 1}, {1, 1}}},
{{{1 + FLT_EPSILON_HALF, 1}, {1, 1 + FLT_EPSILON_HALF}, {1, 1}, {1, 1}}},
@@ -45,7 +45,7 @@ const SkDCubic pointDegenerates[] = {
const size_t pointDegenerates_count = SK_ARRAY_COUNT(pointDegenerates);
-const SkDCubic notPointDegenerates[] = {
+const CubicPts notPointDegenerates[] = {
{{{1 + FLT_EPSILON * 8, 1}, {1, FLT_EPSILON * 8}, {1, 1}, {1, 1}}},
{{{1 + FLT_EPSILON * 8, 1}, {1 - FLT_EPSILON * 8, 1}, {1, 1}, {1, 1}}}
};
@@ -54,7 +54,7 @@ const size_t notPointDegenerates_count =
SK_ARRAY_COUNT(notPointDegenerates);
// from http://www.truetex.com/bezint.htm
-const SkDCubic tests[][2] = {
+const CubicPts tests[][2] = {
{ // intersects in one place (data gives bezier clip fits
{{{0, 45},
{6.0094158284751593, 51.610357411322688},
@@ -109,7 +109,7 @@ const SkDCubic tests[][2] = {
const size_t tests_count = SK_ARRAY_COUNT(tests);
-const SkDCubic lines[] = {
+const CubicPts lines[] = {
{{{0, 0}, {0, 0}, {0, 0}, {1, 0}}}, // 0: horizontal
{{{1, 0}, {0, 0}, {0, 0}, {0, 0}}},
{{{1, 0}, {2, 0}, {3, 0}, {4, 0}}},
@@ -145,7 +145,7 @@ const SkDCubic lines[] = {
const size_t lines_count = SK_ARRAY_COUNT(lines);
// 'not a line' tries to fool the line detection code
-const SkDCubic notLines[] = {
+const CubicPts notLines[] = {
{{{0, 0}, {0, 0}, {0, 1}, {1, 0}}},
{{{0, 0}, {0, 1}, {0, 0}, {1, 0}}},
{{{0, 0}, {0, 1}, {1, 0}, {0, 0}}},
@@ -159,7 +159,7 @@ const size_t notLines_count = SK_ARRAY_COUNT(notLines);
static const double E = FLT_EPSILON * 8;
static const double F = FLT_EPSILON * 8;
-const SkDCubic modEpsilonLines[] = {
+const CubicPts modEpsilonLines[] = {
{{{0, E}, {0, 0}, {0, 0}, {1, 0}}}, // horizontal
{{{0, 0}, {0, E}, {1, 0}, {0, 0}}},
{{{0, 0}, {1, 0}, {0, E}, {0, 0}}},
@@ -202,7 +202,7 @@ const SkDCubic modEpsilonLines[] = {
const size_t modEpsilonLines_count = SK_ARRAY_COUNT(modEpsilonLines);
-const SkDCubic lessEpsilonLines[] = {
+const CubicPts lessEpsilonLines[] = {
{{{0, D}, {0, 0}, {0, 0}, {1, 0}}}, // horizontal
{{{1, 0}, {0, 0}, {0, 0}, {0, D}}},
{{{1, D}, {2, 0}, {3, 0}, {4, 0}}},
@@ -238,7 +238,7 @@ const SkDCubic lessEpsilonLines[] = {
const size_t lessEpsilonLines_count = SK_ARRAY_COUNT(lessEpsilonLines);
-const SkDCubic negEpsilonLines[] = {
+const CubicPts negEpsilonLines[] = {
{{{0, N}, {0, 0}, {0, 0}, {1, 0}}}, // horizontal
{{{1, 0}, {0, 0}, {0, 0}, {0, N}}},
{{{1, N}, {2, 0}, {3, 0}, {4, 0}}},
diff --git a/tests/PathOpsCubicIntersectionTestData.h b/tests/PathOpsCubicIntersectionTestData.h
index e37d5716d3..4c9894c410 100644
--- a/tests/PathOpsCubicIntersectionTestData.h
+++ b/tests/PathOpsCubicIntersectionTestData.h
@@ -4,18 +4,18 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "SkPathOpsCubic.h"
+#include "PathOpsTestCommon.h"
-extern const SkDCubic pointDegenerates[];
-extern const SkDCubic notPointDegenerates[];
-extern const SkDCubic tests[][2];
-extern SkDCubic hexTests[][2];
+extern const CubicPts pointDegenerates[];
+extern const CubicPts notPointDegenerates[];
+extern const CubicPts tests[][2];
+extern CubicPts hexTests[][2];
-extern const SkDCubic lines[];
-extern const SkDCubic notLines[];
-extern const SkDCubic modEpsilonLines[];
-extern const SkDCubic lessEpsilonLines[];
-extern const SkDCubic negEpsilonLines[];
+extern const CubicPts lines[];
+extern const CubicPts notLines[];
+extern const CubicPts modEpsilonLines[];
+extern const CubicPts lessEpsilonLines[];
+extern const CubicPts negEpsilonLines[];
extern const size_t pointDegenerates_count;
extern const size_t notPointDegenerates_count;
diff --git a/tests/PathOpsCubicLineIntersectionIdeas.cpp b/tests/PathOpsCubicLineIntersectionIdeas.cpp
index b23dd0ceaf..15554751da 100644
--- a/tests/PathOpsCubicLineIntersectionIdeas.cpp
+++ b/tests/PathOpsCubicLineIntersectionIdeas.cpp
@@ -16,7 +16,7 @@
static bool gPathOpsCubicLineIntersectionIdeasVerbose = false;
static struct CubicLineFailures {
- SkDCubic c;
+ CubicPts c;
double t;
SkDPoint p;
} cubicLineFailures[] = {
@@ -145,13 +145,15 @@ DEF_TEST(PathOpsCubicLineRoots, reporter) {
double largestR2 = 0;
for (int index = 0; index < 1000000000; ++index) {
SkDPoint origin = {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)};
- SkDCubic cubic = {{origin,
+ CubicPts cuPts = {{origin,
{ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
{ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)},
{ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)}
}};
// construct a line at a known intersection
double t = ran.nextRangeF(0, 1);
+ SkDCubic cubic;
+ cubic.debugSet(cuPts.fPts);
SkDPoint pt = cubic.ptAtT(t);
// skip answers with no intersections (although note the bug!) or two, or more
// see if the line / cubic has a fun range of roots
@@ -248,7 +250,9 @@ DEF_TEST(PathOpsCubicLineRoots, reporter) {
}
static double testOneFailure(const CubicLineFailures& failure) {
- const SkDCubic& cubic = failure.c;
+ const CubicPts& c = failure.c;
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
const SkDPoint& pt = failure.p;
double A, B, C, D;
SkDCubic::Coefficients(&cubic[0].fY, &A, &B, &C, &D);
diff --git a/tests/PathOpsCubicLineIntersectionTest.cpp b/tests/PathOpsCubicLineIntersectionTest.cpp
index a2b870d000..a6ae5e6441 100644
--- a/tests/PathOpsCubicLineIntersectionTest.cpp
+++ b/tests/PathOpsCubicLineIntersectionTest.cpp
@@ -12,7 +12,7 @@
#include "Test.h"
struct lineCubic {
- SkDCubic cubic;
+ CubicPts cubic;
SkDLine line;
};
@@ -25,7 +25,9 @@ static lineCubic failLineCubicTests[] = {
static const size_t failLineCubicTests_count = SK_ARRAY_COUNT(failLineCubicTests);
static void testFail(skiatest::Reporter* reporter, int iIndex) {
- const SkDCubic& cubic = failLineCubicTests[iIndex].cubic;
+ const CubicPts& cuPts = failLineCubicTests[iIndex].cubic;
+ SkDCubic cubic;
+ cubic.debugSet(cuPts.fPts);
SkASSERT(ValidCubic(cubic));
const SkDLine& line = failLineCubicTests[iIndex].line;
SkASSERT(ValidLine(line));
@@ -123,7 +125,9 @@ static int doIntersect(SkIntersections& intersections, const SkDCubic& cubic, co
}
static void testOne(skiatest::Reporter* reporter, int iIndex) {
- const SkDCubic& cubic = lineCubicTests[iIndex].cubic;
+ const CubicPts& cuPts = lineCubicTests[iIndex].cubic;
+ SkDCubic cubic;
+ cubic.debugSet(cuPts.fPts);
SkASSERT(ValidCubic(cubic));
const SkDLine& line = lineCubicTests[iIndex].line;
SkASSERT(ValidLine(line));
@@ -188,7 +192,9 @@ DEF_TEST(PathOpsCubicLineIntersection, reporter) {
DEF_TEST(PathOpsCubicLineIntersectionOneOff, reporter) {
int iIndex = 0;
testOne(reporter, iIndex);
- const SkDCubic& cubic = lineCubicTests[iIndex].cubic;
+ const CubicPts& cuPts = lineCubicTests[iIndex].cubic;
+ SkDCubic cubic;
+ cubic.debugSet(cuPts.fPts);
const SkDLine& line = lineCubicTests[iIndex].line;
SkIntersections i;
i.intersect(cubic, line);
diff --git a/tests/PathOpsCubicQuadIntersectionTest.cpp b/tests/PathOpsCubicQuadIntersectionTest.cpp
index 98665af517..87c7e13d8a 100644
--- a/tests/PathOpsCubicQuadIntersectionTest.cpp
+++ b/tests/PathOpsCubicQuadIntersectionTest.cpp
@@ -13,8 +13,8 @@
#include "Test.h"
static struct quadCubic {
- SkDCubic cubic;
- SkDQuad quad;
+ CubicPts cubic;
+ QuadPts quad;
} quadCubicTests[] = {
{{{{945.08099365234375, 747.1619873046875}, {982.5679931640625, 747.1619873046875}, {1013.6290283203125, 719.656005859375}, {1019.1910400390625, 683.72601318359375}}},
{{{945, 747}, {976.0660400390625, 747}, {998.03302001953125, 725.03302001953125}}}},
@@ -53,9 +53,13 @@ static const int quadCubicTests_count = (int) SK_ARRAY_COUNT(quadCubicTests);
static void cubicQuadIntersection(skiatest::Reporter* reporter, int index) {
int iIndex = static_cast<int>(index);
- const SkDCubic& cubic = quadCubicTests[index].cubic;
+ const CubicPts& c = quadCubicTests[index].cubic;
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
- const SkDQuad& quad = quadCubicTests[index].quad;
+ const QuadPts& q = quadCubicTests[index].quad;
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
SkReduceOrder reduce1;
SkReduceOrder reduce2;
diff --git a/tests/PathOpsCubicReduceOrderTest.cpp b/tests/PathOpsCubicReduceOrderTest.cpp
index 6b5cd9bde1..89a263cce3 100644
--- a/tests/PathOpsCubicReduceOrderTest.cpp
+++ b/tests/PathOpsCubicReduceOrderTest.cpp
@@ -105,7 +105,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
? firstTestIndex : SK_MaxS32;
#endif
for (index = firstPointDegeneratesTest; index < pointDegenerates_count; ++index) {
- const SkDCubic& cubic = pointDegenerates[index];
+ const CubicPts& c = pointDegenerates[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
if (order != 1) {
@@ -114,7 +116,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstNotPointDegeneratesTest; index < notPointDegenerates_count; ++index) {
- const SkDCubic& cubic = notPointDegenerates[index];
+ const CubicPts& c = notPointDegenerates[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
if (order == 1) {
@@ -124,7 +128,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstLinesTest; index < lines_count; ++index) {
- const SkDCubic& cubic = lines[index];
+ const CubicPts& c = lines[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
if (order != 2) {
@@ -133,7 +139,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstNotLinesTest; index < notLines_count; ++index) {
- const SkDCubic& cubic = notLines[index];
+ const CubicPts& c = notLines[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
if (order == 2) {
@@ -142,7 +150,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstModEpsilonTest; index < modEpsilonLines_count; ++index) {
- const SkDCubic& cubic = modEpsilonLines[index];
+ const CubicPts& c = modEpsilonLines[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
if (order == 2) {
@@ -151,7 +161,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstLessEpsilonTest; index < lessEpsilonLines_count; ++index) {
- const SkDCubic& cubic = lessEpsilonLines[index];
+ const CubicPts& c = lessEpsilonLines[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
if (order != 2) {
@@ -161,7 +173,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstNegEpsilonTest; index < negEpsilonLines_count; ++index) {
- const SkDCubic& cubic = negEpsilonLines[index];
+ const CubicPts& c = negEpsilonLines[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
if (order != 2) {
@@ -170,7 +184,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstQuadraticPointTest; index < quadraticPoints_count; ++index) {
- const SkDQuad& quad = quadraticPoints[index];
+ const QuadPts& q = quadraticPoints[index];
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
SkDCubic cubic = quad.debugToCubic();
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
@@ -180,7 +196,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index) {
- const SkDQuad& quad = quadraticLines[index];
+ const QuadPts& q = quadraticLines[index];
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
SkDCubic cubic = quad.debugToCubic();
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
@@ -190,7 +208,9 @@ DEF_TEST(PathOpsReduceOrderCubic, reporter) {
}
}
for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_count; ++index) {
- const SkDQuad& quad = quadraticModEpsilonLines[index];
+ const QuadPts& q = quadraticModEpsilonLines[index];
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
SkDCubic cubic = quad.debugToCubic();
order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics);
diff --git a/tests/PathOpsDCubicTest.cpp b/tests/PathOpsDCubicTest.cpp
index 4b5e7b4b67..b8c08dfd16 100644
--- a/tests/PathOpsDCubicTest.cpp
+++ b/tests/PathOpsDCubicTest.cpp
@@ -8,7 +8,7 @@
#include "SkPathOpsCubic.h"
#include "Test.h"
-static const SkDCubic hullTests[] = {
+static const CubicPts hullTests[] = {
{{{2.6250000819563866, 2.3750000223517418}, {2.833333432674408, 2.3333333432674408}, {3.1111112236976624, 2.3333333134651184}, {3.4074075222015381, 2.3333332538604736}}},
};
@@ -16,7 +16,9 @@ static const size_t hullTests_count = SK_ARRAY_COUNT(hullTests);
DEF_TEST(PathOpsCubicHull, reporter) {
for (size_t index = 0; index < hullTests_count; ++index) {
- const SkDCubic& cubic = hullTests[index];
+ const CubicPts& c = hullTests[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
char order[4];
cubic.convexHull(order);
}
diff --git a/tests/PathOpsDRectTest.cpp b/tests/PathOpsDRectTest.cpp
index 70d39d15c0..fa52e780fa 100644
--- a/tests/PathOpsDRectTest.cpp
+++ b/tests/PathOpsDRectTest.cpp
@@ -11,7 +11,7 @@
#include "SkPathOpsRect.h"
#include "Test.h"
-static const SkDQuad quadTests[] = {
+static const QuadPts quadTests[] = {
{{{1, 1}, {2, 1}, {0, 2}}},
{{{0, 0}, {1, 1}, {3, 1}}},
{{{2, 0}, {1, 1}, {2, 2}}},
@@ -19,7 +19,7 @@ static const SkDQuad quadTests[] = {
{{{0, 0}, {0, 1}, {1, 1}}},
};
-static const SkDCubic cubicTests[] = {
+static const CubicPts cubicTests[] = {
{{{2, 0}, {3, 1}, {2, 2}, {1, 1}}},
{{{3, 1}, {2, 2}, {1, 1}, {2, 0}}},
{{{3, 0}, {2, 1}, {3, 2}, {1, 1}}},
@@ -45,7 +45,9 @@ DEF_TEST(PathOpsDRect, reporter) {
size_t index;
SkDRect rect, rect2;
for (index = 0; index < quadTests_count; ++index) {
- const SkDQuad& quad = quadTests[index];
+ const QuadPts& q = quadTests[index];
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
setRawBounds(quad, &rect);
rect2.setBounds(quad);
@@ -57,7 +59,9 @@ DEF_TEST(PathOpsDRect, reporter) {
REPORTER_ASSERT(reporter, rect.contains(rightBottom));
}
for (index = 0; index < cubicTests_count; ++index) {
- const SkDCubic& cubic = cubicTests[index];
+ const CubicPts& c = cubicTests[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
setRawBounds(cubic, &rect);
rect2.setBounds(cubic);
diff --git a/tests/PathOpsLineParametetersTest.cpp b/tests/PathOpsLineParametetersTest.cpp
index aab1f7a961..66a4be2a05 100644
--- a/tests/PathOpsLineParametetersTest.cpp
+++ b/tests/PathOpsLineParametetersTest.cpp
@@ -9,7 +9,7 @@
#include "Test.h"
// tests to verify that distance calculations are coded correctly
-static const SkDCubic tests[] = {
+static const CubicPts tests[] = {
{{{0, 0}, {1, 1}, {2, 2}, {0, 3}}},
{{{0, 0}, {1, 1}, {2, 2}, {3, 0}}},
{{{0, 0}, {5, 0}, {-2, 4}, {3, 4}}},
@@ -40,7 +40,9 @@ static const size_t tests_count = SK_ARRAY_COUNT(tests);
DEF_TEST(PathOpsLineParameters, reporter) {
for (size_t index = 0; index < tests_count; ++index) {
SkLineParameters lineParameters;
- const SkDCubic& cubic = tests[index];
+ const CubicPts& c = tests[index];
+ SkDCubic cubic;
+ cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
lineParameters.cubicEndPoints(cubic, 0, 3);
double denormalizedDistance[2];
diff --git a/tests/PathOpsOpTest.cpp b/tests/PathOpsOpTest.cpp
index 84f2310f96..fa569a4c69 100644
--- a/tests/PathOpsOpTest.cpp
+++ b/tests/PathOpsOpTest.cpp
@@ -3589,8 +3589,11 @@ static void loop1(skiatest::Reporter* reporter, const char* filename) {
#include "SkPathOpsCubic.h"
static void loop1asQuad(skiatest::Reporter* reporter, const char* filename) {
- SkDCubic c1 = {{{0,1}, {1,5}, {-5.66666651f,3.33333349f}, {8.83333302f,2.33333349f}}};
- SkDCubic c2 = {{{1,5}, {-5.66666651f,3.33333349f}, {8.83333302f,2.33333349f}, {0,1}}};
+ CubicPts cubic1 = {{{0,1}, {1,5}, {-5.66666651f,3.33333349f}, {8.83333302f,2.33333349f}}};
+ CubicPts cubic2 = {{{1,5}, {-5.66666651f,3.33333349f}, {8.83333302f,2.33333349f}, {0,1}}};
+ SkDCubic c1, c2;
+ c1.debugSet(cubic1.fPts);
+ c2.debugSet(cubic2.fPts);
double c1InflectionTs[2], c2InflectionTs[2];
SkDEBUGCODE(int c1InfTCount =) c1.findInflections(c1InflectionTs);
SkASSERT(c1InfTCount == 2);
diff --git a/tests/PathOpsQuadIntersectionTest.cpp b/tests/PathOpsQuadIntersectionTest.cpp
index be3d5a86d1..cb35944918 100644
--- a/tests/PathOpsQuadIntersectionTest.cpp
+++ b/tests/PathOpsQuadIntersectionTest.cpp
@@ -14,9 +14,13 @@
static void standardTestCases(skiatest::Reporter* reporter) {
bool showSkipped = false;
for (size_t index = 0; index < quadraticTests_count; ++index) {
- const SkDQuad& quad1 = quadraticTests[index][0];
+ const QuadPts& q1 = quadraticTests[index][0];
+ SkDQuad quad1;
+ quad1.debugSet(q1.fPts);
SkASSERT(ValidQuad(quad1));
- const SkDQuad& quad2 = quadraticTests[index][1];
+ const QuadPts& q2 = quadraticTests[index][1];
+ SkDQuad quad2;
+ quad2.debugSet(q2.fPts);
SkASSERT(ValidQuad(quad2));
SkReduceOrder reduce1, reduce2;
int order1 = reduce1.reduce(quad1);
@@ -52,7 +56,7 @@ static void standardTestCases(skiatest::Reporter* reporter) {
}
}
-static const SkDQuad testSet[] = {
+static const QuadPts testSet[] = {
{{{-0.001019871095195412636, -0.008523519150912761688}, {-0.005396408028900623322, -0.005396373569965362549}, {-0.02855382487177848816, -0.02855364233255386353}}},
{{{-0.004567248281091451645, -0.01482933573424816132}, {-0.01142475008964538574, -0.01140109263360500336}, {-0.02852955088019371033, -0.02847047336399555206}}},
@@ -326,9 +330,13 @@ static const SkDQuad testSet[] = {
const size_t testSetCount = SK_ARRAY_COUNT(testSet);
static void oneOffTest1(skiatest::Reporter* reporter, size_t outer, size_t inner) {
- const SkDQuad& quad1 = testSet[outer];
+ const QuadPts& q1 = testSet[outer];
+ SkDQuad quad1;
+ quad1.debugSet(q1.fPts);
SkASSERT(ValidQuad(quad1));
- const SkDQuad& quad2 = testSet[inner];
+ const QuadPts& q2 = testSet[inner];
+ SkDQuad quad2;
+ quad2.debugSet(q2.fPts);
SkASSERT(ValidQuad(quad2));
SkIntersections intersections;
intersections.intersect(quad1, quad2);
@@ -358,7 +366,7 @@ static void oneOffTests(skiatest::Reporter* reporter) {
}
}
-static const SkDQuad coincidentTestSet[] = {
+static const QuadPts coincidentTestSet[] = {
{{{4914.9990234375, 1523}, {4942.75146484375, 1523}, {4962.375, 1542.6239013671875}}},
{{{4962.3759765625, 1542.6239013671875}, {4942.75244140625, 1523}, {4915, 1523}}},
#if 0
@@ -374,9 +382,13 @@ static const SkDQuad coincidentTestSet[] = {
static const int coincidentTestSetCount = (int) SK_ARRAY_COUNT(coincidentTestSet);
static void coincidentTestOne(skiatest::Reporter* reporter, int test1, int test2) {
- const SkDQuad& quad1 = coincidentTestSet[test1];
+ const QuadPts& q1 = coincidentTestSet[test1];
+ SkDQuad quad1;
+ quad1.debugSet(q1.fPts);
SkASSERT(ValidQuad(quad1));
- const SkDQuad& quad2 = coincidentTestSet[test2];
+ const QuadPts& q2 = coincidentTestSet[test2];
+ SkDQuad quad2;
+ quad2.debugSet(q2.fPts);
SkASSERT(ValidQuad(quad2));
SkIntersections intersections2;
intersections2.intersect(quad1, quad2);
@@ -398,9 +410,11 @@ static void coincidentTest(skiatest::Reporter* reporter) {
}
static void intersectionFinder(int test1, int test2) {
- const SkDQuad& quad1 = testSet[test1];
- const SkDQuad& quad2 = testSet[test2];
-
+ const QuadPts& q1 = testSet[test1];
+ const QuadPts& q2 = testSet[test2];
+ SkDQuad quad1, quad2;
+ quad1.debugSet(q1.fPts);
+ quad2.debugSet(q2.fPts);
double t1Seed = 0.5;
double t2Seed = 0.8;
double t1Step = 0.1;
@@ -521,8 +535,12 @@ DEF_TEST(PathOpsQuadBinaryProfile, reporter) {
int outer = 0;
int inner = outer + 1;
do {
- const SkDQuad& quad1 = testSet[outer];
- const SkDQuad& quad2 = testSet[inner];
+ const QuadPts& q1 = testSet[outer];
+ SkDQuad quad1;
+ quad1.debugSet(q1.fPts);
+ const QuadPts& q2 = testSet[inner];
+ SkDQuad quad2;
+ quad2.debugSet(q2.fPts);
(void) intersections.intersect(quad1, quad2);
REPORTER_ASSERT(reporter, intersections.used() >= 0); // make sure code isn't tossed
inner += 2;
@@ -531,8 +549,11 @@ DEF_TEST(PathOpsQuadBinaryProfile, reporter) {
}
for (int x = 0; x < 100; ++x) {
for (size_t test = 0; test < quadraticTests_count; ++test) {
- const SkDQuad& quad1 = quadraticTests[test][0];
- const SkDQuad& quad2 = quadraticTests[test][1];
+ const QuadPts& q1 = quadraticTests[test][0];
+ const QuadPts& q2 = quadraticTests[test][1];
+ SkDQuad quad1, quad2;
+ quad1.debugSet(q1.fPts);
+ quad2.debugSet(q2.fPts);
(void) intersections.intersect(quad1, quad2);
REPORTER_ASSERT(reporter, intersections.used() >= 0); // make sure code isn't tossed
}
diff --git a/tests/PathOpsQuadIntersectionTestData.cpp b/tests/PathOpsQuadIntersectionTestData.cpp
index f51f9518bd..537b5099d9 100644
--- a/tests/PathOpsQuadIntersectionTestData.cpp
+++ b/tests/PathOpsQuadIntersectionTestData.cpp
@@ -7,7 +7,7 @@
#include "PathOpsQuadIntersectionTestData.h"
-const SkDQuad quadraticPoints[] = {
+const QuadPts quadraticPoints[] = {
{{{0, 0}, {1, 0}, {0, 0}}},
{{{0, 0}, {0, 1}, {0, 0}}},
{{{0, 0}, {1, 1}, {0, 0}}},
@@ -16,7 +16,7 @@ const SkDQuad quadraticPoints[] = {
const size_t quadraticPoints_count = SK_ARRAY_COUNT(quadraticPoints);
-const SkDQuad quadraticLines[] = {
+const QuadPts quadraticLines[] = {
{{{0, 0}, {0, 0}, {1, 0}}},
{{{1, 0}, {0, 0}, {0, 0}}},
{{{1, 0}, {2, 0}, {3, 0}}},
@@ -49,7 +49,7 @@ static const double H = FLT_EPSILON * 32;
static const double J = FLT_EPSILON * 32;
static const double K = FLT_EPSILON * 32; // INVESTIGATE: why are larger multiples necessary?
-const SkDQuad quadraticModEpsilonLines[] = {
+const QuadPts quadraticModEpsilonLines[] = {
{{{0, F}, {0, 0}, {1, 0}}},
{{{0, 0}, {1, 0}, {0, F}}},
{{{1, 0}, {0, F}, {0, 0}}},
@@ -82,7 +82,7 @@ const SkDQuad quadraticModEpsilonLines[] = {
const size_t quadraticModEpsilonLines_count =
SK_ARRAY_COUNT(quadraticModEpsilonLines);
-const SkDQuad quadraticTests[][2] = {
+const QuadPts quadraticTests[][2] = {
{ // one intersection
{{{0, 0},
{0, 1},
diff --git a/tests/PathOpsQuadIntersectionTestData.h b/tests/PathOpsQuadIntersectionTestData.h
index 3090fc96dd..be46a33310 100644
--- a/tests/PathOpsQuadIntersectionTestData.h
+++ b/tests/PathOpsQuadIntersectionTestData.h
@@ -4,12 +4,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "SkPathOpsQuad.h"
+#include "PathOpsTestCommon.h"
-extern const SkDQuad quadraticLines[];
-extern const SkDQuad quadraticPoints[];
-extern const SkDQuad quadraticModEpsilonLines[];
-extern const SkDQuad quadraticTests[][2];
+extern const QuadPts quadraticLines[];
+extern const QuadPts quadraticPoints[];
+extern const QuadPts quadraticModEpsilonLines[];
+extern const QuadPts quadraticTests[][2];
extern const size_t quadraticLines_count;
extern const size_t quadraticPoints_count;
diff --git a/tests/PathOpsQuadLineIntersectionTest.cpp b/tests/PathOpsQuadLineIntersectionTest.cpp
index 6a9e497b91..f24b2e4d7a 100644
--- a/tests/PathOpsQuadLineIntersectionTest.cpp
+++ b/tests/PathOpsQuadLineIntersectionTest.cpp
@@ -13,7 +13,7 @@
#include "Test.h"
static struct lineQuad {
- SkDQuad quad;
+ QuadPts quad;
SkDLine line;
int result;
SkDPoint expected[2];
@@ -56,7 +56,7 @@ static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, cons
}
static struct oneLineQuad {
- SkDQuad quad;
+ QuadPts quad;
SkDLine line;
} oneOffs[] = {
{{{{97.9337616,100}, {88,112.94265}, {88,130}}},
@@ -79,7 +79,9 @@ static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs);
static void testOneOffs(skiatest::Reporter* reporter) {
bool flipped = false;
for (size_t index = 0; index < oneOffs_count; ++index) {
- const SkDQuad& quad = oneOffs[index].quad;
+ const QuadPts& q = oneOffs[index].quad;
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
const SkDLine& line = oneOffs[index].line;
SkASSERT(ValidLine(line));
@@ -106,7 +108,9 @@ DEF_TEST(PathOpsQuadLineIntersectionOneOff, reporter) {
DEF_TEST(PathOpsQuadLineIntersection, reporter) {
for (size_t index = 0; index < lineQuadTests_count; ++index) {
int iIndex = static_cast<int>(index);
- const SkDQuad& quad = lineQuadTests[index].quad;
+ const QuadPts& q = lineQuadTests[index].quad;
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
const SkDLine& line = lineQuadTests[index].line;
SkASSERT(ValidLine(line));
diff --git a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
index 7766cfe028..a82ac28fde 100644
--- a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
+++ b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
#include "PathOpsExtendedTest.h"
+#include "PathOpsTestCommon.h"
#include "PathOpsThreadedCommon.h"
#include "SkIntersections.h"
#include "SkPathOpsLine.h"
@@ -79,8 +80,10 @@ static void testQuadLineIntersectMain(PathOpsThreadState* data)
int by = state.fB >> 2;
int cx = state.fC & 0x03;
int cy = state.fC >> 2;
- SkDQuad quad = {{{(double) ax, (double) ay}, {(double) bx, (double) by},
+ QuadPts q = {{{(double) ax, (double) ay}, {(double) bx, (double) by},
{(double) cx, (double) cy}}};
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkReduceOrder reducer;
int order = reducer.reduce(quad);
if (order < 3) {
diff --git a/tests/PathOpsQuadReduceOrderTest.cpp b/tests/PathOpsQuadReduceOrderTest.cpp
index dd2c493f78..4f62026fa7 100644
--- a/tests/PathOpsQuadReduceOrderTest.cpp
+++ b/tests/PathOpsQuadReduceOrderTest.cpp
@@ -10,7 +10,7 @@
#include "SkReduceOrder.h"
#include "Test.h"
-static const SkDQuad testSet[] = {
+static const QuadPts testSet[] = {
{{{1, 1}, {2, 2}, {1, 1.000003}}},
{{{1, 0}, {2, 6}, {3, 0}}}
};
@@ -19,7 +19,9 @@ static const size_t testSetCount = SK_ARRAY_COUNT(testSet);
static void oneOffTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < testSetCount; ++index) {
- const SkDQuad& quad = testSet[index];
+ const QuadPts& q = testSet[index];
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
SkReduceOrder reducer;
SkDEBUGCODE(int result = ) reducer.reduce(quad);
SkASSERT(result == 3);
@@ -47,14 +49,18 @@ static void standardTestCases(skiatest::Reporter* reporter) {
: SK_MaxS32;
for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index) {
- const SkDQuad& quad = quadraticLines[index];
+ const QuadPts& q = quadraticLines[index];
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
order = reducer.reduce(quad);
if (order != 2) {
SkDebugf("[%d] line quad order=%d\n", (int) index, order);
}
}
for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_count; ++index) {
- const SkDQuad& quad = quadraticModEpsilonLines[index];
+ const QuadPts& q = quadraticModEpsilonLines[index];
+ SkDQuad quad;
+ quad.debugSet(q.fPts);
order = reducer.reduce(quad);
if (order != 2 && order != 3) { // FIXME: data probably is not good
SkDebugf("[%d] line mod quad order=%d\n", (int) index, order);
diff --git a/tests/PathOpsTestCommon.h b/tests/PathOpsTestCommon.h
index c5ebbd1027..ba64d931ad 100644
--- a/tests/PathOpsTestCommon.h
+++ b/tests/PathOpsTestCommon.h
@@ -12,6 +12,21 @@
struct SkPathOpsBounds;
+struct QuadPts {
+ static const int kPointCount = 3;
+ SkDPoint fPts[kPointCount];
+};
+
+struct ConicPts {
+ QuadPts fPts;
+ SkScalar fWeight;
+};
+
+struct CubicPts {
+ static const int kPointCount = 4;
+ SkDPoint fPts[kPointCount];
+};
+
void CubicPathToQuads(const SkPath& cubicPath, SkPath* quadPath);
void CubicPathToSimple(const SkPath& cubicPath, SkPath* simplePath);
void CubicToQuads(const SkDCubic& cubic, double precision, SkTArray<SkDQuad, true>& quads);
diff --git a/tests/PathOpsThreeWayTest.cpp b/tests/PathOpsThreeWayTest.cpp
index 6a93bfbc59..b86ff65c8b 100644
--- a/tests/PathOpsThreeWayTest.cpp
+++ b/tests/PathOpsThreeWayTest.cpp
@@ -4,6 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "PathOpsTestCommon.h"
#include "SkIntersections.h"
#include "SkTDArray.h"
#include "Test.h"
@@ -12,7 +13,7 @@
struct Curve {
int ptCount;
- SkDCubic curve; // largest can hold lines / quads/ cubics
+ CubicPts curve; // largest can hold lines / quads/ cubics
};
static const Curve testSet0[] = { // extracted from skpClip2
@@ -49,16 +50,19 @@ static void testSetTest(skiatest::Reporter* reporter, int index) {
const Curve& iTest = testSet.tests[inner];
SkIntersections* i = combos.append();
sk_bzero(i, sizeof(SkIntersections));
- SkDLine oLine = {{ oTest.curve[0], oTest.curve[1] }};
- SkDLine iLine = {{ iTest.curve[0], iTest.curve[1] }};
+ SkDLine oLine = {{ oTest.curve.fPts[0], oTest.curve.fPts[1] }};
+ SkDLine iLine = {{ iTest.curve.fPts[0], iTest.curve.fPts[1] }};
+ SkDCubic iCurve, oCurve;
+ iCurve.debugSet(iTest.curve.fPts);
+ oCurve.debugSet(oTest.curve.fPts);
if (oTest.ptCount == 1 && iTest.ptCount == 1) {
i->intersect(oLine, iLine);
} else if (oTest.ptCount == 1 && iTest.ptCount == 4) {
- i->intersect(iTest.curve, oLine);
+ i->intersect(iCurve, oLine);
} else if (oTest.ptCount == 4 && iTest.ptCount == 1) {
- i->intersect(oTest.curve, iLine);
+ i->intersect(oCurve, iLine);
} else if (oTest.ptCount == 4 && iTest.ptCount == 4) {
- i->intersect(oTest.curve, iTest.curve);
+ i->intersect(oCurve, iCurve);
} else {
SkASSERT(0);
}
diff --git a/tests/StrokerTest.cpp b/tests/StrokerTest.cpp
index 68792d9d47..7b9a3400fd 100755
--- a/tests/StrokerTest.cpp
+++ b/tests/StrokerTest.cpp
@@ -8,6 +8,7 @@
#include "PathOpsCubicIntersectionTestData.h"
#include "PathOpsQuadIntersectionTestData.h"
#include "SkCommonFlags.h"
+#include "SkPathOpsCubic.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkRandom.h"
@@ -49,10 +50,12 @@ static void quadTest(const SkPoint c[3]) {
pathTest(path);
}
-static void cubicSetTest(const SkDCubic* dCubic, size_t count) {
+static void cubicSetTest(const CubicPts* dCubic, size_t count) {
skiatest::Timer timer;
for (size_t index = 0; index < count; ++index) {
- const SkDCubic& d = dCubic[index];
+ const CubicPts& dPts = dCubic[index];
+ SkDCubic d;
+ d.debugSet(dPts.fPts);
SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, (float) d[1].fY},
{(float) d[2].fX, (float) d[2].fY}, {(float) d[3].fX, (float) d[3].fY} };
cubicTest(c);
@@ -62,11 +65,13 @@ static void cubicSetTest(const SkDCubic* dCubic, size_t count) {
}
}
-static void cubicPairSetTest(const SkDCubic dCubic[][2], size_t count) {
+static void cubicPairSetTest(const CubicPts dCubic[][2], size_t count) {
skiatest::Timer timer;
for (size_t index = 0; index < count; ++index) {
for (int pair = 0; pair < 2; ++pair) {
- const SkDCubic& d = dCubic[index][pair];
+ const CubicPts& dPts = dCubic[index][pair];
+ SkDCubic d;
+ d.debugSet(dPts.fPts);
SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, (float) d[1].fY},
{(float) d[2].fX, (float) d[2].fY}, {(float) d[3].fX, (float) d[3].fY} };
cubicTest(c);
@@ -77,10 +82,12 @@ static void cubicPairSetTest(const SkDCubic dCubic[][2], size_t count) {
}
}
-static void quadSetTest(const SkDQuad* dQuad, size_t count) {
+static void quadSetTest(const QuadPts* dQuad, size_t count) {
skiatest::Timer timer;
for (size_t index = 0; index < count; ++index) {
- const SkDQuad& d = dQuad[index];
+ const QuadPts& dPts = dQuad[index];
+ SkDQuad d;
+ d.debugSet(dPts.fPts);
SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, (float) d[1].fY},
{(float) d[2].fX, (float) d[2].fY} };
quadTest(c);
@@ -90,11 +97,13 @@ static void quadSetTest(const SkDQuad* dQuad, size_t count) {
}
}
-static void quadPairSetTest(const SkDQuad dQuad[][2], size_t count) {
+static void quadPairSetTest(const QuadPts dQuad[][2], size_t count) {
skiatest::Timer timer;
for (size_t index = 0; index < count; ++index) {
for (int pair = 0; pair < 2; ++pair) {
- const SkDQuad& d = dQuad[index][pair];
+ const QuadPts& dPts = dQuad[index][pair];
+ SkDQuad d;
+ d.debugSet(dPts.fPts);
SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, (float) d[1].fY},
{(float) d[2].fX, (float) d[2].fY} };
quadTest(c);