OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkOpSpan_DEFINED | 7 #ifndef SkOpSpan_DEFINED |
8 #define SkOpSpan_DEFINED | 8 #define SkOpSpan_DEFINED |
9 | 9 |
10 #include "SkPathOpsDebug.h" | 10 #include "SkPathOpsDebug.h" |
| 11 #include "SkPathOpsTypes.h" |
11 #include "SkPoint.h" | 12 #include "SkPoint.h" |
12 | 13 |
13 class SkChunkAlloc; | 14 class SkChunkAlloc; |
14 struct SkOpAngle; | 15 struct SkOpAngle; |
15 class SkOpContour; | 16 class SkOpContour; |
16 class SkOpGlobalState; | 17 class SkOpGlobalState; |
17 class SkOpSegment; | 18 class SkOpSegment; |
18 class SkOpSpanBase; | 19 class SkOpSpanBase; |
19 class SkOpSpan; | 20 class SkOpSpan; |
20 | 21 |
(...skipping 19 matching lines...) Expand all Loading... |
40 } | 41 } |
41 | 42 |
42 SkOpPtT* oldNext = this->fNext; | 43 SkOpPtT* oldNext = this->fNext; |
43 SkASSERT(this != opp); | 44 SkASSERT(this != opp); |
44 this->fNext = opp; | 45 this->fNext = opp; |
45 SkASSERT(oppPrev != oldNext); | 46 SkASSERT(oppPrev != oldNext); |
46 oppPrev->fNext = oldNext; | 47 oppPrev->fNext = oldNext; |
47 } | 48 } |
48 | 49 |
49 bool alias() const; | 50 bool alias() const; |
| 51 bool contains(const SkOpPtT* ) const; |
| 52 SkOpPtT* contains(const SkOpSegment* ); |
50 SkOpContour* contour() const; | 53 SkOpContour* contour() const; |
51 | 54 |
52 int debugID() const { | 55 int debugID() const { |
53 return SkDEBUGRELEASE(fID, -1); | 56 return SkDEBUGRELEASE(fID, -1); |
54 } | 57 } |
55 | 58 |
56 const SkOpAngle* debugAngle(int id) const; | 59 const SkOpAngle* debugAngle(int id) const; |
57 SkOpContour* debugContour(int id); | 60 SkOpContour* debugContour(int id); |
58 int debugLoopLimit(bool report) const; | 61 int debugLoopLimit(bool report) const; |
59 bool debugMatchID(int id) const; | 62 bool debugMatchID(int id) const; |
60 const SkOpPtT* debugPtT(int id) const; | 63 const SkOpPtT* debugPtT(int id) const; |
61 const SkOpSegment* debugSegment(int id) const; | 64 const SkOpSegment* debugSegment(int id) const; |
62 const SkOpSpanBase* debugSpan(int id) const; | 65 const SkOpSpanBase* debugSpan(int id) const; |
63 SkOpGlobalState* globalState() const; | 66 SkOpGlobalState* globalState() const; |
64 void debugValidate() const; | 67 void debugValidate() const; |
65 | 68 |
66 bool deleted() const { | 69 bool deleted() const { |
67 return fDeleted; | 70 return fDeleted; |
68 } | 71 } |
69 | 72 |
| 73 SkOpPtT* doppelganger(); |
| 74 |
70 bool duplicate() const { | 75 bool duplicate() const { |
71 return fDuplicatePt; | 76 return fDuplicatePt; |
72 } | 77 } |
73 | 78 |
74 void dump() const; // available to testing only | 79 void dump() const; // available to testing only |
75 void dumpAll() const; | 80 void dumpAll() const; |
76 void dumpBase() const; | 81 void dumpBase() const; |
77 | 82 |
| 83 SkOpPtT* find(SkOpSegment* ); |
78 void init(SkOpSpanBase* , double t, const SkPoint& , bool dup); | 84 void init(SkOpSpanBase* , double t, const SkPoint& , bool dup); |
79 | 85 |
80 void insert(SkOpPtT* span) { | 86 void insert(SkOpPtT* span) { |
81 SkASSERT(span != this); | 87 SkASSERT(span != this); |
82 span->fNext = fNext; | 88 span->fNext = fNext; |
83 fNext = span; | 89 fNext = span; |
84 } | 90 } |
85 | 91 |
86 const SkOpPtT* next() const { | 92 const SkOpPtT* next() const { |
87 return fNext; | 93 return fNext; |
88 } | 94 } |
89 | 95 |
90 SkOpPtT* next() { | 96 SkOpPtT* next() { |
91 return fNext; | 97 return fNext; |
92 } | 98 } |
93 | 99 |
94 bool onEnd() const; | 100 bool onEnd() const; |
| 101 |
| 102 static bool Overlaps(SkOpPtT* s1, SkOpPtT* e1, SkOpPtT* s2, SkOpPtT* e2, |
| 103 SkOpPtT** sOut, SkOpPtT** eOut) { |
| 104 SkOpPtT* start1 = s1->fT < e1->fT ? s1 : e1; |
| 105 SkOpPtT* start2 = s2->fT < e2->fT ? s2 : e2; |
| 106 *sOut = between(s1->fT, start2->fT, e1->fT) ? start2 |
| 107 : between(s2->fT, start1->fT, e2->fT) ? start1 : NULL; |
| 108 SkOpPtT* end1 = s1->fT < e1->fT ? e1 : s1; |
| 109 SkOpPtT* end2 = s2->fT < e2->fT ? e2 : s2; |
| 110 *eOut = between(s1->fT, end2->fT, e1->fT) ? end2 |
| 111 : between(s2->fT, end1->fT, e2->fT) ? end1 : NULL; |
| 112 if (*sOut == *eOut) { |
| 113 SkASSERT(start1->fT >= end2->fT || start2->fT >= end1->fT); |
| 114 return false; |
| 115 } |
| 116 SkASSERT(!*sOut || *sOut != *eOut); |
| 117 return *sOut && *eOut; |
| 118 } |
| 119 |
95 SkOpPtT* prev(); | 120 SkOpPtT* prev(); |
96 SkOpPtT* remove(); | 121 SkOpPtT* remove(); |
97 void removeNext(SkOpPtT* kept); | 122 void removeNext(SkOpPtT* kept); |
98 | 123 |
99 const SkOpSegment* segment() const; | 124 const SkOpSegment* segment() const; |
100 SkOpSegment* segment(); | 125 SkOpSegment* segment(); |
101 | 126 |
102 void setDeleted() { | 127 void setDeleted() { |
103 SkASSERT(!fDeleted); | 128 SkASSERT(!fDeleted); |
104 fDeleted = true; | 129 fDeleted = true; |
105 } | 130 } |
106 | 131 |
107 const SkOpSpanBase* span() const { | 132 const SkOpSpanBase* span() const { |
108 return fSpan; | 133 return fSpan; |
109 } | 134 } |
110 | 135 |
111 SkOpSpanBase* span() { | 136 SkOpSpanBase* span() { |
112 return fSpan; | 137 return fSpan; |
113 } | 138 } |
114 | 139 |
| 140 const SkOpPtT* starter(const SkOpPtT* end) const { |
| 141 return fT < end->fT ? this : end; |
| 142 } |
| 143 |
115 double fT; | 144 double fT; |
116 SkPoint fPt; // cache of point value at this t | 145 SkPoint fPt; // cache of point value at this t |
117 protected: | 146 protected: |
118 SkOpSpanBase* fSpan; // contains winding data | 147 SkOpSpanBase* fSpan; // contains winding data |
119 SkOpPtT* fNext; // intersection on opposite curve or alias on this curve | 148 SkOpPtT* fNext; // intersection on opposite curve or alias on this curve |
120 bool fDeleted; // set if removed from span list | 149 bool fDeleted; // set if removed from span list |
121 bool fDuplicatePt; // set if identical pt is somewhere in the next loop | 150 bool fDuplicatePt; // set if identical pt is somewhere in the next loop |
122 SkDEBUGCODE(int fID); | 151 SkDEBUGCODE(int fID); |
123 }; | 152 }; |
124 | 153 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 SkOpSpanBase* fNext; // next intersection point | 491 SkOpSpanBase* fNext; // next intersection point |
463 int fWindSum; // accumulated from contours surrounding this one. | 492 int fWindSum; // accumulated from contours surrounding this one. |
464 int fOppSum; // for binary operators: the opposite winding sum | 493 int fOppSum; // for binary operators: the opposite winding sum |
465 int fWindValue; // 0 == canceled; 1 == normal; >1 == coincident | 494 int fWindValue; // 0 == canceled; 1 == normal; >1 == coincident |
466 int fOppValue; // normally 0 -- when binary coincident edges combine, opp v
alue goes here | 495 int fOppValue; // normally 0 -- when binary coincident edges combine, opp v
alue goes here |
467 int fTopTTry; // specifies direction and t value to try next | 496 int fTopTTry; // specifies direction and t value to try next |
468 bool fDone; // if set, this span to next higher T has been processed | 497 bool fDone; // if set, this span to next higher T has been processed |
469 }; | 498 }; |
470 | 499 |
471 #endif | 500 #endif |
OLD | NEW |