| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #ifndef SkOpCoincidence_DEFINED | 7 #ifndef SkOpCoincidence_DEFINED |
| 8 #define SkOpCoincidence_DEFINED | 8 #define SkOpCoincidence_DEFINED |
| 9 | 9 |
| 10 #include "SkOpTAllocator.h" | 10 #include "SkOpTAllocator.h" |
| 11 #include "SkOpSpan.h" | 11 #include "SkOpSpan.h" |
| 12 #include "SkPathOpsTypes.h" | 12 #include "SkPathOpsTypes.h" |
| 13 | 13 |
| 14 class SkOpPtT; | 14 class SkOpPtT; |
| 15 | 15 |
| 16 struct SkCoincidentSpans { | 16 struct SkCoincidentSpans { |
| 17 SkCoincidentSpans* fNext; | 17 SkCoincidentSpans* fNext; |
| 18 SkOpPtT* fCoinPtTStart; | 18 SkOpPtT* fCoinPtTStart; |
| 19 SkOpPtT* fCoinPtTEnd; | 19 SkOpPtT* fCoinPtTEnd; |
| 20 SkOpPtT* fOppPtTStart; | 20 SkOpPtT* fOppPtTStart; |
| 21 SkOpPtT* fOppPtTEnd; | 21 SkOpPtT* fOppPtTEnd; |
| 22 bool fFlipped; | 22 bool fFlipped; |
| 23 SkDEBUGCODE(int fID); |
| 24 |
| 25 int debugID() const { |
| 26 return SkDEBUGRELEASE(fID, -1); |
| 27 } |
| 23 | 28 |
| 24 void dump() const; | 29 void dump() const; |
| 25 }; | 30 }; |
| 26 | 31 |
| 27 class SkOpCoincidence { | 32 class SkOpCoincidence { |
| 28 public: | 33 public: |
| 29 SkOpCoincidence() | 34 SkOpCoincidence() |
| 30 : fHead(nullptr) | 35 : fHead(nullptr) |
| 31 , fTop(nullptr) | 36 , fTop(nullptr) |
| 32 SkDEBUGPARAMS(fDebugState(nullptr)) | 37 SkDEBUGPARAMS(fDebugState(nullptr)) |
| 33 { | 38 { |
| 34 } | 39 } |
| 35 | 40 |
| 36 void add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart, | 41 void add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart, |
| 37 SkOpPtT* oppPtTEnd, SkChunkAlloc* allocator); | 42 SkOpPtT* oppPtTEnd, SkChunkAlloc* allocator); |
| 38 void addExpanded(SkChunkAlloc* allocator PATH_OPS_DEBUG_VALIDATE_PARAMS(SkO
pGlobalState* )); | 43 bool addExpanded(SkChunkAlloc* allocator PATH_OPS_DEBUG_VALIDATE_PARAMS(SkO
pGlobalState* )); |
| 39 bool addMissing(SkChunkAlloc* allocator); | 44 bool addMissing(SkChunkAlloc* allocator); |
| 40 void addMissing(SkCoincidentSpans* check, SkChunkAlloc* allocator); | |
| 41 bool apply(); | 45 bool apply(); |
| 42 bool contains(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTSta
rt, | 46 bool contains(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, |
| 43 SkOpPtT* oppPtTEnd, bool flipped); | 47 const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd, bool fli
pped) const; |
| 48 |
| 49 void debugAddExpanded(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
| 50 void debugAddMissing(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
| 44 | 51 |
| 45 const SkOpAngle* debugAngle(int id) const { | 52 const SkOpAngle* debugAngle(int id) const { |
| 46 return SkDEBUGRELEASE(fDebugState->debugAngle(id), nullptr); | 53 return SkDEBUGRELEASE(fDebugState->debugAngle(id), nullptr); |
| 47 } | 54 } |
| 48 | 55 |
| 49 SkOpContour* debugContour(int id) { | 56 SkOpContour* debugContour(int id) { |
| 50 return SkDEBUGRELEASE(fDebugState->debugContour(id), nullptr); | 57 return SkDEBUGRELEASE(fDebugState->debugContour(id), nullptr); |
| 51 } | 58 } |
| 52 | 59 |
| 60 bool debugExpand(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
| 61 void debugMark(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
| 62 |
| 53 const SkOpPtT* debugPtT(int id) const { | 63 const SkOpPtT* debugPtT(int id) const { |
| 54 return SkDEBUGRELEASE(fDebugState->debugPtT(id), nullptr); | 64 return SkDEBUGRELEASE(fDebugState->debugPtT(id), nullptr); |
| 55 } | 65 } |
| 56 | 66 |
| 57 const SkOpSegment* debugSegment(int id) const { | 67 const SkOpSegment* debugSegment(int id) const { |
| 58 return SkDEBUGRELEASE(fDebugState->debugSegment(id), nullptr); | 68 return SkDEBUGRELEASE(fDebugState->debugSegment(id), nullptr); |
| 59 } | 69 } |
| 60 | 70 |
| 61 void debugSetGlobalState(SkOpGlobalState* debugState) { | 71 void debugSetGlobalState(SkOpGlobalState* debugState) { |
| 62 SkDEBUGCODE(fDebugState = debugState); | 72 SkDEBUGCODE(fDebugState = debugState); |
| 63 } | 73 } |
| 64 | 74 |
| 75 void debugFixAligned(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
| 65 void debugShowCoincidence() const; | 76 void debugShowCoincidence() const; |
| 66 | 77 |
| 67 const SkOpSpanBase* debugSpan(int id) const { | 78 const SkOpSpanBase* debugSpan(int id) const { |
| 68 return SkDEBUGRELEASE(fDebugState->debugSpan(id), nullptr); | 79 return SkDEBUGRELEASE(fDebugState->debugSpan(id), nullptr); |
| 69 } | 80 } |
| 70 | 81 |
| 71 void detach(SkCoincidentSpans* ); | 82 void detach(SkCoincidentSpans* ); |
| 72 void dump() const; | 83 void dump() const; |
| 73 bool expand(); | 84 bool expand(); |
| 74 bool extend(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart
, | 85 bool extend(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart
, |
| 75 SkOpPtT* oppPtTEnd); | 86 SkOpPtT* oppPtTEnd); |
| 76 void findOverlaps(SkOpCoincidence* , SkChunkAlloc* allocator) const; | 87 void findOverlaps(SkOpCoincidence* , SkChunkAlloc* allocator) const; |
| 77 void fixAligned(); | 88 void fixAligned(); |
| 78 void fixUp(SkOpPtT* deleted, SkOpPtT* kept); | 89 void fixUp(SkOpPtT* deleted, SkOpPtT* kept); |
| 79 | 90 |
| 80 bool isEmpty() const { | 91 bool isEmpty() const { |
| 81 return !fHead; | 92 return !fHead; |
| 82 } | 93 } |
| 83 | 94 |
| 84 void mark(); | 95 void mark(); |
| 85 | 96 |
| 86 private: | 97 private: |
| 87 void addIfMissing(const SkCoincidentSpans* outer, SkOpPtT* over1s, SkOpPtT*
over1e, | 98 bool addIfMissing(const SkCoincidentSpans* outer, SkOpPtT* over1s, SkOpPtT*
over1e, |
| 88 SkChunkAlloc* ); | 99 SkChunkAlloc* ); |
| 89 bool addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over1e, | 100 bool addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over1e, |
| 90 const SkOpPtT* over2s, const SkOpPtT* over2e, | 101 const SkOpPtT* over2s, const SkOpPtT* over2e, |
| 91 double tStart, double tEnd, | 102 double tStart, double tEnd, |
| 92 SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, | 103 SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, |
| 93 SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd, | 104 SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd, |
| 94 SkChunkAlloc* ); | 105 SkChunkAlloc* ); |
| 95 void addOverlap(SkOpSegment* seg1, SkOpSegment* seg1o, SkOpSegment* seg2, Sk
OpSegment* seg2o, | 106 void addOverlap(SkOpSegment* seg1, SkOpSegment* seg1o, SkOpSegment* seg2, Sk
OpSegment* seg2o, |
| 96 SkOpPtT* overS, SkOpPtT* overE, SkChunkAlloc* ); | 107 SkOpPtT* overS, SkOpPtT* overE, SkChunkAlloc* ); |
| 108 bool debugAddIfMissing(const SkCoincidentSpans* outer, const SkOpPtT* over1s
, |
| 109 const SkOpPtT* over1e) const; |
| 110 bool debugAddIfMissing(const SkOpPtT* over1s, const SkOpPtT* over1e, |
| 111 const SkOpPtT* over2s, const SkOpPtT* over2e, |
| 112 double tStart, double tEnd, |
| 113 SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, |
| 114 SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd) const
; |
| 97 bool overlap(const SkOpPtT* coinStart1, const SkOpPtT* coinEnd1, | 115 bool overlap(const SkOpPtT* coinStart1, const SkOpPtT* coinEnd1, |
| 98 const SkOpPtT* coinStart2, const SkOpPtT* coinEnd2, | 116 const SkOpPtT* coinStart2, const SkOpPtT* coinEnd2, |
| 99 double* overS, double* overE) const; | 117 double* overS, double* overE) const; |
| 100 | 118 |
| 101 bool testForCoincidence(const SkCoincidentSpans* outer, SkOpPtT* testS, SkOp
PtT* testE) const; | 119 bool testForCoincidence(const SkCoincidentSpans* outer, const SkOpPtT* testS
, |
| 120 const SkOpPtT* testE) const; |
| 102 SkCoincidentSpans* fHead; | 121 SkCoincidentSpans* fHead; |
| 103 SkCoincidentSpans* fTop; | 122 SkCoincidentSpans* fTop; |
| 104 SkDEBUGCODE_(SkOpGlobalState* fDebugState); | 123 SkDEBUGCODE_(SkOpGlobalState* fDebugState); |
| 105 }; | 124 }; |
| 106 | 125 |
| 107 #endif | 126 #endif |
| OLD | NEW |