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
diff --git a/src/pathops/SkDQuadLineIntersection.cpp b/src/pathops/SkDQuadLineIntersection.cpp
index a3d10bc..dc237f5 100644
--- a/src/pathops/SkDQuadLineIntersection.cpp
+++ b/src/pathops/SkDQuadLineIntersection.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
#include "SkIntersections.h"
+#include "SkPathOpsCurve.h"
#include "SkPathOpsLine.h"
#include "SkPathOpsQuad.h"
@@ -98,11 +99,11 @@
, fLine(&l)
, fIntersections(i)
, fAllowNear(true) {
- i->setMax(3); // allow short partial coincidence plus discrete intersection
+ i->setMax(4); // allow short partial coincidence plus discrete intersections
}
LineQuadraticIntersections(const SkDQuad& q)
- : fQuad(q)
+ : fQuad(q)
SkDEBUGPARAMS(fLine(nullptr))
SkDEBUGPARAMS(fIntersections(nullptr))
SkDEBUGPARAMS(fAllowNear(false)) {
@@ -297,7 +298,22 @@
}
fIntersections->insert(quadT, lineT, fQuad[qIndex]);
}
- // FIXME: see if line end is nearly on quad
+ this->addLineNearEndPoints();
+ }
+
+ void addLineNearEndPoints() {
+ for (int lIndex = 0; lIndex < 2; ++lIndex) {
+ double lineT = (double) lIndex;
+ if (fIntersections->hasOppT(lineT)) {
+ continue;
+ }
+ double quadT = ((SkDCurve*) &fQuad)->nearPoint(SkPath::kQuad_Verb,
+ (*fLine)[lIndex], (*fLine)[!lIndex]);
+ if (quadT < 0) {
+ continue;
+ }
+ fIntersections->insert(quadT, lineT, (*fLine)[lIndex]);
+ }
}
void addExactHorizontalEndPoints(double left, double right, double y) {
@@ -323,7 +339,7 @@
}
fIntersections->insert(quadT, lineT, fQuad[qIndex]);
}
- // FIXME: see if line end is nearly on quad
+ this->addLineNearEndPoints();
}
void addExactVerticalEndPoints(double top, double bottom, double x) {
@@ -349,7 +365,7 @@
}
fIntersections->insert(quadT, lineT, fQuad[qIndex]);
}
- // FIXME: see if line end is nearly on quad
+ this->addLineNearEndPoints();
}
double findLineT(double t) {