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 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 fPts = srcPts; | 1770 fPts = srcPts; |
1771 return (Verb)verb; | 1771 return (Verb)verb; |
1772 } | 1772 } |
1773 | 1773 |
1774 /////////////////////////////////////////////////////////////////////////////// | 1774 /////////////////////////////////////////////////////////////////////////////// |
1775 | 1775 |
1776 SkPath::RawIter::RawIter() { | 1776 SkPath::RawIter::RawIter() { |
1777 #ifdef SK_DEBUG | 1777 #ifdef SK_DEBUG |
1778 fPts = NULL; | 1778 fPts = NULL; |
1779 fConicWeights = NULL; | 1779 fConicWeights = NULL; |
1780 fMoveTo.fX = fMoveTo.fY = fLastPt.fX = fLastPt.fY = 0; | 1780 fMoveTo.fX = fMoveTo.fY = 0; |
1781 #endif | 1781 #endif |
1782 // need to init enough to make next() harmlessly return kDone_Verb | 1782 // need to init enough to make next() harmlessly return kDone_Verb |
1783 fVerbs = NULL; | 1783 fVerbs = NULL; |
1784 fVerbStop = NULL; | 1784 fVerbStop = NULL; |
1785 } | 1785 } |
1786 | 1786 |
1787 SkPath::RawIter::RawIter(const SkPath& path) { | 1787 SkPath::RawIter::RawIter(const SkPath& path) { |
1788 this->setPath(path); | 1788 this->setPath(path); |
1789 } | 1789 } |
1790 | 1790 |
1791 void SkPath::RawIter::setPath(const SkPath& path) { | 1791 void SkPath::RawIter::setPath(const SkPath& path) { |
1792 fPts = path.fPathRef->points(); | 1792 fPts = path.fPathRef->points(); |
1793 fVerbs = path.fPathRef->verbs(); | 1793 fVerbs = path.fPathRef->verbs(); |
1794 fVerbStop = path.fPathRef->verbsMemBegin(); | 1794 fVerbStop = path.fPathRef->verbsMemBegin(); |
1795 fConicWeights = path.fPathRef->conicWeights() - 1; // begin one behind | 1795 fConicWeights = path.fPathRef->conicWeights() - 1; // begin one behind |
1796 fMoveTo.fX = fMoveTo.fY = 0; | 1796 fMoveTo.fX = fMoveTo.fY = 0; |
1797 fLastPt.fX = fLastPt.fY = 0; | |
1798 } | 1797 } |
1799 | 1798 |
1800 SkPath::Verb SkPath::RawIter::next(SkPoint pts[4]) { | 1799 SkPath::Verb SkPath::RawIter::next(SkPoint pts[4]) { |
1801 SkASSERT(pts); | 1800 SkASSERT(pts); |
1802 if (fVerbs == fVerbStop) { | 1801 if (fVerbs == fVerbStop) { |
1803 return kDone_Verb; | 1802 return kDone_Verb; |
1804 } | 1803 } |
1805 | 1804 |
1806 // fVerbs points one beyond next verb so decrement first. | 1805 // fVerbs points one beyond next verb so decrement first. |
1807 unsigned verb = *(--fVerbs); | 1806 unsigned verb = *(--fVerbs); |
1808 const SkPoint* srcPts = fPts; | 1807 const SkPoint* srcPts = fPts; |
1809 | 1808 |
1810 switch (verb) { | 1809 switch (verb) { |
1811 case kMove_Verb: | 1810 case kMove_Verb: |
1812 pts[0] = *srcPts; | 1811 fMoveTo = pts[0] = srcPts[0]; |
1813 fMoveTo = srcPts[0]; | |
1814 fLastPt = fMoveTo; | |
1815 srcPts += 1; | 1812 srcPts += 1; |
1816 break; | 1813 break; |
1817 case kLine_Verb: | 1814 case kLine_Verb: |
1818 pts[0] = fLastPt; | 1815 pts[0] = srcPts[-1]; |
1819 pts[1] = srcPts[0]; | 1816 pts[1] = srcPts[0]; |
1820 fLastPt = srcPts[0]; | |
1821 srcPts += 1; | 1817 srcPts += 1; |
1822 break; | 1818 break; |
1823 case kConic_Verb: | 1819 case kConic_Verb: |
1824 fConicWeights += 1; | 1820 fConicWeights += 1; |
1825 // fall-through | 1821 // fall-through |
1826 case kQuad_Verb: | 1822 case kQuad_Verb: |
1827 pts[0] = fLastPt; | 1823 pts[0] = srcPts[-1]; |
1828 memcpy(&pts[1], srcPts, 2 * sizeof(SkPoint)); | 1824 pts[1] = srcPts[0]; |
1829 fLastPt = srcPts[1]; | 1825 pts[2] = srcPts[1]; |
1830 srcPts += 2; | 1826 srcPts += 2; |
1831 break; | 1827 break; |
1832 case kCubic_Verb: | 1828 case kCubic_Verb: |
1833 pts[0] = fLastPt; | 1829 pts[0] = srcPts[-1]; |
1834 memcpy(&pts[1], srcPts, 3 * sizeof(SkPoint)); | 1830 pts[1] = srcPts[0]; |
1835 fLastPt = srcPts[2]; | 1831 pts[2] = srcPts[1]; |
| 1832 pts[3] = srcPts[2]; |
1836 srcPts += 3; | 1833 srcPts += 3; |
1837 break; | 1834 break; |
1838 case kClose_Verb: | 1835 case kClose_Verb: |
1839 fLastPt = fMoveTo; | |
1840 pts[0] = fMoveTo; | 1836 pts[0] = fMoveTo; |
1841 break; | 1837 break; |
1842 } | 1838 } |
1843 fPts = srcPts; | 1839 fPts = srcPts; |
1844 return (Verb)verb; | 1840 return (Verb)verb; |
1845 } | 1841 } |
1846 | 1842 |
1847 /////////////////////////////////////////////////////////////////////////////// | 1843 /////////////////////////////////////////////////////////////////////////////// |
1848 | 1844 |
1849 /* | 1845 /* |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2789 switch (this->getFillType()) { | 2785 switch (this->getFillType()) { |
2790 case SkPath::kEvenOdd_FillType: | 2786 case SkPath::kEvenOdd_FillType: |
2791 case SkPath::kInverseEvenOdd_FillType: | 2787 case SkPath::kInverseEvenOdd_FillType: |
2792 w &= 1; | 2788 w &= 1; |
2793 break; | 2789 break; |
2794 default: | 2790 default: |
2795 break; | 2791 break; |
2796 } | 2792 } |
2797 return SkToBool(w); | 2793 return SkToBool(w); |
2798 } | 2794 } |
OLD | NEW |