OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkOpCoincidence.h" | 7 #include "SkOpCoincidence.h" |
8 #include "SkOpContour.h" | 8 #include "SkOpContour.h" |
9 #include "SkOpSegment.h" | 9 #include "SkOpSegment.h" |
10 #include "SkPathWriter.h" | 10 #include "SkPathWriter.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 return contour()->globalState(); | 21 return contour()->globalState(); |
22 } | 22 } |
23 | 23 |
24 void SkOpPtT::init(SkOpSpanBase* span, double t, const SkPoint& pt, bool duplica
te) { | 24 void SkOpPtT::init(SkOpSpanBase* span, double t, const SkPoint& pt, bool duplica
te) { |
25 fT = t; | 25 fT = t; |
26 fPt = pt; | 26 fPt = pt; |
27 fSpan = span; | 27 fSpan = span; |
28 fNext = this; | 28 fNext = this; |
29 fDuplicatePt = duplicate; | 29 fDuplicatePt = duplicate; |
30 fDeleted = false; | 30 fDeleted = false; |
31 PATH_OPS_DEBUG_CODE(fID = span->globalState()->nextPtTID()); | 31 SkDEBUGCODE(fID = span->globalState()->nextPtTID()); |
32 } | 32 } |
33 | 33 |
34 bool SkOpPtT::onEnd() const { | 34 bool SkOpPtT::onEnd() const { |
35 const SkOpSpanBase* span = this->span(); | 35 const SkOpSpanBase* span = this->span(); |
36 if (span->ptT() != this) { | 36 if (span->ptT() != this) { |
37 return false; | 37 return false; |
38 } | 38 } |
39 const SkOpSegment* segment = this->segment(); | 39 const SkOpSegment* segment = this->segment(); |
40 return span == segment->head() || span == segment->tail(); | 40 return span == segment->head() || span == segment->tail(); |
41 } | 41 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return span()->segment(); | 82 return span()->segment(); |
83 } | 83 } |
84 | 84 |
85 SkOpSegment* SkOpPtT::segment() { | 85 SkOpSegment* SkOpPtT::segment() { |
86 return span()->segment(); | 86 return span()->segment(); |
87 } | 87 } |
88 | 88 |
89 // find the starting or ending span with an existing loop of angles | 89 // find the starting or ending span with an existing loop of angles |
90 // OPTIMIZE? remove the spans pointing to windValue==0 here or earlier? | 90 // OPTIMIZE? remove the spans pointing to windValue==0 here or earlier? |
91 // FIXME? assert that only one other span has a valid windValue or oppValue | 91 // FIXME? assert that only one other span has a valid windValue or oppValue |
92 void SkOpSpanBase::addSimpleAngle(bool checkFrom, SkChunkAlloc* allocator) { | 92 bool SkOpSpanBase::addSimpleAngle(bool checkFrom, SkChunkAlloc* allocator) { |
93 SkOpAngle* angle; | 93 SkOpAngle* angle; |
94 if (checkFrom) { | 94 if (checkFrom) { |
95 SkASSERT(this->final()); | 95 if (!this->final()) { |
| 96 return false; |
| 97 } |
96 if (this->fromAngle()) { | 98 if (this->fromAngle()) { |
97 SkASSERT(this->fromAngle()->loopCount() == 2); | 99 SkASSERT(this->fromAngle()->loopCount() == 2); |
98 return; | 100 return true; |
99 } | 101 } |
100 angle = this->segment()->addEndSpan(allocator); | 102 angle = this->segment()->addEndSpan(allocator); |
101 } else { | 103 } else { |
102 SkASSERT(this->t() == 0); | 104 SkASSERT(this->t() == 0); |
103 SkOpSpan* span = this->upCast(); | 105 SkOpSpan* span = this->upCast(); |
104 if (span->toAngle()) { | 106 if (span->toAngle()) { |
105 SkASSERT(span->toAngle()->loopCount() == 2); | 107 SkASSERT(span->toAngle()->loopCount() == 2); |
106 SkASSERT(!span->fromAngle()); | 108 SkASSERT(!span->fromAngle()); |
107 span->setFromAngle(span->toAngle()->next()); | 109 span->setFromAngle(span->toAngle()->next()); |
108 return; | 110 return true; |
109 } | 111 } |
110 angle = this->segment()->addStartSpan(allocator); | 112 angle = this->segment()->addStartSpan(allocator); |
111 } | 113 } |
112 SkOpPtT* ptT = this->ptT(); | 114 SkOpPtT* ptT = this->ptT(); |
113 SkOpSpanBase* oSpanBase; | 115 SkOpSpanBase* oSpanBase; |
114 SkOpSpan* oSpan; | 116 SkOpSpan* oSpan; |
115 SkOpSegment* other; | 117 SkOpSegment* other; |
116 do { | 118 do { |
117 ptT = ptT->next(); | 119 ptT = ptT->next(); |
118 oSpanBase = ptT->span(); | 120 oSpanBase = ptT->span(); |
(...skipping 14 matching lines...) Expand all Loading... |
133 SkOpAngle* oAngle; | 135 SkOpAngle* oAngle; |
134 if (checkFrom) { | 136 if (checkFrom) { |
135 oAngle = other->addStartSpan(allocator); | 137 oAngle = other->addStartSpan(allocator); |
136 SkASSERT(oSpan && !oSpan->final()); | 138 SkASSERT(oSpan && !oSpan->final()); |
137 SkASSERT(oAngle == oSpan->toAngle()); | 139 SkASSERT(oAngle == oSpan->toAngle()); |
138 } else { | 140 } else { |
139 oAngle = other->addEndSpan(allocator); | 141 oAngle = other->addEndSpan(allocator); |
140 SkASSERT(oAngle == oSpanBase->fromAngle()); | 142 SkASSERT(oAngle == oSpanBase->fromAngle()); |
141 } | 143 } |
142 angle->insert(oAngle); | 144 angle->insert(oAngle); |
| 145 return true; |
143 } | 146 } |
144 | 147 |
145 void SkOpSpanBase::align() { | 148 void SkOpSpanBase::align() { |
146 if (this->fAligned) { | 149 if (this->fAligned) { |
147 return; | 150 return; |
148 } | 151 } |
149 SkASSERT(!zero_or_one(this->fPtT.fT)); | 152 SkASSERT(!zero_or_one(this->fPtT.fT)); |
150 SkASSERT(this->fPtT.next()); | 153 SkASSERT(this->fPtT.next()); |
151 // if a linked pt/t pair has a t of zero or one, use it as the base for alig
nment | 154 // if a linked pt/t pair has a t of zero or one, use it as the base for alig
nment |
152 SkOpPtT* ptT = &this->fPtT, * stopPtT = ptT; | 155 SkOpPtT* ptT = &this->fPtT, * stopPtT = ptT; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 270 } |
268 | 271 |
269 void SkOpSpanBase::initBase(SkOpSegment* segment, SkOpSpan* prev, double t, cons
t SkPoint& pt) { | 272 void SkOpSpanBase::initBase(SkOpSegment* segment, SkOpSpan* prev, double t, cons
t SkPoint& pt) { |
270 fSegment = segment; | 273 fSegment = segment; |
271 fPtT.init(this, t, pt, false); | 274 fPtT.init(this, t, pt, false); |
272 fCoinEnd = this; | 275 fCoinEnd = this; |
273 fFromAngle = NULL; | 276 fFromAngle = NULL; |
274 fPrev = prev; | 277 fPrev = prev; |
275 fAligned = true; | 278 fAligned = true; |
276 fChased = false; | 279 fChased = false; |
277 PATH_OPS_DEBUG_CODE(fCount = 1); | 280 SkDEBUGCODE(fCount = 1); |
278 PATH_OPS_DEBUG_CODE(fID = globalState()->nextSpanID()); | 281 SkDEBUGCODE(fID = globalState()->nextSpanID()); |
279 } | 282 } |
280 | 283 |
281 // this pair of spans share a common t value or point; merge them and eliminate
duplicates | 284 // this pair of spans share a common t value or point; merge them and eliminate
duplicates |
282 // this does not compute the best t or pt value; this merely moves all data into
a single list | 285 // this does not compute the best t or pt value; this merely moves all data into
a single list |
283 void SkOpSpanBase::merge(SkOpSpan* span) { | 286 void SkOpSpanBase::merge(SkOpSpan* span) { |
284 SkOpPtT* spanPtT = span->ptT(); | 287 SkOpPtT* spanPtT = span->ptT(); |
285 SkASSERT(this->t() != spanPtT->fT); | 288 SkASSERT(this->t() != spanPtT->fT); |
286 SkASSERT(!zero_or_one(spanPtT->fT)); | 289 SkASSERT(!zero_or_one(spanPtT->fT)); |
287 span->detach(this->ptT()); | 290 span->detach(this->ptT()); |
288 SkOpPtT* remainder = spanPtT->next(); | 291 SkOpPtT* remainder = spanPtT->next(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 349 |
347 void SkOpSpan::setOppSum(int oppSum) { | 350 void SkOpSpan::setOppSum(int oppSum) { |
348 SkASSERT(!final()); | 351 SkASSERT(!final()); |
349 if (fOppSum != SK_MinS32 && fOppSum != oppSum) { | 352 if (fOppSum != SK_MinS32 && fOppSum != oppSum) { |
350 this->globalState()->setWindingFailed(); | 353 this->globalState()->setWindingFailed(); |
351 return; | 354 return; |
352 } | 355 } |
353 SkASSERT(!DEBUG_LIMIT_WIND_SUM || abs(oppSum) <= DEBUG_LIMIT_WIND_SUM); | 356 SkASSERT(!DEBUG_LIMIT_WIND_SUM || abs(oppSum) <= DEBUG_LIMIT_WIND_SUM); |
354 fOppSum = oppSum; | 357 fOppSum = oppSum; |
355 } | 358 } |
OLD | NEW |