| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 "SkBuffer.h" | 8 #include "SkBuffer.h" |
| 9 #include "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
| 10 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
| (...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 // Set the first return pt to the move pt | 1605 // Set the first return pt to the move pt |
| 1606 fSegmentState = kAfterPrimitive_SegmentState; | 1606 fSegmentState = kAfterPrimitive_SegmentState; |
| 1607 return fMoveTo; | 1607 return fMoveTo; |
| 1608 } else { | 1608 } else { |
| 1609 SkASSERT(fSegmentState == kAfterPrimitive_SegmentState); | 1609 SkASSERT(fSegmentState == kAfterPrimitive_SegmentState); |
| 1610 // Set the first return pt to the last pt of the previous primitive. | 1610 // Set the first return pt to the last pt of the previous primitive. |
| 1611 return fPts[-1]; | 1611 return fPts[-1]; |
| 1612 } | 1612 } |
| 1613 } | 1613 } |
| 1614 | 1614 |
| 1615 void SkPath::Iter::consumeDegenerateSegments() { | 1615 void SkPath::Iter::consumeDegenerateSegments(bool exact) { |
| 1616 // We need to step over anything that will not move the current draw point | 1616 // We need to step over anything that will not move the current draw point |
| 1617 // forward before the next move is seen | 1617 // forward before the next move is seen |
| 1618 const uint8_t* lastMoveVerb = 0; | 1618 const uint8_t* lastMoveVerb = 0; |
| 1619 const SkPoint* lastMovePt = 0; | 1619 const SkPoint* lastMovePt = 0; |
| 1620 const SkScalar* lastMoveWeight = NULL; | 1620 const SkScalar* lastMoveWeight = NULL; |
| 1621 SkPoint lastPt = fLastPt; | 1621 SkPoint lastPt = fLastPt; |
| 1622 while (fVerbs != fVerbStop) { | 1622 while (fVerbs != fVerbStop) { |
| 1623 unsigned verb = *(fVerbs - 1); // fVerbs is one beyond the current verb | 1623 unsigned verb = *(fVerbs - 1); // fVerbs is one beyond the current verb |
| 1624 switch (verb) { | 1624 switch (verb) { |
| 1625 case kMove_Verb: | 1625 case kMove_Verb: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1636 // A close when we are in a segment is always valid except when
it | 1636 // A close when we are in a segment is always valid except when
it |
| 1637 // follows a move which follows a segment. | 1637 // follows a move which follows a segment. |
| 1638 if (fSegmentState == kAfterPrimitive_SegmentState && !lastMoveVe
rb) { | 1638 if (fSegmentState == kAfterPrimitive_SegmentState && !lastMoveVe
rb) { |
| 1639 return; | 1639 return; |
| 1640 } | 1640 } |
| 1641 // A close at any other time must be ignored | 1641 // A close at any other time must be ignored |
| 1642 fVerbs--; | 1642 fVerbs--; |
| 1643 break; | 1643 break; |
| 1644 | 1644 |
| 1645 case kLine_Verb: | 1645 case kLine_Verb: |
| 1646 if (!IsLineDegenerate(lastPt, fPts[0])) { | 1646 if (!IsLineDegenerate(lastPt, fPts[0], exact)) { |
| 1647 if (lastMoveVerb) { | 1647 if (lastMoveVerb) { |
| 1648 fVerbs = lastMoveVerb; | 1648 fVerbs = lastMoveVerb; |
| 1649 fPts = lastMovePt; | 1649 fPts = lastMovePt; |
| 1650 fConicWeights = lastMoveWeight; | 1650 fConicWeights = lastMoveWeight; |
| 1651 return; | 1651 return; |
| 1652 } | 1652 } |
| 1653 return; | 1653 return; |
| 1654 } | 1654 } |
| 1655 // Ignore this line and continue | 1655 // Ignore this line and continue |
| 1656 fVerbs--; | 1656 fVerbs--; |
| 1657 fPts++; | 1657 fPts++; |
| 1658 break; | 1658 break; |
| 1659 | 1659 |
| 1660 case kConic_Verb: | 1660 case kConic_Verb: |
| 1661 case kQuad_Verb: | 1661 case kQuad_Verb: |
| 1662 if (!IsQuadDegenerate(lastPt, fPts[0], fPts[1])) { | 1662 if (!IsQuadDegenerate(lastPt, fPts[0], fPts[1], exact)) { |
| 1663 if (lastMoveVerb) { | 1663 if (lastMoveVerb) { |
| 1664 fVerbs = lastMoveVerb; | 1664 fVerbs = lastMoveVerb; |
| 1665 fPts = lastMovePt; | 1665 fPts = lastMovePt; |
| 1666 fConicWeights = lastMoveWeight; | 1666 fConicWeights = lastMoveWeight; |
| 1667 return; | 1667 return; |
| 1668 } | 1668 } |
| 1669 return; | 1669 return; |
| 1670 } | 1670 } |
| 1671 // Ignore this line and continue | 1671 // Ignore this line and continue |
| 1672 fVerbs--; | 1672 fVerbs--; |
| 1673 fPts += 2; | 1673 fPts += 2; |
| 1674 fConicWeights += (kConic_Verb == verb); | 1674 fConicWeights += (kConic_Verb == verb); |
| 1675 break; | 1675 break; |
| 1676 | 1676 |
| 1677 case kCubic_Verb: | 1677 case kCubic_Verb: |
| 1678 if (!IsCubicDegenerate(lastPt, fPts[0], fPts[1], fPts[2])) { | 1678 if (!IsCubicDegenerate(lastPt, fPts[0], fPts[1], fPts[2], exact)
) { |
| 1679 if (lastMoveVerb) { | 1679 if (lastMoveVerb) { |
| 1680 fVerbs = lastMoveVerb; | 1680 fVerbs = lastMoveVerb; |
| 1681 fPts = lastMovePt; | 1681 fPts = lastMovePt; |
| 1682 fConicWeights = lastMoveWeight; | 1682 fConicWeights = lastMoveWeight; |
| 1683 return; | 1683 return; |
| 1684 } | 1684 } |
| 1685 return; | 1685 return; |
| 1686 } | 1686 } |
| 1687 // Ignore this line and continue | 1687 // Ignore this line and continue |
| 1688 fVerbs--; | 1688 fVerbs--; |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 } | 2109 } |
| 2110 | 2110 |
| 2111 if (0 == fPtCount) { | 2111 if (0 == fPtCount) { |
| 2112 fCurrPt = pt; | 2112 fCurrPt = pt; |
| 2113 ++fPtCount; | 2113 ++fPtCount; |
| 2114 } else { | 2114 } else { |
| 2115 SkVector vec = pt - fCurrPt; | 2115 SkVector vec = pt - fCurrPt; |
| 2116 SkScalar lengthSqd = vec.lengthSqd(); | 2116 SkScalar lengthSqd = vec.lengthSqd(); |
| 2117 if (!SkScalarIsFinite(lengthSqd)) { | 2117 if (!SkScalarIsFinite(lengthSqd)) { |
| 2118 fIsFinite = false; | 2118 fIsFinite = false; |
| 2119 } else if (!SkScalarNearlyZero(lengthSqd, SK_ScalarNearlyZero*SK_Sca
larNearlyZero)) { | 2119 } else if (lengthSqd) { |
| 2120 fPriorPt = fLastPt; | 2120 fPriorPt = fLastPt; |
| 2121 fLastPt = fCurrPt; | 2121 fLastPt = fCurrPt; |
| 2122 fCurrPt = pt; | 2122 fCurrPt = pt; |
| 2123 if (++fPtCount == 2) { | 2123 if (++fPtCount == 2) { |
| 2124 fFirstVec = fLastVec = vec; | 2124 fFirstVec = fLastVec = vec; |
| 2125 } else { | 2125 } else { |
| 2126 SkASSERT(fPtCount > 2); | 2126 SkASSERT(fPtCount > 2); |
| 2127 this->addVec(vec); | 2127 this->addVec(vec); |
| 2128 } | 2128 } |
| 2129 | 2129 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2246 SkPath::Verb verb; | 2246 SkPath::Verb verb; |
| 2247 SkPath::Iter iter(*this, true); | 2247 SkPath::Iter iter(*this, true); |
| 2248 | 2248 |
| 2249 int contourCount = 0; | 2249 int contourCount = 0; |
| 2250 int count; | 2250 int count; |
| 2251 Convexicator state; | 2251 Convexicator state; |
| 2252 | 2252 |
| 2253 if (!isFinite()) { | 2253 if (!isFinite()) { |
| 2254 return kUnknown_Convexity; | 2254 return kUnknown_Convexity; |
| 2255 } | 2255 } |
| 2256 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { | 2256 while ((verb = iter.next(pts, true, true)) != SkPath::kDone_Verb) { |
| 2257 switch (verb) { | 2257 switch (verb) { |
| 2258 case kMove_Verb: | 2258 case kMove_Verb: |
| 2259 if (++contourCount > 1) { | 2259 if (++contourCount > 1) { |
| 2260 fConvexity = kConcave_Convexity; | 2260 fConvexity = kConcave_Convexity; |
| 2261 return kConcave_Convexity; | 2261 return kConcave_Convexity; |
| 2262 } | 2262 } |
| 2263 pts[1] = pts[0]; | 2263 pts[1] = pts[0]; |
| 2264 // fall through | 2264 // fall through |
| 2265 case kLine_Verb: | 2265 case kLine_Verb: |
| 2266 count = 1; | 2266 count = 1; |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2808 switch (this->getFillType()) { | 2808 switch (this->getFillType()) { |
| 2809 case SkPath::kEvenOdd_FillType: | 2809 case SkPath::kEvenOdd_FillType: |
| 2810 case SkPath::kInverseEvenOdd_FillType: | 2810 case SkPath::kInverseEvenOdd_FillType: |
| 2811 w &= 1; | 2811 w &= 1; |
| 2812 break; | 2812 break; |
| 2813 default: | 2813 default: |
| 2814 break; | 2814 break; |
| 2815 } | 2815 } |
| 2816 return SkToBool(w); | 2816 return SkToBool(w); |
| 2817 } | 2817 } |
| OLD | NEW |