| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkOpSegment.h" | 8 #include "SkOpSegment.h" |
| 9 #include "SkPathOpsTSect.h" | 9 #include "SkPathOpsTSect.h" |
| 10 | 10 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 SkASSERT(Ordered(coinPtTStart, oppPtTStart)); | 235 SkASSERT(Ordered(coinPtTStart, oppPtTStart)); |
| 236 // choose the ptT at the front of the list to track | 236 // choose the ptT at the front of the list to track |
| 237 coinPtTStart = coinPtTStart->span()->ptT(); | 237 coinPtTStart = coinPtTStart->span()->ptT(); |
| 238 coinPtTEnd = coinPtTEnd->span()->ptT(); | 238 coinPtTEnd = coinPtTEnd->span()->ptT(); |
| 239 oppPtTStart = oppPtTStart->span()->ptT(); | 239 oppPtTStart = oppPtTStart->span()->ptT(); |
| 240 oppPtTEnd = oppPtTEnd->span()->ptT(); | 240 oppPtTEnd = oppPtTEnd->span()->ptT(); |
| 241 SkOPASSERT(coinPtTStart->fT < coinPtTEnd->fT); | 241 SkOPASSERT(coinPtTStart->fT < coinPtTEnd->fT); |
| 242 SkASSERT(oppPtTStart->fT != oppPtTEnd->fT); | 242 SkOPASSERT(oppPtTStart->fT != oppPtTEnd->fT); |
| 243 SkOPASSERT(!coinPtTStart->deleted()); | 243 SkOPASSERT(!coinPtTStart->deleted()); |
| 244 SkOPASSERT(!coinPtTEnd->deleted()); | 244 SkOPASSERT(!coinPtTEnd->deleted()); |
| 245 SkOPASSERT(!oppPtTStart->deleted()); | 245 SkOPASSERT(!oppPtTStart->deleted()); |
| 246 SkOPASSERT(!oppPtTEnd->deleted()); | 246 SkOPASSERT(!oppPtTEnd->deleted()); |
| 247 DebugCheckAdd(fHead, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); | 247 DebugCheckAdd(fHead, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); |
| 248 DebugCheckAdd(fTop, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); | 248 DebugCheckAdd(fTop, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); |
| 249 SkCoincidentSpans* coinRec = SkOpTAllocator<SkCoincidentSpans>::Allocate( | 249 SkCoincidentSpans* coinRec = SkOpTAllocator<SkCoincidentSpans>::Allocate( |
| 250 this->globalState()->allocator()); | 250 this->globalState()->allocator()); |
| 251 coinRec->init(SkDEBUGCODE(fGlobalState)); | 251 coinRec->init(SkDEBUGCODE(fGlobalState)); |
| 252 coinRec->set(this->fHead, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); | 252 coinRec->set(this->fHead, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 return true; | 969 return true; |
| 970 } | 970 } |
| 971 do { | 971 do { |
| 972 SkOpSpan* start = coin->coinPtTStartWritable()->span()->upCast(); | 972 SkOpSpan* start = coin->coinPtTStartWritable()->span()->upCast(); |
| 973 if (start->deleted()) { | 973 if (start->deleted()) { |
| 974 continue; | 974 continue; |
| 975 } | 975 } |
| 976 const SkOpSpanBase* end = coin->coinPtTEnd()->span(); | 976 const SkOpSpanBase* end = coin->coinPtTEnd()->span(); |
| 977 SkASSERT(start == start->starter(end)); | 977 SkASSERT(start == start->starter(end)); |
| 978 bool flipped = coin->flipped(); | 978 bool flipped = coin->flipped(); |
| 979 SkOpSpan* oStart = (flipped ? coin->oppPtTEndWritable() | 979 SkOpSpanBase* oStartBase = (flipped ? coin->oppPtTEndWritable() |
| 980 : coin->oppPtTStartWritable())->span()->upCast(); | 980 : coin->oppPtTStartWritable())->span(); |
| 981 FAIL_IF(!oStartBase->upCastable()); |
| 982 SkOpSpan* oStart = oStartBase->upCast(); |
| 981 if (oStart->deleted()) { | 983 if (oStart->deleted()) { |
| 982 continue; | 984 continue; |
| 983 } | 985 } |
| 984 const SkOpSpanBase* oEnd = (flipped ? coin->oppPtTStart() : coin->oppPtT
End())->span(); | 986 const SkOpSpanBase* oEnd = (flipped ? coin->oppPtTStart() : coin->oppPtT
End())->span(); |
| 985 SkASSERT(oStart == oStart->starter(oEnd)); | 987 SkASSERT(oStart == oStart->starter(oEnd)); |
| 986 SkOpSegment* segment = start->segment(); | 988 SkOpSegment* segment = start->segment(); |
| 987 SkOpSegment* oSegment = oStart->segment(); | 989 SkOpSegment* oSegment = oStart->segment(); |
| 988 bool operandSwap = segment->operand() != oSegment->operand(); | 990 bool operandSwap = segment->operand() != oSegment->operand(); |
| 989 if (flipped) { | 991 if (flipped) { |
| 990 if (oEnd->deleted()) { | 992 if (oEnd->deleted()) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 segment->markDone(start); | 1070 segment->markDone(start); |
| 1069 } | 1071 } |
| 1070 if (!oWindValue && !oOppValue) { | 1072 if (!oWindValue && !oOppValue) { |
| 1071 oSegment->markDone(oStart); | 1073 oSegment->markDone(oStart); |
| 1072 } | 1074 } |
| 1073 SkOpSpanBase* next = start->next(); | 1075 SkOpSpanBase* next = start->next(); |
| 1074 SkOpSpanBase* oNext = flipped ? oStart->prev() : oStart->next(); | 1076 SkOpSpanBase* oNext = flipped ? oStart->prev() : oStart->next(); |
| 1075 if (next == end) { | 1077 if (next == end) { |
| 1076 break; | 1078 break; |
| 1077 } | 1079 } |
| 1080 FAIL_IF(!next->upCastable()); |
| 1078 start = next->upCast(); | 1081 start = next->upCast(); |
| 1079 // if the opposite ran out too soon, just reuse the last span | 1082 // if the opposite ran out too soon, just reuse the last span |
| 1080 if (!oNext || !oNext->upCastable()) { | 1083 if (!oNext || !oNext->upCastable()) { |
| 1081 oNext = oStart; | 1084 oNext = oStart; |
| 1082 } | 1085 } |
| 1083 oStart = oNext->upCast(); | 1086 oStart = oNext->upCast(); |
| 1084 } while (true); | 1087 } while (true); |
| 1085 } while ((coin = coin->next())); | 1088 } while ((coin = coin->next())); |
| 1086 return true; | 1089 return true; |
| 1087 } | 1090 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 const SkOpSegment* oSegment = oStart->segment(); | 1302 const SkOpSegment* oSegment = oStart->segment(); |
| 1300 SkOpSpanBase* next = start; | 1303 SkOpSpanBase* next = start; |
| 1301 SkOpSpanBase* oNext = oStart; | 1304 SkOpSpanBase* oNext = oStart; |
| 1302 bool ordered; | 1305 bool ordered; |
| 1303 FAIL_IF(!coin->ordered(&ordered)); | 1306 FAIL_IF(!coin->ordered(&ordered)); |
| 1304 while ((next = next->upCast()->next()) != end) { | 1307 while ((next = next->upCast()->next()) != end) { |
| 1305 FAIL_IF(!next->upCastable()); | 1308 FAIL_IF(!next->upCastable()); |
| 1306 SkAssertResult(next->upCast()->insertCoincidence(oSegment, flipped,
ordered)); | 1309 SkAssertResult(next->upCast()->insertCoincidence(oSegment, flipped,
ordered)); |
| 1307 } | 1310 } |
| 1308 while ((oNext = oNext->upCast()->next()) != oEnd) { | 1311 while ((oNext = oNext->upCast()->next()) != oEnd) { |
| 1312 FAIL_IF(!oNext->upCastable()); |
| 1309 FAIL_IF(!oNext->upCast()->insertCoincidence(segment, flipped, ordere
d)); | 1313 FAIL_IF(!oNext->upCast()->insertCoincidence(segment, flipped, ordere
d)); |
| 1310 } | 1314 } |
| 1311 } while ((coin = coin->next())); | 1315 } while ((coin = coin->next())); |
| 1312 return true; | 1316 return true; |
| 1313 } | 1317 } |
| 1314 | 1318 |
| 1315 // Please keep in sync with debugMarkCollapsed() | 1319 // Please keep in sync with debugMarkCollapsed() |
| 1316 void SkOpCoincidence::markCollapsed(SkCoincidentSpans* coin, SkOpPtT* test) { | 1320 void SkOpCoincidence::markCollapsed(SkCoincidentSpans* coin, SkOpPtT* test) { |
| 1317 SkCoincidentSpans* head = coin; | 1321 SkCoincidentSpans* head = coin; |
| 1318 while (coin) { | 1322 while (coin) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 } | 1378 } |
| 1375 do { | 1379 do { |
| 1376 if (coin->coinPtTStart()->segment() == deleted | 1380 if (coin->coinPtTStart()->segment() == deleted |
| 1377 || coin->coinPtTEnd()->segment() == deleted | 1381 || coin->coinPtTEnd()->segment() == deleted |
| 1378 || coin->oppPtTStart()->segment() == deleted | 1382 || coin->oppPtTStart()->segment() == deleted |
| 1379 || coin->oppPtTEnd()->segment() == deleted) { | 1383 || coin->oppPtTEnd()->segment() == deleted) { |
| 1380 this->release(fHead, coin); | 1384 this->release(fHead, coin); |
| 1381 } | 1385 } |
| 1382 } while ((coin = coin->next())); | 1386 } while ((coin = coin->next())); |
| 1383 } | 1387 } |
| OLD | NEW |