| 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 GrAllocator_DEFINED | 8 #ifndef GrAllocator_DEFINED |
| 9 #define GrAllocator_DEFINED | 9 #define GrAllocator_DEFINED |
| 10 | 10 |
| 11 #include "GrConfig.h" | 11 #include "GrConfig.h" |
| 12 #include "GrTypes.h" | 12 #include "GrTypes.h" |
| 13 #include "SkTArray.h" | 13 #include "SkTArray.h" |
| 14 #include "SkTypes.h" | 14 #include "SkTypes.h" |
| 15 | 15 |
| 16 class GrAllocator : public SkNoncopyable { | 16 class GrAllocator : SkNoncopyable { |
| 17 public: | 17 public: |
| 18 ~GrAllocator() { | 18 ~GrAllocator() { |
| 19 reset(); | 19 reset(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Create an allocator | 23 * Create an allocator |
| 24 * | 24 * |
| 25 * @param itemSize the size of each item to allocate | 25 * @param itemSize the size of each item to allocate |
| 26 * @param itemsPerBlock the number of items to allocate at once | 26 * @param itemsPerBlock the number of items to allocate at once |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 size_t fBlockSize; | 146 size_t fBlockSize; |
| 147 size_t fItemSize; | 147 size_t fItemSize; |
| 148 int fItemsPerBlock; | 148 int fItemsPerBlock; |
| 149 bool fOwnFirstBlock; | 149 bool fOwnFirstBlock; |
| 150 int fCount; | 150 int fCount; |
| 151 | 151 |
| 152 typedef SkNoncopyable INHERITED; | 152 typedef SkNoncopyable INHERITED; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 template <typename T> | 155 template <typename T> |
| 156 class GrTAllocator : public SkNoncopyable { | 156 class GrTAllocator : SkNoncopyable { |
| 157 public: | 157 public: |
| 158 virtual ~GrTAllocator() { this->reset(); }; | 158 virtual ~GrTAllocator() { this->reset(); }; |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * Create an allocator | 161 * Create an allocator |
| 162 * | 162 * |
| 163 * @param itemsPerBlock the number of items to allocate at once | 163 * @param itemsPerBlock the number of items to allocate at once |
| 164 */ | 164 */ |
| 165 explicit GrTAllocator(int itemsPerBlock) | 165 explicit GrTAllocator(int itemsPerBlock) |
| 166 : fAllocator(sizeof(T), itemsPerBlock, NULL) {} | 166 : fAllocator(sizeof(T), itemsPerBlock, NULL) {} |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 public: | 259 public: |
| 260 GrSTAllocator() : INHERITED(N) { | 260 GrSTAllocator() : INHERITED(N) { |
| 261 this->setInitialBlock(fStorage.get()); | 261 this->setInitialBlock(fStorage.get()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 private: | 264 private: |
| 265 SkAlignedSTStorage<N, T> fStorage; | 265 SkAlignedSTStorage<N, T> fStorage; |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 #endif | 268 #endif |
| OLD | NEW |