diff options
author | caryclark <caryclark@google.com> | 2016-09-14 07:18:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-14 07:18:20 -0700 |
commit | eed356d281adbf93ecbd89cb23913a7861cd8578 (patch) | |
tree | e1f354471538f9484de7bd53eb9fafebd18f411a /src/pathops/SkOpContour.h | |
parent | 8bbcd5aab81dc0742c3367479c0c9d97363b1203 (diff) |
Rewriting path writer
The path writer takes constructs the output path out of
curves that satisfy the pathop operation.
Curves contain lists of t/point pairs that may not be
comparable to each other. To match up curve ends in the
output path, look for adjacent curves to have a shared
membership rather than comparing point values.
Use path utilities to connect partial curve lists into
closed contours.
Share the angle code that determines if a curve has become
a degenerate line with the path writer.
Clean up some code on the way, and delete some unused
functions.
TBR=reed@google.com
BUG=5188
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2321973005
Review-Url: https://codereview.chromium.org/2321973005
Diffstat (limited to 'src/pathops/SkOpContour.h')
-rw-r--r-- | src/pathops/SkOpContour.h | 73 |
1 files changed, 45 insertions, 28 deletions
diff --git a/src/pathops/SkOpContour.h b/src/pathops/SkOpContour.h index 412fecd73f..acc6744f2a 100644 --- a/src/pathops/SkOpContour.h +++ b/src/pathops/SkOpContour.h @@ -63,18 +63,6 @@ public: return *result; } - SkOpContour* appendContour() { - SkOpContour* contour = SkOpTAllocator<SkOpContour>::New(this->globalState()->allocator()); - contour->setNext(nullptr); - SkOpContour* prev = this; - SkOpContour* next; - while ((next = prev->next())) { - prev = next; - } - prev->setNext(contour); - return contour; - } - const SkPathOpsBounds& bounds() const { return fBounds; } @@ -219,6 +207,15 @@ public: return fXor; } + void joinSegments() { + SkOpSegment* segment = &fHead; + SkOpSegment* next; + do { + next = segment->next(); + segment->joinEnds(next ? next : &fHead); + } while ((segment = next)); + } + void markAllDone() { SkOpSegment* segment = &fHead; do { @@ -289,22 +286,6 @@ public: void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkChunkAlloc* ); - void remove(SkOpContour* contour) { - if (contour == this) { - SkASSERT(fCount == 0); - return; - } - SkASSERT(contour->fNext == nullptr); - SkOpContour* prev = this; - SkOpContour* next; - while ((next = prev->next()) != contour) { - SkASSERT(next); - prev = next; - } - SkASSERT(prev); - prev->setNext(nullptr); - } - void reset() { fTail = nullptr; fNext = nullptr; @@ -416,6 +397,42 @@ private: }; class SkOpContourHead : public SkOpContour { +public: + SkOpContour* appendContour() { + SkOpContour* contour = SkOpTAllocator<SkOpContour>::New(this->globalState()->allocator()); + contour->setNext(nullptr); + SkOpContour* prev = this; + SkOpContour* next; + while ((next = prev->next())) { + prev = next; + } + prev->setNext(contour); + return contour; + } + + void joinAllSegments() { + SkOpContour* next = this; + do { + next->joinSegments(); + } while ((next = next->next())); + } + + void remove(SkOpContour* contour) { + if (contour == this) { + SkASSERT(this->count() == 0); + return; + } + SkASSERT(contour->next() == nullptr); + SkOpContour* prev = this; + SkOpContour* next; + while ((next = prev->next()) != contour) { + SkASSERT(next); + prev = next; + } + SkASSERT(prev); + prev->setNext(nullptr); + } + }; #endif |