diff options
author | caryclark <caryclark@google.com> | 2016-07-18 10:01:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-18 10:01:36 -0700 |
commit | 55888e44171ffd48b591d19256884a969fe4da17 (patch) | |
tree | e3aed151b6074bba5357263199a5915ec31a0b99 /src/pathops/SkPathOpsTSect.h | |
parent | 6451a0cea6007aff54565ec82e2f86cb1d32ecc7 (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 'src/pathops/SkPathOpsTSect.h')
-rw-r--r-- | src/pathops/SkPathOpsTSect.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/pathops/SkPathOpsTSect.h b/src/pathops/SkPathOpsTSect.h index 48aa540945..9032af83eb 100644 --- a/src/pathops/SkPathOpsTSect.h +++ b/src/pathops/SkPathOpsTSect.h @@ -250,7 +250,7 @@ private: SkTSpan<TCurve, OppCurve>* addFollowing(SkTSpan<TCurve, OppCurve>* prior); void addForPerp(SkTSpan<OppCurve, TCurve>* span, double t); SkTSpan<TCurve, OppCurve>* addOne(); - + SkTSpan<TCurve, OppCurve>* addSplitAt(SkTSpan<TCurve, OppCurve>* span, double t) { SkTSpan<TCurve, OppCurve>* result = this->addOne(); result->splitAt(span, t, &fHeap); @@ -343,7 +343,7 @@ void SkTCoincident<TCurve, OppCurve>::setPerp(const TCurve& c1, double t, if (used == 0 || used == 3) { this->init(); return; - } + } fPerpT = i[0][0]; fPerpPt = i.pt(0); SkASSERT(used <= 2); @@ -858,7 +858,7 @@ SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::addOne() { result->reset(); result->fHasPerp = false; result->fDeleted = false; - ++fActiveCount; + ++fActiveCount; PATH_OPS_DEBUG_T_SECT_CODE(result->fID = fDebugCount++ * 2 + fID); SkDEBUGCODE(result->fDebugSect = this); #ifdef SK_DEBUG @@ -969,6 +969,9 @@ void SkTSect<TCurve, OppCurve>::coincidentCheck(SkTSect<OppCurve, TCurve>* sect2 do { coinStart = this->extractCoincident(sect2, coinStart, last); } while (coinStart && !last->fDeleted); + if (!fHead || !sect2->fHead) { + break; + } } while ((first = next)); } @@ -1208,7 +1211,7 @@ SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::extractCoincident( } this->validate(); sect2->validate(); - return last && !last->fDeleted ? last : nullptr; + return last && !last->fDeleted && fHead && sect2->fHead ? last : nullptr; } template<typename TCurve, typename OppCurve> @@ -1511,7 +1514,7 @@ template<typename TCurve, typename OppCurve> void SkTSect<TCurve, OppCurve>::matchedDirCheck(double t, const SkTSect<OppCurve, TCurve>* sect2, double t2, bool* calcMatched, bool* oppMatched) const { if (*calcMatched) { - SkASSERT(*oppMatched == this->matchedDirection(t, sect2, t2)); + SkASSERT(*oppMatched == this->matchedDirection(t, sect2, t2)); } else { *oppMatched = this->matchedDirection(t, sect2, t2); *calcMatched = true; @@ -1584,7 +1587,7 @@ SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::prev( test = test->fNext; SkASSERT(test); } - return result; + return result; } template<typename TCurve, typename OppCurve> @@ -1939,7 +1942,7 @@ struct SkClosestRecord { fC1Index = mate.fC1Index; fC2Index = mate.fC2Index; } - + void reset() { fClosest = FLT_MAX; SkDEBUGCODE(fC1Span = nullptr); @@ -2099,7 +2102,7 @@ void SkTSect<TCurve, OppCurve>::BinarySearch(SkTSect<TCurve, OppCurve>* sect1, gets stuck in a loop. It adds an extension to allow a coincident end perpendicular to track its intersection in the opposite curve. However, the bounding box of the extension does not intersect the original curve, - so the extension is discarded, only to be added again the next time around. */ + so the extension is discarded, only to be added again the next time around. */ sect1->coincidentForce(sect2, start1s, start1e); sect1->validate(); sect2->validate(); |