aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsDebug.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-07-18 10:01:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-18 10:01:36 -0700
commit55888e44171ffd48b591d19256884a969fe4da17 (patch)
treee3aed151b6074bba5357263199a5915ec31a0b99 /tests/PathOpsDebug.cpp
parent6451a0cea6007aff54565ec82e2f86cb1d32ecc7 (diff)
pathops coincidence and security rewrite
Most changes stem from working on an examples bracketed by #if DEBUG_UNDER_DEVELOPMENT // tiger These exposed many problems with coincident curves, as well as errors throughout the code. Fixing these errors also fixed a number of fuzzer-inspired bug reports. * Line/Curve Intersections Check to see if the end of the line nearly intersects the curve. This was a FIXME in the old code. * Performance Use a central chunk allocator. Plumb the allocator into the global variable state so that it can be shared. (Note that 'SkGlobalState' is allocated on the stack and is visible to children functions but not other threads.) * Refactor Let SkOpAngle grow up from a structure to a class. Let SkCoincidentSpans grow up from a structure to a class. Rename enum Alias to AliasMatch. * Coincidence Rewrite Add more debugging to coincidence detection. Parallel debugging routines have read-only logic to report the current coincidence state so that steps through the logic can expose whether things got better or worse. More functions can error-out and cause the pathops engine to non-destructively exit. * Accuracy Remove code that adjusted point locations. Instead, offset the curve part so that sorted curves all use the same origin. Reduce the size (and influence) of magic numbers. * Testing The debug suite with verify and the full release suite ./out/Debug/pathops_unittest -v -V ./out/Release/pathops_unittest -v -V -x expose one error. That error is captured as cubics_d3. This error exists in the checked in code as well. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2128633003 BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2128633003 Review-Url: https://codereview.chromium.org/2128633003
Diffstat (limited to 'tests/PathOpsDebug.cpp')
-rwxr-xr-xtests/PathOpsDebug.cpp76
1 files changed, 62 insertions, 14 deletions
diff --git a/tests/PathOpsDebug.cpp b/tests/PathOpsDebug.cpp
index 0f96ef4f88..7770b00c6a 100755
--- a/tests/PathOpsDebug.cpp
+++ b/tests/PathOpsDebug.cpp
@@ -50,6 +50,14 @@ void SkPathOpsDebug::WindingPrintf(int wind) {
}
#endif
+static void DumpID(int id) {
+ SkDebugf("} ");
+ if (id >= 0) {
+ SkDebugf("id=%d", id);
+ }
+ SkDebugf("\n");
+}
+
void SkDConic::dump() const {
dumpInner();
SkDebugf("},\n");
@@ -57,7 +65,7 @@ void SkDConic::dump() const {
void SkDConic::dumpID(int id) const {
dumpInner();
- SkDebugf("} id=%d\n", id);
+ DumpID(id);
}
void SkDConic::dumpInner() const {
@@ -73,7 +81,8 @@ void SkDCubic::dump() const {
void SkDCubic::dumpID(int id) const {
this->dumpInner();
- SkDebugf("}} id=%d\n", id);
+ SkDebugf("}");
+ DumpID(id);
}
static inline bool double_is_NaN(double x) { return x != x; }
@@ -97,6 +106,10 @@ void SkDCubic::dumpInner() const {
fPts[index].dump();
}
+void SkDCurve::dump() const {
+ dumpID(-1);
+}
+
void SkDCurve::dumpID(int id) const {
#ifndef SK_RELEASE
switch(fVerb) {
@@ -127,7 +140,8 @@ void SkDLine::dump() const {
void SkDLine::dumpID(int id) const {
this->dumpInner();
- SkDebugf("}} id=%d\n", id);
+ SkDebugf("}");
+ DumpID(id);
}
void SkDLine::dumpInner() const {
@@ -168,7 +182,8 @@ void SkDQuad::dump() const {
void SkDQuad::dumpID(int id) const {
dumpInner();
- SkDebugf("}} id=%d\n", id);
+ SkDebugf("}");
+ DumpID(id);
}
void SkDQuad::dumpInner() const {
@@ -787,6 +802,10 @@ const SkOpAngle* SkOpAngle::debugAngle(int id) const {
return this->segment()->debugAngle(id);
}
+const SkOpCoincidence* SkOpAngle::debugCoincidence() const {
+ return this->segment()->debugCoincidence();
+}
+
SkOpContour* SkOpAngle::debugContour(int id) {
return this->segment()->debugContour(id);
}
@@ -925,6 +944,10 @@ SkOpContour* SkOpPtT::debugContour(int id) {
return this->span()->debugContour(id);
}
+const SkOpCoincidence* SkOpPtT::debugCoincidence() const {
+ return this->span()->debugCoincidence();
+}
+
const SkOpPtT* SkOpPtT::debugPtT(int id) const {
return this->span()->debugPtT(id);
}
@@ -964,7 +987,8 @@ void SkOpPtT::dumpAll() const {
}
void SkOpPtT::dumpBase() const {
- SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s", this->fT, this->fPt.fX, this->fPt.fY,
+ SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fPt.fY,
+ this->fCoincident ? " coin" : "",
this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
}
@@ -972,6 +996,10 @@ const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
return this->segment()->debugAngle(id);
}
+const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const {
+ return this->segment()->debugCoincidence();
+}
+
SkOpContour* SkOpSpanBase::debugContour(int id) {
return this->segment()->debugContour(id);
}
@@ -989,15 +1017,19 @@ const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
}
void SkOpSpanBase::dump() const {
- this->dumpAll();
- SkDebugf("\n");
+ this->dumpHead();
+ this->fPtT.dump();
}
-void SkOpSpanBase::dumpAll() const {
+void SkOpSpanBase::dumpHead() const {
SkDebugf("%.*s", contour()->debugIndent(), " ");
SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
this->dumpBase();
SkDebugf("\n");
+}
+
+void SkOpSpanBase::dumpAll() const {
+ this->dumpHead();
this->fPtT.dumpAll();
}
@@ -1008,6 +1040,11 @@ void SkOpSpanBase::dumpBase() const {
if (this->fChased) {
SkDebugf(" chased");
}
+#ifdef SK_DEBUG
+ if (this->fDeleted) {
+ SkDebugf(" deleted");
+ }
+#endif
if (!this->final()) {
this->upCast()->dumpSpan();
}
@@ -1069,6 +1106,11 @@ const SkOpAngle* SkOpSegment::debugAngle(int id) const {
return this->contour()->debugAngle(id);
}
+
+const SkOpCoincidence* SkOpSegment::debugCoincidence() const {
+ return this->contour()->debugCoincidence();
+}
+
SkOpContour* SkOpSegment::debugContour(int id) {
return this->contour()->debugContour(id);
}
@@ -1188,20 +1230,26 @@ void SkOpCoincidence::dump() const {
SkCoincidentSpans* span = fHead;
while (span) {
span->dump();
- span = span->fNext;
+ span = span->next();
}
if (!fTop || fHead == fTop) {
return;
}
SkDebugf("top:\n");
span = fTop;
- if (fHead) {
- span->dump();
- return;
- }
+ int count = 0;
while (span) {
span->dump();
- span = span->fNext;
+ span = span->next();
+ SkCoincidentSpans* check = fTop;
+ ++count;
+ for (int index = 0; index < count; ++index) {
+ if (span == check) {
+ SkDebugf("(loops to #%d)\n", index);
+ return;
+ }
+ check = check->next();
+ }
}
}