OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 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 SkPtrSet_DEFINED | 10 #ifndef SkPtrSet_DEFINED |
11 #define SkPtrSet_DEFINED | 11 #define SkPtrSet_DEFINED |
12 | 12 |
13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
14 #include "SkFlattenable.h" | 14 #include "SkFlattenable.h" |
15 #include "SkTDArray.h" | 15 #include "SkTDArray.h" |
16 | 16 |
17 /** | 17 /** |
18 * Maintains a set of ptrs, assigning each a unique ID [1...N]. Duplicate ptrs | 18 * Maintains a set of ptrs, assigning each a unique ID [1...N]. Duplicate ptrs |
19 * return the same ID (since its a set). Subclasses can override inPtr() | 19 * return the same ID (since its a set). Subclasses can override inPtr() |
20 * and decPtr(). incPtr() is called each time a unique ptr is added ot the | 20 * and decPtr(). incPtr() is called each time a unique ptr is added ot the |
21 * set. decPtr() is called on each ptr when the set is destroyed or reset. | 21 * set. decPtr() is called on each ptr when the set is destroyed or reset. |
22 */ | 22 */ |
23 class SkPtrSet : public SkRefCnt { | 23 class SkPtrSet : public SkRefCnt { |
24 public: | 24 public: |
25 SK_DECLARE_INST_COUNT(SkPtrSet) | 25 |
26 | 26 |
27 /** | 27 /** |
28 * Search for the specified ptr in the set. If it is found, return its | 28 * Search for the specified ptr in the set. If it is found, return its |
29 * 32bit ID [1..N], or if not found, return 0. Always returns 0 for NULL. | 29 * 32bit ID [1..N], or if not found, return 0. Always returns 0 for NULL. |
30 */ | 30 */ |
31 uint32_t find(void*) const; | 31 uint32_t find(void*) const; |
32 | 32 |
33 /** | 33 /** |
34 * Add the specified ptr to the set, returning a unique 32bit ID for it | 34 * Add the specified ptr to the set, returning a unique 32bit ID for it |
35 * [1...N]. Duplicate ptrs will return the same ID. | 35 * [1...N]. Duplicate ptrs will return the same ID. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 }; | 137 }; |
138 | 138 |
139 class SkFactorySet : public SkTPtrSet<SkFlattenable::Factory> {}; | 139 class SkFactorySet : public SkTPtrSet<SkFlattenable::Factory> {}; |
140 | 140 |
141 /** | 141 /** |
142 * Similar to SkFactorySet, but only allows Factorys that have registered names. | 142 * Similar to SkFactorySet, but only allows Factorys that have registered names. |
143 * Also has a function to return the next added Factory's name. | 143 * Also has a function to return the next added Factory's name. |
144 */ | 144 */ |
145 class SkNamedFactorySet : public SkRefCnt { | 145 class SkNamedFactorySet : public SkRefCnt { |
146 public: | 146 public: |
147 SK_DECLARE_INST_COUNT(SkNamedFactorySet) | 147 |
148 | 148 |
149 SkNamedFactorySet(); | 149 SkNamedFactorySet(); |
150 | 150 |
151 /** | 151 /** |
152 * Find the specified Factory in the set. If it is not already in the set, | 152 * Find the specified Factory in the set. If it is not already in the set, |
153 * and has registered its name, add it to the set, and return its index. | 153 * and has registered its name, add it to the set, and return its index. |
154 * If the Factory has no registered name, return 0. | 154 * If the Factory has no registered name, return 0. |
155 */ | 155 */ |
156 uint32_t find(SkFlattenable::Factory); | 156 uint32_t find(SkFlattenable::Factory); |
157 | 157 |
158 /** | 158 /** |
159 * If new Factorys have been added to the set, return the name of the first | 159 * If new Factorys have been added to the set, return the name of the first |
160 * Factory added after the Factory name returned by the last call to this | 160 * Factory added after the Factory name returned by the last call to this |
161 * function. | 161 * function. |
162 */ | 162 */ |
163 const char* getNextAddedFactoryName(); | 163 const char* getNextAddedFactoryName(); |
164 private: | 164 private: |
165 int fNextAddedFactory; | 165 int fNextAddedFactory; |
166 SkFactorySet fFactorySet; | 166 SkFactorySet fFactorySet; |
167 SkTDArray<const char*> fNames; | 167 SkTDArray<const char*> fNames; |
168 | 168 |
169 typedef SkRefCnt INHERITED; | 169 typedef SkRefCnt INHERITED; |
170 }; | 170 }; |
171 | 171 |
172 #endif | 172 #endif |
OLD | NEW |