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" |
11 #include "SkTDArray.h" | 11 #include "SkTDArray.h" |
12 #include "SkTSort.h" | 12 #include "SkTSort.h" |
13 | 13 |
14 class SkChunkAlloc; | 14 class SkChunkAlloc; |
15 class SkPathWriter; | 15 class SkPathWriter; |
16 | 16 |
17 class SkOpContour { | 17 class SkOpContour { |
18 public: | 18 public: |
19 SkOpContour() { | 19 SkOpContour() { |
20 reset(); | 20 reset(); |
21 } | 21 } |
22 | 22 |
23 ~SkOpContour() { | |
24 if (fNext) { | |
25 fNext->~SkOpContour(); | |
26 } | |
27 } | |
28 | |
29 bool operator<(const SkOpContour& rh) const { | 23 bool operator<(const SkOpContour& rh) const { |
30 return fBounds.fTop == rh.fBounds.fTop | 24 return fBounds.fTop == rh.fBounds.fTop |
31 ? fBounds.fLeft < rh.fBounds.fLeft | 25 ? fBounds.fLeft < rh.fBounds.fLeft |
32 : fBounds.fTop < rh.fBounds.fTop; | 26 : fBounds.fTop < rh.fBounds.fTop; |
33 } | 27 } |
34 | 28 |
35 void addCubic(SkPoint pts[4], SkChunkAlloc* allocator) { | 29 void addCubic(SkPoint pts[4], SkChunkAlloc* allocator) { |
36 appendSegment(allocator).addCubic(pts, this); | 30 appendSegment(allocator).addCubic(pts, this); |
37 } | 31 } |
38 | 32 |
(...skipping 21 matching lines...) Expand all Loading... |
60 result->setPrev(fTail); | 54 result->setPrev(fTail); |
61 if (fTail) { | 55 if (fTail) { |
62 fTail->setNext(result); | 56 fTail->setNext(result); |
63 } | 57 } |
64 fTail = result; | 58 fTail = result; |
65 return *result; | 59 return *result; |
66 } | 60 } |
67 | 61 |
68 SkOpContour* appendContour(SkChunkAlloc* allocator) { | 62 SkOpContour* appendContour(SkChunkAlloc* allocator) { |
69 SkOpContour* contour = SkOpTAllocator<SkOpContour>::New(allocator); | 63 SkOpContour* contour = SkOpTAllocator<SkOpContour>::New(allocator); |
70 contour->setNext(NULL); | 64 |
71 SkOpContour* prev = this; | 65 SkOpContour* prev = this; |
72 SkOpContour* next; | 66 SkOpContour* next; |
73 while ((next = prev->next())) { | 67 while ((next = prev->next())) { |
74 prev = next; | 68 prev = next; |
75 } | 69 } |
76 prev->setNext(contour); | 70 prev->setNext(contour); |
77 return contour; | 71 return contour; |
78 } | 72 } |
79 | 73 |
80 const SkPathOpsBounds& bounds() const { | 74 const SkPathOpsBounds& bounds() const { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 while ((segment = segment->next())) { | 266 while ((segment = segment->next())) { |
273 fBounds.add(segment->bounds()); | 267 fBounds.add(segment->bounds()); |
274 } | 268 } |
275 } | 269 } |
276 | 270 |
277 void setGlobalState(SkOpGlobalState* state) { | 271 void setGlobalState(SkOpGlobalState* state) { |
278 fState = state; | 272 fState = state; |
279 } | 273 } |
280 | 274 |
281 void setNext(SkOpContour* contour) { | 275 void setNext(SkOpContour* contour) { |
282 // SkASSERT(!fNext == !!contour); | 276 SkASSERT(!fNext == !!contour); |
283 fNext = contour; | 277 fNext = contour; |
284 } | 278 } |
285 | 279 |
286 void setOperand(bool isOp) { | 280 void setOperand(bool isOp) { |
287 fOperand = isOp; | 281 fOperand = isOp; |
288 } | 282 } |
289 | 283 |
290 void setOppXor(bool isOppXor) { | 284 void setOppXor(bool isOppXor) { |
291 fOppXor = isOppXor; | 285 fOppXor = isOppXor; |
292 } | 286 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 int fFirstSorted; | 341 int fFirstSorted; |
348 bool fDone; // set by find top segment | 342 bool fDone; // set by find top segment |
349 bool fOperand; // true for the second argument to a binary operator | 343 bool fOperand; // true for the second argument to a binary operator |
350 bool fXor; // set if original path had even-odd fill | 344 bool fXor; // set if original path had even-odd fill |
351 bool fOppXor; // set if opposite path had even-odd fill | 345 bool fOppXor; // set if opposite path had even-odd fill |
352 PATH_OPS_DEBUG_CODE(int fID); | 346 PATH_OPS_DEBUG_CODE(int fID); |
353 PATH_OPS_DEBUG_CODE(int fIndent); | 347 PATH_OPS_DEBUG_CODE(int fIndent); |
354 }; | 348 }; |
355 | 349 |
356 #endif | 350 #endif |
OLD | NEW |