OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrAllocPool_DEFINED | 8 #ifndef GrAllocPool_DEFINED |
9 #define GrAllocPool_DEFINED | 9 #define GrAllocPool_DEFINED |
10 | 10 |
11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
12 | 12 |
13 class GrAllocPool : public SkNoncopyable { | 13 class GrAllocPool : SkNoncopyable { |
14 public: | 14 public: |
15 GrAllocPool(size_t blockSize = 0); | 15 GrAllocPool(size_t blockSize = 0); |
16 ~GrAllocPool(); | 16 ~GrAllocPool(); |
17 | 17 |
18 /** | 18 /** |
19 * Frees all blocks that have been allocated with alloc(). | 19 * Frees all blocks that have been allocated with alloc(). |
20 */ | 20 */ |
21 void reset(); | 21 void reset(); |
22 | 22 |
23 /** | 23 /** |
(...skipping 27 matching lines...) Expand all Loading... |
51 GrTAllocPool(int count) : fPool(count * sizeof(T)) {} | 51 GrTAllocPool(int count) : fPool(count * sizeof(T)) {} |
52 | 52 |
53 void reset() { fPool.reset(); } | 53 void reset() { fPool.reset(); } |
54 T* alloc() { return (T*)fPool.alloc(sizeof(T)); } | 54 T* alloc() { return (T*)fPool.alloc(sizeof(T)); } |
55 | 55 |
56 private: | 56 private: |
57 GrAllocPool fPool; | 57 GrAllocPool fPool; |
58 }; | 58 }; |
59 | 59 |
60 #endif | 60 #endif |
OLD | NEW |