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

Side by Side Diff: src/gpu/GrTHashCache.h

Issue 23566022: move GrMalloc, GrFree, Gr_bzero to their sk equivalents (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months 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 | « src/gpu/GrRectanizer_fifo.cpp ('k') | no next file » | 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 2010 Google Inc. 3 * Copyright 2010 Google Inc.
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 10
(...skipping 16 matching lines...) Expand all
27 * Key needs 27 * Key needs
28 * static bool EQ(const Entry&, const HashKey&); 28 * static bool EQ(const Entry&, const HashKey&);
29 * static bool LT(const Entry&, const HashKey&); 29 * static bool LT(const Entry&, const HashKey&);
30 * uint32_t getHash() const; 30 * uint32_t getHash() const;
31 * 31 *
32 * Allows duplicate key entries but on find you may get 32 * Allows duplicate key entries but on find you may get
33 * any of the duplicate entries returned. 33 * any of the duplicate entries returned.
34 */ 34 */
35 template <typename T, typename Key, size_t kHashBits> class GrTHashTable { 35 template <typename T, typename Key, size_t kHashBits> class GrTHashTable {
36 public: 36 public:
37 GrTHashTable() { Gr_bzero(fHash, sizeof(fHash)); } 37 GrTHashTable() { sk_bzero(fHash, sizeof(fHash)); }
38 ~GrTHashTable() {} 38 ~GrTHashTable() {}
39 39
40 int count() const { return fSorted.count(); } 40 int count() const { return fSorted.count(); }
41 T* find(const Key&) const; 41 T* find(const Key&) const;
42 template <typename FindFuncType> T* find(const Key&, const FindFuncType&) c onst; 42 template <typename FindFuncType> T* find(const Key&, const FindFuncType&) c onst;
43 // return true if key was unique when inserted. 43 // return true if key was unique when inserted.
44 bool insert(const Key&, T*); 44 bool insert(const Key&, T*);
45 void remove(const Key&, const T*); 45 void remove(const Key&, const T*);
46 T* removeAt(int index, uint32_t hash); 46 T* removeAt(int index, uint32_t hash);
47 void removeAll(); 47 void removeAll();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 // remove from our sorted array 204 // remove from our sorted array
205 T* elem = fSorted[elemIndex]; 205 T* elem = fSorted[elemIndex];
206 fSorted.remove(elemIndex); 206 fSorted.remove(elemIndex);
207 return elem; 207 return elem;
208 } 208 }
209 209
210 template <typename T, typename Key, size_t kHashBits> 210 template <typename T, typename Key, size_t kHashBits>
211 void GrTHashTable<T, Key, kHashBits>::removeAll() { 211 void GrTHashTable<T, Key, kHashBits>::removeAll() {
212 fSorted.reset(); 212 fSorted.reset();
213 Gr_bzero(fHash, sizeof(fHash)); 213 sk_bzero(fHash, sizeof(fHash));
214 } 214 }
215 215
216 template <typename T, typename Key, size_t kHashBits> 216 template <typename T, typename Key, size_t kHashBits>
217 void GrTHashTable<T, Key, kHashBits>::deleteAll() { 217 void GrTHashTable<T, Key, kHashBits>::deleteAll() {
218 fSorted.deleteAll(); 218 fSorted.deleteAll();
219 Gr_bzero(fHash, sizeof(fHash)); 219 sk_bzero(fHash, sizeof(fHash));
220 } 220 }
221 221
222 template <typename T, typename Key, size_t kHashBits> 222 template <typename T, typename Key, size_t kHashBits>
223 void GrTHashTable<T, Key, kHashBits>::unrefAll() { 223 void GrTHashTable<T, Key, kHashBits>::unrefAll() {
224 fSorted.unrefAll(); 224 fSorted.unrefAll();
225 Gr_bzero(fHash, sizeof(fHash)); 225 sk_bzero(fHash, sizeof(fHash));
226 } 226 }
227 227
228 #ifdef SK_DEBUG 228 #ifdef SK_DEBUG
229 template <typename T, typename Key, size_t kHashBits> 229 template <typename T, typename Key, size_t kHashBits>
230 void GrTHashTable<T, Key, kHashBits>::validate() const { 230 void GrTHashTable<T, Key, kHashBits>::validate() const {
231 int count = fSorted.count(); 231 int count = fSorted.count();
232 for (int i = 1; i < count; i++) { 232 for (int i = 1; i < count; i++) {
233 SkASSERT(Key::LT(*fSorted[i - 1], *fSorted[i]) || 233 SkASSERT(Key::LT(*fSorted[i - 1], *fSorted[i]) ||
234 Key::EQ(*fSorted[i - 1], *fSorted[i])); 234 Key::EQ(*fSorted[i - 1], *fSorted[i]));
235 } 235 }
236 } 236 }
237 237
238 template <typename T, typename Key, size_t kHashBits> 238 template <typename T, typename Key, size_t kHashBits>
239 bool GrTHashTable<T, Key, kHashBits>::contains(T* elem) const { 239 bool GrTHashTable<T, Key, kHashBits>::contains(T* elem) const {
240 int index = fSorted.find(elem); 240 int index = fSorted.find(elem);
241 return index >= 0; 241 return index >= 0;
242 } 242 }
243 243
244 #endif 244 #endif
245 245
246 #endif 246 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrRectanizer_fifo.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698