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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 if (coin->fOppPtTStart->span() == kept->span()) { | 627 if (coin->fOppPtTStart->span() == kept->span()) { |
628 this->release(coin); | 628 this->release(coin); |
629 continue; | 629 continue; |
630 } | 630 } |
631 coin->fOppPtTEnd = kept; | 631 coin->fOppPtTEnd = kept; |
632 } | 632 } |
633 } while ((coin = coin->fNext)); | 633 } while ((coin = coin->fNext)); |
634 } | 634 } |
635 | 635 |
636 /* this sets up the coincidence links in the segments when the coincidence cross
es multiple spans */ | 636 /* this sets up the coincidence links in the segments when the coincidence cross
es multiple spans */ |
637 void SkOpCoincidence::mark() { | 637 bool SkOpCoincidence::mark() { |
638 SkCoincidentSpans* coin = fHead; | 638 SkCoincidentSpans* coin = fHead; |
639 if (!coin) { | 639 if (!coin) { |
640 return; | 640 return true; |
641 } | 641 } |
642 do { | 642 do { |
643 SkOpSpanBase* end = coin->fCoinPtTEnd->span(); | 643 SkOpSpanBase* end = coin->fCoinPtTEnd->span(); |
| 644 if (end->deleted()) { |
| 645 return false; |
| 646 } |
644 SkOpSpanBase* oldEnd = end; | 647 SkOpSpanBase* oldEnd = end; |
645 SkOpSpan* start = coin->fCoinPtTStart->span()->starter(&end); | 648 SkOpSpan* start = coin->fCoinPtTStart->span()->starter(&end); |
646 SkOpSpanBase* oEnd = coin->fOppPtTEnd->span(); | 649 SkOpSpanBase* oEnd = coin->fOppPtTEnd->span(); |
| 650 if (oEnd->deleted()) { |
| 651 return false; |
| 652 } |
647 SkOpSpanBase* oOldEnd = oEnd; | 653 SkOpSpanBase* oOldEnd = oEnd; |
648 SkOpSpanBase* oStart = coin->fOppPtTStart->span()->starter(&oEnd); | 654 SkOpSpanBase* oStart = coin->fOppPtTStart->span()->starter(&oEnd); |
649 bool flipped = (end == oldEnd) != (oEnd == oOldEnd); | 655 bool flipped = (end == oldEnd) != (oEnd == oOldEnd); |
650 if (flipped) { | 656 if (flipped) { |
651 SkTSwap(oStart, oEnd); | 657 SkTSwap(oStart, oEnd); |
652 } | 658 } |
653 SkOpSpanBase* next = start; | 659 SkOpSpanBase* next = start; |
654 SkOpSpanBase* oNext = oStart; | 660 SkOpSpanBase* oNext = oStart; |
655 do { | 661 do { |
656 next = next->upCast()->next(); | 662 next = next->upCast()->next(); |
657 oNext = flipped ? oNext->prev() : oNext->upCast()->next(); | 663 oNext = flipped ? oNext->prev() : oNext->upCast()->next(); |
658 if (next == end || oNext == oEnd) { | 664 if (next == end || oNext == oEnd) { |
659 break; | 665 break; |
660 } | 666 } |
661 if (!next->containsCoinEnd(oNext)) { | 667 if (!next->containsCoinEnd(oNext)) { |
662 next->insertCoinEnd(oNext); | 668 next->insertCoinEnd(oNext); |
663 } | 669 } |
664 SkOpSpan* nextSpan = next->upCast(); | 670 SkOpSpan* nextSpan = next->upCast(); |
665 SkOpSpan* oNextSpan = oNext->upCast(); | 671 SkOpSpan* oNextSpan = oNext->upCast(); |
666 if (!nextSpan->containsCoincidence(oNextSpan)) { | 672 if (!nextSpan->containsCoincidence(oNextSpan)) { |
667 nextSpan->insertCoincidence(oNextSpan); | 673 nextSpan->insertCoincidence(oNextSpan); |
668 } | 674 } |
669 } while (true); | 675 } while (true); |
670 } while ((coin = coin->fNext)); | 676 } while ((coin = coin->fNext)); |
| 677 return true; |
671 } | 678 } |
672 | 679 |
673 bool SkOpCoincidence::overlap(const SkOpPtT* coin1s, const SkOpPtT* coin1e, | 680 bool SkOpCoincidence::overlap(const SkOpPtT* coin1s, const SkOpPtT* coin1e, |
674 const SkOpPtT* coin2s, const SkOpPtT* coin2e, double* overS, double* ove
rE) const { | 681 const SkOpPtT* coin2s, const SkOpPtT* coin2e, double* overS, double* ove
rE) const { |
675 SkASSERT(coin1s->segment() == coin2s->segment()); | 682 SkASSERT(coin1s->segment() == coin2s->segment()); |
676 *overS = SkTMax(SkTMin(coin1s->fT, coin1e->fT), SkTMin(coin2s->fT, coin2e->f
T)); | 683 *overS = SkTMax(SkTMin(coin1s->fT, coin1e->fT), SkTMin(coin2s->fT, coin2e->f
T)); |
677 *overE = SkTMin(SkTMax(coin1s->fT, coin1e->fT), SkTMax(coin2s->fT, coin2e->f
T)); | 684 *overE = SkTMin(SkTMax(coin1s->fT, coin1e->fT), SkTMax(coin2s->fT, coin2e->f
T)); |
678 return *overS < *overE; | 685 return *overS < *overE; |
679 } | 686 } |
680 | 687 |
681 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, | 688 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, |
682 const SkOpPtT* testE) const { | 689 const SkOpPtT* testE) const { |
683 return testS->segment()->testForCoincidence(testS, testE, testS->span(), | 690 return testS->segment()->testForCoincidence(testS, testE, testS->span(), |
684 testE->span(), outer->fCoinPtTStart->segment(), 120000); // FIXME:
replace with tuned | 691 testE->span(), outer->fCoinPtTStart->segment(), 120000); // FIXME:
replace with tuned |
685 } | 692 } |
OLD | NEW |