| 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 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 ++fBlockIndex; | 135 ++fBlockIndex; |
| 136 fIndexInBlock = 0; | 136 fIndexInBlock = 0; |
| 137 } | 137 } |
| 138 return fItemIndex < fAllocator->fCount; | 138 return fItemIndex < fAllocator->fCount; |
| 139 } | 139 } |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * Gets the current iterator value. Call next() at least once before cal
ling. Don't call | 142 * Gets the current iterator value. Call next() at least once before cal
ling. Don't call |
| 143 * after next() returns false. | 143 * after next() returns false. |
| 144 */ | 144 */ |
| 145 const void* get() const { | 145 void* get() const { |
| 146 SkASSERT(fItemIndex >= 0 && fItemIndex < fAllocator->fCount); | 146 SkASSERT(fItemIndex >= 0 && fItemIndex < fAllocator->fCount); |
| 147 return (char*) fAllocator->fBlocks[fBlockIndex] + fIndexInBlock * fA
llocator->fItemSize; | 147 return (char*) fAllocator->fBlocks[fBlockIndex] + fIndexInBlock * fA
llocator->fItemSize; |
| 148 } | 148 } |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 const GrAllocator* fAllocator; | 151 const GrAllocator* fAllocator; |
| 152 int fBlockIndex; | 152 int fBlockIndex; |
| 153 int fIndexInBlock; | 153 int fIndexInBlock; |
| 154 int fItemIndex; | 154 int fItemIndex; |
| 155 }; | 155 }; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 289 |
| 290 /** | 290 /** |
| 291 * Advances the iterator. Iteration is finished when next() returns fals
e. | 291 * Advances the iterator. Iteration is finished when next() returns fals
e. |
| 292 */ | 292 */ |
| 293 bool next() { return fImpl.next(); } | 293 bool next() { return fImpl.next(); } |
| 294 | 294 |
| 295 /** | 295 /** |
| 296 * Gets the current iterator value. Call next() at least once before cal
ling. Don't call | 296 * Gets the current iterator value. Call next() at least once before cal
ling. Don't call |
| 297 * after next() returns false. | 297 * after next() returns false. |
| 298 */ | 298 */ |
| 299 const T* get() const { return (const T*) fImpl.get(); } | 299 T* get() const { return (T*) fImpl.get(); } |
| 300 | 300 |
| 301 /** | 301 /** |
| 302 * Convenience operators. Same rules for calling apply as get(). | 302 * Convenience operators. Same rules for calling apply as get(). |
| 303 */ | 303 */ |
| 304 const T& operator*() const { return *this->get(); } | 304 T& operator*() const { return *this->get(); } |
| 305 const T* operator->() const { return this->get(); } | 305 T* operator->() const { return this->get(); } |
| 306 | 306 |
| 307 private: | 307 private: |
| 308 GrAllocator::Iter fImpl; | 308 GrAllocator::Iter fImpl; |
| 309 }; | 309 }; |
| 310 | 310 |
| 311 /** | 311 /** |
| 312 * Access item by index. | 312 * Access item by index. |
| 313 */ | 313 */ |
| 314 T& operator[] (int i) { | 314 T& operator[] (int i) { |
| 315 return *(T*)(fAllocator[i]); | 315 return *(T*)(fAllocator[i]); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 346 public: | 346 public: |
| 347 GrSTAllocator() : INHERITED(N) { | 347 GrSTAllocator() : INHERITED(N) { |
| 348 this->setInitialBlock(fStorage.get()); | 348 this->setInitialBlock(fStorage.get()); |
| 349 } | 349 } |
| 350 | 350 |
| 351 private: | 351 private: |
| 352 SkAlignedSTStorage<N, T> fStorage; | 352 SkAlignedSTStorage<N, T> fStorage; |
| 353 }; | 353 }; |
| 354 | 354 |
| 355 #endif | 355 #endif |
| OLD | NEW |