caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | #ifndef SkOpCoincidence_DEFINED |
| 8 | #define SkOpCoincidence_DEFINED |
| 9 | |
| 10 | #include "SkOpTAllocator.h" |
| 11 | #include "SkOpSpan.h" |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 12 | #include "SkPathOpsTypes.h" |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 13 | |
| 14 | class SkOpPtT; |
| 15 | |
| 16 | struct SkCoincidentSpans { |
| 17 | SkCoincidentSpans* fNext; |
| 18 | SkOpPtT* fCoinPtTStart; |
| 19 | SkOpPtT* fCoinPtTEnd; |
| 20 | SkOpPtT* fOppPtTStart; |
| 21 | SkOpPtT* fOppPtTEnd; |
| 22 | bool fFlipped; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 23 | |
| 24 | void dump() const; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | class SkOpCoincidence { |
| 28 | public: |
| 29 | SkOpCoincidence() |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 30 | : fHead(NULL) |
| 31 | , fTop(NULL) |
| 32 | SkDEBUGPARAMS(fDebugState(NULL)) |
| 33 | { |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart, |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 37 | SkOpPtT* oppPtTEnd, SkChunkAlloc* allocator); |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 38 | void addExpanded(SkChunkAlloc* allocator PATH_OPS_DEBUG_VALIDATE_PARAMS(SkOpGlobalState* )); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 39 | bool addMissing(SkChunkAlloc* allocator); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 40 | void addMissing(SkCoincidentSpans* check, SkChunkAlloc* allocator); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 41 | bool apply(); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 42 | bool contains(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart, |
| 43 | SkOpPtT* oppPtTEnd, bool flipped); |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 44 | |
| 45 | const SkOpAngle* debugAngle(int id) const { |
| 46 | return SkDEBUGRELEASE(fDebugState->debugAngle(id), NULL); |
| 47 | } |
| 48 | |
| 49 | SkOpContour* debugContour(int id) { |
| 50 | return SkDEBUGRELEASE(fDebugState->debugContour(id), NULL); |
| 51 | } |
| 52 | |
| 53 | const SkOpPtT* debugPtT(int id) const { |
| 54 | return SkDEBUGRELEASE(fDebugState->debugPtT(id), NULL); |
| 55 | } |
| 56 | |
| 57 | const SkOpSegment* debugSegment(int id) const { |
| 58 | return SkDEBUGRELEASE(fDebugState->debugSegment(id), NULL); |
| 59 | } |
| 60 | |
| 61 | void debugSetGlobalState(SkOpGlobalState* debugState) { |
| 62 | SkDEBUGCODE(fDebugState = debugState); |
| 63 | } |
| 64 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 65 | void debugShowCoincidence() const; |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 66 | |
| 67 | const SkOpSpanBase* debugSpan(int id) const { |
| 68 | return SkDEBUGRELEASE(fDebugState->debugSpan(id), NULL); |
| 69 | } |
| 70 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 71 | void detach(SkCoincidentSpans* ); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 72 | void dump() const; |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 73 | bool expand(); |
caryclark | bca19f7 | 2015-05-13 08:23:48 -0700 | [diff] [blame] | 74 | bool extend(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart, |
| 75 | SkOpPtT* oppPtTEnd); |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 76 | void findOverlaps(SkOpCoincidence* , SkChunkAlloc* allocator) const; |
| 77 | void fixAligned(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 78 | void fixUp(SkOpPtT* deleted, SkOpPtT* kept); |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 79 | |
| 80 | bool isEmpty() const { |
| 81 | return !fHead; |
| 82 | } |
| 83 | |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 84 | void mark(); |
| 85 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 86 | private: |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 87 | void addIfMissing(const SkCoincidentSpans* outer, SkOpPtT* over1s, SkOpPtT* over1e, |
| 88 | SkChunkAlloc* ); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 89 | bool addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over1e, |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 90 | const SkOpPtT* over2s, const SkOpPtT* over2e, |
| 91 | double tStart, double tEnd, |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 92 | SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, |
| 93 | SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd, |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 94 | SkChunkAlloc* ); |
| 95 | void addOverlap(SkOpSegment* seg1, SkOpSegment* seg1o, SkOpSegment* seg2, SkOpSegment* seg2o, |
| 96 | SkOpPtT* overS, SkOpPtT* overE, SkChunkAlloc* ); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 97 | bool overlap(const SkOpPtT* coinStart1, const SkOpPtT* coinEnd1, |
| 98 | const SkOpPtT* coinStart2, const SkOpPtT* coinEnd2, |
| 99 | double* overS, double* overE) const; |
| 100 | |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 101 | bool testForCoincidence(const SkCoincidentSpans* outer, SkOpPtT* testS, SkOpPtT* testE) const; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 102 | SkCoincidentSpans* fHead; |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame^] | 103 | SkCoincidentSpans* fTop; |
| 104 | SkDEBUGCODE_(SkOpGlobalState* fDebugState); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | #endif |