blob: b3cd54cbc0f978e2ce1e23f00098dc75394b66b5 [file] [log] [blame]
caryclark@google.com07393ca2013-04-08 11:47:37 +00001/*
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
caryclark54359292015-03-26 07:52:43 -070010#include "SkPathOpsDebug.h"
caryclark27c8eb82015-07-06 11:38:33 -070011#include "SkPathOpsTypes.h"
caryclark@google.com07393ca2013-04-08 11:47:37 +000012#include "SkPoint.h"
13
Herb Derbyc3cc5fa2017-03-07 11:11:47 -050014class SkArenaAlloc;
caryclark55888e42016-07-18 10:01:36 -070015class SkOpAngle;
caryclark54359292015-03-26 07:52:43 -070016class SkOpContour;
17class SkOpGlobalState;
caryclark@google.com07393ca2013-04-08 11:47:37 +000018class SkOpSegment;
caryclark54359292015-03-26 07:52:43 -070019class SkOpSpanBase;
20class SkOpSpan;
caryclark55888e42016-07-18 10:01:36 -070021struct SkPathOpsBounds;
caryclark@google.com07393ca2013-04-08 11:47:37 +000022
caryclark54359292015-03-26 07:52:43 -070023// subset of op span used by terminal span (when t is equal to one)
24class SkOpPtT {
25public:
26 enum {
27 kIsAlias = 1,
28 kIsDuplicate = 1
29 };
30
caryclark30b9fdd2016-08-31 14:36:29 -070031 const SkOpPtT* active() const;
32
caryclark55888e42016-07-18 10:01:36 -070033 // please keep in sync with debugAddOpp()
caryclark29b25632016-08-25 11:27:17 -070034 void addOpp(SkOpPtT* opp, SkOpPtT* oppPrev) {
caryclark54359292015-03-26 07:52:43 -070035 SkOpPtT* oldNext = this->fNext;
36 SkASSERT(this != opp);
37 this->fNext = opp;
38 SkASSERT(oppPrev != oldNext);
39 oppPrev->fNext = oldNext;
40 }
41
42 bool alias() const;
caryclark55888e42016-07-18 10:01:36 -070043 bool coincident() const { return fCoincident; }
caryclark27c8eb82015-07-06 11:38:33 -070044 bool contains(const SkOpPtT* ) const;
caryclark55888e42016-07-18 10:01:36 -070045 bool contains(const SkOpSegment*, const SkPoint& ) const;
46 bool contains(const SkOpSegment*, double t) const;
47 const SkOpPtT* contains(const SkOpSegment* ) const;
caryclark54359292015-03-26 07:52:43 -070048 SkOpContour* contour() const;
49
50 int debugID() const {
caryclark1049f122015-04-20 08:31:59 -070051 return SkDEBUGRELEASE(fID, -1);
caryclark54359292015-03-26 07:52:43 -070052 }
53
caryclark29b25632016-08-25 11:27:17 -070054 void debugAddOpp(const SkOpPtT* opp, const SkOpPtT* oppPrev) const;
caryclark54359292015-03-26 07:52:43 -070055 const SkOpAngle* debugAngle(int id) const;
caryclark55888e42016-07-18 10:01:36 -070056 const SkOpCoincidence* debugCoincidence() const;
caryclark26ad22a2015-10-16 09:03:38 -070057 bool debugContains(const SkOpPtT* ) const;
58 const SkOpPtT* debugContains(const SkOpSegment* check) const;
caryclark30b9fdd2016-08-31 14:36:29 -070059 SkOpContour* debugContour(int id) const;
caryclark8016b262016-09-06 05:59:47 -070060 const SkOpPtT* debugEnder(const SkOpPtT* end) const;
caryclark54359292015-03-26 07:52:43 -070061 int debugLoopLimit(bool report) const;
62 bool debugMatchID(int id) const;
caryclark29b25632016-08-25 11:27:17 -070063 const SkOpPtT* debugOppPrev(const SkOpPtT* opp) const;
caryclark54359292015-03-26 07:52:43 -070064 const SkOpPtT* debugPtT(int id) const;
caryclark025b11e2016-08-25 05:21:14 -070065 void debugResetCoinT() const;
caryclark54359292015-03-26 07:52:43 -070066 const SkOpSegment* debugSegment(int id) const;
caryclark025b11e2016-08-25 05:21:14 -070067 void debugSetCoinT(int ) const;
caryclark54359292015-03-26 07:52:43 -070068 const SkOpSpanBase* debugSpan(int id) const;
caryclark54359292015-03-26 07:52:43 -070069 void debugValidate() const;
70
71 bool deleted() const {
72 return fDeleted;
73 }
74
75 bool duplicate() const {
76 return fDuplicatePt;
77 }
78
79 void dump() const; // available to testing only
80 void dumpAll() const;
81 void dumpBase() const;
82
caryclark55888e42016-07-18 10:01:36 -070083 const SkOpPtT* find(const SkOpSegment* ) const;
caryclark26ad22a2015-10-16 09:03:38 -070084 SkOpGlobalState* globalState() const;
caryclark54359292015-03-26 07:52:43 -070085 void init(SkOpSpanBase* , double t, const SkPoint& , bool dup);
86
87 void insert(SkOpPtT* span) {
88 SkASSERT(span != this);
89 span->fNext = fNext;
90 fNext = span;
91 }
92
93 const SkOpPtT* next() const {
94 return fNext;
95 }
96
97 SkOpPtT* next() {
98 return fNext;
99 }
100
101 bool onEnd() const;
caryclark27c8eb82015-07-06 11:38:33 -0700102
caryclark30b9fdd2016-08-31 14:36:29 -0700103 // returns nullptr if this is already in the opp ptT loop
104 SkOpPtT* oppPrev(const SkOpPtT* opp) const {
caryclark29b25632016-08-25 11:27:17 -0700105 // find the fOpp ptr to opp
106 SkOpPtT* oppPrev = opp->fNext;
107 if (oppPrev == this) {
108 return nullptr;
109 }
110 while (oppPrev->fNext != opp) {
111 oppPrev = oppPrev->fNext;
112 if (oppPrev == this) {
113 return nullptr;
114 }
115 }
116 return oppPrev;
117 }
118
caryclark55888e42016-07-18 10:01:36 -0700119 static bool Overlaps(const SkOpPtT* s1, const SkOpPtT* e1, const SkOpPtT* s2,
120 const SkOpPtT* e2, const SkOpPtT** sOut, const SkOpPtT** eOut) {
121 const SkOpPtT* start1 = s1->fT < e1->fT ? s1 : e1;
122 const SkOpPtT* start2 = s2->fT < e2->fT ? s2 : e2;
caryclark27c8eb82015-07-06 11:38:33 -0700123 *sOut = between(s1->fT, start2->fT, e1->fT) ? start2
halcanary96fcdcc2015-08-27 07:41:13 -0700124 : between(s2->fT, start1->fT, e2->fT) ? start1 : nullptr;
caryclark55888e42016-07-18 10:01:36 -0700125 const SkOpPtT* end1 = s1->fT < e1->fT ? e1 : s1;
126 const SkOpPtT* end2 = s2->fT < e2->fT ? e2 : s2;
caryclark27c8eb82015-07-06 11:38:33 -0700127 *eOut = between(s1->fT, end2->fT, e1->fT) ? end2
halcanary96fcdcc2015-08-27 07:41:13 -0700128 : between(s2->fT, end1->fT, e2->fT) ? end1 : nullptr;
caryclark27c8eb82015-07-06 11:38:33 -0700129 if (*sOut == *eOut) {
Cary Clark8d8a5d92018-04-02 12:40:49 -0400130 SkOPOBJASSERT(s1, start1->fT >= end2->fT || start2->fT >= end1->fT);
caryclark27c8eb82015-07-06 11:38:33 -0700131 return false;
132 }
133 SkASSERT(!*sOut || *sOut != *eOut);
134 return *sOut && *eOut;
135 }
136
caryclark55888e42016-07-18 10:01:36 -0700137 bool ptAlreadySeen(const SkOpPtT* head) const;
caryclark54359292015-03-26 07:52:43 -0700138 SkOpPtT* prev();
caryclark54359292015-03-26 07:52:43 -0700139
140 const SkOpSegment* segment() const;
141 SkOpSegment* segment();
142
caryclark55888e42016-07-18 10:01:36 -0700143 void setCoincident() const {
caryclarkfc560e02016-07-27 08:46:10 -0700144 SkOPASSERT(!fDeleted);
caryclark55888e42016-07-18 10:01:36 -0700145 fCoincident = true;
146 }
147
148 void setDeleted();
149
150 void setSpan(const SkOpSpanBase* span) {
151 fSpan = const_cast<SkOpSpanBase*>(span);
caryclark54359292015-03-26 07:52:43 -0700152 }
153
154 const SkOpSpanBase* span() const {
155 return fSpan;
156 }
157
158 SkOpSpanBase* span() {
159 return fSpan;
160 }
161
caryclark27c8eb82015-07-06 11:38:33 -0700162 const SkOpPtT* starter(const SkOpPtT* end) const {
163 return fT < end->fT ? this : end;
164 }
165
caryclark55888e42016-07-18 10:01:36 -0700166 double fT;
caryclark54359292015-03-26 07:52:43 -0700167 SkPoint fPt; // cache of point value at this t
168protected:
169 SkOpSpanBase* fSpan; // contains winding data
170 SkOpPtT* fNext; // intersection on opposite curve or alias on this curve
caryclark55888e42016-07-18 10:01:36 -0700171 bool fDeleted; // set if removed from span list
caryclark54359292015-03-26 07:52:43 -0700172 bool fDuplicatePt; // set if identical pt is somewhere in the next loop
caryclark55888e42016-07-18 10:01:36 -0700173 // below mutable since referrer is otherwise always const
174 mutable bool fCoincident; // set if at some point a coincident span pointed here
caryclark1049f122015-04-20 08:31:59 -0700175 SkDEBUGCODE(int fID);
caryclark54359292015-03-26 07:52:43 -0700176};
177
178class SkOpSpanBase {
179public:
Cary Clarkba610292018-06-19 09:47:15 -0400180 enum class Collapsed {
181 kNo,
182 kYes,
183 kError,
184 };
185
Cary Clarkd058b182018-11-29 09:02:32 -0500186 bool addOpp(SkOpSpanBase* opp);
caryclark54359292015-03-26 07:52:43 -0700187
caryclark08bc8482015-04-24 09:08:57 -0700188 void bumpSpanAdds() {
189 ++fSpanAdds;
190 }
191
caryclark54359292015-03-26 07:52:43 -0700192 bool chased() const {
193 return fChased;
194 }
195
caryclark55888e42016-07-18 10:01:36 -0700196 void checkForCollapsedCoincidence();
caryclark54359292015-03-26 07:52:43 -0700197
198 const SkOpSpanBase* coinEnd() const {
199 return fCoinEnd;
200 }
201
Cary Clarkba610292018-06-19 09:47:15 -0400202 Collapsed collapsed(double s, double e) const;
caryclark54359292015-03-26 07:52:43 -0700203 bool contains(const SkOpSpanBase* ) const;
caryclark55888e42016-07-18 10:01:36 -0700204 const SkOpPtT* contains(const SkOpSegment* ) const;
caryclark54359292015-03-26 07:52:43 -0700205
206 bool containsCoinEnd(const SkOpSpanBase* coin) const {
207 SkASSERT(this != coin);
208 const SkOpSpanBase* next = this;
209 while ((next = next->fCoinEnd) != this) {
210 if (next == coin) {
211 return true;
212 }
213 }
214 return false;
215 }
216
217 bool containsCoinEnd(const SkOpSegment* ) const;
218 SkOpContour* contour() const;
219
220 int debugBumpCount() {
caryclark1049f122015-04-20 08:31:59 -0700221 return SkDEBUGRELEASE(++fCount, -1);
caryclark54359292015-03-26 07:52:43 -0700222 }
223
224 int debugID() const {
caryclark1049f122015-04-20 08:31:59 -0700225 return SkDEBUGRELEASE(fID, -1);
caryclark54359292015-03-26 07:52:43 -0700226 }
227
Cary Clarkab87d7a2016-10-04 10:01:04 -0400228#if DEBUG_COIN
229 void debugAddOpp(SkPathOpsDebug::GlitchLog* , const SkOpSpanBase* opp) const;
caryclark30b9fdd2016-08-31 14:36:29 -0700230#endif
caryclark26ad22a2015-10-16 09:03:38 -0700231 bool debugAlignedEnd(double t, const SkPoint& pt) const;
232 bool debugAlignedInner() const;
caryclark54359292015-03-26 07:52:43 -0700233 const SkOpAngle* debugAngle(int id) const;
Cary Clarkab87d7a2016-10-04 10:01:04 -0400234#if DEBUG_COIN
235 void debugCheckForCollapsedCoincidence(SkPathOpsDebug::GlitchLog* ) const;
caryclark55888e42016-07-18 10:01:36 -0700236#endif
237 const SkOpCoincidence* debugCoincidence() const;
caryclark54359292015-03-26 07:52:43 -0700238 bool debugCoinEndLoopCheck() const;
caryclark30b9fdd2016-08-31 14:36:29 -0700239 SkOpContour* debugContour(int id) const;
caryclark55888e42016-07-18 10:01:36 -0700240#ifdef SK_DEBUG
caryclark30b9fdd2016-08-31 14:36:29 -0700241 bool debugDeleted() const { return fDebugDeleted; }
caryclark55888e42016-07-18 10:01:36 -0700242#endif
Cary Clarkab87d7a2016-10-04 10:01:04 -0400243#if DEBUG_COIN
244 void debugInsertCoinEnd(SkPathOpsDebug::GlitchLog* ,
caryclark55888e42016-07-18 10:01:36 -0700245 const SkOpSpanBase* ) const;
Cary Clarkab87d7a2016-10-04 10:01:04 -0400246 void debugMergeMatches(SkPathOpsDebug::GlitchLog* log,
caryclark30b9fdd2016-08-31 14:36:29 -0700247 const SkOpSpanBase* opp) const;
caryclark55888e42016-07-18 10:01:36 -0700248#endif
caryclark54359292015-03-26 07:52:43 -0700249 const SkOpPtT* debugPtT(int id) const;
caryclark025b11e2016-08-25 05:21:14 -0700250 void debugResetCoinT() const;
caryclark54359292015-03-26 07:52:43 -0700251 const SkOpSegment* debugSegment(int id) const;
caryclark025b11e2016-08-25 05:21:14 -0700252 void debugSetCoinT(int ) const;
caryclark30b9fdd2016-08-31 14:36:29 -0700253#ifdef SK_DEBUG
254 void debugSetDeleted() { fDebugDeleted = true; }
255#endif
caryclark54359292015-03-26 07:52:43 -0700256 const SkOpSpanBase* debugSpan(int id) const;
caryclark26ad22a2015-10-16 09:03:38 -0700257 const SkOpSpan* debugStarter(SkOpSpanBase const** endPtr) const;
caryclark54359292015-03-26 07:52:43 -0700258 SkOpGlobalState* globalState() const;
259 void debugValidate() const;
260
261 bool deleted() const {
262 return fPtT.deleted();
263 }
264
265 void dump() const; // available to testing only
266 void dumpCoin() const;
267 void dumpAll() const;
268 void dumpBase() const;
caryclark55888e42016-07-18 10:01:36 -0700269 void dumpHead() const;
caryclark54359292015-03-26 07:52:43 -0700270
271 bool final() const {
272 return fPtT.fT == 1;
273 }
274
275 SkOpAngle* fromAngle() const {
276 return fFromAngle;
277 }
278
279 void initBase(SkOpSegment* parent, SkOpSpan* prev, double t, const SkPoint& pt);
280
caryclark55888e42016-07-18 10:01:36 -0700281 // Please keep this in sync with debugInsertCoinEnd()
caryclark54359292015-03-26 07:52:43 -0700282 void insertCoinEnd(SkOpSpanBase* coin) {
283 if (containsCoinEnd(coin)) {
284 SkASSERT(coin->containsCoinEnd(this));
285 return;
286 }
287 debugValidate();
288 SkASSERT(this != coin);
289 SkOpSpanBase* coinNext = coin->fCoinEnd;
290 coin->fCoinEnd = this->fCoinEnd;
291 this->fCoinEnd = coinNext;
292 debugValidate();
293 }
294
295 void merge(SkOpSpan* span);
Cary Clarkd058b182018-11-29 09:02:32 -0500296 bool mergeMatches(SkOpSpanBase* opp);
caryclark54359292015-03-26 07:52:43 -0700297
caryclark55888e42016-07-18 10:01:36 -0700298 const SkOpSpan* prev() const {
299 return fPrev;
300 }
301
302 SkOpSpan* prev() {
caryclark54359292015-03-26 07:52:43 -0700303 return fPrev;
304 }
305
306 const SkPoint& pt() const {
307 return fPtT.fPt;
308 }
309
310 const SkOpPtT* ptT() const {
311 return &fPtT;
312 }
313
314 SkOpPtT* ptT() {
315 return &fPtT;
316 }
317
318 SkOpSegment* segment() const {
319 return fSegment;
320 }
321
caryclarkd4349722015-07-23 12:40:22 -0700322 void setAligned() {
323 fAligned = true;
324 }
325
caryclark54359292015-03-26 07:52:43 -0700326 void setChased(bool chased) {
327 fChased = chased;
328 }
329
caryclark54359292015-03-26 07:52:43 -0700330 void setFromAngle(SkOpAngle* angle) {
331 fFromAngle = angle;
332 }
333
334 void setPrev(SkOpSpan* prev) {
335 fPrev = prev;
336 }
337
338 bool simple() const {
339 fPtT.debugValidate();
caryclark55888e42016-07-18 10:01:36 -0700340 return fPtT.next()->next() == &fPtT;
caryclark54359292015-03-26 07:52:43 -0700341 }
342
caryclark08bc8482015-04-24 09:08:57 -0700343 int spanAddsCount() const {
344 return fSpanAdds;
345 }
346
caryclark54359292015-03-26 07:52:43 -0700347 const SkOpSpan* starter(const SkOpSpanBase* end) const {
348 const SkOpSpanBase* result = t() < end->t() ? this : end;
349 return result->upCast();
350 }
351
352 SkOpSpan* starter(SkOpSpanBase* end) {
353 SkASSERT(this->segment() == end->segment());
354 SkOpSpanBase* result = t() < end->t() ? this : end;
355 return result->upCast();
356 }
357
358 SkOpSpan* starter(SkOpSpanBase** endPtr) {
359 SkOpSpanBase* end = *endPtr;
360 SkASSERT(this->segment() == end->segment());
361 SkOpSpanBase* result;
362 if (t() < end->t()) {
363 result = this;
364 } else {
365 result = end;
366 *endPtr = this;
367 }
368 return result->upCast();
369 }
370
371 int step(const SkOpSpanBase* end) const {
372 return t() < end->t() ? 1 : -1;
373 }
374
375 double t() const {
376 return fPtT.fT;
377 }
378
379 void unaligned() {
380 fAligned = false;
381 }
382
383 SkOpSpan* upCast() {
384 SkASSERT(!final());
385 return (SkOpSpan*) this;
386 }
387
388 const SkOpSpan* upCast() const {
caryclarkef4f32a2016-08-24 09:24:18 -0700389 SkOPASSERT(!final());
caryclark54359292015-03-26 07:52:43 -0700390 return (const SkOpSpan*) this;
391 }
392
393 SkOpSpan* upCastable() {
halcanary96fcdcc2015-08-27 07:41:13 -0700394 return final() ? nullptr : upCast();
caryclark54359292015-03-26 07:52:43 -0700395 }
396
397 const SkOpSpan* upCastable() const {
halcanary96fcdcc2015-08-27 07:41:13 -0700398 return final() ? nullptr : upCast();
caryclark54359292015-03-26 07:52:43 -0700399 }
400
401private:
402 void alignInner();
403
404protected: // 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
caryclark08bc8482015-04-24 09:08:57 -0700410 int fSpanAdds; // number of times intersections have been added to span
caryclark54359292015-03-26 07:52:43 -0700411 bool fAligned;
412 bool fChased; // set after span has been added to chase array
caryclark1049f122015-04-20 08:31:59 -0700413 SkDEBUGCODE(int fCount); // number of pt/t pairs added
414 SkDEBUGCODE(int fID);
caryclark30b9fdd2016-08-31 14:36:29 -0700415 SkDEBUGCODE(bool fDebugDeleted); // set when span was merged with another span
caryclark54359292015-03-26 07:52:43 -0700416};
417
418class SkOpSpan : public SkOpSpanBase {
419public:
caryclarkef784fb2015-10-30 12:03:06 -0700420 bool alreadyAdded() const {
421 if (fAlreadyAdded) {
422 return true;
423 }
caryclarkef784fb2015-10-30 12:03:06 -0700424 return false;
425 }
426
caryclark54359292015-03-26 07:52:43 -0700427 bool clearCoincident() {
428 SkASSERT(!final());
429 if (fCoincident == this) {
430 return false;
431 }
432 fCoincident = this;
433 return true;
434 }
435
caryclarkbca19f72015-05-13 08:23:48 -0700436 int computeWindSum();
caryclark54359292015-03-26 07:52:43 -0700437 bool containsCoincidence(const SkOpSegment* ) const;
438
439 bool containsCoincidence(const SkOpSpan* coin) const {
440 SkASSERT(this != coin);
441 const SkOpSpan* next = this;
442 while ((next = next->fCoincident) != this) {
443 if (next == coin) {
444 return true;
445 }
446 }
447 return false;
448 }
449
450 bool debugCoinLoopCheck() const;
Cary Clarkab87d7a2016-10-04 10:01:04 -0400451#if DEBUG_COIN
452 void debugInsertCoincidence(SkPathOpsDebug::GlitchLog* , const SkOpSpan* ) const;
453 void debugInsertCoincidence(SkPathOpsDebug::GlitchLog* ,
454 const SkOpSegment* , bool flipped, bool ordered) const;
caryclark55888e42016-07-18 10:01:36 -0700455#endif
caryclark30b9fdd2016-08-31 14:36:29 -0700456 void dumpCoin() const;
457 bool dumpSpan() const;
caryclark54359292015-03-26 07:52:43 -0700458
459 bool done() const {
460 SkASSERT(!final());
461 return fDone;
462 }
463
caryclark54359292015-03-26 07:52:43 -0700464 void init(SkOpSegment* parent, SkOpSpan* prev, double t, const SkPoint& pt);
caryclark81a478c2016-09-09 09:37:57 -0700465 bool insertCoincidence(const SkOpSegment* , bool flipped, bool ordered);
caryclark54359292015-03-26 07:52:43 -0700466
caryclark55888e42016-07-18 10:01:36 -0700467 // Please keep this in sync with debugInsertCoincidence()
caryclark54359292015-03-26 07:52:43 -0700468 void insertCoincidence(SkOpSpan* coin) {
469 if (containsCoincidence(coin)) {
470 SkASSERT(coin->containsCoincidence(this));
471 return;
472 }
473 debugValidate();
474 SkASSERT(this != coin);
475 SkOpSpan* coinNext = coin->fCoincident;
476 coin->fCoincident = this->fCoincident;
477 this->fCoincident = coinNext;
478 debugValidate();
479 }
480
481 bool isCanceled() const {
482 SkASSERT(!final());
483 return fWindValue == 0 && fOppValue == 0;
484 }
485
486 bool isCoincident() const {
487 SkASSERT(!final());
488 return fCoincident != this;
489 }
490
Cary Clarkcadc5062018-08-06 17:24:04 -0400491 void markAdded() {
492 fAlreadyAdded = true;
493 }
494
caryclark54359292015-03-26 07:52:43 -0700495 SkOpSpanBase* next() const {
496 SkASSERT(!final());
497 return fNext;
498 }
499
500 int oppSum() const {
501 SkASSERT(!final());
502 return fOppSum;
503 }
504
505 int oppValue() const {
506 SkASSERT(!final());
507 return fOppValue;
508 }
509
caryclark30b9fdd2016-08-31 14:36:29 -0700510 void release(const SkOpPtT* );
511
caryclark54359292015-03-26 07:52:43 -0700512 SkOpPtT* setCoinStart(SkOpSpan* oldCoinStart, SkOpSegment* oppSegment);
513
514 void setDone(bool done) {
515 SkASSERT(!final());
516 fDone = done;
517 }
518
519 void setNext(SkOpSpanBase* nextT) {
520 SkASSERT(!final());
521 fNext = nextT;
522 }
523
524 void setOppSum(int oppSum);
525
526 void setOppValue(int oppValue) {
527 SkASSERT(!final());
528 SkASSERT(fOppSum == SK_MinS32);
caryclark595ac282016-10-24 08:41:45 -0700529 SkOPASSERT(!oppValue || !fDone);
caryclark54359292015-03-26 07:52:43 -0700530 fOppValue = oppValue;
531 }
532
533 void setToAngle(SkOpAngle* angle) {
534 SkASSERT(!final());
535 fToAngle = angle;
536 }
537
caryclark624637c2015-05-11 07:21:27 -0700538 void setWindSum(int windSum);
caryclark54359292015-03-26 07:52:43 -0700539
540 void setWindValue(int windValue) {
541 SkASSERT(!final());
542 SkASSERT(windValue >= 0);
543 SkASSERT(fWindSum == SK_MinS32);
caryclarkef4f32a2016-08-24 09:24:18 -0700544 SkOPASSERT(!windValue || !fDone);
caryclark54359292015-03-26 07:52:43 -0700545 fWindValue = windValue;
546 }
547
caryclark624637c2015-05-11 07:21:27 -0700548 bool sortableTop(SkOpContour* );
549
caryclark54359292015-03-26 07:52:43 -0700550 SkOpAngle* toAngle() const {
551 SkASSERT(!final());
552 return fToAngle;
553 }
554
555 int windSum() const {
556 SkASSERT(!final());
557 return fWindSum;
558 }
559
560 int windValue() const {
caryclarkef4f32a2016-08-24 09:24:18 -0700561 SkOPASSERT(!final());
caryclark54359292015-03-26 07:52:43 -0700562 return fWindValue;
563 }
564
565private: // 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
caryclark@google.com07393ca2013-04-08 11:47:37 +0000569 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
caryclark624637c2015-05-11 07:21:27 -0700573 int fTopTTry; // specifies direction and t value to try next
caryclark@google.com07393ca2013-04-08 11:47:37 +0000574 bool fDone; // if set, this span to next higher T has been processed
Cary Clarkcadc5062018-08-06 17:24:04 -0400575 bool fAlreadyAdded;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000576};
577
578#endif