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 20 matching lines...) Expand all Loading... |
31 * Caller is responsible for freeing this memory. | 31 * Caller is responsible for freeing this memory. |
32 */ | 32 */ |
33 GrAllocator(size_t itemSize, int itemsPerBlock, void* initialBlock) : | 33 GrAllocator(size_t itemSize, int itemsPerBlock, void* initialBlock) : |
34 fItemSize(itemSize), | 34 fItemSize(itemSize), |
35 fItemsPerBlock(itemsPerBlock), | 35 fItemsPerBlock(itemsPerBlock), |
36 fOwnFirstBlock(NULL == initialBlock), | 36 fOwnFirstBlock(NULL == initialBlock), |
37 fCount(0) { | 37 fCount(0) { |
38 SkASSERT(itemsPerBlock > 0); | 38 SkASSERT(itemsPerBlock > 0); |
39 fBlockSize = fItemSize * fItemsPerBlock; | 39 fBlockSize = fItemSize * fItemsPerBlock; |
40 fBlocks.push_back() = initialBlock; | 40 fBlocks.push_back() = initialBlock; |
41 GR_DEBUGCODE(if (!fOwnFirstBlock) {*((char*)initialBlock+fBlockSize-1)='
a';} ); | 41 SkDEBUGCODE(if (!fOwnFirstBlock) {*((char*)initialBlock+fBlockSize-1)='a
';} ); |
42 } | 42 } |
43 | 43 |
44 /** | 44 /** |
45 * Adds an item and returns pointer to it. | 45 * Adds an item and returns pointer to it. |
46 * | 46 * |
47 * @return pointer to the added item. | 47 * @return pointer to the added item. |
48 */ | 48 */ |
49 void* push_back() { | 49 void* push_back() { |
50 int indexInBlock = fCount % fItemsPerBlock; | 50 int indexInBlock = fCount % fItemsPerBlock; |
51 // we always have at least one block | 51 // we always have at least one block |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 public: | 242 public: |
243 GrSTAllocator() : INHERITED(N, fStorage.get()) { | 243 GrSTAllocator() : INHERITED(N, fStorage.get()) { |
244 } | 244 } |
245 | 245 |
246 private: | 246 private: |
247 SkAlignedSTStorage<N, T> fStorage; | 247 SkAlignedSTStorage<N, T> fStorage; |
248 }; | 248 }; |
249 | 249 |
250 #endif | 250 #endif |
OLD | NEW |