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 "SkTDArray.h" | 10 #include "SkTDArray.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 bool extend(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, | 49 bool extend(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, |
50 const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd); | 50 const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd); |
51 bool flipped() const { return fOppPtTStart->fT > fOppPtTEnd->fT; } | 51 bool flipped() const { return fOppPtTStart->fT > fOppPtTEnd->fT; } |
52 SkDEBUGCODE(SkOpGlobalState* globalState() { return fGlobalState; }) | 52 SkDEBUGCODE(SkOpGlobalState* globalState() { return fGlobalState; }) |
53 | 53 |
54 void init(SkDEBUGCODE(SkOpGlobalState* globalState)) { | 54 void init(SkDEBUGCODE(SkOpGlobalState* globalState)) { |
55 sk_bzero(this, sizeof(*this)); | 55 sk_bzero(this, sizeof(*this)); |
56 SkDEBUGCODE(fGlobalState = globalState); | 56 SkDEBUGCODE(fGlobalState = globalState); |
57 } | 57 } |
58 | 58 |
| 59 SkCoincidentSpans* next() { return fNext; } |
| 60 const SkCoincidentSpans* next() const { return fNext; } |
| 61 SkCoincidentSpans** nextPtr() { return &fNext; } |
59 const SkOpPtT* oppPtTStart() const { return fOppPtTStart; } | 62 const SkOpPtT* oppPtTStart() const { return fOppPtTStart; } |
60 const SkOpPtT* oppPtTEnd() const { return fOppPtTEnd; } | 63 const SkOpPtT* oppPtTEnd() const { return fOppPtTEnd; } |
61 // These return non-const pointers so that, as copies, they can be added | 64 // These return non-const pointers so that, as copies, they can be added |
62 // to a new span pair | 65 // to a new span pair |
63 SkOpPtT* oppPtTStartWritable() const { return const_cast<SkOpPtT*>(fOppPtTSt
art); } | 66 SkOpPtT* oppPtTStartWritable() const { return const_cast<SkOpPtT*>(fOppPtTSt
art); } |
64 SkOpPtT* oppPtTEndWritable() const { return const_cast<SkOpPtT*>(fOppPtTEnd)
; } | 67 SkOpPtT* oppPtTEndWritable() const { return const_cast<SkOpPtT*>(fOppPtTEnd)
; } |
65 SkCoincidentSpans* next() { return fNext; } | 68 bool ordered() const; |
66 const SkCoincidentSpans* next() const { return fNext; } | |
67 SkCoincidentSpans** nextPtr() { return &fNext; } | |
68 int spanCount() const; | 69 int spanCount() const; |
69 | 70 |
70 void set(SkCoincidentSpans* next, const SkOpPtT* coinPtTStart, const SkOpPtT
* coinPtTEnd, | 71 void set(SkCoincidentSpans* next, const SkOpPtT* coinPtTStart, const SkOpPtT
* coinPtTEnd, |
71 const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd | 72 const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd |
72 SkDEBUGPARAMS(int id)); | 73 SkDEBUGPARAMS(int id)); |
73 | 74 |
74 void setCoinPtTEnd(const SkOpPtT* ptT) { | 75 void setCoinPtTEnd(const SkOpPtT* ptT) { |
75 SkOPASSERT(ptT == ptT->span()->ptT()); | 76 SkOPASSERT(ptT == ptT->span()->ptT()); |
76 SkASSERT(!fCoinPtTStart || ptT->fT != fCoinPtTStart->fT); | 77 SkASSERT(!fCoinPtTStart || ptT->fT != fCoinPtTStart->fT); |
77 SkASSERT(!fCoinPtTStart || fCoinPtTStart->segment() == ptT->segment()); | 78 SkASSERT(!fCoinPtTStart || fCoinPtTStart->segment() == ptT->segment()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 void setStarts(const SkOpPtT* coinPtTStart, const SkOpPtT* oppPtTStart) { | 112 void setStarts(const SkOpPtT* coinPtTStart, const SkOpPtT* oppPtTStart) { |
112 this->setCoinPtTStart(coinPtTStart); | 113 this->setCoinPtTStart(coinPtTStart); |
113 this->setOppPtTStart(oppPtTStart); | 114 this->setOppPtTStart(oppPtTStart); |
114 } | 115 } |
115 | 116 |
116 void setNext(SkCoincidentSpans* next) { fNext = next; } | 117 void setNext(SkCoincidentSpans* next) { fNext = next; } |
117 | 118 |
118 bool startEquals(const SkOpSpanBase* outer, const SkOpSpanBase* over) const
{ | 119 bool startEquals(const SkOpSpanBase* outer, const SkOpSpanBase* over) const
{ |
119 return fCoinPtTStart->span() == over && fOppPtTStart->span() == outer; | 120 return fCoinPtTStart->span() == over && fOppPtTStart->span() == outer; |
120 } | 121 } |
| 122 |
121 private: | 123 private: |
122 SkCoincidentSpans* fNext; | 124 SkCoincidentSpans* fNext; |
123 const SkOpPtT* fCoinPtTStart; | 125 const SkOpPtT* fCoinPtTStart; |
124 const SkOpPtT* fCoinPtTEnd; | 126 const SkOpPtT* fCoinPtTEnd; |
125 const SkOpPtT* fOppPtTStart; | 127 const SkOpPtT* fOppPtTStart; |
126 const SkOpPtT* fOppPtTEnd; | 128 const SkOpPtT* fOppPtTEnd; |
127 SkDEBUGCODE(SkOpGlobalState* fGlobalState); | 129 SkDEBUGCODE(SkOpGlobalState* fGlobalState); |
128 SkDEBUGCODE(int fID); | 130 SkDEBUGCODE(int fID); |
129 }; | 131 }; |
130 | 132 |
131 class SkOpCoincidence { | 133 class SkOpCoincidence { |
132 public: | 134 public: |
133 SkOpCoincidence(SkOpGlobalState* globalState) | 135 SkOpCoincidence(SkOpGlobalState* globalState) |
134 : fHead(nullptr) | 136 : fHead(nullptr) |
135 , fTop(nullptr) | 137 , fTop(nullptr) |
136 , fGlobalState(globalState) | 138 , fGlobalState(globalState) |
137 , fContinue(false) | 139 , fContinue(false) |
138 , fSpanDeleted(false) | 140 , fSpanDeleted(false) |
139 , fPtAllocated(false) | 141 , fPtAllocated(false) |
140 , fCoinExtended(false) | 142 , fCoinExtended(false) |
141 , fSpanMerged(false) { | 143 , fSpanMerged(false) { |
142 globalState->setCoincidence(this); | 144 globalState->setCoincidence(this); |
143 } | 145 } |
144 | 146 |
145 void add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart, | 147 void add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart, |
146 SkOpPtT* oppPtTEnd); | 148 SkOpPtT* oppPtTEnd); |
147 bool addEndMovedSpans(); | 149 bool addEndMovedSpans(); |
148 bool addExpanded(); | 150 bool addExpanded(); |
149 bool addMissing(); | 151 bool addMissing(bool* added); |
150 bool addUncommon(); | 152 bool addUncommon(); |
151 bool apply(); | 153 bool apply(); |
152 bool contains(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, | 154 bool contains(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, |
153 const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd) const; | 155 const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd) const; |
154 void correctEnds(); | 156 void correctEnds(); |
155 | 157 |
156 #if DEBUG_COINCIDENCE_VERBOSE | 158 #if DEBUG_COINCIDENCE_VERBOSE |
157 void debugAddExpanded(const char* id, SkPathOpsDebug::GlitchLog* ) const; | 159 void debugAddExpanded(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
158 void debugAddMissing(const char* id, SkPathOpsDebug::GlitchLog* ) const; | 160 void debugAddMissing(const char* id, SkPathOpsDebug::GlitchLog* , bool* adde
d) const; |
159 void debugAddOrOverlap(const char* id, SkPathOpsDebug::GlitchLog* log, | 161 void debugAddOrOverlap(const char* id, SkPathOpsDebug::GlitchLog* log, |
160 const SkOpSegment* coinSeg, const SkOpSegment* oppSeg
, | 162 const SkOpSegment* coinSeg, const SkOpSegment* oppSeg
, |
161 double coinTs, double coinTe, double oppTs, double op
pTe) const; | 163 double coinTs, double coinTe, double oppTs, double op
pTe, |
| 164 bool* added) const; |
162 #endif | 165 #endif |
163 | 166 |
164 const SkOpAngle* debugAngle(int id) const { | 167 const SkOpAngle* debugAngle(int id) const { |
165 return SkDEBUGRELEASE(fGlobalState->debugAngle(id), nullptr); | 168 return SkDEBUGRELEASE(fGlobalState->debugAngle(id), nullptr); |
166 } | 169 } |
167 | 170 |
168 #if DEBUG_COINCIDENCE_VERBOSE | 171 #if DEBUG_COINCIDENCE_VERBOSE |
169 void debugCheckOverlap(const char* id, SkPathOpsDebug::GlitchLog* log) const
; | |
170 void debugCheckValid(const char* id, SkPathOpsDebug::GlitchLog* log) const; | 172 void debugCheckValid(const char* id, SkPathOpsDebug::GlitchLog* log) const; |
171 #endif | 173 #endif |
172 | 174 |
173 SkOpContour* debugContour(int id) const { | 175 SkOpContour* debugContour(int id) const { |
174 return SkDEBUGRELEASE(fGlobalState->debugContour(id), nullptr); | 176 return SkDEBUGRELEASE(fGlobalState->debugContour(id), nullptr); |
175 } | 177 } |
176 | 178 |
177 #if DEBUG_COINCIDENCE_VERBOSE | 179 #if DEBUG_COINCIDENCE_VERBOSE |
178 bool debugExpand(const char* id, SkPathOpsDebug::GlitchLog* ) const; | 180 bool debugExpand(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
179 void debugMark(const char* id, SkPathOpsDebug::GlitchLog* ) const; | 181 void debugMark(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
(...skipping 29 matching lines...) Expand all Loading... |
209 bool expand(); | 211 bool expand(); |
210 bool extend(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, const Sk
OpPtT* oppPtTStart, | 212 bool extend(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, const Sk
OpPtT* oppPtTStart, |
211 const SkOpPtT* oppPtTEnd); | 213 const SkOpPtT* oppPtTEnd); |
212 bool findOverlaps(SkOpCoincidence* ) const; | 214 bool findOverlaps(SkOpCoincidence* ) const; |
213 void fixUp(SkOpPtT* deleted, const SkOpPtT* kept); | 215 void fixUp(SkOpPtT* deleted, const SkOpPtT* kept); |
214 | 216 |
215 SkOpGlobalState* globalState() { | 217 SkOpGlobalState* globalState() { |
216 return fGlobalState; | 218 return fGlobalState; |
217 } | 219 } |
218 | 220 |
| 221 const SkOpGlobalState* globalState() const { |
| 222 return fGlobalState; |
| 223 } |
| 224 |
219 bool isEmpty() const { | 225 bool isEmpty() const { |
220 return !fHead && !fTop; | 226 return !fHead && !fTop; |
221 } | 227 } |
222 | 228 |
223 bool mark(); | 229 bool mark(); |
224 void markCollapsed(SkOpPtT* ); | 230 void markCollapsed(SkOpPtT* ); |
225 | 231 |
226 static bool Ordered(const SkOpPtT* coinPtTStart, const SkOpPtT* oppPtTStart)
{ | 232 static bool Ordered(const SkOpPtT* coinPtTStart, const SkOpPtT* oppPtTStart)
{ |
227 return Ordered(coinPtTStart->segment(), oppPtTStart->segment()); | 233 return Ordered(coinPtTStart->segment(), oppPtTStart->segment()); |
228 } | 234 } |
(...skipping 15 matching lines...) Expand all Loading... |
244 bool addEndMovedSpans(const SkOpPtT* ptT); | 250 bool addEndMovedSpans(const SkOpPtT* ptT); |
245 | 251 |
246 bool addIfMissing(const SkCoincidentSpans* outer, SkOpPtT* over1s, SkOpPtT*
over1e); | 252 bool addIfMissing(const SkCoincidentSpans* outer, SkOpPtT* over1s, SkOpPtT*
over1e); |
247 | 253 |
248 bool addIfMissing(const SkCoincidentSpans* outer, const SkOpPtT* over1s, | 254 bool addIfMissing(const SkCoincidentSpans* outer, const SkOpPtT* over1s, |
249 const SkOpPtT* over1e) { | 255 const SkOpPtT* over1e) { |
250 return addIfMissing(outer, const_cast<SkOpPtT*>(over1s), const_cast<SkOp
PtT*>(over1e)); | 256 return addIfMissing(outer, const_cast<SkOpPtT*>(over1s), const_cast<SkOp
PtT*>(over1e)); |
251 } | 257 } |
252 | 258 |
253 bool addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over2s, | 259 bool addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over2s, |
254 double tStart, double tEnd, SkOpSegment* coinSeg, SkOpSegm
ent* oppSeg | 260 double tStart, double tEnd, SkOpSegment* coinSeg, SkOpSegm
ent* oppSeg, |
| 261 bool* added |
255 SkDEBUGPARAMS(const SkOpPtT* over1e) SkDEBUGPARAMS(const S
kOpPtT* over2e)); | 262 SkDEBUGPARAMS(const SkOpPtT* over1e) SkDEBUGPARAMS(const S
kOpPtT* over2e)); |
256 bool addOrOverlap(SkOpSegment* coinSeg, SkOpSegment* oppSeg, | 263 bool addOrOverlap(SkOpSegment* coinSeg, SkOpSegment* oppSeg, |
257 double coinTs, double coinTe, double oppTs, double oppTe | 264 double coinTs, double coinTe, double oppTs, double oppTe,
bool* added); |
258 SkDEBUGPARAMS(bool callerAborts)); | |
259 bool addOverlap(const SkOpSegment* seg1, const SkOpSegment* seg1o, | 265 bool addOverlap(const SkOpSegment* seg1, const SkOpSegment* seg1o, |
260 const SkOpSegment* seg2, const SkOpSegment* seg2o, | 266 const SkOpSegment* seg2, const SkOpSegment* seg2o, |
261 const SkOpPtT* overS, const SkOpPtT* overE); | 267 const SkOpPtT* overS, const SkOpPtT* overE); |
262 bool alreadyAdded(const SkCoincidentSpans* check, const SkCoincidentSpans* o
uter, | 268 bool alreadyAdded(const SkCoincidentSpans* check, const SkCoincidentSpans* o
uter, |
263 const SkOpPtT* over1s, const SkOpPtT* over1e) const; | 269 const SkOpPtT* over1s, const SkOpPtT* over1e) const; |
264 bool checkOverlap(SkCoincidentSpans* check, | 270 bool checkOverlap(SkCoincidentSpans* check, |
265 const SkOpSegment* coinSeg, const SkOpSegment* oppSeg, | 271 const SkOpSegment* coinSeg, const SkOpSegment* oppSeg, |
266 double coinTs, double coinTe, double oppTs, double oppTe, | 272 double coinTs, double coinTe, double oppTs, double oppTe, |
267 SkTDArray<SkCoincidentSpans*>* overlaps) const; | 273 SkTDArray<SkCoincidentSpans*>* overlaps) const; |
268 bool contains(const SkOpSegment* seg, const SkOpSegment* opp, double oppT) c
onst; | 274 bool contains(const SkOpSegment* seg, const SkOpSegment* opp, double oppT) c
onst; |
269 bool contains(const SkCoincidentSpans* coin, const SkOpSegment* seg, | 275 bool contains(const SkCoincidentSpans* coin, const SkOpSegment* seg, |
270 const SkOpSegment* opp, double oppT) const; | 276 const SkOpSegment* opp, double oppT) const; |
271 #if DEBUG_COINCIDENCE_VERBOSE | 277 #if DEBUG_COINCIDENCE_VERBOSE |
272 void debugAddIfMissing(const char* id, SkPathOpsDebug::GlitchLog* , | 278 void debugAddIfMissing(const char* id, SkPathOpsDebug::GlitchLog* , |
273 const SkCoincidentSpans* outer, const SkOpPtT* over1s
, | 279 const SkCoincidentSpans* outer, const SkOpPtT* over1s
, |
274 const SkOpPtT* over1e) const; | 280 const SkOpPtT* over1e) const; |
275 void debugAddIfMissing(const char* id, SkPathOpsDebug::GlitchLog* , | 281 void debugAddIfMissing(const char* id, SkPathOpsDebug::GlitchLog* , |
276 const SkOpPtT* over1s, const SkOpPtT* over2s, | 282 const SkOpPtT* over1s, const SkOpPtT* over2s, |
277 double tStart, double tEnd, | 283 double tStart, double tEnd, |
278 const SkOpSegment* coinSeg, const SkOpSegment* oppSeg
, | 284 const SkOpSegment* coinSeg, const SkOpSegment* oppSeg
, bool* added, |
279 const SkOpPtT* over1e, const SkOpPtT* over2e) const; | 285 const SkOpPtT* over1e, const SkOpPtT* over2e) const; |
280 #endif | 286 #endif |
281 void fixUp(SkCoincidentSpans* coin, SkOpPtT* deleted, const SkOpPtT* kept); | 287 void fixUp(SkCoincidentSpans* coin, SkOpPtT* deleted, const SkOpPtT* kept); |
282 void markCollapsed(SkCoincidentSpans* head, SkOpPtT* test); | 288 void markCollapsed(SkCoincidentSpans* head, SkOpPtT* test); |
283 bool overlap(const SkOpPtT* coinStart1, const SkOpPtT* coinEnd1, | 289 bool overlap(const SkOpPtT* coinStart1, const SkOpPtT* coinEnd1, |
284 const SkOpPtT* coinStart2, const SkOpPtT* coinEnd2, | 290 const SkOpPtT* coinStart2, const SkOpPtT* coinEnd2, |
285 double* overS, double* overE) const; | 291 double* overS, double* overE) const; |
286 bool release(SkCoincidentSpans* coin, SkCoincidentSpans* ); | 292 bool release(SkCoincidentSpans* coin, SkCoincidentSpans* ); |
287 void releaseDeleted(SkCoincidentSpans* ); | 293 void releaseDeleted(SkCoincidentSpans* ); |
288 void restoreHead(); | 294 void restoreHead(); |
289 bool testForCoincidence(const SkCoincidentSpans* outer, const SkOpPtT* testS
, | 295 bool testForCoincidence(const SkCoincidentSpans* outer, const SkOpPtT* testS
, |
290 const SkOpPtT* testE) const; | 296 const SkOpPtT* testE) const; |
291 // return coinPtT->segment()->t mapped from overS->fT <= t <= overE->fT | 297 // return coinPtT->segment()->t mapped from overS->fT <= t <= overE->fT |
292 static double TRange(const SkOpPtT* overS, double t, const SkOpSegment* coin
PtT | 298 static double TRange(const SkOpPtT* overS, double t, const SkOpSegment* coin
PtT |
293 SkDEBUGPARAMS(const SkOpPtT* overE)); | 299 SkDEBUGPARAMS(const SkOpPtT* overE)); |
294 | 300 |
295 SkCoincidentSpans* fHead; | 301 SkCoincidentSpans* fHead; |
296 SkCoincidentSpans* fTop; | 302 SkCoincidentSpans* fTop; |
297 SkOpGlobalState* fGlobalState; | 303 SkOpGlobalState* fGlobalState; |
298 bool fContinue; | 304 bool fContinue; |
299 bool fSpanDeleted; | 305 bool fSpanDeleted; |
300 bool fPtAllocated; | 306 bool fPtAllocated; |
301 bool fCoinExtended; | 307 bool fCoinExtended; |
302 bool fSpanMerged; | 308 bool fSpanMerged; |
303 }; | 309 }; |
304 | 310 |
305 #endif | 311 #endif |
OLD | NEW |