OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 * Releases the most recently allocated bytes back to allocpool. | 34 * Releases the most recently allocated bytes back to allocpool. |
35 */ | 35 */ |
36 void release(size_t bytes); | 36 void release(size_t bytes); |
37 | 37 |
38 private: | 38 private: |
39 struct Block; | 39 struct Block; |
40 | 40 |
41 Block* fBlock; | 41 Block* fBlock; |
42 size_t fMinBlockSize; | 42 size_t fMinBlockSize; |
43 | 43 |
44 #if GR_DEBUG | 44 #if SK_DEBUG |
45 int fBlocksAllocated; | 45 int fBlocksAllocated; |
46 void validate() const; | 46 void validate() const; |
47 #else | 47 #else |
48 void validate() const {} | 48 void validate() const {} |
49 #endif | 49 #endif |
50 }; | 50 }; |
51 | 51 |
52 template <typename T> class GrTAllocPool { | 52 template <typename T> class GrTAllocPool { |
53 public: | 53 public: |
54 GrTAllocPool(int count) : fPool(count * sizeof(T)) {} | 54 GrTAllocPool(int count) : fPool(count * sizeof(T)) {} |
55 | 55 |
56 void reset() { fPool.reset(); } | 56 void reset() { fPool.reset(); } |
57 T* alloc() { return (T*)fPool.alloc(sizeof(T)); } | 57 T* alloc() { return (T*)fPool.alloc(sizeof(T)); } |
58 | 58 |
59 private: | 59 private: |
60 GrAllocPool fPool; | 60 GrAllocPool fPool; |
61 }; | 61 }; |
62 | 62 |
63 #endif | 63 #endif |
OLD | NEW |