aboutsummaryrefslogtreecommitdiffhomepage
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
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
-rw-r--r--src/pathops/SkAddIntersections.cpp12
-rw-r--r--src/pathops/SkDConicLineIntersection.cpp4
-rw-r--r--src/pathops/SkDCubicLineIntersection.cpp1
-rw-r--r--src/pathops/SkDLineIntersection.cpp2
-rw-r--r--src/pathops/SkIntersections.h6
-rw-r--r--src/pathops/SkOpAngle.cpp2
-rwxr-xr-xsrc/pathops/SkOpCoincidence.cpp35
-rw-r--r--src/pathops/SkOpCoincidence.h6
-rw-r--r--src/pathops/SkOpSegment.cpp11
-rw-r--r--src/pathops/SkPathOpsCommon.cpp4
-rw-r--r--src/pathops/SkPathOpsConic.cpp3
-rw-r--r--src/pathops/SkPathOpsConic.h15
-rw-r--r--src/pathops/SkPathOpsCubic.cpp2
-rw-r--r--src/pathops/SkPathOpsCubic.h14
-rw-r--r--src/pathops/SkPathOpsDebug.cpp28
-rw-r--r--src/pathops/SkPathOpsQuad.h15
-rw-r--r--src/pathops/SkPathOpsRect.h4
-rw-r--r--src/pathops/SkPathOpsTSect.cpp24
-rw-r--r--src/pathops/SkPathOpsTSect.h54
-rw-r--r--src/pathops/SkPathOpsTypes.h4
-rw-r--r--src/pathops/SkPathWriter.cpp11
-rw-r--r--src/pathops/SkPathWriter.h2
-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
48 files changed, 521 insertions, 279 deletions
diff --git a/src/pathops/SkAddIntersections.cpp b/src/pathops/SkAddIntersections.cpp
index b3a82cdeca..17bc9e2ecb 100644
--- a/src/pathops/SkAddIntersections.cpp
+++ b/src/pathops/SkAddIntersections.cpp
@@ -450,8 +450,10 @@ bool AddIntersectTs(SkOpContour* test, SkOpContour* next, SkOpCoincidence* coinc
}
case SkIntersectionHelper::kCubic_Segment: {
swap = true;
- pts = ts.intersect(cubic2.set(wn.pts()),
- conic1.set(wt.pts(), wt.weight()));
+ pts = ts.intersect(cubic2.set(wn.pts()
+ SkDEBUGPARAMS(ts.globalState())),
+ conic1.set(wt.pts(), wt.weight()
+ SkDEBUGPARAMS(ts.globalState())));
debugShowCubicConicIntersection(pts, wn, wt, ts);
break;
}
@@ -479,8 +481,10 @@ bool AddIntersectTs(SkOpContour* test, SkOpContour* next, SkOpCoincidence* coinc
break;
}
case SkIntersectionHelper::kConic_Segment: {
- pts = ts.intersect(cubic1.set(wt.pts()),
- conic2.set(wn.pts(), wn.weight()));
+ pts = ts.intersect(cubic1.set(wt.pts()
+ SkDEBUGPARAMS(ts.globalState())),
+ conic2.set(wn.pts(), wn.weight()
+ SkDEBUGPARAMS(ts.globalState())));
debugShowCubicConicIntersection(pts, wt, wn, ts);
break;
}
diff --git a/src/pathops/SkDConicLineIntersection.cpp b/src/pathops/SkDConicLineIntersection.cpp
index eb32068d0e..102a4c3c90 100644
--- a/src/pathops/SkDConicLineIntersection.cpp
+++ b/src/pathops/SkDConicLineIntersection.cpp
@@ -105,8 +105,8 @@ public:
double conicT = rootVals[index];
double lineT = this->findLineT(conicT);
#ifdef SK_DEBUG
- if (!fIntersections->debugGlobalState()
- || !fIntersections->debugGlobalState()->debugSkipAssert()) {
+ if (!fIntersections->globalState()
+ || !fIntersections->globalState()->debugSkipAssert()) {
SkDEBUGCODE(SkDPoint conicPt = fConic.ptAtT(conicT));
SkDEBUGCODE(SkDPoint linePt = fLine->ptAtT(lineT));
SkASSERT(conicPt.approximatelyDEqual(linePt));
diff --git a/src/pathops/SkDCubicLineIntersection.cpp b/src/pathops/SkDCubicLineIntersection.cpp
index fd060de646..ceedce18e9 100644
--- a/src/pathops/SkDCubicLineIntersection.cpp
+++ b/src/pathops/SkDCubicLineIntersection.cpp
@@ -122,6 +122,7 @@ public:
double adj = fLine[1].fX - fLine[0].fX;
double opp = fLine[1].fY - fLine[0].fY;
SkDCubic c;
+ SkDEBUGCODE(c.fDebugGlobalState = fIntersections->globalState());
for (int n = 0; n < 4; ++n) {
c[n].fX = (fCubic[n].fY - fLine[0].fY) * adj - (fCubic[n].fX - fLine[0].fX) * opp;
}
diff --git a/src/pathops/SkDLineIntersection.cpp b/src/pathops/SkDLineIntersection.cpp
index 71e2a064d5..082e2987b9 100644
--- a/src/pathops/SkDLineIntersection.cpp
+++ b/src/pathops/SkDLineIntersection.cpp
@@ -152,7 +152,7 @@ int SkIntersections::intersect(const SkDLine& a, const SkDLine& b) {
continue;
}
SkASSERT(a[iA] != b[nearer]);
- SkASSERT(iA == (bNearA[nearer] > 0.5));
+ SkOPASSERT(iA == (bNearA[nearer] > 0.5));
insertNear(iA, nearer, a[iA], b[nearer]);
aNearB[iA] = -1;
bNearA[nearer] = -1;
diff --git a/src/pathops/SkIntersections.h b/src/pathops/SkIntersections.h
index abc10e19dd..d5d217cc80 100644
--- a/src/pathops/SkIntersections.h
+++ b/src/pathops/SkIntersections.h
@@ -104,7 +104,7 @@ public:
}
#ifdef SK_DEBUG
- SkOpGlobalState* debugGlobalState() { return fDebugGlobalState; }
+ SkOpGlobalState* globalState() const { return fDebugGlobalState; }
#endif
bool hasT(double t) const {
@@ -308,9 +308,9 @@ private:
void cleanUpParallelLines(bool parallel);
void computePoints(const SkDLine& line, int used);
- SkDPoint fPt[12]; // FIXME: since scans store points as SkPoint, this should also
+ SkDPoint fPt[13]; // FIXME: since scans store points as SkPoint, this should also
SkDPoint fPt2[2]; // used by nearly same to store alternate intersection point
- double fT[2][12];
+ double fT[2][13];
uint16_t fIsCoincident[2]; // bit set for each curve's coincident T
bool fNearlySame[2]; // true if end points nearly match
unsigned char fUsed;
diff --git a/src/pathops/SkOpAngle.cpp b/src/pathops/SkOpAngle.cpp
index 99f93dd544..1223ac106e 100644
--- a/src/pathops/SkOpAngle.cpp
+++ b/src/pathops/SkOpAngle.cpp
@@ -152,7 +152,7 @@ bool SkOpAngle::after(SkOpAngle* test) {
// FIXME : once this is verified to work, remove one opposite angle call
SkDEBUGCODE(bool lrOpposite = lh->oppositePlanes(rh));
bool ltOpposite = lh->oppositePlanes(this);
- SkASSERT(lrOpposite != ltOpposite);
+ SkOPASSERT(lrOpposite != ltOpposite);
return COMPARE_RESULT(8, ltOpposite);
} else if (ltOrder == 1 && trOrder == 0) {
SkASSERT(lrOrder < 0);
diff --git a/src/pathops/SkOpCoincidence.cpp b/src/pathops/SkOpCoincidence.cpp
index aa5f5bfba7..d16f6f8642 100755
--- a/src/pathops/SkOpCoincidence.cpp
+++ b/src/pathops/SkOpCoincidence.cpp
@@ -128,11 +128,12 @@ bool SkCoincidentSpans::contains(const SkOpPtT* s, const SkOpPtT* e) const {
// A coincident span is unordered if the pairs of points in the main and opposite curves'
// t values do not ascend or descend. For instance, if a tightly arced quadratic is
// coincident with another curve, it may intersect it out of order.
-bool SkCoincidentSpans::ordered() const {
+bool SkCoincidentSpans::ordered(bool* result) const {
const SkOpSpanBase* start = this->coinPtTStart()->span();
const SkOpSpanBase* end = this->coinPtTEnd()->span();
const SkOpSpanBase* next = start->upCast()->next();
if (next == end) {
+ *result = true;
return true;
}
bool flipped = this->flipped();
@@ -141,21 +142,24 @@ bool SkCoincidentSpans::ordered() const {
do {
const SkOpPtT* opp = next->contains(oppSeg);
if (!opp) {
- SkASSERT(0); // may assert if coincident span isn't fully processed
- continue;
+ SkOPOBJASSERT(start, 0); // may assert if coincident span isn't fully processed
+ return false;
}
if ((oppLastT > opp->fT) != flipped) {
- return false;
+ *result = false;
+ return true;
}
oppLastT = opp->fT;
if (next == end) {
break;
}
if (!next->upCastable()) {
- return false;
+ *result = false;
+ return true;
}
next = next->upCast()->next();
} while (true);
+ *result = true;
return true;
}
@@ -234,7 +238,7 @@ void SkOpCoincidence::add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* o
coinPtTEnd = coinPtTEnd->span()->ptT();
oppPtTStart = oppPtTStart->span()->ptT();
oppPtTEnd = oppPtTEnd->span()->ptT();
- SkASSERT(coinPtTStart->fT < coinPtTEnd->fT);
+ SkOPASSERT(coinPtTStart->fT < coinPtTEnd->fT);
SkASSERT(oppPtTStart->fT != oppPtTEnd->fT);
SkOPASSERT(!coinPtTStart->deleted());
SkOPASSERT(!coinPtTEnd->deleted());
@@ -754,7 +758,7 @@ bool SkOpCoincidence::addMissing(bool* added DEBUG_COIN_DECLARE_PARAMS()) {
// save head so that walker can iterate over old data unperturbed
// addifmissing adds to head freely then add saved head in the end
const SkOpPtT* ocs = outer->coinPtTStart();
- SkASSERT(!ocs->deleted());
+ FAIL_IF(ocs->deleted());
const SkOpSegment* outerCoin = ocs->segment();
SkASSERT(!outerCoin->done()); // if it's done, should have already been removed from list
const SkOpPtT* oos = outer->oppPtTStart();
@@ -772,9 +776,9 @@ bool SkOpCoincidence::addMissing(bool* added DEBUG_COIN_DECLARE_PARAMS()) {
const SkOpPtT* ics = inner->coinPtTStart();
FAIL_IF(ics->deleted());
const SkOpSegment* innerCoin = ics->segment();
- SkASSERT(!innerCoin->done());
+ FAIL_IF(innerCoin->done());
const SkOpPtT* ios = inner->oppPtTStart();
- SkASSERT(!ios->deleted());
+ FAIL_IF(ios->deleted());
const SkOpSegment* innerOpp = ios->segment();
SkASSERT(!innerOpp->done());
SkOpSegment* innerCoinWritable = const_cast<SkOpSegment*>(innerCoin);
@@ -855,9 +859,11 @@ bool SkOpCoincidence::addOverlap(const SkOpSegment* seg1, const SkOpSegment* seg
}
const SkOpPtT* s2 = overS->find(seg2);
const SkOpPtT* e2 = overE->find(seg2);
+ FAIL_IF(!e2);
if (!s2->starter(e2)->span()->upCast()->windValue()) {
s2 = overS->find(seg2o);
e2 = overE->find(seg2o);
+ FAIL_IF(!s2);
if (!s2->starter(e2)->span()->upCast()->windValue()) {
return true;
}
@@ -956,11 +962,11 @@ void SkOpCoincidence::correctEnds(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
}
// walk span sets in parallel, moving winding from one to the other
-void SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
+bool SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
DEBUG_SET_PHASE();
SkCoincidentSpans* coin = fHead;
if (!coin) {
- return;
+ return true;
}
do {
SkOpSpan* start = coin->coinPtTStartWritable()->span()->upCast();
@@ -1055,6 +1061,7 @@ void SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
#endif
start->setWindValue(windValue);
start->setOppValue(oppValue);
+ FAIL_IF(oWindValue == -1);
oStart->setWindValue(oWindValue);
oStart->setOppValue(oOppValue);
if (!windValue && !oppValue) {
@@ -1076,6 +1083,7 @@ void SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
oStart = oNext->upCast();
} while (true);
} while ((coin = coin->next()));
+ return true;
}
// Please keep this in sync with debugRelease()
@@ -1272,7 +1280,7 @@ bool SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
SkOpSpanBase* startBase = coin->coinPtTStartWritable()->span();
FAIL_IF(!startBase->upCastable());
SkOpSpan* start = startBase->upCast();
- SkASSERT(!start->deleted());
+ FAIL_IF(start->deleted());
SkOpSpanBase* end = coin->coinPtTEndWritable()->span();
SkOPASSERT(!end->deleted());
SkOpSpanBase* oStart = coin->oppPtTStartWritable()->span();
@@ -1291,7 +1299,8 @@ bool SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
const SkOpSegment* oSegment = oStart->segment();
SkOpSpanBase* next = start;
SkOpSpanBase* oNext = oStart;
- bool ordered = coin->ordered();
+ bool ordered;
+ FAIL_IF(!coin->ordered(&ordered));
while ((next = next->upCast()->next()) != end) {
FAIL_IF(!next->upCastable());
SkAssertResult(next->upCast()->insertCoincidence(oSegment, flipped, ordered));
diff --git a/src/pathops/SkOpCoincidence.h b/src/pathops/SkOpCoincidence.h
index e2188bebbd..af84870253 100644
--- a/src/pathops/SkOpCoincidence.h
+++ b/src/pathops/SkOpCoincidence.h
@@ -73,7 +73,7 @@ public:
// to a new span pair
SkOpPtT* oppPtTStartWritable() const { return const_cast<SkOpPtT*>(fOppPtTStart); }
SkOpPtT* oppPtTEndWritable() const { return const_cast<SkOpPtT*>(fOppPtTEnd); }
- bool ordered() const;
+ bool ordered(bool* result) const;
void set(SkCoincidentSpans* next, const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd,
const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd);
@@ -108,7 +108,7 @@ public:
}
void setOppPtTStart(const SkOpPtT* ptT) {
- SkASSERT(ptT == ptT->span()->ptT());
+ SkOPASSERT(ptT == ptT->span()->ptT());
SkOPASSERT(!fOppPtTEnd || ptT->fT != fOppPtTEnd->fT);
SkASSERT(!fOppPtTEnd || fOppPtTEnd->segment() == ptT->segment());
fOppPtTStart = ptT;
@@ -150,7 +150,7 @@ public:
bool addEndMovedSpans(DEBUG_COIN_DECLARE_ONLY_PARAMS());
bool addExpanded(DEBUG_COIN_DECLARE_ONLY_PARAMS());
bool addMissing(bool* added DEBUG_COIN_DECLARE_PARAMS());
- void apply(DEBUG_COIN_DECLARE_ONLY_PARAMS());
+ bool apply(DEBUG_COIN_DECLARE_ONLY_PARAMS());
bool contains(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd,
const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd) const;
void correctEnds(DEBUG_COIN_DECLARE_ONLY_PARAMS());
diff --git a/src/pathops/SkOpSegment.cpp b/src/pathops/SkOpSegment.cpp
index 6012d832bf..439392fc4f 100644
--- a/src/pathops/SkOpSegment.cpp
+++ b/src/pathops/SkOpSegment.cpp
@@ -169,18 +169,18 @@ bool SkOpSegment::addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end,
path->deferredMove(start->ptT());
switch (verb) {
case SkPath::kLine_Verb:
- path->deferredLine(end->ptT());
+ FAIL_IF(!path->deferredLine(end->ptT()));
break;
case SkPath::kQuad_Verb:
- path->quadTo(curvePart.fCurve.fQuad.fPts[1].asSkPoint(), end->ptT());
+ path->quadTo(curvePart.fCurve.fQuad[1].asSkPoint(), end->ptT());
break;
case SkPath::kConic_Verb:
- path->conicTo(curvePart.fCurve.fConic.fPts[1].asSkPoint(), end->ptT(),
+ path->conicTo(curvePart.fCurve.fConic[1].asSkPoint(), end->ptT(),
curvePart.fCurve.fConic.fWeight);
break;
case SkPath::kCubic_Verb:
- path->cubicTo(curvePart.fCurve.fCubic.fPts[1].asSkPoint(),
- curvePart.fCurve.fCubic.fPts[2].asSkPoint(), end->ptT());
+ path->cubicTo(curvePart.fCurve.fCubic[1].asSkPoint(),
+ curvePart.fCurve.fCubic[2].asSkPoint(), end->ptT());
break;
default:
SkASSERT(0);
@@ -225,6 +225,7 @@ bool SkOpSegment::addExpanded(double newT, const SkOpSpanBase* test, bool* start
return true;
}
this->globalState()->resetAllocatedOpSpan();
+ FAIL_IF(!between(0, newT, 1));
SkOpPtT* newPtT = this->addT(newT);
*startOver |= this->globalState()->allocatedOpSpan();
if (!newPtT) {
diff --git a/src/pathops/SkPathOpsCommon.cpp b/src/pathops/SkPathOpsCommon.cpp
index a1cd7bbd63..7387249904 100644
--- a/src/pathops/SkPathOpsCommon.cpp
+++ b/src/pathops/SkPathOpsCommon.cpp
@@ -318,7 +318,9 @@ bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc
do {
SkOpCoincidence* pairs = overlaps.isEmpty() ? coincidence : &overlaps;
// adjust the winding value to account for coincident edges
- pairs->apply(DEBUG_ITER_ONLY_PARAMS(SAFETY_COUNT - safetyHatch));
+ if (!pairs->apply(DEBUG_ITER_ONLY_PARAMS(SAFETY_COUNT - safetyHatch))) {
+ return false;
+ }
// For each coincident pair that overlaps another, when the receivers (the 1st of the pair)
// are different, construct a new pair to resolve their mutual span
if (!pairs->findOverlaps(&overlaps DEBUG_ITER_PARAMS(SAFETY_COUNT - safetyHatch))) {
diff --git a/src/pathops/SkPathOpsConic.cpp b/src/pathops/SkPathOpsConic.cpp
index dd523211de..82f3a7b0cc 100644
--- a/src/pathops/SkPathOpsConic.cpp
+++ b/src/pathops/SkPathOpsConic.cpp
@@ -156,7 +156,8 @@ SkDConic SkDConic::subDivide(double t1, double t2) const {
double bx = 2 * dx - (ax + cx) / 2;
double by = 2 * dy - (ay + cy) / 2;
double bz = 2 * dz - (az + cz) / 2;
- SkDConic dst = {{{{ax / az, ay / az}, {bx / bz, by / bz}, {cx / cz, cy / cz}}},
+ SkDConic dst = {{{{ax / az, ay / az}, {bx / bz, by / bz}, {cx / cz, cy / cz}}
+ SkDEBUGPARAMS(fPts.fDebugGlobalState) },
SkDoubleToScalar(bz / sqrt(az * cz)) };
return dst;
}
diff --git a/src/pathops/SkPathOpsConic.h b/src/pathops/SkPathOpsConic.h
index 4cbe147b49..42362797a2 100644
--- a/src/pathops/SkPathOpsConic.h
+++ b/src/pathops/SkPathOpsConic.h
@@ -31,15 +31,23 @@ struct SkDConic {
fPts.debugInit();
}
+ void debugSet(const SkDPoint* pts, SkScalar weight);
+
SkDConic flip() const {
- SkDConic result = {{{fPts[2], fPts[1], fPts[0]}}, fWeight};
+ SkDConic result = {{{fPts[2], fPts[1], fPts[0]}
+ SkDEBUGPARAMS(fPts.fDebugGlobalState) }, fWeight};
return result;
}
+#ifdef SK_DEBUG
+ SkOpGlobalState* globalState() const { return fPts.globalState(); }
+#endif
+
static bool IsConic() { return true; }
- const SkDConic& set(const SkPoint pts[kPointCount], SkScalar weight) {
- fPts.set(pts);
+ const SkDConic& set(const SkPoint pts[kPointCount], SkScalar weight
+ SkDEBUGPARAMS(SkOpGlobalState* state = nullptr)) {
+ fPts.set(pts SkDEBUGPARAMS(state));
fWeight = weight;
return *this;
}
@@ -117,6 +125,7 @@ struct SkDConic {
void dump() const;
void dumpID(int id) const;
void dumpInner() const;
+
};
diff --git a/src/pathops/SkPathOpsCubic.cpp b/src/pathops/SkPathOpsCubic.cpp
index bdae492de0..eaf9062476 100644
--- a/src/pathops/SkPathOpsCubic.cpp
+++ b/src/pathops/SkPathOpsCubic.cpp
@@ -36,7 +36,7 @@ double SkDCubic::binarySearch(double min, double max, double axisIntercept,
double calcDist = calcPos - axisIntercept;
do {
double priorT = t - step;
- SkASSERT(priorT >= min);
+ SkOPASSERT(priorT >= min);
SkDPoint lessPt = ptAtT(priorT);
if (approximately_equal_half(lessPt.fX, cubicAtT.fX)
&& approximately_equal_half(lessPt.fY, cubicAtT.fY)) {
diff --git a/src/pathops/SkPathOpsCubic.h b/src/pathops/SkPathOpsCubic.h
index 16bca79533..f868fbe2c7 100644
--- a/src/pathops/SkPathOpsCubic.h
+++ b/src/pathops/SkPathOpsCubic.h
@@ -58,6 +58,8 @@ struct SkDCubic {
sk_bzero(fPts, sizeof(fPts));
}
+ void debugSet(const SkDPoint* pts);
+
void dump() const; // callable from the debugger when the implementation code is linked in
void dumpID(int id) const;
void dumpInner() const;
@@ -72,6 +74,11 @@ struct SkDCubic {
}
int findMaxCurvature(double tValues[]) const;
+
+#ifdef SK_DEBUG
+ SkOpGlobalState* globalState() const { return fDebugGlobalState; }
+#endif
+
bool hullIntersects(const SkDCubic& c2, bool* isLinear) const;
bool hullIntersects(const SkDConic& c, bool* isLinear) const;
bool hullIntersects(const SkDQuad& c2, bool* isLinear) const;
@@ -98,11 +105,14 @@ struct SkDCubic {
*/
int verticalIntersect(double xIntercept, double roots[3]) const;
- const SkDCubic& set(const SkPoint pts[kPointCount]) {
+// add debug only global pointer so asserts can be skipped by fuzzers
+ const SkDCubic& set(const SkPoint pts[kPointCount]
+ SkDEBUGPARAMS(SkOpGlobalState* state = nullptr)) {
fPts[0] = pts[0];
fPts[1] = pts[1];
fPts[2] = pts[2];
fPts[3] = pts[3];
+ SkDEBUGCODE(fDebugGlobalState = state);
return *this;
}
@@ -125,8 +135,8 @@ struct SkDCubic {
SkDQuad toQuad() const;
static const int gPrecisionUnit;
-
SkDPoint fPts[kPointCount];
+ SkDEBUGCODE(SkOpGlobalState* fDebugGlobalState);
};
/* Given the set [0, 1, 2, 3], and two of the four members, compute an XOR mask
diff --git a/src/pathops/SkPathOpsDebug.cpp b/src/pathops/SkPathOpsDebug.cpp
index a0fcff58e0..476fafb425 100644
--- a/src/pathops/SkPathOpsDebug.cpp
+++ b/src/pathops/SkPathOpsDebug.cpp
@@ -691,8 +691,8 @@ void SkIntersections::debugResetLoopCount() {
}
#endif
+#include "SkPathOpsConic.h"
#include "SkPathOpsCubic.h"
-#include "SkPathOpsQuad.h"
SkDCubic SkDQuad::debugToCubic() const {
SkDCubic cubic;
@@ -706,6 +706,21 @@ SkDCubic SkDQuad::debugToCubic() const {
return cubic;
}
+void SkDQuad::debugSet(const SkDPoint* pts) {
+ memcpy(fPts, pts, sizeof(fPts));
+ SkDEBUGCODE(fDebugGlobalState = nullptr);
+}
+
+void SkDCubic::debugSet(const SkDPoint* pts) {
+ memcpy(fPts, pts, sizeof(fPts));
+ SkDEBUGCODE(fDebugGlobalState = nullptr);
+}
+
+void SkDConic::debugSet(const SkDPoint* pts, SkScalar weight) {
+ fPts.debugSet(pts);
+ fWeight = weight;
+}
+
void SkDRect::debugInit() {
fLeft = fTop = fRight = fBottom = SK_ScalarNaN;
}
@@ -1595,6 +1610,7 @@ void SkOpCoincidence::debugAddEndMovedSpans(SkPathOpsDebug::GlitchLog* log) cons
// for each coincident pair, match the spans
// if the spans don't match, add the mssing pt to the segment and loop it in the opposite span
void SkOpCoincidence::debugAddExpanded(SkPathOpsDebug::GlitchLog* log) const {
+// DEBUG_SET_PHASE();
const SkCoincidentSpans* coin = this->fHead;
if (!coin) {
return;
@@ -1639,14 +1655,15 @@ void SkOpCoincidence::debugAddExpanded(SkPathOpsDebug::GlitchLog* log) const {
walk = walk->upCast()->next();
} while (!(walkOpp = walk->ptT()->contains(oSeg))
&& walk != coin->coinPtTEnd()->span());
+ FAIL_IF(!walkOpp, coin);
nextT = walk->t();
oNextT = walkOpp->fT;
}
// use t ranges to guess which one is missing
- double startRange = coin->coinPtTEnd()->fT - startPtT->fT;
+ double startRange = nextT - priorT;
FAIL_IF(!startRange, coin);
- double startPart = (test->t() - startPtT->fT) / startRange;
- double oStartRange = coin->oppPtTEnd()->fT - oStartPtT->fT;
+ double startPart = (test->t() - priorT) / startRange;
+ double oStartRange = oNextT - oPriorT;
FAIL_IF(!oStartRange, coin);
double oStartPart = (oTest->t() - oStartPtT->fT) / oStartRange;
FAIL_IF(startPart == oStartPart, coin);
@@ -2029,7 +2046,8 @@ void SkOpCoincidence::debugMark(SkPathOpsDebug::GlitchLog* log) const {
const SkOpSegment* oSegment = oStart->segment();
const SkOpSpanBase* next = start;
const SkOpSpanBase* oNext = oStart;
- bool ordered = coin->ordered();
+ bool ordered;
+ FAIL_IF(!coin->ordered(&ordered), coin);
while ((next = next->upCast()->next()) != end) {
FAIL_IF(!next->upCastable(), coin);
if (next->upCast()->debugInsertCoincidence(log, oSegment, flipped, ordered), false) {
diff --git a/src/pathops/SkPathOpsQuad.h b/src/pathops/SkPathOpsQuad.h
index 32cfe58ecf..34740d6b1d 100644
--- a/src/pathops/SkPathOpsQuad.h
+++ b/src/pathops/SkPathOpsQuad.h
@@ -40,17 +40,21 @@ struct SkDQuad {
sk_bzero(fPts, sizeof(fPts));
}
+ void debugSet(const SkDPoint* pts);
+
SkDQuad flip() const {
- SkDQuad result = {{fPts[2], fPts[1], fPts[0]}};
+ SkDQuad result = {{fPts[2], fPts[1], fPts[0]} SkDEBUGPARAMS(fDebugGlobalState) };
return result;
}
static bool IsConic() { return false; }
- const SkDQuad& set(const SkPoint pts[kPointCount]) {
+ const SkDQuad& set(const SkPoint pts[kPointCount]
+ SkDEBUGPARAMS(SkOpGlobalState* state = nullptr)) {
fPts[0] = pts[0];
fPts[1] = pts[1];
fPts[2] = pts[2];
+ SkDEBUGCODE(fDebugGlobalState = state);
return *this;
}
@@ -63,6 +67,10 @@ struct SkDQuad {
SkDVector dxdyAtT(double t) const;
static int FindExtrema(const double src[], double tValue[1]);
+#ifdef SK_DEBUG
+ SkOpGlobalState* globalState() const { return fDebugGlobalState; }
+#endif
+
/**
* Return the number of valid roots (0 < root < 1) for this cubic intersecting the
* specified horizontal line.
@@ -106,8 +114,7 @@ struct SkDQuad {
void dumpID(int id) const;
void dumpInner() const;
-private:
-// static double Tangent(const double* quadratic, double t); // uncalled
+ SkDEBUGCODE(SkOpGlobalState* fDebugGlobalState);
};
#endif
diff --git a/src/pathops/SkPathOpsRect.h b/src/pathops/SkPathOpsRect.h
index d4e5f5489a..1efbb8c6ea 100644
--- a/src/pathops/SkPathOpsRect.h
+++ b/src/pathops/SkPathOpsRect.h
@@ -64,6 +64,10 @@ struct SkDRect {
}
void setBounds(const SkDQuad& curve, const SkDQuad& sub, double tStart, double tEnd);
+
+ bool valid() const {
+ return fLeft <= fRight && fTop <= fBottom;
+ }
};
#endif
diff --git a/src/pathops/SkPathOpsTSect.cpp b/src/pathops/SkPathOpsTSect.cpp
index 3e7817ca9e..9bff5af4f0 100644
--- a/src/pathops/SkPathOpsTSect.cpp
+++ b/src/pathops/SkPathOpsTSect.cpp
@@ -9,54 +9,54 @@
int SkIntersections::intersect(const SkDQuad& quad1, const SkDQuad& quad2) {
SkTSect<SkDQuad, SkDQuad> sect1(quad1
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
SkTSect<SkDQuad, SkDQuad> sect2(quad2
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
SkTSect<SkDQuad, SkDQuad>::BinarySearch(&sect1, &sect2, this);
return used();
}
int SkIntersections::intersect(const SkDConic& conic, const SkDQuad& quad) {
SkTSect<SkDConic, SkDQuad> sect1(conic
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
SkTSect<SkDQuad, SkDConic> sect2(quad
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
SkTSect<SkDConic, SkDQuad>::BinarySearch(&sect1, &sect2, this);
return used();
}
int SkIntersections::intersect(const SkDConic& conic1, const SkDConic& conic2) {
SkTSect<SkDConic, SkDConic> sect1(conic1
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
SkTSect<SkDConic, SkDConic> sect2(conic2
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
SkTSect<SkDConic, SkDConic>::BinarySearch(&sect1, &sect2, this);
return used();
}
int SkIntersections::intersect(const SkDCubic& cubic, const SkDQuad& quad) {
SkTSect<SkDCubic, SkDQuad> sect1(cubic
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
SkTSect<SkDQuad, SkDCubic> sect2(quad
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
SkTSect<SkDCubic, SkDQuad>::BinarySearch(&sect1, &sect2, this);
return used();
}
int SkIntersections::intersect(const SkDCubic& cubic, const SkDConic& conic) {
SkTSect<SkDCubic, SkDConic> sect1(cubic
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
SkTSect<SkDConic, SkDCubic> sect2(conic
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
SkTSect<SkDCubic, SkDConic>::BinarySearch(&sect1, &sect2, this);
return used();
}
int SkIntersections::intersect(const SkDCubic& cubic1, const SkDCubic& cubic2) {
SkTSect<SkDCubic, SkDCubic> sect1(cubic1
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
SkTSect<SkDCubic, SkDCubic> sect2(cubic2
- SkDEBUGPARAMS(debugGlobalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
+ SkDEBUGPARAMS(globalState()) PATH_OPS_DEBUG_T_SECT_PARAMS(2));
SkTSect<SkDCubic, SkDCubic>::BinarySearch(&sect1, &sect2, this);
return used();
}
diff --git a/src/pathops/SkPathOpsTSect.h b/src/pathops/SkPathOpsTSect.h
index f22322bbe1..51ea44a26c 100644
--- a/src/pathops/SkPathOpsTSect.h
+++ b/src/pathops/SkPathOpsTSect.h
@@ -137,7 +137,7 @@ public:
int hullsIntersect(SkTSpan<OppCurve, TCurve>* span, bool* start, bool* oppStart);
void init(const TCurve& );
- void initBounds(const TCurve& );
+ bool initBounds(const TCurve& );
bool isBounded() const {
return fBounded != nullptr;
@@ -317,7 +317,7 @@ private:
void removeSpans(SkTSpan<TCurve, OppCurve>* span, SkTSect<OppCurve, TCurve>* opp);
SkTSpan<TCurve, OppCurve>* spanAtT(double t, SkTSpan<TCurve, OppCurve>** priorSpan);
SkTSpan<TCurve, OppCurve>* tail();
- void trim(SkTSpan<TCurve, OppCurve>* span, SkTSect<OppCurve, TCurve>* opp);
+ bool trim(SkTSpan<TCurve, OppCurve>* span, SkTSect<OppCurve, TCurve>* opp);
void unlinkSpan(SkTSpan<TCurve, OppCurve>* span);
bool updateBounded(SkTSpan<TCurve, OppCurve>* first, SkTSpan<TCurve, OppCurve>* last,
SkTSpan<OppCurve, TCurve>* oppFirst);
@@ -351,7 +351,7 @@ void SkTCoincident<TCurve, OppCurve>::setPerp(const TCurve& c1, double t,
const SkDPoint& cPt, const OppCurve& c2) {
SkDVector dxdy = c1.dxdyAtT(t);
SkDLine perp = {{ cPt, {cPt.fX + dxdy.fY, cPt.fY - dxdy.fX} }};
- SkIntersections i;
+ SkIntersections i SkDEBUGCODE((c1.globalState()));
int used = i.intersectRay(c2, perp);
// only keep closest
if (used == 0 || used == 3) {
@@ -565,7 +565,7 @@ void SkTSpan<TCurve, OppCurve>::init(const TCurve& c) {
}
template<typename TCurve, typename OppCurve>
-void SkTSpan<TCurve, OppCurve>::initBounds(const TCurve& c) {
+bool SkTSpan<TCurve, OppCurve>::initBounds(const TCurve& c) {
fPart = c.subDivide(fStartT, fEndT);
fBounds.setBounds(fPart);
fCoinStart.init();
@@ -579,6 +579,7 @@ void SkTSpan<TCurve, OppCurve>::initBounds(const TCurve& c) {
SkDebugf(""); // for convenient breakpoints
}
#endif
+ return fBounds.valid();
}
template<typename TCurve, typename OppCurve>
@@ -1206,6 +1207,7 @@ bool SkTSect<TCurve, OppCurve>::extractCoincident(
}
} else {
SkDEBUGCODE(coinStart = first->fStartT);
+ FAIL_IF(!oppFirst);
SkDEBUGCODE(oppStartT = oppMatched ? oppFirst->fStartT : oppFirst->fEndT);
}
// FIXME: incomplete : if we're not at the end, find end of coin
@@ -1286,7 +1288,7 @@ SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::findCoincidentRun(
work->validatePerpT(work->fCoinStart.perpT());
work->validatePerpPt(work->fCoinStart.perpT(), work->fCoinStart.perpPt());
#endif
- SkASSERT(work->hasOppT(work->fCoinStart.perpT()));
+ SkOPASSERT(work->hasOppT(work->fCoinStart.perpT()));
if (!work->fCoinEnd.isMatch()) {
break;
}
@@ -1400,7 +1402,8 @@ template<typename TCurve, typename OppCurve>
int SkTSect<TCurve, OppCurve>::linesIntersect(SkTSpan<TCurve, OppCurve>* span,
SkTSect<OppCurve, TCurve>* opp,
SkTSpan<OppCurve, TCurve>* oppSpan, SkIntersections* i) {
- SkIntersections thisRayI, oppRayI;
+ SkIntersections thisRayI SkDEBUGCODE((span->fDebugGlobalState));
+ SkIntersections oppRayI SkDEBUGCODE((span->fDebugGlobalState));
SkDLine thisLine = {{ span->fPart[0], span->fPart[TCurve::kPointLast] }};
SkDLine oppLine = {{ oppSpan->fPart[0], oppSpan->fPart[OppCurve::kPointLast] }};
int loopCount = 0;
@@ -1810,9 +1813,9 @@ SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::tail() {
/* Each span has a range of opposite spans it intersects. After the span is split in two,
adjust the range to its new size */
template<typename TCurve, typename OppCurve>
-void SkTSect<TCurve, OppCurve>::trim(SkTSpan<TCurve, OppCurve>* span,
+bool SkTSect<TCurve, OppCurve>::trim(SkTSpan<TCurve, OppCurve>* span,
SkTSect<OppCurve, TCurve>* opp) {
- span->initBounds(fCurve);
+ FAIL_IF(!span->initBounds(fCurve));
const SkTSpanBounded<OppCurve, TCurve>* testBounded = span->fBounded;
while (testBounded) {
SkTSpan<OppCurve, TCurve>* test = testBounded->fBounded;
@@ -1826,7 +1829,7 @@ void SkTSect<TCurve, OppCurve>::trim(SkTSpan<TCurve, OppCurve>* span,
if (sects == 2) {
span->initBounds(fCurve);
this->removeAllBut(test, span, opp);
- return;
+ return true;
}
} else {
if (span->removeBounded(test)) {
@@ -1838,6 +1841,7 @@ void SkTSect<TCurve, OppCurve>::trim(SkTSpan<TCurve, OppCurve>* span,
}
testBounded = next;
}
+ return true;
}
template<typename TCurve, typename OppCurve>
@@ -2112,7 +2116,7 @@ void SkTSect<TCurve, OppCurve>::BinarySearch(SkTSect<TCurve, OppCurve>* sect1,
SkDEBUGCODE(sect1->fOppSect = sect2);
SkDEBUGCODE(sect2->fOppSect = sect1);
intersections->reset();
- intersections->setMax(TCurve::kMaxIntersections + 3); // give extra for slop
+ intersections->setMax(TCurve::kMaxIntersections + 4); // give extra for slop
SkTSpan<TCurve, OppCurve>* span1 = sect1->fHead;
SkTSpan<OppCurve, TCurve>* span2 = sect2->fHead;
int oppSect, sect = sect1->intersects(span1, sect2, span2, &oppSect);
@@ -2151,8 +2155,14 @@ void SkTSect<TCurve, OppCurve>::BinarySearch(SkTSect<TCurve, OppCurve>* sect1,
if (!half1->split(largest1, &sect1->fHeap)) {
break;
}
- sect1->trim(largest1, sect2);
- sect1->trim(half1, sect2);
+ if (!sect1->trim(largest1, sect2)) {
+ SkOPOBJASSERT(intersections, 0);
+ return;
+ }
+ if (!sect1->trim(half1, sect2)) {
+ SkOPOBJASSERT(intersections, 0);
+ return;
+ }
} else {
if (largest2->fCollapsed) {
break;
@@ -2163,8 +2173,14 @@ void SkTSect<TCurve, OppCurve>::BinarySearch(SkTSect<TCurve, OppCurve>* sect1,
if (!half2->split(largest2, &sect2->fHeap)) {
break;
}
- sect2->trim(largest2, sect1);
- sect2->trim(half2, sect1);
+ if (!sect2->trim(largest2, sect1)) {
+ SkOPOBJASSERT(intersections, 0);
+ return;
+ }
+ if (!sect2->trim(half2, sect1)) {
+ SkOPOBJASSERT(intersections, 0);
+ return;
+ }
}
sect1->validate();
sect2->validate();
@@ -2250,28 +2266,28 @@ void SkTSect<TCurve, OppCurve>::BinarySearch(SkTSect<TCurve, OppCurve>* sect1,
// if the final iteration contains an end (0 or 1),
if (sect1->fRemovedStartT && !(zeroOneSet & kZeroS1Set)) {
SkTCoincident<TCurve, OppCurve> perp; // intersect perpendicular with opposite curve
- perp.setPerp(sect1->fCurve, 0, sect1->fCurve.fPts[0], sect2->fCurve);
+ perp.setPerp(sect1->fCurve, 0, sect1->fCurve[0], sect2->fCurve);
if (perp.isMatch()) {
intersections->insert(0, perp.perpT(), perp.perpPt());
}
}
if (sect1->fRemovedEndT && !(zeroOneSet & kOneS1Set)) {
SkTCoincident<TCurve, OppCurve> perp;
- perp.setPerp(sect1->fCurve, 1, sect1->fCurve.fPts[TCurve::kPointLast], sect2->fCurve);
+ perp.setPerp(sect1->fCurve, 1, sect1->fCurve[TCurve::kPointLast], sect2->fCurve);
if (perp.isMatch()) {
intersections->insert(1, perp.perpT(), perp.perpPt());
}
}
if (sect2->fRemovedStartT && !(zeroOneSet & kZeroS2Set)) {
SkTCoincident<OppCurve, TCurve> perp;
- perp.setPerp(sect2->fCurve, 0, sect2->fCurve.fPts[0], sect1->fCurve);
+ perp.setPerp(sect2->fCurve, 0, sect2->fCurve[0], sect1->fCurve);
if (perp.isMatch()) {
intersections->insert(perp.perpT(), 0, perp.perpPt());
}
}
if (sect2->fRemovedEndT && !(zeroOneSet & kOneS2Set)) {
SkTCoincident<OppCurve, TCurve> perp;
- perp.setPerp(sect2->fCurve, 1, sect2->fCurve.fPts[OppCurve::kPointLast], sect1->fCurve);
+ perp.setPerp(sect2->fCurve, 1, sect2->fCurve[OppCurve::kPointLast], sect1->fCurve);
if (perp.isMatch()) {
intersections->insert(perp.perpT(), 1, perp.perpPt());
}
@@ -2365,7 +2381,7 @@ void SkTSect<TCurve, OppCurve>::BinarySearch(SkTSect<TCurve, OppCurve>* sect1,
}
intersections->setCoincident(index);
}
- SkASSERT(intersections->used() <= TCurve::kMaxIntersections);
+ SkOPOBJASSERT(intersections, intersections->used() <= TCurve::kMaxIntersections);
}
#endif
diff --git a/src/pathops/SkPathOpsTypes.h b/src/pathops/SkPathOpsTypes.h
index 786eb2288e..e390b4b2b1 100644
--- a/src/pathops/SkPathOpsTypes.h
+++ b/src/pathops/SkPathOpsTypes.h
@@ -221,8 +221,8 @@ private:
#define SkOPASSERT(cond) SkASSERT((this->globalState() && \
this->globalState()->debugSkipAssert()) || (cond))
#endif
-#define SkOPOBJASSERT(obj, cond) SkASSERT((obj->debugGlobalState() && \
- obj->debugGlobalState()->debugSkipAssert()) || (cond))
+#define SkOPOBJASSERT(obj, cond) SkASSERT((obj->globalState() && \
+ obj->globalState()->debugSkipAssert()) || (cond))
#else
#define SkOPASSERT(cond)
#define SkOPOBJASSERT(obj, cond)
diff --git a/src/pathops/SkPathWriter.cpp b/src/pathops/SkPathWriter.cpp
index 1f6dddd137..c94809e8ec 100644
--- a/src/pathops/SkPathWriter.cpp
+++ b/src/pathops/SkPathWriter.cpp
@@ -48,23 +48,26 @@ void SkPathWriter::cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkOpPtT
fCurrent.cubicTo(pt1, pt2, pt3->fPt);
}
-void SkPathWriter::deferredLine(const SkOpPtT* pt) {
+bool SkPathWriter::deferredLine(const SkOpPtT* pt) {
SkASSERT(fFirstPtT);
SkASSERT(fDefer[0]);
if (fDefer[0] == pt) {
// FIXME: why we're adding a degenerate line? Caller should have preflighted this.
- return;
+ return true;
}
if (pt->contains(fDefer[0])) {
// FIXME: why we're adding a degenerate line?
- return;
+ return true;
+ }
+ if (this->matchedLast(pt)) {
+ return false;
}
- SkASSERT(!this->matchedLast(pt));
if (fDefer[1] && this->changedSlopes(pt)) {
this->lineTo();
fDefer[0] = fDefer[1];
}
fDefer[1] = pt;
+ return true;
}
void SkPathWriter::deferredMove(const SkOpPtT* pt) {
diff --git a/src/pathops/SkPathWriter.h b/src/pathops/SkPathWriter.h
index bd13c718a9..5dd1bf6f60 100644
--- a/src/pathops/SkPathWriter.h
+++ b/src/pathops/SkPathWriter.h
@@ -23,7 +23,7 @@ public:
void assemble();
void conicTo(const SkPoint& pt1, const SkOpPtT* pt2, SkScalar weight);
void cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkOpPtT* pt3);
- void deferredLine(const SkOpPtT* pt);
+ bool deferredLine(const SkOpPtT* pt);
void deferredMove(const SkOpPtT* pt);
void finishContour();
bool hasMove() const { return !fFirstPtT; }
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);