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 SkOpContour_DEFINED | 7 #ifndef SkOpContour_DEFINED |
8 #define SkOpContour_DEFINED | 8 #define SkOpContour_DEFINED |
9 | 9 |
10 #include "SkOpSegment.h" | 10 #include "SkOpSegment.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 SkOpSegment* result = fCount++ | 56 SkOpSegment* result = fCount++ |
57 ? SkOpTAllocator<SkOpSegment>::Allocate(this->globalState()->allocat
or()) : &fHead; | 57 ? SkOpTAllocator<SkOpSegment>::Allocate(this->globalState()->allocat
or()) : &fHead; |
58 result->setPrev(fTail); | 58 result->setPrev(fTail); |
59 if (fTail) { | 59 if (fTail) { |
60 fTail->setNext(result); | 60 fTail->setNext(result); |
61 } | 61 } |
62 fTail = result; | 62 fTail = result; |
63 return *result; | 63 return *result; |
64 } | 64 } |
65 | 65 |
66 SkOpContour* appendContour() { | |
67 SkOpContour* contour = SkOpTAllocator<SkOpContour>::New(this->globalStat
e()->allocator()); | |
68 contour->setNext(nullptr); | |
69 SkOpContour* prev = this; | |
70 SkOpContour* next; | |
71 while ((next = prev->next())) { | |
72 prev = next; | |
73 } | |
74 prev->setNext(contour); | |
75 return contour; | |
76 } | |
77 | |
78 const SkPathOpsBounds& bounds() const { | 66 const SkPathOpsBounds& bounds() const { |
79 return fBounds; | 67 return fBounds; |
80 } | 68 } |
81 | 69 |
82 void calcAngles() { | 70 void calcAngles() { |
83 SkASSERT(fCount > 0); | 71 SkASSERT(fCount > 0); |
84 SkOpSegment* segment = &fHead; | 72 SkOpSegment* segment = &fHead; |
85 do { | 73 do { |
86 segment->calcAngles(); | 74 segment->calcAngles(); |
87 } while ((segment = segment->next())); | 75 } while ((segment = segment->next())); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 200 } |
213 | 201 |
214 int isCcw() const { | 202 int isCcw() const { |
215 return fCcw; | 203 return fCcw; |
216 } | 204 } |
217 | 205 |
218 bool isXor() const { | 206 bool isXor() const { |
219 return fXor; | 207 return fXor; |
220 } | 208 } |
221 | 209 |
| 210 void joinSegments() { |
| 211 SkOpSegment* segment = &fHead; |
| 212 SkOpSegment* next; |
| 213 do { |
| 214 next = segment->next(); |
| 215 segment->joinEnds(next ? next : &fHead); |
| 216 } while ((segment = next)); |
| 217 } |
| 218 |
222 void markAllDone() { | 219 void markAllDone() { |
223 SkOpSegment* segment = &fHead; | 220 SkOpSegment* segment = &fHead; |
224 do { | 221 do { |
225 segment->markAllDone(); | 222 segment->markAllDone(); |
226 } while ((segment = segment->next())); | 223 } while ((segment = segment->next())); |
227 } | 224 } |
228 | 225 |
229 // Please keep this aligned with debugMissingCoincidence() | 226 // Please keep this aligned with debugMissingCoincidence() |
230 bool missingCoincidence() { | 227 bool missingCoincidence() { |
231 SkASSERT(fCount > 0); | 228 SkASSERT(fCount > 0); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 bool oppXor() const { | 279 bool oppXor() const { |
283 return fOppXor; | 280 return fOppXor; |
284 } | 281 } |
285 | 282 |
286 void outdentDump() const { | 283 void outdentDump() const { |
287 SkDEBUGCODE(fDebugIndent -= 2); | 284 SkDEBUGCODE(fDebugIndent -= 2); |
288 } | 285 } |
289 | 286 |
290 void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkC
hunkAlloc* ); | 287 void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkC
hunkAlloc* ); |
291 | 288 |
292 void remove(SkOpContour* contour) { | |
293 if (contour == this) { | |
294 SkASSERT(fCount == 0); | |
295 return; | |
296 } | |
297 SkASSERT(contour->fNext == nullptr); | |
298 SkOpContour* prev = this; | |
299 SkOpContour* next; | |
300 while ((next = prev->next()) != contour) { | |
301 SkASSERT(next); | |
302 prev = next; | |
303 } | |
304 SkASSERT(prev); | |
305 prev->setNext(nullptr); | |
306 } | |
307 | |
308 void reset() { | 289 void reset() { |
309 fTail = nullptr; | 290 fTail = nullptr; |
310 fNext = nullptr; | 291 fNext = nullptr; |
311 fCount = 0; | 292 fCount = 0; |
312 fDone = false; | 293 fDone = false; |
313 SkDEBUGCODE(fBounds.set(SK_ScalarMax, SK_ScalarMax, SK_ScalarMin, SK_Sca
larMin)); | 294 SkDEBUGCODE(fBounds.set(SK_ScalarMax, SK_ScalarMax, SK_ScalarMin, SK_Sca
larMin)); |
314 SkDEBUGCODE(fFirstSorted = -1); | 295 SkDEBUGCODE(fFirstSorted = -1); |
315 SkDEBUGCODE(fDebugIndent = 0); | 296 SkDEBUGCODE(fDebugIndent = 0); |
316 } | 297 } |
317 | 298 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 bool fDone; // set by find top segment | 390 bool fDone; // set by find top segment |
410 bool fOperand; // true for the second argument to a binary operator | 391 bool fOperand; // true for the second argument to a binary operator |
411 bool fReverse; // true if contour should be reverse written to path (used o
nly by fix winding) | 392 bool fReverse; // true if contour should be reverse written to path (used o
nly by fix winding) |
412 bool fXor; // set if original path had even-odd fill | 393 bool fXor; // set if original path had even-odd fill |
413 bool fOppXor; // set if opposite path had even-odd fill | 394 bool fOppXor; // set if opposite path had even-odd fill |
414 SkDEBUGCODE(int fID); | 395 SkDEBUGCODE(int fID); |
415 SkDEBUGCODE(mutable int fDebugIndent); | 396 SkDEBUGCODE(mutable int fDebugIndent); |
416 }; | 397 }; |
417 | 398 |
418 class SkOpContourHead : public SkOpContour { | 399 class SkOpContourHead : public SkOpContour { |
| 400 public: |
| 401 SkOpContour* appendContour() { |
| 402 SkOpContour* contour = SkOpTAllocator<SkOpContour>::New(this->globalStat
e()->allocator()); |
| 403 contour->setNext(nullptr); |
| 404 SkOpContour* prev = this; |
| 405 SkOpContour* next; |
| 406 while ((next = prev->next())) { |
| 407 prev = next; |
| 408 } |
| 409 prev->setNext(contour); |
| 410 return contour; |
| 411 } |
| 412 |
| 413 void joinAllSegments() { |
| 414 SkOpContour* next = this; |
| 415 do { |
| 416 next->joinSegments(); |
| 417 } while ((next = next->next())); |
| 418 } |
| 419 |
| 420 void remove(SkOpContour* contour) { |
| 421 if (contour == this) { |
| 422 SkASSERT(this->count() == 0); |
| 423 return; |
| 424 } |
| 425 SkASSERT(contour->next() == nullptr); |
| 426 SkOpContour* prev = this; |
| 427 SkOpContour* next; |
| 428 while ((next = prev->next()) != contour) { |
| 429 SkASSERT(next); |
| 430 prev = next; |
| 431 } |
| 432 SkASSERT(prev); |
| 433 prev->setNext(nullptr); |
| 434 } |
| 435 |
419 }; | 436 }; |
420 | 437 |
421 #endif | 438 #endif |
OLD | NEW |