diff options
author | Chris Dalton <csmartdalton@google.com> | 2018-06-08 11:51:39 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-08 19:32:03 +0000 |
commit | d0d409d3ebd083b4f5263949e404c1700c615d3b (patch) | |
tree | 14ba1abdcdca89ef8cc414ae22368d24b2e0b77c /src/gpu/GrAllocator.h | |
parent | 59d997a6e1d32f2d0a3021931aed87984d15a7ee (diff) |
Add a front() accessor to GrAllocator
Bug: skia:
Change-Id: If0bde2ddfe2dd1d84b27f4516076acc1b68daa40
Reviewed-on: https://skia-review.googlesource.com/133461
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrAllocator.h')
-rw-r--r-- | src/gpu/GrAllocator.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h index e5d2f4ea61..314e58a99a 100644 --- a/src/gpu/GrAllocator.h +++ b/src/gpu/GrAllocator.h @@ -110,6 +110,24 @@ public: bool empty() const { return 0 == fCount; } /** + * Access first item, only call if count() != 0 + */ + void* front() { + SkASSERT(fCount); + SkASSERT(fInsertionIndexInBlock > 0); + return (char*)(fBlocks.front()); + } + + /** + * Access first item, only call if count() != 0 + */ + const void* front() const { + SkASSERT(fCount); + SkASSERT(fInsertionIndexInBlock > 0); + return (const char*)(fBlocks.front()); + } + + /** * Access last item, only call if count() != 0 */ void* back() { @@ -297,6 +315,20 @@ public: bool empty() const { return fAllocator.empty(); } /** + * Access first item, only call if count() != 0 + */ + T& front() { + return *(T*)fAllocator.front(); + } + + /** + * Access first item, only call if count() != 0 + */ + const T& front() const { + return *(T*)fAllocator.front(); + } + + /** * Access last item, only call if count() != 0 */ T& back() { |