Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: src/core/SkPath.cpp

Issue 1156893003: simplify RawIter - don't return a pt in kClose (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPath.h ('k') | tests/PathTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = 0;
1781 #endif 1780 #endif
1782 // need to init enough to make next() harmlessly return kDone_Verb 1781 // need to init enough to make next() harmlessly return kDone_Verb
1783 fVerbs = NULL; 1782 fVerbs = NULL;
1784 fVerbStop = NULL; 1783 fVerbStop = NULL;
1785 } 1784 }
1786 1785
1787 SkPath::RawIter::RawIter(const SkPath& path) { 1786 SkPath::RawIter::RawIter(const SkPath& path) {
1788 this->setPath(path); 1787 this->setPath(path);
1789 } 1788 }
1790 1789
1791 void SkPath::RawIter::setPath(const SkPath& path) { 1790 void SkPath::RawIter::setPath(const SkPath& path) {
1792 fPts = path.fPathRef->points(); 1791 fPts = path.fPathRef->points();
1793 fVerbs = path.fPathRef->verbs(); 1792 fVerbs = path.fPathRef->verbs();
1794 fVerbStop = path.fPathRef->verbsMemBegin(); 1793 fVerbStop = path.fPathRef->verbsMemBegin();
1795 fConicWeights = path.fPathRef->conicWeights() - 1; // begin one behind 1794 fConicWeights = path.fPathRef->conicWeights() - 1; // begin one behind
1796 fMoveTo.fX = fMoveTo.fY = 0;
1797 } 1795 }
1798 1796
1799 SkPath::Verb SkPath::RawIter::next(SkPoint pts[4]) { 1797 SkPath::Verb SkPath::RawIter::next(SkPoint pts[4]) {
1800 SkASSERT(pts); 1798 SkASSERT(pts);
1801 if (fVerbs == fVerbStop) { 1799 if (fVerbs == fVerbStop) {
1802 return kDone_Verb; 1800 return kDone_Verb;
1803 } 1801 }
1804 1802
1805 // fVerbs points one beyond next verb so decrement first. 1803 // fVerbs points one beyond next verb so decrement first.
1806 unsigned verb = *(--fVerbs); 1804 unsigned verb = *(--fVerbs);
1807 const SkPoint* srcPts = fPts; 1805 const SkPoint* srcPts = fPts;
1808 1806
1809 switch (verb) { 1807 switch (verb) {
1810 case kMove_Verb: 1808 case kMove_Verb:
1811 fMoveTo = pts[0] = srcPts[0]; 1809 pts[0] = srcPts[0];
1812 srcPts += 1; 1810 srcPts += 1;
1813 break; 1811 break;
1814 case kLine_Verb: 1812 case kLine_Verb:
1815 pts[0] = srcPts[-1]; 1813 pts[0] = srcPts[-1];
1816 pts[1] = srcPts[0]; 1814 pts[1] = srcPts[0];
1817 srcPts += 1; 1815 srcPts += 1;
1818 break; 1816 break;
1819 case kConic_Verb: 1817 case kConic_Verb:
1820 fConicWeights += 1; 1818 fConicWeights += 1;
1821 // fall-through 1819 // fall-through
1822 case kQuad_Verb: 1820 case kQuad_Verb:
1823 pts[0] = srcPts[-1]; 1821 pts[0] = srcPts[-1];
1824 pts[1] = srcPts[0]; 1822 pts[1] = srcPts[0];
1825 pts[2] = srcPts[1]; 1823 pts[2] = srcPts[1];
1826 srcPts += 2; 1824 srcPts += 2;
1827 break; 1825 break;
1828 case kCubic_Verb: 1826 case kCubic_Verb:
1829 pts[0] = srcPts[-1]; 1827 pts[0] = srcPts[-1];
1830 pts[1] = srcPts[0]; 1828 pts[1] = srcPts[0];
1831 pts[2] = srcPts[1]; 1829 pts[2] = srcPts[1];
1832 pts[3] = srcPts[2]; 1830 pts[3] = srcPts[2];
1833 srcPts += 3; 1831 srcPts += 3;
1834 break; 1832 break;
1835 case kClose_Verb: 1833 case kClose_Verb:
1836 pts[0] = fMoveTo; 1834 break;
1835 case kDone_Verb:
1836 SkASSERT(fVerbs == fVerbStop);
1837 break; 1837 break;
1838 } 1838 }
1839 fPts = srcPts; 1839 fPts = srcPts;
1840 return (Verb)verb; 1840 return (Verb)verb;
1841 } 1841 }
1842 1842
1843 /////////////////////////////////////////////////////////////////////////////// 1843 ///////////////////////////////////////////////////////////////////////////////
1844 1844
1845 /* 1845 /*
1846 Format in compressed buffer: [ptCount, verbCount, pts[], verbs[]] 1846 Format in compressed buffer: [ptCount, verbCount, pts[], verbs[]]
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 switch (this->getFillType()) { 2785 switch (this->getFillType()) {
2786 case SkPath::kEvenOdd_FillType: 2786 case SkPath::kEvenOdd_FillType:
2787 case SkPath::kInverseEvenOdd_FillType: 2787 case SkPath::kInverseEvenOdd_FillType:
2788 w &= 1; 2788 w &= 1;
2789 break; 2789 break;
2790 default: 2790 default:
2791 break; 2791 break;
2792 } 2792 }
2793 return SkToBool(w); 2793 return SkToBool(w);
2794 } 2794 }
OLDNEW
« no previous file with comments | « include/core/SkPath.h ('k') | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698