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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 double SkOpCoincidence::TRange(const SkOpPtT* overS, double t, | 544 double SkOpCoincidence::TRange(const SkOpPtT* overS, double t, |
545 const SkOpSegment* coinSeg SkDEBUGPARAMS(const SkOpPtT* overE)) { | 545 const SkOpSegment* coinSeg SkDEBUGPARAMS(const SkOpPtT* overE)) { |
546 const SkOpSpanBase* work = overS->span(); | 546 const SkOpSpanBase* work = overS->span(); |
547 const SkOpPtT* foundStart = nullptr; | 547 const SkOpPtT* foundStart = nullptr; |
548 const SkOpPtT* foundEnd = nullptr; | 548 const SkOpPtT* foundEnd = nullptr; |
549 const SkOpPtT* coinStart = nullptr; | 549 const SkOpPtT* coinStart = nullptr; |
550 const SkOpPtT* coinEnd = nullptr; | 550 const SkOpPtT* coinEnd = nullptr; |
551 do { | 551 do { |
552 const SkOpPtT* contained = work->contains(coinSeg); | 552 const SkOpPtT* contained = work->contains(coinSeg); |
553 if (!contained) { | 553 if (!contained) { |
554 if (work->t() >= t) { | 554 if (work->final()) { |
555 return 1; | 555 break; |
556 } | 556 } |
557 continue; | 557 continue; |
558 } | 558 } |
559 if (work->t() <= t) { | 559 if (work->t() <= t) { |
560 coinStart = contained; | 560 coinStart = contained; |
561 foundStart = work->ptT(); | 561 foundStart = work->ptT(); |
562 } | 562 } |
563 if (work->t() >= t) { | 563 if (work->t() >= t) { |
564 coinEnd = contained; | 564 coinEnd = contained; |
565 foundEnd = work->ptT(); | 565 foundEnd = work->ptT(); |
566 break; | 566 break; |
567 } | 567 } |
568 SkASSERT(work->ptT() != overE); | 568 SkASSERT(work->ptT() != overE); |
569 } while ((work = work->upCast()->next())); | 569 } while ((work = work->upCast()->next())); |
570 SkASSERT(coinStart); | 570 if (!coinStart || !coinEnd) { |
571 SkASSERT(coinEnd); | 571 return 1; |
| 572 } |
572 // while overS->fT <=t and overS contains coinSeg | 573 // while overS->fT <=t and overS contains coinSeg |
573 double denom = foundEnd->fT - foundStart->fT; | 574 double denom = foundEnd->fT - foundStart->fT; |
574 double sRatio = denom ? (t - foundStart->fT) / denom : 1; | 575 double sRatio = denom ? (t - foundStart->fT) / denom : 1; |
575 return coinStart->fT + (coinEnd->fT - coinStart->fT) * sRatio; | 576 return coinStart->fT + (coinEnd->fT - coinStart->fT) * sRatio; |
576 } | 577 } |
577 | 578 |
578 // return true if span overlaps existing and needs to adjust the coincident list | 579 // return true if span overlaps existing and needs to adjust the coincident list |
579 bool SkOpCoincidence::checkOverlap(SkCoincidentSpans* check, | 580 bool SkOpCoincidence::checkOverlap(SkCoincidentSpans* check, |
580 const SkOpSegment* coinSeg, const SkOpSegment* oppSeg, | 581 const SkOpSegment* coinSeg, const SkOpSegment* oppSeg, |
581 double coinTs, double coinTe, double oppTs, double oppTe, | 582 double coinTs, double coinTe, double oppTs, double oppTe, |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 this->release(fHead, coin); | 1568 this->release(fHead, coin); |
1568 } | 1569 } |
1569 } while ((coin = coin->next())); | 1570 } while ((coin = coin->next())); |
1570 } | 1571 } |
1571 | 1572 |
1572 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, | 1573 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, |
1573 const SkOpPtT* testE) const { | 1574 const SkOpPtT* testE) const { |
1574 return testS->segment()->testForCoincidence(testS, testE, testS->span(), | 1575 return testS->segment()->testForCoincidence(testS, testE, testS->span(), |
1575 testE->span(), outer->coinPtTStart()->segment()); | 1576 testE->span(), outer->coinPtTStart()->segment()); |
1576 } | 1577 } |
OLD | NEW |