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

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: now with more tests 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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 Iter(); 792 Iter();
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.
robertphillips 2015/07/13 17:49:11 @param exact if true perform exact comparison ...
caryclark 2015/07/13 18:23:41 Done. Good catch -- I forgot about updating the do
803 @return The verb for the current segment 803 @return The verb for the current segment
804 */ 804 */
805 Verb next(SkPoint pts[4], bool doConsumeDegerates = true) { 805 Verb next(SkPoint pts[4], bool doConsumeDegerates = true, bool exact = f alse) {
806 if (doConsumeDegerates) { 806 if (doConsumeDegerates) {
807 this->consumeDegenerateSegments(); 807 this->consumeDegenerateSegments(exact);
808 } 808 }
809 return this->doNext(pts); 809 return this->doNext(pts);
810 } 810 }
811 811
812 /** 812 /**
813 * Return the weight for the current conic. Only valid if the current 813 * Return the weight for the current conic. Only valid if the current
814 * segment return by next() was a conic. 814 * segment return by next() was a conic.
815 */ 815 */
816 SkScalar conicWeight() const { return *fConicWeights; } 816 SkScalar conicWeight() const { return *fConicWeights; }
817 817
(...skipping 19 matching lines...) Expand all
837 const SkScalar* fConicWeights; 837 const SkScalar* fConicWeights;
838 SkPoint fMoveTo; 838 SkPoint fMoveTo;
839 SkPoint fLastPt; 839 SkPoint fLastPt;
840 SkBool8 fForceClose; 840 SkBool8 fForceClose;
841 SkBool8 fNeedClose; 841 SkBool8 fNeedClose;
842 SkBool8 fCloseLine; 842 SkBool8 fCloseLine;
843 SkBool8 fSegmentState; 843 SkBool8 fSegmentState;
844 844
845 inline const SkPoint& cons_moveTo(); 845 inline const SkPoint& cons_moveTo();
846 Verb autoClose(SkPoint pts[2]); 846 Verb autoClose(SkPoint pts[2]);
847 void consumeDegenerateSegments(); 847 void consumeDegenerateSegments(bool exact);
848 Verb doNext(SkPoint pts[4]); 848 Verb doNext(SkPoint pts[4]);
849 }; 849 };
850 850
851 /** Iterate through the verbs in the path, providing the associated points. 851 /** Iterate through the verbs in the path, providing the associated points.
852 */ 852 */
853 class SK_API RawIter { 853 class SK_API RawIter {
854 public: 854 public:
855 RawIter(); 855 RawIter();
856 RawIter(const SkPath&); 856 RawIter(const SkPath&);
857 857
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 void setPt(int index, SkScalar x, SkScalar y); 997 void setPt(int index, SkScalar x, SkScalar y);
998 998
999 friend class SkAutoPathBoundsUpdate; 999 friend class SkAutoPathBoundsUpdate;
1000 friend class SkAutoDisableOvalCheck; 1000 friend class SkAutoDisableOvalCheck;
1001 friend class SkAutoDisableDirectionCheck; 1001 friend class SkAutoDisableDirectionCheck;
1002 friend class SkBench_AddPathTest; // perf test reversePathTo 1002 friend class SkBench_AddPathTest; // perf test reversePathTo
1003 friend class PathTest_Private; // unit test reversePathTo 1003 friend class PathTest_Private; // unit test reversePathTo
1004 }; 1004 };
1005 1005
1006 #endif 1006 #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