/src/skia/src/pathops/SkOpSpan.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2012 Google Inc. |
3 | | * |
4 | | * Use of this source code is governed by a BSD-style license that can be |
5 | | * found in the LICENSE file. |
6 | | */ |
7 | | #ifndef SkOpSpan_DEFINED |
8 | | #define SkOpSpan_DEFINED |
9 | | |
10 | | #include "include/core/SkPoint.h" |
11 | | #include "include/core/SkTypes.h" |
12 | | #include "include/private/base/SkDebug.h" |
13 | | #include "include/private/base/SkMath.h" |
14 | | #include "src/pathops/SkPathOpsTypes.h" |
15 | | |
16 | | class SkOpAngle; |
17 | | class SkOpCoincidence; |
18 | | class SkOpContour; |
19 | | class SkOpSegment; |
20 | | class SkOpSpan; |
21 | | class SkOpSpanBase; |
22 | | |
23 | | // subset of op span used by terminal span (when t is equal to one) |
24 | | class SkOpPtT { |
25 | | public: |
26 | | enum { |
27 | | kIsAlias = 1, |
28 | | kIsDuplicate = 1 |
29 | | }; |
30 | | |
31 | | const SkOpPtT* active() const; |
32 | | |
33 | | // please keep in sync with debugAddOpp() |
34 | 36.0M | void addOpp(SkOpPtT* opp, SkOpPtT* oppPrev) { |
35 | 36.0M | SkOpPtT* oldNext = this->fNext; |
36 | 36.0M | SkASSERT(this != opp); |
37 | 36.0M | this->fNext = opp; |
38 | 36.0M | SkASSERT(oppPrev != oldNext); |
39 | 36.0M | oppPrev->fNext = oldNext; |
40 | 36.0M | } |
41 | | |
42 | | bool alias() const; |
43 | 321M | bool coincident() const { return fCoincident; } |
44 | | bool contains(const SkOpPtT* ) const; |
45 | | bool contains(const SkOpSegment*, const SkPoint& ) const; |
46 | | bool contains(const SkOpSegment*, double t) const; |
47 | | const SkOpPtT* contains(const SkOpSegment* ) const; |
48 | | SkOpContour* contour() const; |
49 | | |
50 | 0 | int debugID() const { |
51 | 0 | return SkDEBUGRELEASE(fID, -1); |
52 | 0 | } |
53 | | |
54 | | void debugAddOpp(const SkOpPtT* opp, const SkOpPtT* oppPrev) const; |
55 | | const SkOpAngle* debugAngle(int id) const; |
56 | | const SkOpCoincidence* debugCoincidence() const; |
57 | | bool debugContains(const SkOpPtT* ) const; |
58 | | const SkOpPtT* debugContains(const SkOpSegment* check) const; |
59 | | SkOpContour* debugContour(int id) const; |
60 | | const SkOpPtT* debugEnder(const SkOpPtT* end) const; |
61 | | int debugLoopLimit(bool report) const; |
62 | | bool debugMatchID(int id) const; |
63 | | const SkOpPtT* debugOppPrev(const SkOpPtT* opp) const; |
64 | | const SkOpPtT* debugPtT(int id) const; |
65 | | void debugResetCoinT() const; |
66 | | const SkOpSegment* debugSegment(int id) const; |
67 | | void debugSetCoinT(int ) const; |
68 | | const SkOpSpanBase* debugSpan(int id) const; |
69 | | void debugValidate() const; |
70 | | |
71 | 14.8G | bool deleted() const { |
72 | 14.8G | return fDeleted; |
73 | 14.8G | } |
74 | | |
75 | 0 | bool duplicate() const { |
76 | 0 | return fDuplicatePt; |
77 | 0 | } |
78 | | |
79 | | void dump() const; // available to testing only |
80 | | void dumpAll() const; |
81 | | void dumpBase() const; |
82 | | |
83 | | const SkOpPtT* find(const SkOpSegment* ) const; |
84 | | SkOpGlobalState* globalState() const; |
85 | | void init(SkOpSpanBase* , double t, const SkPoint& , bool dup); |
86 | | |
87 | 83.7k | void insert(SkOpPtT* span) { |
88 | 83.7k | SkASSERT(span != this); |
89 | 83.7k | span->fNext = fNext; |
90 | 83.7k | fNext = span; |
91 | 83.7k | } |
92 | | |
93 | 33.3G | const SkOpPtT* next() const { |
94 | 33.3G | return fNext; |
95 | 33.3G | } |
96 | | |
97 | 9.51G | SkOpPtT* next() { |
98 | 9.51G | return fNext; |
99 | 9.51G | } |
100 | | |
101 | | bool onEnd() const; |
102 | | |
103 | | // returns nullptr if this is already in the opp ptT loop |
104 | 35.4M | SkOpPtT* oppPrev(const SkOpPtT* opp) const { |
105 | | // find the fOpp ptr to opp |
106 | 35.4M | SkOpPtT* oppPrev = opp->fNext; |
107 | 35.4M | if (oppPrev == this) { |
108 | 32.8k | return nullptr; |
109 | 32.8k | } |
110 | 176M | while (oppPrev->fNext != opp) { |
111 | 140M | oppPrev = oppPrev->fNext; |
112 | 140M | if (oppPrev == this) { |
113 | 102k | return nullptr; |
114 | 102k | } |
115 | 140M | } |
116 | 35.2M | return oppPrev; |
117 | 35.3M | } |
118 | | |
119 | | static bool Overlaps(const SkOpPtT* s1, const SkOpPtT* e1, const SkOpPtT* s2, |
120 | 29.1M | const SkOpPtT* e2, const SkOpPtT** sOut, const SkOpPtT** eOut) { |
121 | 29.1M | const SkOpPtT* start1 = s1->fT < e1->fT ? s1 : e1; |
122 | 29.1M | const SkOpPtT* start2 = s2->fT < e2->fT ? s2 : e2; |
123 | 29.1M | *sOut = between(s1->fT, start2->fT, e1->fT) ? start2 |
124 | 29.1M | : between(s2->fT, start1->fT, e2->fT) ? start1 : nullptr; |
125 | 29.1M | const SkOpPtT* end1 = s1->fT < e1->fT ? e1 : s1; |
126 | 29.1M | const SkOpPtT* end2 = s2->fT < e2->fT ? e2 : s2; |
127 | 29.1M | *eOut = between(s1->fT, end2->fT, e1->fT) ? end2 |
128 | 29.1M | : between(s2->fT, end1->fT, e2->fT) ? end1 : nullptr; |
129 | 29.1M | if (*sOut == *eOut) { |
130 | 3.88M | SkOPOBJASSERT(s1, start1->fT >= end2->fT || start2->fT >= end1->fT); |
131 | 3.88M | return false; |
132 | 3.88M | } |
133 | 25.2M | SkASSERT(!*sOut || *sOut != *eOut); |
134 | 25.2M | return *sOut && *eOut; |
135 | 29.1M | } |
136 | | |
137 | | bool ptAlreadySeen(const SkOpPtT* head) const; |
138 | | SkOpPtT* prev(); |
139 | | |
140 | | const SkOpSegment* segment() const; |
141 | | SkOpSegment* segment(); |
142 | | |
143 | 24.2M | void setCoincident() const { |
144 | 24.2M | SkOPASSERT(!fDeleted); |
145 | 24.2M | fCoincident = true; |
146 | 24.2M | } |
147 | | |
148 | | void setDeleted(); |
149 | | |
150 | 9.22M | void setSpan(const SkOpSpanBase* span) { |
151 | 9.22M | fSpan = const_cast<SkOpSpanBase*>(span); |
152 | 9.22M | } |
153 | | |
154 | 35.4G | const SkOpSpanBase* span() const { |
155 | 35.4G | return fSpan; |
156 | 35.4G | } |
157 | | |
158 | 9.23G | SkOpSpanBase* span() { |
159 | 9.23G | return fSpan; |
160 | 9.23G | } |
161 | | |
162 | 89.8M | const SkOpPtT* starter(const SkOpPtT* end) const { |
163 | 89.8M | return fT < end->fT ? this : end; |
164 | 89.8M | } |
165 | | |
166 | | double fT; |
167 | | SkPoint fPt; // cache of point value at this t |
168 | | protected: |
169 | | SkOpSpanBase* fSpan; // contains winding data |
170 | | SkOpPtT* fNext; // intersection on opposite curve or alias on this curve |
171 | | bool fDeleted; // set if removed from span list |
172 | | bool fDuplicatePt; // set if identical pt is somewhere in the next loop |
173 | | // below mutable since referrer is otherwise always const |
174 | | mutable bool fCoincident; // set if at some point a coincident span pointed here |
175 | | SkDEBUGCODE(int fID;) |
176 | | }; |
177 | | |
178 | | class SkOpSpanBase { |
179 | | public: |
180 | | enum class Collapsed { |
181 | | kNo, |
182 | | kYes, |
183 | | kError, |
184 | | }; |
185 | | |
186 | | bool addOpp(SkOpSpanBase* opp); |
187 | | |
188 | 122M | void bumpSpanAdds() { |
189 | 122M | ++fSpanAdds; |
190 | 122M | } |
191 | | |
192 | 10.0M | bool chased() const { |
193 | 10.0M | return fChased; |
194 | 10.0M | } |
195 | | |
196 | | void checkForCollapsedCoincidence(); |
197 | | |
198 | 0 | const SkOpSpanBase* coinEnd() const { |
199 | 0 | return fCoinEnd; |
200 | 0 | } |
201 | | |
202 | | Collapsed collapsed(double s, double e) const; |
203 | | bool contains(const SkOpSpanBase* ) const; |
204 | | const SkOpPtT* contains(const SkOpSegment* ) const; |
205 | | |
206 | 3.20M | bool containsCoinEnd(const SkOpSpanBase* coin) const { |
207 | 3.20M | SkASSERT(this != coin); |
208 | 3.20M | const SkOpSpanBase* next = this; |
209 | 15.7M | while ((next = next->fCoinEnd) != this) { |
210 | 14.2M | if (next == coin) { |
211 | 1.68M | return true; |
212 | 1.68M | } |
213 | 14.2M | } |
214 | 1.52M | return false; |
215 | 3.20M | } SkOpSpanBase::containsCoinEnd(SkOpSpanBase const*) const Line | Count | Source | 206 | 3.20M | bool containsCoinEnd(const SkOpSpanBase* coin) const { | 207 | 3.20M | SkASSERT(this != coin); | 208 | 3.20M | const SkOpSpanBase* next = this; | 209 | 15.7M | while ((next = next->fCoinEnd) != this) { | 210 | 14.2M | if (next == coin) { | 211 | 1.68M | return true; | 212 | 1.68M | } | 213 | 14.2M | } | 214 | 1.52M | return false; | 215 | 3.20M | } |
Unexecuted instantiation: SkOpSpanBase::containsCoinEnd(SkOpSpanBase const*) const |
216 | | |
217 | | bool containsCoinEnd(const SkOpSegment* ) const; |
218 | | SkOpContour* contour() const; |
219 | | |
220 | 0 | int debugBumpCount() { |
221 | 0 | return SkDEBUGRELEASE(++fCount, -1); |
222 | 0 | } |
223 | | |
224 | 0 | int debugID() const { |
225 | 0 | return SkDEBUGRELEASE(fID, -1); |
226 | 0 | } |
227 | | |
228 | | #if DEBUG_COIN |
229 | | void debugAddOpp(SkPathOpsDebug::GlitchLog* , const SkOpSpanBase* opp) const; |
230 | | #endif |
231 | | bool debugAlignedEnd(double t, const SkPoint& pt) const; |
232 | | bool debugAlignedInner() const; |
233 | | const SkOpAngle* debugAngle(int id) const; |
234 | | #if DEBUG_COIN |
235 | | void debugCheckForCollapsedCoincidence(SkPathOpsDebug::GlitchLog* ) const; |
236 | | #endif |
237 | | const SkOpCoincidence* debugCoincidence() const; |
238 | | bool debugCoinEndLoopCheck() const; |
239 | | SkOpContour* debugContour(int id) const; |
240 | | #ifdef SK_DEBUG |
241 | 0 | bool debugDeleted() const { return fDebugDeleted; } |
242 | | #endif |
243 | | #if DEBUG_COIN |
244 | | void debugInsertCoinEnd(SkPathOpsDebug::GlitchLog* , |
245 | | const SkOpSpanBase* ) const; |
246 | | void debugMergeMatches(SkPathOpsDebug::GlitchLog* log, |
247 | | const SkOpSpanBase* opp) const; |
248 | | #endif |
249 | | const SkOpPtT* debugPtT(int id) const; |
250 | | void debugResetCoinT() const; |
251 | | const SkOpSegment* debugSegment(int id) const; |
252 | | void debugSetCoinT(int ) const; |
253 | | #ifdef SK_DEBUG |
254 | 0 | void debugSetDeleted() { fDebugDeleted = true; } |
255 | | #endif |
256 | | const SkOpSpanBase* debugSpan(int id) const; |
257 | | const SkOpSpan* debugStarter(SkOpSpanBase const** endPtr) const; |
258 | | SkOpGlobalState* globalState() const; |
259 | | void debugValidate() const; |
260 | | |
261 | 282M | bool deleted() const { |
262 | 282M | return fPtT.deleted(); |
263 | 282M | } |
264 | | |
265 | | void dump() const; // available to testing only |
266 | | void dumpCoin() const; |
267 | | void dumpAll() const; |
268 | | void dumpBase() const; |
269 | | void dumpHead() const; |
270 | | |
271 | 1.51G | bool final() const { |
272 | 1.51G | return fPtT.fT == 1; |
273 | 1.51G | } |
274 | | |
275 | 343M | SkOpAngle* fromAngle() const { |
276 | 343M | return fFromAngle; |
277 | 343M | } |
278 | | |
279 | | void initBase(SkOpSegment* parent, SkOpSpan* prev, double t, const SkPoint& pt); |
280 | | |
281 | | // Please keep this in sync with debugInsertCoinEnd() |
282 | 3.20M | void insertCoinEnd(SkOpSpanBase* coin) { |
283 | 3.20M | if (containsCoinEnd(coin)) { |
284 | 1.68M | SkASSERT(coin->containsCoinEnd(this)); |
285 | 1.68M | return; |
286 | 1.68M | } |
287 | 1.52M | debugValidate(); |
288 | 1.52M | SkASSERT(this != coin); |
289 | 1.52M | SkOpSpanBase* coinNext = coin->fCoinEnd; |
290 | 1.52M | coin->fCoinEnd = this->fCoinEnd; |
291 | 1.52M | this->fCoinEnd = coinNext; |
292 | 1.52M | debugValidate(); |
293 | 1.52M | } |
294 | | |
295 | | void merge(SkOpSpan* span); |
296 | | bool mergeMatches(SkOpSpanBase* opp); |
297 | | |
298 | 39.2M | const SkOpSpan* prev() const { |
299 | 39.2M | return fPrev; |
300 | 39.2M | } |
301 | | |
302 | 325M | SkOpSpan* prev() { |
303 | 325M | return fPrev; |
304 | 325M | } |
305 | | |
306 | 33.7M | const SkPoint& pt() const { |
307 | 33.7M | return fPtT.fPt; |
308 | 33.7M | } |
309 | | |
310 | 1.14G | const SkOpPtT* ptT() const { |
311 | 1.14G | return &fPtT; |
312 | 1.14G | } |
313 | | |
314 | 1.15G | SkOpPtT* ptT() { |
315 | 1.15G | return &fPtT; |
316 | 1.15G | } |
317 | | |
318 | 66.4G | SkOpSegment* segment() const { |
319 | 66.4G | return fSegment; |
320 | 66.4G | } |
321 | | |
322 | 0 | void setAligned() { |
323 | 0 | fAligned = true; |
324 | 0 | } |
325 | | |
326 | 7.54M | void setChased(bool chased) { |
327 | 7.54M | fChased = chased; |
328 | 7.54M | } |
329 | | |
330 | 14.7M | void setFromAngle(SkOpAngle* angle) { |
331 | 14.7M | fFromAngle = angle; |
332 | 14.7M | } |
333 | | |
334 | 38.9M | void setPrev(SkOpSpan* prev) { |
335 | 38.9M | fPrev = prev; |
336 | 38.9M | } |
337 | | |
338 | 27.2M | bool simple() const { |
339 | 27.2M | fPtT.debugValidate(); |
340 | 27.2M | return fPtT.next()->next() == &fPtT; |
341 | 27.2M | } |
342 | | |
343 | 483M | int spanAddsCount() const { |
344 | 483M | return fSpanAdds; |
345 | 483M | } |
346 | | |
347 | 30.1M | const SkOpSpan* starter(const SkOpSpanBase* end) const { |
348 | 30.1M | const SkOpSpanBase* result = t() < end->t() ? this : end; |
349 | 30.1M | return result->upCast(); |
350 | 30.1M | } |
351 | | |
352 | 150M | SkOpSpan* starter(SkOpSpanBase* end) { |
353 | 150M | SkASSERT(this->segment() == end->segment()); |
354 | 150M | SkOpSpanBase* result = t() < end->t() ? this : end; |
355 | 150M | return result->upCast(); |
356 | 150M | } |
357 | | |
358 | 0 | SkOpSpan* starter(SkOpSpanBase** endPtr) { |
359 | 0 | SkOpSpanBase* end = *endPtr; |
360 | 0 | SkASSERT(this->segment() == end->segment()); |
361 | 0 | SkOpSpanBase* result; |
362 | 0 | if (t() < end->t()) { |
363 | 0 | result = this; |
364 | 0 | } else { |
365 | 0 | result = end; |
366 | 0 | *endPtr = this; |
367 | 0 | } |
368 | 0 | return result->upCast(); |
369 | 0 | } |
370 | | |
371 | 103M | int step(const SkOpSpanBase* end) const { |
372 | 103M | return t() < end->t() ? 1 : -1; |
373 | 103M | } |
374 | | |
375 | 3.43G | double t() const { |
376 | 3.43G | return fPtT.fT; |
377 | 3.43G | } |
378 | | |
379 | 11.1M | void unaligned() { |
380 | 11.1M | fAligned = false; |
381 | 11.1M | } |
382 | | |
383 | 1.70G | SkOpSpan* upCast() { |
384 | 1.70G | SkASSERT(!final()); |
385 | 1.70G | return (SkOpSpan*) this; |
386 | 1.70G | } |
387 | | |
388 | 1.46G | const SkOpSpan* upCast() const { |
389 | 1.46G | SkOPASSERT(!final()); |
390 | 1.46G | return (const SkOpSpan*) this; |
391 | 1.46G | } |
392 | | |
393 | 86.1M | SkOpSpan* upCastable() { |
394 | 86.1M | return final() ? nullptr : upCast(); |
395 | 86.1M | } |
396 | | |
397 | 500M | const SkOpSpan* upCastable() const { |
398 | 500M | return final() ? nullptr : upCast(); |
399 | 500M | } |
400 | | |
401 | | private: |
402 | | void alignInner(); |
403 | | |
404 | | protected: // no direct access to internals to avoid treating a span base as a span |
405 | | SkOpPtT fPtT; // list of points and t values associated with the start of this span |
406 | | SkOpSegment* fSegment; // segment that contains this span |
407 | | SkOpSpanBase* fCoinEnd; // linked list of coincident spans that end here (may point to itself) |
408 | | SkOpAngle* fFromAngle; // points to next angle from span start to end |
409 | | SkOpSpan* fPrev; // previous intersection point |
410 | | int fSpanAdds; // number of times intersections have been added to span |
411 | | bool fAligned; |
412 | | bool fChased; // set after span has been added to chase array |
413 | | SkDEBUGCODE(int fCount;) // number of pt/t pairs added |
414 | | SkDEBUGCODE(int fID;) |
415 | | SkDEBUGCODE(bool fDebugDeleted;) // set when span was merged with another span |
416 | | }; |
417 | | |
418 | | class SkOpSpan : public SkOpSpanBase { |
419 | | public: |
420 | 12.8M | bool alreadyAdded() const { |
421 | 12.8M | if (fAlreadyAdded) { |
422 | 157k | return true; |
423 | 157k | } |
424 | 12.6M | return false; |
425 | 12.8M | } |
426 | | |
427 | 0 | bool clearCoincident() { |
428 | 0 | SkASSERT(!final()); |
429 | 0 | if (fCoincident == this) { |
430 | 0 | return false; |
431 | 0 | } |
432 | 0 | fCoincident = this; |
433 | 0 | return true; |
434 | 0 | } |
435 | | |
436 | | int computeWindSum(); |
437 | | bool containsCoincidence(const SkOpSegment* ) const; |
438 | | |
439 | 4.55M | bool containsCoincidence(const SkOpSpan* coin) const { |
440 | 4.55M | SkASSERT(this != coin); |
441 | 4.55M | const SkOpSpan* next = this; |
442 | 21.2M | while ((next = next->fCoincident) != this) { |
443 | 18.5M | if (next == coin) { |
444 | 1.79M | return true; |
445 | 1.79M | } |
446 | 18.5M | } |
447 | 2.75M | return false; |
448 | 4.55M | } SkOpSpan::containsCoincidence(SkOpSpan const*) const Line | Count | Source | 439 | 4.55M | bool containsCoincidence(const SkOpSpan* coin) const { | 440 | 4.55M | SkASSERT(this != coin); | 441 | 4.55M | const SkOpSpan* next = this; | 442 | 21.2M | while ((next = next->fCoincident) != this) { | 443 | 18.5M | if (next == coin) { | 444 | 1.79M | return true; | 445 | 1.79M | } | 446 | 18.5M | } | 447 | 2.75M | return false; | 448 | 4.55M | } |
Unexecuted instantiation: SkOpSpan::containsCoincidence(SkOpSpan const*) const |
449 | | |
450 | | bool debugCoinLoopCheck() const; |
451 | | #if DEBUG_COIN |
452 | | void debugInsertCoincidence(SkPathOpsDebug::GlitchLog* , const SkOpSpan* ) const; |
453 | | void debugInsertCoincidence(SkPathOpsDebug::GlitchLog* , |
454 | | const SkOpSegment* , bool flipped, bool ordered) const; |
455 | | #endif |
456 | | void dumpCoin() const; |
457 | | bool dumpSpan() const; |
458 | | |
459 | 178M | bool done() const { |
460 | 178M | SkASSERT(!final()); |
461 | 178M | return fDone; |
462 | 178M | } |
463 | | |
464 | | void init(SkOpSegment* parent, SkOpSpan* prev, double t, const SkPoint& pt); |
465 | | bool insertCoincidence(const SkOpSegment* , bool flipped, bool ordered); |
466 | | |
467 | | // Please keep this in sync with debugInsertCoincidence() |
468 | 4.55M | void insertCoincidence(SkOpSpan* coin) { |
469 | 4.55M | if (containsCoincidence(coin)) { |
470 | 1.79M | SkASSERT(coin->containsCoincidence(this)); |
471 | 1.79M | return; |
472 | 1.79M | } |
473 | 2.75M | debugValidate(); |
474 | 2.75M | SkASSERT(this != coin); |
475 | 2.75M | SkOpSpan* coinNext = coin->fCoincident; |
476 | 2.75M | coin->fCoincident = this->fCoincident; |
477 | 2.75M | this->fCoincident = coinNext; |
478 | 2.75M | debugValidate(); |
479 | 2.75M | } |
480 | | |
481 | 26.0M | bool isCanceled() const { |
482 | 26.0M | SkASSERT(!final()); |
483 | 26.0M | return fWindValue == 0 && fOppValue == 0; |
484 | 26.0M | } |
485 | | |
486 | 0 | bool isCoincident() const { |
487 | 0 | SkASSERT(!final()); |
488 | 0 | return fCoincident != this; |
489 | 0 | } |
490 | | |
491 | 12.6M | void markAdded() { |
492 | 12.6M | fAlreadyAdded = true; |
493 | 12.6M | } |
494 | | |
495 | 2.15G | SkOpSpanBase* next() const { |
496 | 2.15G | SkASSERT(!final()); |
497 | 2.15G | return fNext; |
498 | 2.15G | } |
499 | | |
500 | 26.3M | int oppSum() const { |
501 | 26.3M | SkASSERT(!final()); |
502 | 26.3M | return fOppSum; |
503 | 26.3M | } |
504 | | |
505 | 128M | int oppValue() const { |
506 | 128M | SkASSERT(!final()); |
507 | 128M | return fOppValue; |
508 | 128M | } |
509 | | |
510 | | void release(const SkOpPtT* ); |
511 | | |
512 | | SkOpPtT* setCoinStart(SkOpSpan* oldCoinStart, SkOpSegment* oppSegment); |
513 | | |
514 | 23.7M | void setDone(bool done) { |
515 | 23.7M | SkASSERT(!final()); |
516 | 23.7M | fDone = done; |
517 | 23.7M | } |
518 | | |
519 | 57.2M | void setNext(SkOpSpanBase* nextT) { |
520 | 57.2M | SkASSERT(!final()); |
521 | 57.2M | fNext = nextT; |
522 | 57.2M | } |
523 | | |
524 | | void setOppSum(int oppSum); |
525 | | |
526 | 13.5M | void setOppValue(int oppValue) { |
527 | 13.5M | SkASSERT(!final()); |
528 | 13.5M | SkASSERT(fOppSum == SK_MinS32); |
529 | 13.5M | SkOPASSERT(!oppValue || !fDone); |
530 | 13.5M | fOppValue = oppValue; |
531 | 13.5M | } |
532 | | |
533 | 14.7M | void setToAngle(SkOpAngle* angle) { |
534 | 14.7M | SkASSERT(!final()); |
535 | 14.7M | fToAngle = angle; |
536 | 14.7M | } |
537 | | |
538 | | void setWindSum(int windSum); |
539 | | |
540 | 13.5M | void setWindValue(int windValue) { |
541 | 13.5M | SkASSERT(!final()); |
542 | 13.5M | SkASSERT(windValue >= 0); |
543 | 13.5M | SkASSERT(fWindSum == SK_MinS32); |
544 | 13.5M | SkOPASSERT(!windValue || !fDone); |
545 | 13.5M | fWindValue = windValue; |
546 | 13.5M | } |
547 | | |
548 | | bool sortableTop(SkOpContour* ); |
549 | | |
550 | 322M | SkOpAngle* toAngle() const { |
551 | 322M | SkASSERT(!final()); |
552 | 322M | return fToAngle; |
553 | 322M | } |
554 | | |
555 | 115M | int windSum() const { |
556 | 115M | SkASSERT(!final()); |
557 | 115M | return fWindSum; |
558 | 115M | } |
559 | | |
560 | 269M | int windValue() const { |
561 | 269M | SkOPASSERT(!final()); |
562 | 269M | return fWindValue; |
563 | 269M | } |
564 | | |
565 | | private: // no direct access to internals to avoid treating a span base as a span |
566 | | SkOpSpan* fCoincident; // linked list of spans coincident with this one (may point to itself) |
567 | | SkOpAngle* fToAngle; // points to next angle from span start to end |
568 | | SkOpSpanBase* fNext; // next intersection point |
569 | | int fWindSum; // accumulated from contours surrounding this one. |
570 | | int fOppSum; // for binary operators: the opposite winding sum |
571 | | int fWindValue; // 0 == canceled; 1 == normal; >1 == coincident |
572 | | int fOppValue; // normally 0 -- when binary coincident edges combine, opp value goes here |
573 | | int fTopTTry; // specifies direction and t value to try next |
574 | | bool fDone; // if set, this span to next higher T has been processed |
575 | | bool fAlreadyAdded; |
576 | | }; |
577 | | |
578 | | #endif |