| 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 if (!success) { | 454 if (!success) { |
| 455 SkOPASSERT(false); | 455 SkOPASSERT(false); |
| 456 return false; | 456 return false; |
| 457 } | 457 } |
| 458 if (startOver) { | 458 if (startOver) { |
| 459 test = start; | 459 test = start; |
| 460 oTest = oStart; | 460 oTest = oStart; |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 if (test != end) { | 463 if (test != end) { |
| 464 if (!test->upCastable()) { |
| 465 return false; |
| 466 } |
| 464 test = test->upCast()->next(); | 467 test = test->upCast()->next(); |
| 465 } | 468 } |
| 466 if (oTest != oEnd) { | 469 if (oTest != oEnd) { |
| 467 oTest = coin->flipped() ? oTest->prev() : oTest->upCast()->next(
); | 470 oTest = coin->flipped() ? oTest->prev() : oTest->upCast()->next(
); |
| 468 if (!oTest) { | 471 if (!oTest) { |
| 469 return false; | 472 return false; |
| 470 } | 473 } |
| 471 } | 474 } |
| 472 } | 475 } |
| 473 } while ((coin = coin->next())); | 476 } while ((coin = coin->next())); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 if (coinSeg == oppSeg) { | 602 if (coinSeg == oppSeg) { |
| 600 return false; | 603 return false; |
| 601 } | 604 } |
| 602 return this->addOrOverlap(coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe); | 605 return this->addOrOverlap(coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe); |
| 603 } | 606 } |
| 604 | 607 |
| 605 /* Please keep this in sync with debugAddOrOverlap() */ | 608 /* Please keep this in sync with debugAddOrOverlap() */ |
| 606 bool SkOpCoincidence::addOrOverlap(SkOpSegment* coinSeg, SkOpSegment* oppSeg, | 609 bool SkOpCoincidence::addOrOverlap(SkOpSegment* coinSeg, SkOpSegment* oppSeg, |
| 607 double coinTs, double coinTe, double oppTs, double oppTe) { | 610 double coinTs, double coinTe, double oppTs, double oppTe) { |
| 608 SkTDArray<SkCoincidentSpans*> overlaps; | 611 SkTDArray<SkCoincidentSpans*> overlaps; |
| 609 SkASSERT(fTop); | 612 if (!fTop) { |
| 613 return false; |
| 614 } |
| 610 if (!this->checkOverlap(fTop, coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe,
&overlaps)) { | 615 if (!this->checkOverlap(fTop, coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe,
&overlaps)) { |
| 611 return false; | 616 return false; |
| 612 } | 617 } |
| 613 if (fHead && !this->checkOverlap(fHead, coinSeg, oppSeg, coinTs, | 618 if (fHead && !this->checkOverlap(fHead, coinSeg, oppSeg, coinTs, |
| 614 coinTe, oppTs, oppTe, &overlaps)) { | 619 coinTe, oppTs, oppTe, &overlaps)) { |
| 615 return false; | 620 return false; |
| 616 } | 621 } |
| 617 SkCoincidentSpans* overlap = overlaps.count() ? overlaps[0] : nullptr; | 622 SkCoincidentSpans* overlap = overlaps.count() ? overlaps[0] : nullptr; |
| 618 for (int index = 1; index < overlaps.count(); ++index) { // combine overlaps
before continuing | 623 for (int index = 1; index < overlaps.count(); ++index) { // combine overlaps
before continuing |
| 619 SkCoincidentSpans* test = overlaps[index]; | 624 SkCoincidentSpans* test = overlaps[index]; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 if (oeExisting && (oeExisting == os || oeExisting->contains(osExisting ? osE
xisting : os))) { | 681 if (oeExisting && (oeExisting == os || oeExisting->contains(osExisting ? osE
xisting : os))) { |
| 677 return false; | 682 return false; |
| 678 } | 683 } |
| 679 // extra line in debug code | 684 // extra line in debug code |
| 680 this->debugValidate(); | 685 this->debugValidate(); |
| 681 if (!cs || !os) { | 686 if (!cs || !os) { |
| 682 SkOpPtT* csWritable = cs ? const_cast<SkOpPtT*>(cs) | 687 SkOpPtT* csWritable = cs ? const_cast<SkOpPtT*>(cs) |
| 683 : coinSeg->addT(coinTs, SkOpSegment::kNoAliasMatch, nullptr); | 688 : coinSeg->addT(coinTs, SkOpSegment::kNoAliasMatch, nullptr); |
| 684 SkOpPtT* osWritable = os ? const_cast<SkOpPtT*>(os) | 689 SkOpPtT* osWritable = os ? const_cast<SkOpPtT*>(os) |
| 685 : oppSeg->addT(oppTs, SkOpSegment::kNoAliasMatch, nullptr); | 690 : oppSeg->addT(oppTs, SkOpSegment::kNoAliasMatch, nullptr); |
| 691 if (!osWritable) { |
| 692 return false; |
| 693 } |
| 686 csWritable->span()->addOppAndMerge(osWritable->span()); | 694 csWritable->span()->addOppAndMerge(osWritable->span()); |
| 687 cs = csWritable; | 695 cs = csWritable; |
| 688 os = osWritable; | 696 os = osWritable; |
| 689 if ((ce && ce->deleted()) || (oe && oe->deleted())) { | 697 if ((ce && ce->deleted()) || (oe && oe->deleted())) { |
| 690 return false; | 698 return false; |
| 691 } | 699 } |
| 692 } | 700 } |
| 693 if (!ce || !oe) { | 701 if (!ce || !oe) { |
| 694 SkOpPtT* ceWritable = ce ? const_cast<SkOpPtT*>(ce) | 702 SkOpPtT* ceWritable = ce ? const_cast<SkOpPtT*>(ce) |
| 695 : coinSeg->addT(coinTe, SkOpSegment::kNoAliasMatch, nullptr); | 703 : coinSeg->addT(coinTe, SkOpSegment::kNoAliasMatch, nullptr); |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 SkOpSpanBase* oNext = oStart; | 1380 SkOpSpanBase* oNext = oStart; |
| 1373 while ((next = next->upCast()->next()) != end) { | 1381 while ((next = next->upCast()->next()) != end) { |
| 1374 if (!next->upCastable()) { | 1382 if (!next->upCastable()) { |
| 1375 return false; | 1383 return false; |
| 1376 } | 1384 } |
| 1377 if (!next->upCast()->insertCoincidence(oSegment, flipped)) { | 1385 if (!next->upCast()->insertCoincidence(oSegment, flipped)) { |
| 1378 return false; | 1386 return false; |
| 1379 } | 1387 } |
| 1380 } | 1388 } |
| 1381 while ((oNext = oNext->upCast()->next()) != oEnd) { | 1389 while ((oNext = oNext->upCast()->next()) != oEnd) { |
| 1390 if (!oNext->upCastable()) { |
| 1391 return false; |
| 1392 } |
| 1382 if (!oNext->upCast()->insertCoincidence(segment, flipped)) { | 1393 if (!oNext->upCast()->insertCoincidence(segment, flipped)) { |
| 1383 return false; | 1394 return false; |
| 1384 } | 1395 } |
| 1385 } | 1396 } |
| 1386 } while ((coin = coin->next())); | 1397 } while ((coin = coin->next())); |
| 1387 return true; | 1398 return true; |
| 1388 } | 1399 } |
| 1389 | 1400 |
| 1390 // Please keep in sync with debugMarkCollapsed() | 1401 // Please keep in sync with debugMarkCollapsed() |
| 1391 void SkOpCoincidence::markCollapsed(SkCoincidentSpans* coin, SkOpPtT* test) { | 1402 void SkOpCoincidence::markCollapsed(SkCoincidentSpans* coin, SkOpPtT* test) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 this->release(fHead, coin); | 1466 this->release(fHead, coin); |
| 1456 } | 1467 } |
| 1457 } while ((coin = coin->next())); | 1468 } while ((coin = coin->next())); |
| 1458 } | 1469 } |
| 1459 | 1470 |
| 1460 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, | 1471 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, |
| 1461 const SkOpPtT* testE) const { | 1472 const SkOpPtT* testE) const { |
| 1462 return testS->segment()->testForCoincidence(testS, testE, testS->span(), | 1473 return testS->segment()->testForCoincidence(testS, testE, testS->span(), |
| 1463 testE->span(), outer->coinPtTStart()->segment()); | 1474 testE->span(), outer->coinPtTStart()->segment()); |
| 1464 } | 1475 } |
| OLD | NEW |