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

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

Issue 49693002: Use SkPathRef gen id for SkPath::getGenerationID (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: upload again, rietveld diff failed. Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | include/core/SkPathRef.h » ('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 /* 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
11 #define SkPath_DEFINED 11 #define SkPath_DEFINED
12 12
13 #include "SkInstCnt.h" 13 #include "SkInstCnt.h"
14 #include "SkMatrix.h" 14 #include "SkMatrix.h"
15 #include "SkPathRef.h" 15 #include "SkPathRef.h"
16 #include "SkTDArray.h" 16 #include "SkTDArray.h"
17 #include "SkRefCnt.h" 17 #include "SkRefCnt.h"
18 18
19 #ifdef SK_BUILD_FOR_ANDROID
20 #define GEN_ID_INC fGenerationID++
21 #define GEN_ID_PTR_INC(ptr) (ptr)->fGenerationID++
22 #else
23 #define GEN_ID_INC
24 #define GEN_ID_PTR_INC(ptr)
25 #endif
26
27 class SkReader32; 19 class SkReader32;
28 class SkWriter32; 20 class SkWriter32;
29 class SkAutoPathBoundsUpdate; 21 class SkAutoPathBoundsUpdate;
30 class SkString; 22 class SkString;
31 class SkRRect; 23 class SkRRect;
32 24
33 /** \class SkPath 25 /** \class SkPath
34 26
35 The SkPath class encapsulates compound (multiple contour) geometric paths 27 The SkPath class encapsulates compound (multiple contour) geometric paths
36 consisting of straight line segments, quadratic curves, and cubic curves. 28 consisting of straight line segments, quadratic curves, and cubic curves.
37 */ 29 */
38 class SK_API SkPath { 30 class SK_API SkPath {
39 public: 31 public:
40 SK_DECLARE_INST_COUNT_ROOT(SkPath); 32 SK_DECLARE_INST_COUNT_ROOT(SkPath);
41 33
42 SkPath(); 34 SkPath();
43 SkPath(const SkPath&); // Copies fGenerationID on Android. 35 SkPath(const SkPath&);
44 ~SkPath(); 36 ~SkPath();
45 37
46 SkPath& operator=(const SkPath&); // Increments fGenerationID on Android. 38 SkPath& operator=(const SkPath&);
47 friend SK_API bool operator==(const SkPath&, const SkPath&); 39 friend SK_API bool operator==(const SkPath&, const SkPath&);
48 friend bool operator!=(const SkPath& a, const SkPath& b) { 40 friend bool operator!=(const SkPath& a, const SkPath& b) {
49 return !(a == b); 41 return !(a == b);
50 } 42 }
51 43
52 enum FillType { 44 enum FillType {
53 /** Specifies that "inside" is computed by a non-zero sum of signed 45 /** Specifies that "inside" is computed by a non-zero sum of signed
54 edge crossings 46 edge crossings
55 */ 47 */
56 kWinding_FillType, 48 kWinding_FillType,
(...skipping 16 matching lines...) Expand all
73 */ 65 */
74 FillType getFillType() const { return (FillType)fFillType; } 66 FillType getFillType() const { return (FillType)fFillType; }
75 67
76 /** Set the path's fill type. This is used to define how "inside" is 68 /** Set the path's fill type. This is used to define how "inside" is
77 computed. The default value is kWinding_FillType. 69 computed. The default value is kWinding_FillType.
78 70
79 @param ft The new fill type for this path 71 @param ft The new fill type for this path
80 */ 72 */
81 void setFillType(FillType ft) { 73 void setFillType(FillType ft) {
82 fFillType = SkToU8(ft); 74 fFillType = SkToU8(ft);
83 GEN_ID_INC;
84 } 75 }
85 76
86 /** Returns true if the filltype is one of the Inverse variants */ 77 /** Returns true if the filltype is one of the Inverse variants */
87 bool isInverseFillType() const { return IsInverseFillType((FillType)fFillTyp e); } 78 bool isInverseFillType() const { return IsInverseFillType((FillType)fFillTyp e); }
88 79
89 /** 80 /**
90 * Toggle between inverse and normal filltypes. This reverse the return 81 * Toggle between inverse and normal filltypes. This reverse the return
91 * value of isInverseFillType() 82 * value of isInverseFillType()
92 */ 83 */
93 void toggleInverseFillType() { 84 void toggleInverseFillType() {
94 fFillType ^= 2; 85 fFillType ^= 2;
95 GEN_ID_INC;
96 } 86 }
97 87
98 enum Convexity { 88 enum Convexity {
99 kUnknown_Convexity, 89 kUnknown_Convexity,
100 kConvex_Convexity, 90 kConvex_Convexity,
101 kConcave_Convexity 91 kConcave_Convexity
102 }; 92 };
103 93
104 /** 94 /**
105 * Return the path's convexity, as stored in the path. If it is currently u nknown, 95 * Return the path's convexity, as stored in the path. If it is currently u nknown,
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 bool contains(SkScalar x, SkScalar y) const; 897 bool contains(SkScalar x, SkScalar y) const;
908 898
909 void dump(bool forceClose, const char title[] = NULL) const; 899 void dump(bool forceClose, const char title[] = NULL) const;
910 void dump() const; 900 void dump() const;
911 901
912 /** 902 /**
913 * Write the region to the buffer, and return the number of bytes written. 903 * Write the region to the buffer, and return the number of bytes written.
914 * If buffer is NULL, it still returns the number of bytes. 904 * If buffer is NULL, it still returns the number of bytes.
915 */ 905 */
916 uint32_t writeToMemory(void* buffer) const; 906 uint32_t writeToMemory(void* buffer) const;
907
917 /** 908 /**
918 * Initialized the region from the buffer, returning the number 909 * Initialized the region from the buffer, returning the number
919 * of bytes actually read. 910 * of bytes actually read.
920 */ 911 */
921 uint32_t readFromMemory(const void* buffer); 912 uint32_t readFromMemory(const void* buffer);
922 913
914 /** Returns a non-zero, globally unique value corresponding to the set of ve rbs
915 and points in the path (but not the fill type [except on Android skbug.c om/1762]).
916 Each time the path is modified, a different generation ID will be return ed.
917 */
918 uint32_t getGenerationID() const;
919
923 #ifdef SK_BUILD_FOR_ANDROID 920 #ifdef SK_BUILD_FOR_ANDROID
924 uint32_t getGenerationID() const; 921 static const int kPathRefGenIDBitCnt = 30; // leave room for the fill type ( skbug.com/1762)
925 const SkPath* getSourcePath() const; 922 const SkPath* getSourcePath() const;
926 void setSourcePath(const SkPath* path); 923 void setSourcePath(const SkPath* path);
924 #else
925 static const int kPathRefGenIDBitCnt = 32;
927 #endif 926 #endif
928 927
929 SkDEBUGCODE(void validate() const;) 928 SkDEBUGCODE(void validate() const;)
930 929
931 private: 930 private:
932 enum SerializationOffsets { 931 enum SerializationOffsets {
933 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O 932 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
934 kNewFormat_SerializationShift = 28, // requires 1 bit 933 kNewFormat_SerializationShift = 28, // requires 1 bit
935 #endif 934 #endif
936 kDirection_SerializationShift = 26, // requires 2 bits 935 kDirection_SerializationShift = 26, // requires 2 bits
937 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O 936 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
938 // rename to kUnused_SerializationShift 937 // rename to kUnused_SerializationShift
939 kOldIsFinite_SerializationShift = 25, // 1 bit 938 kOldIsFinite_SerializationShift = 25, // 1 bit
940 #endif 939 #endif
941 kIsOval_SerializationShift = 24, // requires 1 bit 940 kIsOval_SerializationShift = 24, // requires 1 bit
942 kConvexity_SerializationShift = 16, // requires 8 bits 941 kConvexity_SerializationShift = 16, // requires 8 bits
943 kFillType_SerializationShift = 8, // requires 8 bits 942 kFillType_SerializationShift = 8, // requires 8 bits
944 kSegmentMask_SerializationShift = 0 // requires 4 bits 943 kSegmentMask_SerializationShift = 0 // requires 4 bits
945 }; 944 };
946 945
947 SkAutoTUnref<SkPathRef> fPathRef; 946 SkAutoTUnref<SkPathRef> fPathRef;
948 947
949 int fLastMoveToIndex; 948 int fLastMoveToIndex;
950 uint8_t fFillType; 949 uint8_t fFillType;
951 uint8_t fSegmentMask; 950 uint8_t fSegmentMask;
952 mutable uint8_t fConvexity; 951 mutable uint8_t fConvexity;
953 mutable uint8_t fDirection; 952 mutable uint8_t fDirection;
954 mutable SkBool8 fIsOval; 953 mutable SkBool8 fIsOval;
955 #ifdef SK_BUILD_FOR_ANDROID 954 #ifdef SK_BUILD_FOR_ANDROID
956 uint32_t fGenerationID;
957 const SkPath* fSourcePath; 955 const SkPath* fSourcePath;
958 #endif 956 #endif
959 957
960 /** Resets all fields other than fPathRef to their initial 'empty' values. 958 /** Resets all fields other than fPathRef to their initial 'empty' values.
961 * Assumes the caller has already emptied fPathRef. 959 * Assumes the caller has already emptied fPathRef.
962 * On Android increments fGenerationID without reseting it. 960 * On Android increments fGenerationID without reseting it.
963 */ 961 */
964 void resetFields(); 962 void resetFields();
965 963
966 /** Sets all fields other than fPathRef to the values in 'that'. 964 /** Sets all fields other than fPathRef to the values in 'that'.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O 1014 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
1017 friend class SkPathRef; // just for SerializationOffsets 1015 friend class SkPathRef; // just for SerializationOffsets
1018 #endif 1016 #endif
1019 friend class SkAutoPathBoundsUpdate; 1017 friend class SkAutoPathBoundsUpdate;
1020 friend class SkAutoDisableOvalCheck; 1018 friend class SkAutoDisableOvalCheck;
1021 friend class SkAutoDisableDirectionCheck; 1019 friend class SkAutoDisableDirectionCheck;
1022 friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo 1020 friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo
1023 }; 1021 };
1024 1022
1025 #endif 1023 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPathRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698