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