| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 double midT = (prev->t() + start->t()) / 2; | 62 double midT = (prev->t() + start->t()) / 2; |
| 63 if (!segment->isClose(midT, oppSegment)) { | 63 if (!segment->isClose(midT, oppSegment)) { |
| 64 break; | 64 break; |
| 65 } | 65 } |
| 66 setStarts(prev->ptT(), oppPtT); | 66 setStarts(prev->ptT(), oppPtT); |
| 67 expanded = true; | 67 expanded = true; |
| 68 } while (true); | 68 } while (true); |
| 69 do { | 69 do { |
| 70 const SkOpSpanBase* end = coinPtTEnd()->span(); | 70 const SkOpSpanBase* end = coinPtTEnd()->span(); |
| 71 SkOpSpanBase* next = end->final() ? nullptr : end->upCast()->next(); | 71 SkOpSpanBase* next = end->final() ? nullptr : end->upCast()->next(); |
| 72 if (next && next->deleted()) { |
| 73 break; |
| 74 } |
| 72 const SkOpPtT* oppPtT; | 75 const SkOpPtT* oppPtT; |
| 73 if (!next || !(oppPtT = next->contains(oppSegment))) { | 76 if (!next || !(oppPtT = next->contains(oppSegment))) { |
| 74 break; | 77 break; |
| 75 } | 78 } |
| 76 double midT = (end->t() + next->t()) / 2; | 79 double midT = (end->t() + next->t()) / 2; |
| 77 if (!segment->isClose(midT, oppSegment)) { | 80 if (!segment->isClose(midT, oppSegment)) { |
| 78 break; | 81 break; |
| 79 } | 82 } |
| 80 setEnds(next->ptT(), oppPtT); | 83 setEnds(next->ptT(), oppPtT); |
| 81 expanded = true; | 84 expanded = true; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 const SkOpPtT* stopPtT = testPtT; | 276 const SkOpPtT* stopPtT = testPtT; |
| 274 const SkOpSegment* baseSeg = base->segment(); | 277 const SkOpSegment* baseSeg = base->segment(); |
| 275 while ((testPtT = testPtT->next()) != stopPtT) { | 278 while ((testPtT = testPtT->next()) != stopPtT) { |
| 276 const SkOpSegment* testSeg = testPtT->segment(); | 279 const SkOpSegment* testSeg = testPtT->segment(); |
| 277 if (testPtT->deleted()) { | 280 if (testPtT->deleted()) { |
| 278 continue; | 281 continue; |
| 279 } | 282 } |
| 280 if (testSeg == baseSeg) { | 283 if (testSeg == baseSeg) { |
| 281 continue; | 284 continue; |
| 282 } | 285 } |
| 286 if (testPtT->span()->ptT() != testPtT) { |
| 287 continue; |
| 288 } |
| 283 if (this->contains(baseSeg, testSeg, testPtT->fT)) { | 289 if (this->contains(baseSeg, testSeg, testPtT->fT)) { |
| 284 continue; | 290 continue; |
| 285 } | 291 } |
| 286 // intersect perp with base->ptT() with testPtT->segment() | 292 // intersect perp with base->ptT() with testPtT->segment() |
| 287 SkDVector dxdy = baseSeg->dSlopeAtT(base->t()); | 293 SkDVector dxdy = baseSeg->dSlopeAtT(base->t()); |
| 288 const SkPoint& pt = base->pt(); | 294 const SkPoint& pt = base->pt(); |
| 289 SkDLine ray = {{{pt.fX, pt.fY}, {pt.fX + dxdy.fY, pt.fY - dxdy.fX}}}; | 295 SkDLine ray = {{{pt.fX, pt.fY}, {pt.fX + dxdy.fY, pt.fY - dxdy.fX}}}; |
| 290 SkIntersections i; | 296 SkIntersections i; |
| 291 (*CurveIntersectRay[testSeg->verb()])(testSeg->pts(), testSeg->weight(),
ray, &i); | 297 (*CurveIntersectRay[testSeg->verb()])(testSeg->pts(), testSeg->weight(),
ray, &i); |
| 292 for (int index = 0; index < i.used(); ++index) { | 298 for (int index = 0; index < i.used(); ++index) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 // if the spans don't match, add the missing pt to the segment and loop it in th
e opposite span | 421 // if the spans don't match, add the missing pt to the segment and loop it in th
e opposite span |
| 416 bool SkOpCoincidence::addExpanded() { | 422 bool SkOpCoincidence::addExpanded() { |
| 417 SkCoincidentSpans* coin = this->fHead; | 423 SkCoincidentSpans* coin = this->fHead; |
| 418 if (!coin) { | 424 if (!coin) { |
| 419 return true; | 425 return true; |
| 420 } | 426 } |
| 421 do { | 427 do { |
| 422 const SkOpPtT* startPtT = coin->coinPtTStart(); | 428 const SkOpPtT* startPtT = coin->coinPtTStart(); |
| 423 const SkOpPtT* oStartPtT = coin->oppPtTStart(); | 429 const SkOpPtT* oStartPtT = coin->oppPtTStart(); |
| 424 SkASSERT(startPtT->contains(oStartPtT)); | 430 SkASSERT(startPtT->contains(oStartPtT)); |
| 425 SkASSERT(coin->coinPtTEnd()->contains(coin->oppPtTEnd())); | 431 SkOPASSERT(coin->coinPtTEnd()->contains(coin->oppPtTEnd())); |
| 426 const SkOpSpanBase* start = startPtT->span(); | 432 const SkOpSpanBase* start = startPtT->span(); |
| 427 const SkOpSpanBase* oStart = oStartPtT->span(); | 433 const SkOpSpanBase* oStart = oStartPtT->span(); |
| 428 const SkOpSpanBase* end = coin->coinPtTEnd()->span(); | 434 const SkOpSpanBase* end = coin->coinPtTEnd()->span(); |
| 429 const SkOpSpanBase* oEnd = coin->oppPtTEnd()->span(); | 435 const SkOpSpanBase* oEnd = coin->oppPtTEnd()->span(); |
| 430 FAIL_IF(oEnd->deleted()); | 436 FAIL_IF(oEnd->deleted()); |
| 431 FAIL_IF(!start->upCastable()); | 437 FAIL_IF(!start->upCastable()); |
| 432 const SkOpSpanBase* test = start->upCast()->next(); | 438 const SkOpSpanBase* test = start->upCast()->next(); |
| 433 const SkOpSpanBase* oTest = coin->flipped() ? oStart->prev() : oStart->u
pCast()->next(); | 439 const SkOpSpanBase* oTest = coin->flipped() ? oStart->prev() : oStart->u
pCast()->next(); |
| 434 if (!oTest) { | 440 if (!oTest) { |
| 435 return false; | 441 return false; |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 this->release(fHead, coin); | 1472 this->release(fHead, coin); |
| 1467 } | 1473 } |
| 1468 } while ((coin = coin->next())); | 1474 } while ((coin = coin->next())); |
| 1469 } | 1475 } |
| 1470 | 1476 |
| 1471 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, | 1477 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, |
| 1472 const SkOpPtT* testE) const { | 1478 const SkOpPtT* testE) const { |
| 1473 return testS->segment()->testForCoincidence(testS, testE, testS->span(), | 1479 return testS->segment()->testForCoincidence(testS, testE, testS->span(), |
| 1474 testE->span(), outer->coinPtTStart()->segment()); | 1480 testE->span(), outer->coinPtTStart()->segment()); |
| 1475 } | 1481 } |
| OLD | NEW |