OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkPath_DEFINED | 10 #ifndef SkPath_DEFINED |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 /** | 179 /** |
180 * Returns true if all of the points in this path are finite, meaning there | 180 * Returns true if all of the points in this path are finite, meaning there |
181 * are no infinities and no NaNs. | 181 * are no infinities and no NaNs. |
182 */ | 182 */ |
183 bool isFinite() const { | 183 bool isFinite() const { |
184 SkDEBUGCODE(this->validate();) | 184 SkDEBUGCODE(this->validate();) |
185 return fPathRef->isFinite(); | 185 return fPathRef->isFinite(); |
186 } | 186 } |
187 | 187 |
| 188 /** Returns true if the path is volatile (i.e. should not be cached by devic
es.) |
| 189 */ |
| 190 bool isVolatile() const { |
| 191 return SkToBool(fIsVolatile); |
| 192 } |
| 193 |
| 194 /** Specify whether this path is volatile. Paths are not volatile by |
| 195 default. Temporary paths that are discarded or modified after use should be |
| 196 marked as volatile. This provides a hint to the device that the path |
| 197 should not be cached. Providing this hint when appropriate can |
| 198 improve performance by avoiding unnecessary overhead and resource |
| 199 consumption on the device. |
| 200 */ |
| 201 void setIsVolatile(bool isVolatile) { |
| 202 fIsVolatile = isVolatile; |
| 203 } |
| 204 |
188 /** Test a line for zero length | 205 /** Test a line for zero length |
189 | 206 |
190 @return true if the line is of zero length; otherwise false. | 207 @return true if the line is of zero length; otherwise false. |
191 */ | 208 */ |
192 static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2) { | 209 static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2) { |
193 return p1.equalsWithinTolerance(p2); | 210 return p1.equalsWithinTolerance(p2); |
194 } | 211 } |
195 | 212 |
196 /** Test a quad for zero length | 213 /** Test a quad for zero length |
197 | 214 |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 static const int kPathRefGenIDBitCnt = 32; | 981 static const int kPathRefGenIDBitCnt = 32; |
965 #endif | 982 #endif |
966 | 983 |
967 SkDEBUGCODE(void validate() const;) | 984 SkDEBUGCODE(void validate() const;) |
968 | 985 |
969 private: | 986 private: |
970 enum SerializationOffsets { | 987 enum SerializationOffsets { |
971 // 1 free bit at 29 | 988 // 1 free bit at 29 |
972 kUnused1_SerializationShift = 28, // 1 free bit | 989 kUnused1_SerializationShift = 28, // 1 free bit |
973 kDirection_SerializationShift = 26, // requires 2 bits | 990 kDirection_SerializationShift = 26, // requires 2 bits |
974 kUnused2_SerializationShift = 25, // 1 free bit | 991 kIsVolatile_SerializationShift = 25, // requires 1 bit |
975 // 1 free bit at 24 | 992 // 1 free bit at 24 |
976 kConvexity_SerializationShift = 16, // requires 8 bits | 993 kConvexity_SerializationShift = 16, // requires 8 bits |
977 kFillType_SerializationShift = 8, // requires 8 bits | 994 kFillType_SerializationShift = 8, // requires 8 bits |
978 // 8 free bits at 0 | 995 // 8 free bits at 0 |
979 }; | 996 }; |
980 | 997 |
981 SkAutoTUnref<SkPathRef> fPathRef; | 998 SkAutoTUnref<SkPathRef> fPathRef; |
982 | 999 |
983 int fLastMoveToIndex; | 1000 int fLastMoveToIndex; |
984 uint8_t fFillType; | 1001 uint8_t fFillType; |
985 mutable uint8_t fConvexity; | 1002 mutable uint8_t fConvexity; |
986 mutable uint8_t fDirection; | 1003 mutable uint8_t fDirection; |
| 1004 mutable SkBool8 fIsVolatile; |
987 #ifdef SK_BUILD_FOR_ANDROID | 1005 #ifdef SK_BUILD_FOR_ANDROID |
988 const SkPath* fSourcePath; | 1006 const SkPath* fSourcePath; |
989 #endif | 1007 #endif |
990 | 1008 |
991 /** Resets all fields other than fPathRef to their initial 'empty' values. | 1009 /** Resets all fields other than fPathRef to their initial 'empty' values. |
992 * Assumes the caller has already emptied fPathRef. | 1010 * Assumes the caller has already emptied fPathRef. |
993 * On Android increments fGenerationID without reseting it. | 1011 * On Android increments fGenerationID without reseting it. |
994 */ | 1012 */ |
995 void resetFields(); | 1013 void resetFields(); |
996 | 1014 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 } | 1060 } |
1043 | 1061 |
1044 friend class SkAutoPathBoundsUpdate; | 1062 friend class SkAutoPathBoundsUpdate; |
1045 friend class SkAutoDisableOvalCheck; | 1063 friend class SkAutoDisableOvalCheck; |
1046 friend class SkAutoDisableDirectionCheck; | 1064 friend class SkAutoDisableDirectionCheck; |
1047 friend class SkBench_AddPathTest; // perf test reversePathTo | 1065 friend class SkBench_AddPathTest; // perf test reversePathTo |
1048 friend class PathTest_Private; // unit test reversePathTo | 1066 friend class PathTest_Private; // unit test reversePathTo |
1049 }; | 1067 }; |
1050 | 1068 |
1051 #endif | 1069 #endif |
OLD | NEW |