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 SkOpSegment_DEFINE | 7 #ifndef SkOpSegment_DEFINE |
8 #define SkOpSegment_DEFINE | 8 #define SkOpSegment_DEFINE |
9 | 9 |
10 #include "SkOpAngle.h" | 10 #include "SkOpAngle.h" |
11 #include "SkOpSpan.h" | 11 #include "SkOpSpan.h" |
12 #include "SkOpTAllocator.h" | 12 #include "SkOpTAllocator.h" |
13 #include "SkPathOpsBounds.h" | 13 #include "SkPathOpsBounds.h" |
14 #include "SkPathOpsCubic.h" | 14 #include "SkPathOpsCubic.h" |
15 #include "SkPathOpsCurve.h" | 15 #include "SkPathOpsCurve.h" |
16 | 16 |
17 struct SkDCurve; | 17 struct SkDCurve; |
18 class SkOpCoincidence; | 18 class SkOpCoincidence; |
19 class SkOpContour; | 19 class SkOpContour; |
20 enum class SkOpRayDir; | 20 enum class SkOpRayDir; |
21 struct SkOpRayHit; | 21 struct SkOpRayHit; |
22 class SkPathWriter; | 22 class SkPathWriter; |
23 | 23 |
24 class SkOpSegment { | 24 class SkOpSegment { |
25 public: | 25 public: |
26 enum AllowAlias { | 26 enum AliasMatch { |
27 kAllowAlias, | 27 kNoAliasMatch, |
28 kNoAlias | 28 kAllowAliasMatch, |
29 }; | 29 }; |
30 | 30 |
31 bool operator<(const SkOpSegment& rh) const { | 31 bool operator<(const SkOpSegment& rh) const { |
32 return fBounds.fTop < rh.fBounds.fTop; | 32 return fBounds.fTop < rh.fBounds.fTop; |
33 } | 33 } |
34 | 34 |
35 SkOpAngle* activeAngle(SkOpSpanBase* start, SkOpSpanBase** startPtr, SkOpSpa
nBase** endPtr, | 35 SkOpAngle* activeAngle(SkOpSpanBase* start, SkOpSpanBase** startPtr, SkOpSpa
nBase** endPtr, |
36 bool* done); | 36 bool* done); |
37 SkOpAngle* activeAngleInner(SkOpSpanBase* start, SkOpSpanBase** startPtr, | 37 SkOpAngle* activeAngleInner(SkOpSpanBase* start, SkOpSpanBase** startPtr, |
38 SkOpSpanBase** endPtr, bool* done); | 38 SkOpSpanBase** endPtr, bool* done); |
39 SkOpAngle* activeAngleOther(SkOpSpanBase* start, SkOpSpanBase** startPtr, | 39 SkOpAngle* activeAngleOther(SkOpSpanBase* start, SkOpSpanBase** startPtr, |
40 SkOpSpanBase** endPtr, bool* done); | 40 SkOpSpanBase** endPtr, bool* done); |
41 bool activeOp(SkOpSpanBase* start, SkOpSpanBase* end, int xorMiMask, int xor
SuMask, | 41 bool activeOp(SkOpSpanBase* start, SkOpSpanBase* end, int xorMiMask, int xor
SuMask, |
42 SkPathOp op); | 42 SkPathOp op); |
43 bool activeOp(int xorMiMask, int xorSuMask, SkOpSpanBase* start, SkOpSpanBas
e* end, SkPathOp op, | 43 bool activeOp(int xorMiMask, int xorSuMask, SkOpSpanBase* start, SkOpSpanBas
e* end, SkPathOp op, |
44 int* sumMiWinding, int* sumSuWinding); | 44 int* sumMiWinding, int* sumSuWinding); |
45 | 45 |
46 bool activeWinding(SkOpSpanBase* start, SkOpSpanBase* end); | 46 bool activeWinding(SkOpSpanBase* start, SkOpSpanBase* end); |
47 bool activeWinding(SkOpSpanBase* start, SkOpSpanBase* end, int* sumWinding); | 47 bool activeWinding(SkOpSpanBase* start, SkOpSpanBase* end, int* sumWinding); |
48 void addAlignIntersection(SkOpPtT& endPtT, SkPoint& oldPt, | |
49 SkOpContourHead* contourList, SkChunkAlloc* allocator); | |
50 | |
51 void addAlignIntersections(SkOpContourHead* contourList, SkChunkAlloc* alloc
ator) { | |
52 this->addAlignIntersection(*fHead.ptT(), fOriginal[0], contourList, allo
cator); | |
53 this->addAlignIntersection(*fTail.ptT(), fOriginal[1], contourList, allo
cator); | |
54 } | |
55 | 48 |
56 SkOpSegment* addConic(SkPoint pts[3], SkScalar weight, SkOpContour* parent)
{ | 49 SkOpSegment* addConic(SkPoint pts[3], SkScalar weight, SkOpContour* parent)
{ |
57 init(pts, weight, parent, SkPath::kConic_Verb); | 50 init(pts, weight, parent, SkPath::kConic_Verb); |
58 SkDCurve curve; | 51 SkDCurve curve; |
59 curve.fConic.set(pts, weight); | 52 curve.fConic.set(pts, weight); |
60 curve.setConicBounds(pts, weight, 0, 1, &fBounds); | 53 curve.setConicBounds(pts, weight, 0, 1, &fBounds); |
61 return this; | 54 return this; |
62 } | 55 } |
63 | 56 |
64 SkOpSegment* addCubic(SkPoint pts[4], SkOpContour* parent) { | 57 SkOpSegment* addCubic(SkPoint pts[4], SkOpContour* parent) { |
65 init(pts, 1, parent, SkPath::kCubic_Verb); | 58 init(pts, 1, parent, SkPath::kCubic_Verb); |
66 SkDCurve curve; | 59 SkDCurve curve; |
67 curve.fCubic.set(pts); | 60 curve.fCubic.set(pts); |
68 curve.setCubicBounds(pts, 1, 0, 1, &fBounds); | 61 curve.setCubicBounds(pts, 1, 0, 1, &fBounds); |
69 return this; | 62 return this; |
70 } | 63 } |
71 | 64 |
72 bool addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end, SkPathWr
iter* path) const; | 65 bool addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end, SkPathWr
iter* path) const; |
73 | 66 |
74 SkOpAngle* addEndSpan(SkChunkAlloc* allocator) { | 67 SkOpAngle* addEndSpan() { |
75 SkOpAngle* angle = SkOpTAllocator<SkOpAngle>::Allocate(allocator); | 68 SkOpAngle* angle = SkOpTAllocator<SkOpAngle>::Allocate(this->globalState
()->allocator()); |
76 angle->set(&fTail, fTail.prev()); | 69 angle->set(&fTail, fTail.prev()); |
77 fTail.setFromAngle(angle); | 70 fTail.setFromAngle(angle); |
78 return angle; | 71 return angle; |
79 } | 72 } |
80 | 73 |
| 74 bool addExpanded(double newT, const SkOpSpanBase* test, bool* startOver); |
| 75 |
81 SkOpSegment* addLine(SkPoint pts[2], SkOpContour* parent) { | 76 SkOpSegment* addLine(SkPoint pts[2], SkOpContour* parent) { |
82 init(pts, 1, parent, SkPath::kLine_Verb); | 77 init(pts, 1, parent, SkPath::kLine_Verb); |
83 fBounds.set(pts, 2); | 78 fBounds.set(pts, 2); |
84 return this; | 79 return this; |
85 } | 80 } |
86 | 81 |
87 SkOpPtT* addMissing(double t, SkOpSegment* opp, SkChunkAlloc* ); | 82 SkOpPtT* addMissing(double t, SkOpSegment* opp, bool* allExist); |
88 | 83 |
89 SkOpAngle* addStartSpan(SkChunkAlloc* allocator) { | 84 SkOpAngle* addStartSpan() { |
90 SkOpAngle* angle = SkOpTAllocator<SkOpAngle>::Allocate(allocator); | 85 SkOpAngle* angle = SkOpTAllocator<SkOpAngle>::Allocate(this->globalState
()->allocator()); |
91 angle->set(&fHead, fHead.next()); | 86 angle->set(&fHead, fHead.next()); |
92 fHead.setToAngle(angle); | 87 fHead.setToAngle(angle); |
93 return angle; | 88 return angle; |
94 } | 89 } |
95 | 90 |
96 SkOpSegment* addQuad(SkPoint pts[3], SkOpContour* parent) { | 91 SkOpSegment* addQuad(SkPoint pts[3], SkOpContour* parent) { |
97 init(pts, 1, parent, SkPath::kQuad_Verb); | 92 init(pts, 1, parent, SkPath::kQuad_Verb); |
98 SkDCurve curve; | 93 SkDCurve curve; |
99 curve.fQuad.set(pts); | 94 curve.fQuad.set(pts); |
100 curve.setQuadBounds(pts, 1, 0, 1, &fBounds); | 95 curve.setQuadBounds(pts, 1, 0, 1, &fBounds); |
101 return this; | 96 return this; |
102 } | 97 } |
103 | 98 |
104 SkOpPtT* addT(double t, AllowAlias , SkChunkAlloc* ); | 99 SkOpPtT* addT(double t, AliasMatch, bool* allocated); |
105 | 100 |
106 void align(); | 101 template<typename T> T* allocateArray(int count) { |
| 102 return SkOpTAllocator<T>::AllocateArray(this->globalState()->allocator()
, count); |
| 103 } |
107 | 104 |
108 const SkPathOpsBounds& bounds() const { | 105 const SkPathOpsBounds& bounds() const { |
109 return fBounds; | 106 return fBounds; |
110 } | 107 } |
111 | 108 |
112 void bumpCount() { | 109 void bumpCount() { |
113 ++fCount; | 110 ++fCount; |
114 } | 111 } |
115 | 112 |
116 void calcAngles(SkChunkAlloc*); | 113 void calcAngles(); |
117 bool collapsed() const; | 114 bool collapsed() const; |
118 static void ComputeOneSum(const SkOpAngle* baseAngle, SkOpAngle* nextAngle, | 115 static void ComputeOneSum(const SkOpAngle* baseAngle, SkOpAngle* nextAngle, |
119 SkOpAngle::IncludeType ); | 116 SkOpAngle::IncludeType ); |
120 static void ComputeOneSumReverse(SkOpAngle* baseAngle, SkOpAngle* nextAngle, | 117 static void ComputeOneSumReverse(SkOpAngle* baseAngle, SkOpAngle* nextAngle, |
121 SkOpAngle::IncludeType ); | 118 SkOpAngle::IncludeType ); |
122 int computeSum(SkOpSpanBase* start, SkOpSpanBase* end, SkOpAngle::IncludeTyp
e includeType); | 119 int computeSum(SkOpSpanBase* start, SkOpSpanBase* end, SkOpAngle::IncludeTyp
e includeType); |
123 | 120 |
| 121 void clearAll(); |
| 122 void clearOne(SkOpSpan* span); |
| 123 static void ClearVisited(SkOpSpanBase* span); |
| 124 bool contains(double t) const; |
| 125 |
124 SkOpContour* contour() const { | 126 SkOpContour* contour() const { |
125 return fContour; | 127 return fContour; |
126 } | 128 } |
127 | 129 |
128 int count() const { | 130 int count() const { |
129 return fCount; | 131 return fCount; |
130 } | 132 } |
131 | 133 |
132 void debugAddAngle(double startT, double endT, SkChunkAlloc*); | 134 void debugAddAngle(double startT, double endT); |
133 void debugAddAlignIntersection(const char* id, SkPathOpsDebug::GlitchLog* gl
itches, | 135 const SkOpPtT* debugAddT(double t, AliasMatch , bool* allocated) const; |
134 const SkOpPtT& endPtT, const SkPoint& oldPt, | |
135 const SkOpContourHead* ) const; | |
136 | |
137 void debugAddAlignIntersections(const char* id, SkPathOpsDebug::GlitchLog* g
litches, | |
138 SkOpContourHead* contourList) const { | |
139 this->debugAddAlignIntersection(id, glitches, *fHead.ptT(), fOriginal[0]
, contourList); | |
140 this->debugAddAlignIntersection(id, glitches, *fTail.ptT(), fOriginal[1]
, contourList); | |
141 } | |
142 | |
143 bool debugAddMissing(double t, const SkOpSegment* opp) const; | |
144 void debugAlign(const char* id, SkPathOpsDebug::GlitchLog* glitches) const; | |
145 const SkOpAngle* debugAngle(int id) const; | 136 const SkOpAngle* debugAngle(int id) const; |
146 #if DEBUG_ANGLE | 137 #if DEBUG_ANGLE |
147 void debugCheckAngleCoin() const; | 138 void debugCheckAngleCoin() const; |
148 #endif | 139 #endif |
| 140 #if DEBUG_COINCIDENCE_VERBOSE |
149 void debugCheckHealth(const char* id, SkPathOpsDebug::GlitchLog* ) const; | 141 void debugCheckHealth(const char* id, SkPathOpsDebug::GlitchLog* ) const; |
| 142 void debugClearAll(const char* id, SkPathOpsDebug::GlitchLog* glitches) cons
t; |
| 143 void debugClearOne(const SkOpSpan* span, const char* id, SkPathOpsDebug::Gli
tchLog* glitches) const; |
| 144 #endif |
| 145 const SkOpCoincidence* debugCoincidence() const; |
150 SkOpContour* debugContour(int id); | 146 SkOpContour* debugContour(int id); |
151 void debugFindCollapsed(const char* id, SkPathOpsDebug::GlitchLog* glitches)
const; | |
152 | 147 |
153 int debugID() const { | 148 int debugID() const { |
154 return SkDEBUGRELEASE(fID, -1); | 149 return SkDEBUGRELEASE(fID, -1); |
155 } | 150 } |
156 | 151 |
157 SkOpAngle* debugLastAngle(); | 152 SkOpAngle* debugLastAngle(); |
158 void debugMissingCoincidence(const char* id, SkPathOpsDebug::GlitchLog* glit
ches, | 153 #if DEBUG_COINCIDENCE_VERBOSE |
159 const SkOpCoincidence* coincidences) const; | 154 void debugMissingCoincidence(const char* id, SkPathOpsDebug::GlitchLog* glit
ches) const; |
160 void debugMoveMultiples(const char* id, SkPathOpsDebug::GlitchLog* glitches)
const; | 155 void debugMoveMultiples(const char* id, SkPathOpsDebug::GlitchLog* glitches)
const; |
161 void debugMoveNearby(const char* id, SkPathOpsDebug::GlitchLog* glitches) co
nst; | 156 void debugMoveNearby(const char* id, SkPathOpsDebug::GlitchLog* glitches) co
nst; |
| 157 #endif |
162 const SkOpPtT* debugPtT(int id) const; | 158 const SkOpPtT* debugPtT(int id) const; |
163 void debugReset(); | 159 void debugReset(); |
164 const SkOpSegment* debugSegment(int id) const; | 160 const SkOpSegment* debugSegment(int id) const; |
165 | 161 |
166 #if DEBUG_ACTIVE_SPANS | 162 #if DEBUG_ACTIVE_SPANS |
167 void debugShowActiveSpans() const; | 163 void debugShowActiveSpans() const; |
168 #endif | 164 #endif |
169 #if DEBUG_MARK_DONE | 165 #if DEBUG_MARK_DONE |
170 void debugShowNewWinding(const char* fun, const SkOpSpan* span, int winding)
; | 166 void debugShowNewWinding(const char* fun, const SkOpSpan* span, int winding)
; |
171 void debugShowNewWinding(const char* fun, const SkOpSpan* span, int winding,
int oppWinding); | 167 void debugShowNewWinding(const char* fun, const SkOpSpan* span, int winding,
int oppWinding); |
172 #endif | 168 #endif |
173 | 169 |
174 const SkOpSpanBase* debugSpan(int id) const; | 170 const SkOpSpanBase* debugSpan(int id) const; |
175 void debugValidate() const; | 171 void debugValidate() const; |
| 172 |
| 173 #if DEBUG_COINCIDENCE |
| 174 static void SkOpSegment::DebugClearVisited(const SkOpSpanBase* span); |
| 175 |
| 176 bool debugVisited() const { |
| 177 if (!fDebugVisited) { |
| 178 fDebugVisited = true; |
| 179 return false; |
| 180 } |
| 181 return true; |
| 182 } |
| 183 #endif |
| 184 |
176 void release(const SkOpSpan* ); | 185 void release(const SkOpSpan* ); |
177 double distSq(double t, const SkOpAngle* opp) const; | 186 double distSq(double t, const SkOpAngle* opp) const; |
178 | 187 |
179 bool done() const { | 188 bool done() const { |
180 SkASSERT(fDoneCount <= fCount); | 189 SkASSERT(this->globalState()->debugSkipAssert() || fDoneCount <= fCount)
; |
181 return fDoneCount == fCount; | 190 return fDoneCount == fCount; |
182 } | 191 } |
183 | 192 |
184 bool done(const SkOpAngle* angle) const { | 193 bool done(const SkOpAngle* angle) const { |
185 return angle->start()->starter(angle->end())->done(); | 194 return angle->start()->starter(angle->end())->done(); |
186 } | 195 } |
187 | 196 |
188 SkDPoint dPtAtT(double mid) const { | 197 SkDPoint dPtAtT(double mid) const { |
189 return (*CurveDPointAtT[fVerb])(fPts, fWeight, mid); | 198 return (*CurveDPointAtT[fVerb])(fPts, fWeight, mid); |
190 } | 199 } |
191 | 200 |
192 SkDVector dSlopeAtT(double mid) const { | 201 SkDVector dSlopeAtT(double mid) const { |
193 return (*CurveDSlopeAtT[fVerb])(fPts, fWeight, mid); | 202 return (*CurveDSlopeAtT[fVerb])(fPts, fWeight, mid); |
194 } | 203 } |
195 | 204 |
196 void dump() const; | 205 void dump() const; |
197 void dumpAll() const; | 206 void dumpAll() const; |
198 void dumpAngles() const; | 207 void dumpAngles() const; |
199 void dumpCoin() const; | 208 void dumpCoin() const; |
200 void dumpPts(const char* prefix = "seg") const; | 209 void dumpPts(const char* prefix = "seg") const; |
201 void dumpPtsInner(const char* prefix = "seg") const; | 210 void dumpPtsInner(const char* prefix = "seg") const; |
202 | 211 |
203 void findCollapsed(); | 212 const SkOpPtT* existing(double t, const SkOpSegment* opp) const; |
204 SkOpSegment* findNextOp(SkTDArray<SkOpSpanBase*>* chase, SkOpSpanBase** next
Start, | 213 SkOpSegment* findNextOp(SkTDArray<SkOpSpanBase*>* chase, SkOpSpanBase** next
Start, |
205 SkOpSpanBase** nextEnd, bool* unsortable, SkPathOp
op, | 214 SkOpSpanBase** nextEnd, bool* unsortable, SkPathOp
op, |
206 int xorMiMask, int xorSuMask); | 215 int xorMiMask, int xorSuMask); |
207 SkOpSegment* findNextWinding(SkTDArray<SkOpSpanBase*>* chase, SkOpSpanBase**
nextStart, | 216 SkOpSegment* findNextWinding(SkTDArray<SkOpSpanBase*>* chase, SkOpSpanBase**
nextStart, |
208 SkOpSpanBase** nextEnd, bool* unsortable); | 217 SkOpSpanBase** nextEnd, bool* unsortable); |
209 SkOpSegment* findNextXor(SkOpSpanBase** nextStart, SkOpSpanBase** nextEnd, b
ool* unsortable); | 218 SkOpSegment* findNextXor(SkOpSpanBase** nextStart, SkOpSpanBase** nextEnd, b
ool* unsortable); |
210 SkOpSpan* findSortableTop(SkOpContour* ); | 219 SkOpSpan* findSortableTop(SkOpContour* ); |
211 SkOpGlobalState* globalState() const; | 220 SkOpGlobalState* globalState() const; |
212 | 221 |
213 const SkOpSpan* head() const { | 222 const SkOpSpan* head() const { |
214 return &fHead; | 223 return &fHead; |
215 } | 224 } |
216 | 225 |
217 SkOpSpan* head() { | 226 SkOpSpan* head() { |
218 return &fHead; | 227 return &fHead; |
219 } | 228 } |
220 | 229 |
221 void init(SkPoint pts[], SkScalar weight, SkOpContour* parent, SkPath::Verb
verb); | 230 void init(SkPoint pts[], SkScalar weight, SkOpContour* parent, SkPath::Verb
verb); |
222 | 231 |
223 SkOpSpan* insert(SkOpSpan* prev, SkChunkAlloc* allocator) { | 232 SkOpSpan* insert(SkOpSpan* prev) { |
224 SkOpSpan* result = SkOpTAllocator<SkOpSpan>::Allocate(allocator); | 233 SkOpSpan* result = SkOpTAllocator<SkOpSpan>::Allocate(this->globalState(
)->allocator()); |
225 SkOpSpanBase* next = prev->next(); | 234 SkOpSpanBase* next = prev->next(); |
226 result->setPrev(prev); | 235 result->setPrev(prev); |
227 prev->setNext(result); | 236 prev->setNext(result); |
228 SkDEBUGCODE(result->ptT()->fT = 0); | 237 SkDEBUGCODE(result->ptT()->fT = 0); |
229 result->setNext(next); | 238 result->setNext(next); |
230 if (next) { | 239 if (next) { |
231 next->setPrev(result); | 240 next->setPrev(result); |
232 } | 241 } |
233 return result; | 242 return result; |
234 } | 243 } |
(...skipping 27 matching lines...) Expand all Loading... |
262 bool markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, int winding
, | 271 bool markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, int winding
, |
263 SkOpSpanBase** lastPtr); | 272 SkOpSpanBase** lastPtr); |
264 bool markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, int winding
, | 273 bool markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, int winding
, |
265 int oppWinding, SkOpSpanBase** lastPtr); | 274 int oppWinding, SkOpSpanBase** lastPtr); |
266 SkOpSpanBase* markAngle(int maxWinding, int sumWinding, const SkOpAngle* ang
le); | 275 SkOpSpanBase* markAngle(int maxWinding, int sumWinding, const SkOpAngle* ang
le); |
267 SkOpSpanBase* markAngle(int maxWinding, int sumWinding, int oppMaxWinding, i
nt oppSumWinding, | 276 SkOpSpanBase* markAngle(int maxWinding, int sumWinding, int oppMaxWinding, i
nt oppSumWinding, |
268 const SkOpAngle* angle); | 277 const SkOpAngle* angle); |
269 void markDone(SkOpSpan* ); | 278 void markDone(SkOpSpan* ); |
270 bool markWinding(SkOpSpan* , int winding); | 279 bool markWinding(SkOpSpan* , int winding); |
271 bool markWinding(SkOpSpan* , int winding, int oppWinding); | 280 bool markWinding(SkOpSpan* , int winding, int oppWinding); |
272 bool match(const SkOpPtT* span, const SkOpSegment* parent, double t, const S
kPoint& pt) const; | 281 bool match(const SkOpPtT* span, const SkOpSegment* parent, double t, const S
kPoint& pt, |
273 bool missingCoincidence(SkOpCoincidence* coincidences, SkChunkAlloc* allocat
or); | 282 AliasMatch ) const; |
| 283 bool missingCoincidence(); |
274 bool moveMultiples(); | 284 bool moveMultiples(); |
275 void moveNearby(); | 285 void moveNearby(); |
276 | 286 |
277 SkOpSegment* next() const { | 287 SkOpSegment* next() const { |
278 return fNext; | 288 return fNext; |
279 } | 289 } |
280 | 290 |
281 SkOpSegment* nextChase(SkOpSpanBase** , int* step, SkOpSpan** , SkOpSpanBase
** last) const; | 291 SkOpSegment* nextChase(SkOpSpanBase** , int* step, SkOpSpan** , SkOpSpanBase
** last) const; |
282 bool operand() const; | 292 bool operand() const; |
283 | 293 |
(...skipping 11 matching lines...) Expand all Loading... |
295 | 305 |
296 SkPoint ptAtT(double mid) const { | 306 SkPoint ptAtT(double mid) const { |
297 return (*CurvePointAtT[fVerb])(fPts, fWeight, mid); | 307 return (*CurvePointAtT[fVerb])(fPts, fWeight, mid); |
298 } | 308 } |
299 | 309 |
300 const SkPoint* pts() const { | 310 const SkPoint* pts() const { |
301 return fPts; | 311 return fPts; |
302 } | 312 } |
303 | 313 |
304 bool ptsDisjoint(const SkOpPtT& span, const SkOpPtT& test) const { | 314 bool ptsDisjoint(const SkOpPtT& span, const SkOpPtT& test) const { |
| 315 SkASSERT(this == span.segment()); |
| 316 SkASSERT(this == test.segment()); |
305 return ptsDisjoint(span.fT, span.fPt, test.fT, test.fPt); | 317 return ptsDisjoint(span.fT, span.fPt, test.fT, test.fPt); |
306 } | 318 } |
307 | 319 |
308 bool ptsDisjoint(const SkOpPtT& span, double t, const SkPoint& pt) const { | 320 bool ptsDisjoint(const SkOpPtT& span, double t, const SkPoint& pt) const { |
| 321 SkASSERT(this == span.segment()); |
309 return ptsDisjoint(span.fT, span.fPt, t, pt); | 322 return ptsDisjoint(span.fT, span.fPt, t, pt); |
310 } | 323 } |
311 | 324 |
| 325 bool ptsDisjoint(const SkOpSpanBase* span, const SkOpSpanBase* test) const { |
| 326 SkASSERT(this == span->segment()); |
| 327 SkASSERT(this == test->segment()); |
| 328 return ptsDisjoint(span->t(), span->pt(), test->t(), test->pt()); |
| 329 } |
| 330 |
312 bool ptsDisjoint(double t1, const SkPoint& pt1, double t2, const SkPoint& pt
2) const; | 331 bool ptsDisjoint(double t1, const SkPoint& pt1, double t2, const SkPoint& pt
2) const; |
313 | 332 |
314 void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, | 333 void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkC
hunkAlloc*); |
315 SkChunkAlloc* allocator); | 334 |
| 335 #if DEBUG_COINCIDENCE |
| 336 void resetDebugVisited() const { |
| 337 fDebugVisited = false; |
| 338 } |
| 339 #endif |
316 | 340 |
317 void resetVisited() { | 341 void resetVisited() { |
318 fVisited = false; | 342 fVisited = false; |
319 } | 343 } |
320 | 344 |
321 void setContour(SkOpContour* contour) { | 345 void setContour(SkOpContour* contour) { |
322 fContour = contour; | 346 fContour = contour; |
323 } | 347 } |
324 | 348 |
325 void setNext(SkOpSegment* next) { | 349 void setNext(SkOpSegment* next) { |
326 fNext = next; | 350 fNext = next; |
327 } | 351 } |
328 | 352 |
329 void setPrev(SkOpSegment* prev) { | 353 void setPrev(SkOpSegment* prev) { |
330 fPrev = prev; | 354 fPrev = prev; |
331 } | 355 } |
332 | 356 |
333 void setVisited() { | |
334 fVisited = true; | |
335 } | |
336 | |
337 void setUpWinding(SkOpSpanBase* start, SkOpSpanBase* end, int* maxWinding, i
nt* sumWinding) { | 357 void setUpWinding(SkOpSpanBase* start, SkOpSpanBase* end, int* maxWinding, i
nt* sumWinding) { |
338 int deltaSum = SpanSign(start, end); | 358 int deltaSum = SpanSign(start, end); |
339 *maxWinding = *sumWinding; | 359 *maxWinding = *sumWinding; |
340 if (*sumWinding == SK_MinS32) { | 360 if (*sumWinding == SK_MinS32) { |
341 return; | 361 return; |
342 } | 362 } |
343 *sumWinding -= deltaSum; | 363 *sumWinding -= deltaSum; |
344 } | 364 } |
345 | 365 |
346 void setUpWindings(SkOpSpanBase* start, SkOpSpanBase* end, int* sumMiWinding
, | 366 void setUpWindings(SkOpSpanBase* start, SkOpSpanBase* end, int* sumMiWinding
, |
347 int* maxWinding, int* sumWinding); | 367 int* maxWinding, int* sumWinding); |
348 void setUpWindings(SkOpSpanBase* start, SkOpSpanBase* end, int* sumMiWinding
, int* sumSuWinding, | 368 void setUpWindings(SkOpSpanBase* start, SkOpSpanBase* end, int* sumMiWinding
, int* sumSuWinding, |
349 int* maxWinding, int* sumWinding, int* oppMaxWinding, int
* oppSumWinding); | 369 int* maxWinding, int* sumWinding, int* oppMaxWinding, int
* oppSumWinding); |
350 void sortAngles(); | 370 void sortAngles(); |
| 371 bool spansNearby(const SkOpSpanBase* ref, const SkOpSpanBase* check) const; |
351 | 372 |
352 static int SpanSign(const SkOpSpanBase* start, const SkOpSpanBase* end) { | 373 static int SpanSign(const SkOpSpanBase* start, const SkOpSpanBase* end) { |
353 int result = start->t() < end->t() ? -start->upCast()->windValue() | 374 int result = start->t() < end->t() ? -start->upCast()->windValue() |
354 : end->upCast()->windValue(); | 375 : end->upCast()->windValue(); |
355 return result; | 376 return result; |
356 } | 377 } |
357 | 378 |
358 SkOpAngle* spanToAngle(SkOpSpanBase* start, SkOpSpanBase* end) { | 379 SkOpAngle* spanToAngle(SkOpSpanBase* start, SkOpSpanBase* end) { |
359 SkASSERT(start != end); | 380 SkASSERT(start != end); |
360 return start->t() < end->t() ? start->upCast()->toAngle() : start->fromA
ngle(); | 381 return start->t() < end->t() ? start->upCast()->toAngle() : start->fromA
ngle(); |
361 } | 382 } |
362 | 383 |
363 bool subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end, SkDCurve*
result) const; | 384 bool subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end, SkDCurve*
result) const; |
364 bool subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end, SkOpCurve
* result) const; | 385 bool subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end, SkOpCurve
* result) const; |
365 | 386 |
366 const SkOpSpanBase* tail() const { | 387 const SkOpSpanBase* tail() const { |
367 return &fTail; | 388 return &fTail; |
368 } | 389 } |
369 | 390 |
370 SkOpSpanBase* tail() { | 391 SkOpSpanBase* tail() { |
371 return &fTail; | 392 return &fTail; |
372 } | 393 } |
373 | 394 |
374 bool testForCoincidence(const SkOpPtT* priorPtT, const SkOpPtT* ptT, const S
kOpSpanBase* prior, | 395 bool testForCoincidence(const SkOpPtT* priorPtT, const SkOpPtT* ptT, const S
kOpSpanBase* prior, |
375 const SkOpSpanBase* spanBase, const SkOpSegment* opp, SkScalar flatn
essLimit) const; | 396 const SkOpSpanBase* spanBase, const SkOpSegment* opp) const; |
376 | 397 |
377 void undoneSpan(SkOpSpanBase** start, SkOpSpanBase** end); | 398 void undoneSpan(SkOpSpanBase** start, SkOpSpanBase** end); |
| 399 bool uniqueT(double t, AliasMatch allowAlias) const; |
378 int updateOppWinding(const SkOpSpanBase* start, const SkOpSpanBase* end) con
st; | 400 int updateOppWinding(const SkOpSpanBase* start, const SkOpSpanBase* end) con
st; |
379 int updateOppWinding(const SkOpAngle* angle) const; | 401 int updateOppWinding(const SkOpAngle* angle) const; |
380 int updateOppWindingReverse(const SkOpAngle* angle) const; | 402 int updateOppWindingReverse(const SkOpAngle* angle) const; |
381 int updateWinding(SkOpSpanBase* start, SkOpSpanBase* end); | 403 int updateWinding(SkOpSpanBase* start, SkOpSpanBase* end); |
382 int updateWinding(SkOpAngle* angle); | 404 int updateWinding(SkOpAngle* angle); |
383 int updateWindingReverse(const SkOpAngle* angle); | 405 int updateWindingReverse(const SkOpAngle* angle); |
384 | 406 |
385 static bool UseInnerWinding(int outerWinding, int innerWinding); | 407 static bool UseInnerWinding(int outerWinding, int innerWinding); |
386 | 408 |
387 SkPath::Verb verb() const { | 409 SkPath::Verb verb() const { |
388 return fVerb; | 410 return fVerb; |
389 } | 411 } |
390 | 412 |
391 // look for two different spans that point to the same opposite segment | 413 // look for two different spans that point to the same opposite segment |
392 bool visited() { | 414 bool visited() { |
393 if (!fVisited) { | 415 if (!fVisited) { |
394 fVisited = true; | 416 fVisited = true; |
395 return false; | 417 return false; |
396 } | 418 } |
397 return true; | 419 return true; |
398 } | 420 } |
399 | 421 |
400 SkScalar weight() const { | 422 SkScalar weight() const { |
401 return fWeight; | 423 return fWeight; |
402 } | 424 } |
403 | 425 |
404 SkOpSpan* windingSpanAtT(double tHit); | 426 SkOpSpan* windingSpanAtT(double tHit); |
405 int windSum(const SkOpAngle* angle) const; | 427 int windSum(const SkOpAngle* angle) const; |
406 | 428 |
407 SkPoint* writablePt(bool end) { | |
408 return &fPts[end ? SkPathOpsVerbToPoints(fVerb) : 0]; | |
409 } | |
410 | |
411 private: | 429 private: |
412 SkOpSpan fHead; // the head span always has its t set to zero | 430 SkOpSpan fHead; // the head span always has its t set to zero |
413 SkOpSpanBase fTail; // the tail span always has its t set to one | 431 SkOpSpanBase fTail; // the tail span always has its t set to one |
414 SkOpContour* fContour; | 432 SkOpContour* fContour; |
415 SkOpSegment* fNext; // forward-only linked list used by contour to walk the
segments | 433 SkOpSegment* fNext; // forward-only linked list used by contour to walk the
segments |
416 const SkOpSegment* fPrev; | 434 const SkOpSegment* fPrev; |
417 SkPoint fOriginal[2]; // if aligned, the original unaligned points are here | |
418 SkPoint* fPts; // pointer into array of points owned by edge builder that m
ay be tweaked | 435 SkPoint* fPts; // pointer into array of points owned by edge builder that m
ay be tweaked |
419 SkPathOpsBounds fBounds; // tight bounds | 436 SkPathOpsBounds fBounds; // tight bounds |
420 SkScalar fWeight; | 437 SkScalar fWeight; |
421 int fCount; // number of spans (one for a non-intersecting segment) | 438 int fCount; // number of spans (one for a non-intersecting segment) |
422 int fDoneCount; // number of processed spans (zero initially) | 439 int fDoneCount; // number of processed spans (zero initially) |
423 SkPath::Verb fVerb; | 440 SkPath::Verb fVerb; |
424 bool fVisited; // used by missing coincidence check | 441 bool fVisited; // used by missing coincidence check |
| 442 #if DEBUG_COINCIDENCE |
| 443 mutable bool fDebugVisited; // used by debug missing coincidence check |
| 444 #endif |
425 SkDEBUGCODE(int fID); | 445 SkDEBUGCODE(int fID); |
426 }; | 446 }; |
427 | 447 |
428 #endif | 448 #endif |
OLD | NEW |