Chromium Code Reviews| Index: src/gpu/GrAllocator.h |
| diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h |
| index 933be9f655aeb62c14c5d152cdd0d754c0cbf99d..37c123f7936c097558896eabfb9a349d2ced488f 100644 |
| --- a/src/gpu/GrAllocator.h |
| +++ b/src/gpu/GrAllocator.h |
| @@ -61,6 +61,24 @@ public: |
| } |
| /** |
|
robertphillips
2014/09/04 20:24:35
Add a unit test for this new capability ?
bsalomon
2014/09/05 20:02:54
Done (in separate CL)
|
| + * Remove the last item, only call if count() != 0 |
| + */ |
| + void pop_back() { |
| + SkASSERT(fCount); |
| + SkASSERT(fInsertionIndexInBlock > 0); |
| + --fInsertionIndexInBlock; |
| + --fCount; |
| + if (0 == fInsertionIndexInBlock) { |
| + // Never delete the first block |
| + if (fBlocks.count() > 1) { |
| + sk_free(fBlocks.back()); |
| + fBlocks.pop_back(); |
| + fInsertionIndexInBlock = fItemsPerBlock; |
| + } |
| + } |
| + } |
| + |
| + /** |
| * Removes all added items. |
| */ |
| void reset() { |
| @@ -109,7 +127,6 @@ public: |
| return (const char*)(fBlocks.back()) + (fInsertionIndexInBlock - 1) * fItemSize; |
| } |
| - |
| /** |
| * Iterates through the allocator. This is faster than using operator[] when walking linearly |
| * through the allocator. |
| @@ -240,6 +257,14 @@ public: |
| } |
| /** |
| + * Remove the last item, only call if count() != 0 |
| + */ |
| + void pop_back() { |
| + this->back().~T(); |
| + fAllocator.pop_back(); |
| + } |
| + |
| + /** |
| * Removes all added items. |
| */ |
| void reset() { |