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

Side by Side Diff: include/core/SkPath.h

Issue 1228383002: compute convexity for very small paths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix path documentation Created 5 years, 5 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 | « no previous file | src/core/SkPath.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 #ifndef SkPath_DEFINED 8 #ifndef SkPath_DEFINED
9 #define SkPath_DEFINED 9 #define SkPath_DEFINED
10 10
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 consumption on the device. 199 consumption on the device.
200 */ 200 */
201 void setIsVolatile(bool isVolatile) { 201 void setIsVolatile(bool isVolatile) {
202 fIsVolatile = isVolatile; 202 fIsVolatile = isVolatile;
203 } 203 }
204 204
205 /** Test a line for zero length 205 /** Test a line for zero length
206 206
207 @return true if the line is of zero length; otherwise false. 207 @return true if the line is of zero length; otherwise false.
208 */ 208 */
209 static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2) { 209 static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2, bool exac t) {
210 return p1.equalsWithinTolerance(p2); 210 return exact ? p1 == p2 : p1.equalsWithinTolerance(p2);
211 } 211 }
212 212
213 /** Test a quad for zero length 213 /** Test a quad for zero length
214 214
215 @return true if the quad is of zero length; otherwise false. 215 @return true if the quad is of zero length; otherwise false.
216 */ 216 */
217 static bool IsQuadDegenerate(const SkPoint& p1, const SkPoint& p2, 217 static bool IsQuadDegenerate(const SkPoint& p1, const SkPoint& p2,
218 const SkPoint& p3) { 218 const SkPoint& p3, bool exact) {
219 return p1.equalsWithinTolerance(p2) && 219 return exact ? p1 == p2 && p2 == p3 : p1.equalsWithinTolerance(p2) &&
220 p2.equalsWithinTolerance(p3); 220 p2.equalsWithinTolerance(p3);
221 } 221 }
222 222
223 /** Test a cubic curve for zero length 223 /** Test a cubic curve for zero length
224 224
225 @return true if the cubic is of zero length; otherwise false. 225 @return true if the cubic is of zero length; otherwise false.
226 */ 226 */
227 static bool IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2, 227 static bool IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2,
228 const SkPoint& p3, const SkPoint& p4) { 228 const SkPoint& p3, const SkPoint& p4, bool exa ct) {
229 return p1.equalsWithinTolerance(p2) && 229 return exact ? p1 == p2 && p2 == p3 && p3 == p4 : p1.equalsWithinToleran ce(p2) &&
230 p2.equalsWithinTolerance(p3) && 230 p2.equalsWithinTolerance(p3) &&
231 p3.equalsWithinTolerance(p4); 231 p3.equalsWithinTolerance(p4);
232 } 232 }
233 233
234 /** 234 /**
235 * Returns true if the path specifies a single line (i.e. it contains just 235 * Returns true if the path specifies a single line (i.e. it contains just
236 * a moveTo and a lineTo). If so, and line[] is not null, it sets the 2 236 * a moveTo and a lineTo). If so, and line[] is not null, it sets the 2
237 * points in line[] to the end-points of the line. If the path is not a 237 * points in line[] to the end-points of the line. If the path is not a
238 * line, returns false and ignores line[]. 238 * line, returns false and ignores line[].
239 */ 239 */
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 Iter(const SkPath&, bool forceClose); 793 Iter(const SkPath&, bool forceClose);
794 794
795 void setPath(const SkPath&, bool forceClose); 795 void setPath(const SkPath&, bool forceClose);
796 796
797 /** Return the next verb in this iteration of the path. When all 797 /** Return the next verb in this iteration of the path. When all
798 segments have been visited, return kDone_Verb. 798 segments have been visited, return kDone_Verb.
799 799
800 @param pts The points representing the current verb and/or segment 800 @param pts The points representing the current verb and/or segment
801 @param doConsumeDegerates If true, first scan for segments that are 801 @param doConsumeDegerates If true, first scan for segments that are
802 deemed degenerate (too short) and skip those. 802 deemed degenerate (too short) and skip those.
803 @param exact if doConsumeDegenerates is true and exact is true, skip only
804 degenerate elements with lengths exactly equal to zero. If ex act
805 is false, skip degenerate elements with lengths close to zero . If
806 doConsumeDegenerates is false, exact has no effect.
803 @return The verb for the current segment 807 @return The verb for the current segment
804 */ 808 */
805 Verb next(SkPoint pts[4], bool doConsumeDegerates = true) { 809 Verb next(SkPoint pts[4], bool doConsumeDegerates = true, bool exact = f alse) {
806 if (doConsumeDegerates) { 810 if (doConsumeDegerates) {
807 this->consumeDegenerateSegments(); 811 this->consumeDegenerateSegments(exact);
808 } 812 }
809 return this->doNext(pts); 813 return this->doNext(pts);
810 } 814 }
811 815
812 /** 816 /**
813 * Return the weight for the current conic. Only valid if the current 817 * Return the weight for the current conic. Only valid if the current
814 * segment return by next() was a conic. 818 * segment return by next() was a conic.
815 */ 819 */
816 SkScalar conicWeight() const { return *fConicWeights; } 820 SkScalar conicWeight() const { return *fConicWeights; }
817 821
(...skipping 19 matching lines...) Expand all
837 const SkScalar* fConicWeights; 841 const SkScalar* fConicWeights;
838 SkPoint fMoveTo; 842 SkPoint fMoveTo;
839 SkPoint fLastPt; 843 SkPoint fLastPt;
840 SkBool8 fForceClose; 844 SkBool8 fForceClose;
841 SkBool8 fNeedClose; 845 SkBool8 fNeedClose;
842 SkBool8 fCloseLine; 846 SkBool8 fCloseLine;
843 SkBool8 fSegmentState; 847 SkBool8 fSegmentState;
844 848
845 inline const SkPoint& cons_moveTo(); 849 inline const SkPoint& cons_moveTo();
846 Verb autoClose(SkPoint pts[2]); 850 Verb autoClose(SkPoint pts[2]);
847 void consumeDegenerateSegments(); 851 void consumeDegenerateSegments(bool exact);
848 Verb doNext(SkPoint pts[4]); 852 Verb doNext(SkPoint pts[4]);
849 }; 853 };
850 854
851 /** Iterate through the verbs in the path, providing the associated points. 855 /** Iterate through the verbs in the path, providing the associated points.
852 */ 856 */
853 class SK_API RawIter { 857 class SK_API RawIter {
854 public: 858 public:
855 RawIter(); 859 RawIter();
856 RawIter(const SkPath&); 860 RawIter(const SkPath&);
857 861
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 void setPt(int index, SkScalar x, SkScalar y); 1001 void setPt(int index, SkScalar x, SkScalar y);
998 1002
999 friend class SkAutoPathBoundsUpdate; 1003 friend class SkAutoPathBoundsUpdate;
1000 friend class SkAutoDisableOvalCheck; 1004 friend class SkAutoDisableOvalCheck;
1001 friend class SkAutoDisableDirectionCheck; 1005 friend class SkAutoDisableDirectionCheck;
1002 friend class SkBench_AddPathTest; // perf test reversePathTo 1006 friend class SkBench_AddPathTest; // perf test reversePathTo
1003 friend class PathTest_Private; // unit test reversePathTo 1007 friend class PathTest_Private; // unit test reversePathTo
1004 }; 1008 };
1005 1009
1006 #endif 1010 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698