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 #ifndef SkPath_DEFINED | 8 #ifndef SkPath_DEFINED |
9 #define SkPath_DEFINED | 9 #define SkPath_DEFINED |
10 | 10 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 * @param rect returns the bounding rect of this oval. It's a circle | 147 * @param rect returns the bounding rect of this oval. It's a circle |
148 * if the height and width are the same. | 148 * if the height and width are the same. |
149 * | 149 * |
150 * @return true if this path is an oval. | 150 * @return true if this path is an oval. |
151 * Tracking whether a path is an oval is considered an | 151 * Tracking whether a path is an oval is considered an |
152 * optimization for performance and so some paths that are in | 152 * optimization for performance and so some paths that are in |
153 * fact ovals can report false. | 153 * fact ovals can report false. |
154 */ | 154 */ |
155 bool isOval(SkRect* rect) const { return fPathRef->isOval(rect); } | 155 bool isOval(SkRect* rect) const { return fPathRef->isOval(rect); } |
156 | 156 |
| 157 /** Returns true if the path is a round rect. |
| 158 * |
| 159 * @param rrect Returns the bounding rect and radii of this round rect. |
| 160 * |
| 161 * @return true if this path is a round rect. |
| 162 * Tracking whether a path is a round rect is considered an |
| 163 * optimization for performance and so some paths that are in |
| 164 * fact round rects can report false. |
| 165 */ |
| 166 bool isRRect(SkRRect* rrect) const { return fPathRef->isRRect(rrect); } |
| 167 |
157 /** Clear any lines and curves from the path, making it empty. This frees up | 168 /** Clear any lines and curves from the path, making it empty. This frees up |
158 internal storage associated with those segments. | 169 internal storage associated with those segments. |
159 On Android, does not change fSourcePath. | 170 On Android, does not change fSourcePath. |
160 */ | 171 */ |
161 void reset(); | 172 void reset(); |
162 | 173 |
163 /** Similar to reset(), in that all lines and curves are removed from the | 174 /** Similar to reset(), in that all lines and curves are removed from the |
164 path. However, any internal storage for those lines/curves is retained, | 175 path. However, any internal storage for those lines/curves is retained, |
165 making reuse of the path potentially faster. | 176 making reuse of the path potentially faster. |
166 On Android, does not change fSourcePath. | 177 On Android, does not change fSourcePath. |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 inline const SkPoint& cons_moveTo(); | 922 inline const SkPoint& cons_moveTo(); |
912 Verb autoClose(SkPoint pts[2]); | 923 Verb autoClose(SkPoint pts[2]); |
913 void consumeDegenerateSegments(bool exact); | 924 void consumeDegenerateSegments(bool exact); |
914 Verb doNext(SkPoint pts[4]); | 925 Verb doNext(SkPoint pts[4]); |
915 }; | 926 }; |
916 | 927 |
917 /** Iterate through the verbs in the path, providing the associated points. | 928 /** Iterate through the verbs in the path, providing the associated points. |
918 */ | 929 */ |
919 class SK_API RawIter { | 930 class SK_API RawIter { |
920 public: | 931 public: |
921 RawIter(); | 932 RawIter() {} |
922 RawIter(const SkPath&); | 933 RawIter(const SkPath& path) { |
| 934 setPath(path); |
| 935 } |
923 | 936 |
924 void setPath(const SkPath&); | 937 void setPath(const SkPath& path) { |
| 938 fRawIter.setPathRef(*path.fPathRef.get()); |
| 939 } |
925 | 940 |
926 /** Return the next verb in this iteration of the path. When all | 941 /** Return the next verb in this iteration of the path. When all |
927 segments have been visited, return kDone_Verb. | 942 segments have been visited, return kDone_Verb. |
928 | 943 |
929 @param pts The points representing the current verb and/or segment | 944 @param pts The points representing the current verb and/or segment |
930 This must not be NULL. | 945 This must not be NULL. |
931 @return The verb for the current segment | 946 @return The verb for the current segment |
932 */ | 947 */ |
933 Verb next(SkPoint pts[4]); | 948 Verb next(SkPoint pts[4]) { |
| 949 return (Verb) fRawIter.next(pts); |
| 950 } |
934 | 951 |
935 SkScalar conicWeight() const { return *fConicWeights; } | 952 SkScalar conicWeight() const { |
| 953 return fRawIter.conicWeight(); |
| 954 } |
936 | 955 |
937 private: | 956 private: |
938 const SkPoint* fPts; | 957 SkPathRef::Iter fRawIter; |
939 const uint8_t* fVerbs; | 958 friend class SkPath; |
940 const uint8_t* fVerbStop; | |
941 const SkScalar* fConicWeights; | |
942 }; | 959 }; |
943 | 960 |
944 /** | 961 /** |
945 * Returns true if the point { x, y } is contained by the path, taking into | 962 * Returns true if the point { x, y } is contained by the path, taking into |
946 * account the FillType. | 963 * account the FillType. |
947 */ | 964 */ |
948 bool contains(SkScalar x, SkScalar y) const; | 965 bool contains(SkScalar x, SkScalar y) const; |
949 | 966 |
950 void dump(SkWStream* , bool forceClose, bool dumpAsHex) const; | 967 void dump(SkWStream* , bool forceClose, bool dumpAsHex) const; |
951 void dump() const; | 968 void dump() const; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 ed.setBounds(rect); | 1076 ed.setBounds(rect); |
1060 } | 1077 } |
1061 | 1078 |
1062 void setPt(int index, SkScalar x, SkScalar y); | 1079 void setPt(int index, SkScalar x, SkScalar y); |
1063 | 1080 |
1064 friend class SkAutoPathBoundsUpdate; | 1081 friend class SkAutoPathBoundsUpdate; |
1065 friend class SkAutoDisableOvalCheck; | 1082 friend class SkAutoDisableOvalCheck; |
1066 friend class SkAutoDisableDirectionCheck; | 1083 friend class SkAutoDisableDirectionCheck; |
1067 friend class SkBench_AddPathTest; // perf test reversePathTo | 1084 friend class SkBench_AddPathTest; // perf test reversePathTo |
1068 friend class PathTest_Private; // unit test reversePathTo | 1085 friend class PathTest_Private; // unit test reversePathTo |
| 1086 friend class ForceIsRRect_Private; // unit test isRRect |
1069 }; | 1087 }; |
1070 | 1088 |
1071 #endif | 1089 #endif |
OLD | NEW |