OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 | 7 |
8 #include "SkMutex.h" | 8 #include "SkMutex.h" |
9 #include "SkOpCoincidence.h" | 9 #include "SkOpCoincidence.h" |
10 #include "SkOpContour.h" | 10 #include "SkOpContour.h" |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 684 |
685 int SkIntersections::debugLoopCount(DebugLoop index) const { | 685 int SkIntersections::debugLoopCount(DebugLoop index) const { |
686 return fDebugLoopCount[index]; | 686 return fDebugLoopCount[index]; |
687 } | 687 } |
688 | 688 |
689 void SkIntersections::debugResetLoopCount() { | 689 void SkIntersections::debugResetLoopCount() { |
690 sk_bzero(fDebugLoopCount, sizeof(fDebugLoopCount)); | 690 sk_bzero(fDebugLoopCount, sizeof(fDebugLoopCount)); |
691 } | 691 } |
692 #endif | 692 #endif |
693 | 693 |
| 694 #include "SkPathOpsConic.h" |
694 #include "SkPathOpsCubic.h" | 695 #include "SkPathOpsCubic.h" |
695 #include "SkPathOpsQuad.h" | |
696 | 696 |
697 SkDCubic SkDQuad::debugToCubic() const { | 697 SkDCubic SkDQuad::debugToCubic() const { |
698 SkDCubic cubic; | 698 SkDCubic cubic; |
699 cubic[0] = fPts[0]; | 699 cubic[0] = fPts[0]; |
700 cubic[2] = fPts[1]; | 700 cubic[2] = fPts[1]; |
701 cubic[3] = fPts[2]; | 701 cubic[3] = fPts[2]; |
702 cubic[1].fX = (cubic[0].fX + cubic[2].fX * 2) / 3; | 702 cubic[1].fX = (cubic[0].fX + cubic[2].fX * 2) / 3; |
703 cubic[1].fY = (cubic[0].fY + cubic[2].fY * 2) / 3; | 703 cubic[1].fY = (cubic[0].fY + cubic[2].fY * 2) / 3; |
704 cubic[2].fX = (cubic[3].fX + cubic[2].fX * 2) / 3; | 704 cubic[2].fX = (cubic[3].fX + cubic[2].fX * 2) / 3; |
705 cubic[2].fY = (cubic[3].fY + cubic[2].fY * 2) / 3; | 705 cubic[2].fY = (cubic[3].fY + cubic[2].fY * 2) / 3; |
706 return cubic; | 706 return cubic; |
707 } | 707 } |
708 | 708 |
| 709 void SkDQuad::debugSet(const SkDPoint* pts) { |
| 710 memcpy(fPts, pts, sizeof(fPts)); |
| 711 SkDEBUGCODE(fDebugGlobalState = nullptr); |
| 712 } |
| 713 |
| 714 void SkDCubic::debugSet(const SkDPoint* pts) { |
| 715 memcpy(fPts, pts, sizeof(fPts)); |
| 716 SkDEBUGCODE(fDebugGlobalState = nullptr); |
| 717 } |
| 718 |
| 719 void SkDConic::debugSet(const SkDPoint* pts, SkScalar weight) { |
| 720 fPts.debugSet(pts); |
| 721 fWeight = weight; |
| 722 } |
| 723 |
709 void SkDRect::debugInit() { | 724 void SkDRect::debugInit() { |
710 fLeft = fTop = fRight = fBottom = SK_ScalarNaN; | 725 fLeft = fTop = fRight = fBottom = SK_ScalarNaN; |
711 } | 726 } |
712 | 727 |
713 #include "SkOpAngle.h" | 728 #include "SkOpAngle.h" |
714 #include "SkOpSegment.h" | 729 #include "SkOpSegment.h" |
715 | 730 |
716 #if DEBUG_COIN | 731 #if DEBUG_COIN |
717 // commented-out lines keep this in sync with addT() | 732 // commented-out lines keep this in sync with addT() |
718 const SkOpPtT* SkOpSegment::debugAddT(double t, SkPathOpsDebug::GlitchLog* log)
const { | 733 const SkOpPtT* SkOpSegment::debugAddT(double t, SkPathOpsDebug::GlitchLog* log)
const { |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 } | 1603 } |
1589 } while ((span = span->next())); | 1604 } while ((span = span->next())); |
1590 // this->restoreHead(); | 1605 // this->restoreHead(); |
1591 return; | 1606 return; |
1592 } | 1607 } |
1593 | 1608 |
1594 /* Commented-out lines keep this in sync with addExpanded */ | 1609 /* Commented-out lines keep this in sync with addExpanded */ |
1595 // for each coincident pair, match the spans | 1610 // for each coincident pair, match the spans |
1596 // if the spans don't match, add the mssing pt to the segment and loop it in the
opposite span | 1611 // if the spans don't match, add the mssing pt to the segment and loop it in the
opposite span |
1597 void SkOpCoincidence::debugAddExpanded(SkPathOpsDebug::GlitchLog* log) const { | 1612 void SkOpCoincidence::debugAddExpanded(SkPathOpsDebug::GlitchLog* log) const { |
| 1613 // DEBUG_SET_PHASE(); |
1598 const SkCoincidentSpans* coin = this->fHead; | 1614 const SkCoincidentSpans* coin = this->fHead; |
1599 if (!coin) { | 1615 if (!coin) { |
1600 return; | 1616 return; |
1601 } | 1617 } |
1602 do { | 1618 do { |
1603 const SkOpPtT* startPtT = coin->coinPtTStart(); | 1619 const SkOpPtT* startPtT = coin->coinPtTStart(); |
1604 const SkOpPtT* oStartPtT = coin->oppPtTStart(); | 1620 const SkOpPtT* oStartPtT = coin->oppPtTStart(); |
1605 double priorT = startPtT->fT; | 1621 double priorT = startPtT->fT; |
1606 double oPriorT = oStartPtT->fT; | 1622 double oPriorT = oStartPtT->fT; |
1607 FAIL_IF(startPtT->contains(oStartPtT), coin); | 1623 FAIL_IF(startPtT->contains(oStartPtT), coin); |
(...skipping 24 matching lines...) Expand all Loading... |
1632 oNextT = oTest->t(); | 1648 oNextT = oTest->t(); |
1633 } else { | 1649 } else { |
1634 // iterate through until a pt-t list found that contains the
other | 1650 // iterate through until a pt-t list found that contains the
other |
1635 const SkOpSpanBase* walk = test; | 1651 const SkOpSpanBase* walk = test; |
1636 const SkOpPtT* walkOpp; | 1652 const SkOpPtT* walkOpp; |
1637 do { | 1653 do { |
1638 FAIL_IF(!walk->upCastable(), coin); | 1654 FAIL_IF(!walk->upCastable(), coin); |
1639 walk = walk->upCast()->next(); | 1655 walk = walk->upCast()->next(); |
1640 } while (!(walkOpp = walk->ptT()->contains(oSeg)) | 1656 } while (!(walkOpp = walk->ptT()->contains(oSeg)) |
1641 && walk != coin->coinPtTEnd()->span()); | 1657 && walk != coin->coinPtTEnd()->span()); |
| 1658 FAIL_IF(!walkOpp, coin); |
1642 nextT = walk->t(); | 1659 nextT = walk->t(); |
1643 oNextT = walkOpp->fT; | 1660 oNextT = walkOpp->fT; |
1644 } | 1661 } |
1645 // use t ranges to guess which one is missing | 1662 // use t ranges to guess which one is missing |
1646 double startRange = coin->coinPtTEnd()->fT - startPtT->fT; | 1663 double startRange = nextT - priorT; |
1647 FAIL_IF(!startRange, coin); | 1664 FAIL_IF(!startRange, coin); |
1648 double startPart = (test->t() - startPtT->fT) / startRange; | 1665 double startPart = (test->t() - priorT) / startRange; |
1649 double oStartRange = coin->oppPtTEnd()->fT - oStartPtT->fT; | 1666 double oStartRange = oNextT - oPriorT; |
1650 FAIL_IF(!oStartRange, coin); | 1667 FAIL_IF(!oStartRange, coin); |
1651 double oStartPart = (oTest->t() - oStartPtT->fT) / oStartRange; | 1668 double oStartPart = (oTest->t() - oStartPtT->fT) / oStartRange; |
1652 FAIL_IF(startPart == oStartPart, coin); | 1669 FAIL_IF(startPart == oStartPart, coin); |
1653 bool addToOpp = !containedOpp && !containedThis ? startPart < oS
tartPart | 1670 bool addToOpp = !containedOpp && !containedThis ? startPart < oS
tartPart |
1654 : !!containedThis; | 1671 : !!containedThis; |
1655 bool startOver = false; | 1672 bool startOver = false; |
1656 addToOpp ? log->record(SkPathOpsDebug::kAddExpandedCoin_Glitch, | 1673 addToOpp ? log->record(SkPathOpsDebug::kAddExpandedCoin_Glitch, |
1657 oPriorT + oStartRange * startPart, test) | 1674 oPriorT + oStartRange * startPart, test) |
1658 : log->record(SkPathOpsDebug::kAddExpandedCoin_Glitch, | 1675 : log->record(SkPathOpsDebug::kAddExpandedCoin_Glitch, |
1659 priorT + startRange * oStartPart, oTest); | 1676 priorT + startRange * oStartPart, oTest); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 SkTSwap(oStart, oEnd); | 2039 SkTSwap(oStart, oEnd); |
2023 } | 2040 } |
2024 /* coin and opp spans may not match up. Mark the ends, and then let the
interior | 2041 /* coin and opp spans may not match up. Mark the ends, and then let the
interior |
2025 get marked as many times as the spans allow */ | 2042 get marked as many times as the spans allow */ |
2026 start->debugInsertCoincidence(log, oStart->upCast()); | 2043 start->debugInsertCoincidence(log, oStart->upCast()); |
2027 end->debugInsertCoinEnd(log, oEnd); | 2044 end->debugInsertCoinEnd(log, oEnd); |
2028 const SkOpSegment* segment = start->segment(); | 2045 const SkOpSegment* segment = start->segment(); |
2029 const SkOpSegment* oSegment = oStart->segment(); | 2046 const SkOpSegment* oSegment = oStart->segment(); |
2030 const SkOpSpanBase* next = start; | 2047 const SkOpSpanBase* next = start; |
2031 const SkOpSpanBase* oNext = oStart; | 2048 const SkOpSpanBase* oNext = oStart; |
2032 bool ordered = coin->ordered(); | 2049 bool ordered; |
| 2050 FAIL_IF(!coin->ordered(&ordered), coin); |
2033 while ((next = next->upCast()->next()) != end) { | 2051 while ((next = next->upCast()->next()) != end) { |
2034 FAIL_IF(!next->upCastable(), coin); | 2052 FAIL_IF(!next->upCastable(), coin); |
2035 if (next->upCast()->debugInsertCoincidence(log, oSegment, flipped, o
rdered), false) { | 2053 if (next->upCast()->debugInsertCoincidence(log, oSegment, flipped, o
rdered), false) { |
2036 return; | 2054 return; |
2037 } | 2055 } |
2038 } | 2056 } |
2039 while ((oNext = oNext->upCast()->next()) != oEnd) { | 2057 while ((oNext = oNext->upCast()->next()) != oEnd) { |
2040 FAIL_IF(!oNext->upCastable(), coin); | 2058 FAIL_IF(!oNext->upCastable(), coin); |
2041 if (oNext->upCast()->debugInsertCoincidence(log, segment, flipped, o
rdered), false) { | 2059 if (oNext->upCast()->debugInsertCoincidence(log, segment, flipped, o
rdered), false) { |
2042 return; | 2060 return; |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2881 #endif | 2899 #endif |
2882 SkPath::FillType fillType = path.getFillType(); | 2900 SkPath::FillType fillType = path.getFillType(); |
2883 SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInver
seEvenOdd_FillType); | 2901 SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInver
seEvenOdd_FillType); |
2884 if (includeDeclaration) { | 2902 if (includeDeclaration) { |
2885 SkDebugf(" SkPath %s;\n", name); | 2903 SkDebugf(" SkPath %s;\n", name); |
2886 } | 2904 } |
2887 SkDebugf(" %s.setFillType(SkPath::%s);\n", name, gFillTypeStr[fillType]); | 2905 SkDebugf(" %s.setFillType(SkPath::%s);\n", name, gFillTypeStr[fillType]); |
2888 iter.setPath(path); | 2906 iter.setPath(path); |
2889 showPathContours(iter, name); | 2907 showPathContours(iter, name); |
2890 } | 2908 } |
OLD | NEW |