OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
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 GrPathRange_DEFINED | 8 #ifndef GrPathRange_DEFINED |
9 #define GrPathRange_DEFINED | 9 #define GrPathRange_DEFINED |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 static const bool kIsWrapped = false; | 29 static const bool kIsWrapped = false; |
30 | 30 |
31 /** | 31 /** |
32 * Return the resourceType intended for cache lookups involving GrPathRange. | 32 * Return the resourceType intended for cache lookups involving GrPathRange. |
33 */ | 33 */ |
34 static GrResourceKey::ResourceType resourceType() { | 34 static GrResourceKey::ResourceType resourceType() { |
35 static const GrResourceKey::ResourceType type = GrResourceKey::GenerateR
esourceType(); | 35 static const GrResourceKey::ResourceType type = GrResourceKey::GenerateR
esourceType(); |
36 return type; | 36 return type; |
37 } | 37 } |
38 | 38 |
| 39 enum PathIndexType { |
| 40 kU8_PathIndexType, //!< uint8_t |
| 41 kU16_PathIndexType, //!< uint16_t |
| 42 kU32_PathIndexType, //!< uint32_t |
| 43 |
| 44 kLast_PathIndexType = kU32_PathIndexType |
| 45 }; |
| 46 |
| 47 static inline int PathIndexSizeInBytes(PathIndexType type) { |
| 48 GR_STATIC_ASSERT(0 == kU8_PathIndexType); |
| 49 GR_STATIC_ASSERT(1 == kU16_PathIndexType); |
| 50 GR_STATIC_ASSERT(2 == kU32_PathIndexType); |
| 51 GR_STATIC_ASSERT(kU32_PathIndexType == kLast_PathIndexType); |
| 52 |
| 53 return 1 << type; |
| 54 } |
| 55 |
39 /** | 56 /** |
40 * Class that generates the paths for a specific range. | 57 * Class that generates the paths for a specific range. |
41 */ | 58 */ |
42 class PathGenerator : public SkRefCnt { | 59 class PathGenerator : public SkRefCnt { |
43 public: | 60 public: |
44 virtual int getNumPaths() = 0; | 61 virtual int getNumPaths() = 0; |
45 virtual void generatePath(int index, SkPath* out) = 0; | 62 virtual void generatePath(int index, SkPath* out) = 0; |
46 virtual bool isEqualTo(const SkDescriptor&) const { return false; } | 63 virtual bool isEqualTo(const SkDescriptor&) const { return false; } |
47 virtual ~PathGenerator() {} | 64 virtual ~PathGenerator() {} |
48 }; | 65 }; |
49 | 66 |
50 /** | 67 /** |
(...skipping 18 matching lines...) Expand all Loading... |
69 | 86 |
70 protected: | 87 protected: |
71 // Initialize a path in the range before drawing. This is only called when | 88 // Initialize a path in the range before drawing. This is only called when |
72 // fPathGenerator is non-null. The child class need not call didChangeGpuMem
orySize(), | 89 // fPathGenerator is non-null. The child class need not call didChangeGpuMem
orySize(), |
73 // GrPathRange will take care of that after the call is complete. | 90 // GrPathRange will take care of that after the call is complete. |
74 virtual void onInitPath(int index, const SkPath&) const = 0; | 91 virtual void onInitPath(int index, const SkPath&) const = 0; |
75 | 92 |
76 private: | 93 private: |
77 // Notify when paths will be drawn in case this is a lazy-loaded path range. | 94 // Notify when paths will be drawn in case this is a lazy-loaded path range. |
78 friend class GrGpu; | 95 friend class GrGpu; |
79 void willDrawPaths(const uint32_t indices[], int count) const; | 96 void willDrawPaths(const void* indices, PathIndexType, int count) const; |
| 97 template<typename IndexType> void willDrawPaths(const void* indices, int cou
nt) const; |
80 | 98 |
81 mutable SkAutoTUnref<PathGenerator> fPathGenerator; | 99 mutable SkAutoTUnref<PathGenerator> fPathGenerator; |
82 mutable SkTArray<uint8_t, true /*MEM_COPY*/> fGeneratedPaths; | 100 mutable SkTArray<uint8_t, true /*MEM_COPY*/> fGeneratedPaths; |
83 const int fNumPaths; | 101 const int fNumPaths; |
84 const SkStrokeRec fStroke; | 102 const SkStrokeRec fStroke; |
85 | 103 |
86 typedef GrGpuResource INHERITED; | 104 typedef GrGpuResource INHERITED; |
87 }; | 105 }; |
88 | 106 |
89 #endif | 107 #endif |
OLD | NEW |