diff options
author | bsalomon <bsalomon@google.com> | 2015-07-30 15:57:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-30 15:57:33 -0700 |
commit | 2aad5f1e6ac0aecc9f35cea7e6b02cc3e9d51da3 (patch) | |
tree | 805443cda72eb715fb48b3438e6c7151087ff4a2 /src | |
parent | 16921ec30a81976129d507b1148c93a322e61a4f (diff) |
Make TRecorder alloc_back return a void*
Speculative fix for this bug:
BUG=chromium:515679
TBR=robertphillips@google.com
Review URL: https://codereview.chromium.org/1268493003
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrTRecorder.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/gpu/GrTRecorder.h b/src/gpu/GrTRecorder.h index 1c49c86f38..59d185f059 100644 --- a/src/gpu/GrTRecorder.h +++ b/src/gpu/GrTRecorder.h @@ -68,7 +68,7 @@ public: TBase& back() { SkASSERT(!this->empty()); - return *fLastItem; + return *reinterpret_cast<TBase*>(fLastItem); } /** @@ -110,7 +110,7 @@ private: int fTotalLength; // The length of an entry including header, item, and data in TAligns. int fPrevLength; // Same but for the previous entry. Used for iterating backwards. }; - template<typename TItem> TItem* alloc_back(int dataLength); + template<typename TItem> void* alloc_back(int dataLength); struct MemBlock : SkNoncopyable { /** Allocates a new block and appends it to prev if not NULL. The length param is in units @@ -154,7 +154,7 @@ private: MemBlock* const fHeadBlock; MemBlock* fTailBlock; - TBase* fLastItem; + void* fLastItem; // really a ptr to TBase template<typename TItem> friend struct GrTRecorderAllocWrapper; @@ -174,7 +174,7 @@ void GrTRecorder<TBase, TAlign>::pop_back() { Header* header = reinterpret_cast<Header*>( reinterpret_cast<TAlign*>(fLastItem) - length_of<Header>::kValue); fTailBlock->fBack -= header->fTotalLength; - fLastItem->~TBase(); + reinterpret_cast<TBase*>(fLastItem)->~TBase(); int lastItemLength = header->fPrevLength; @@ -190,13 +190,12 @@ void GrTRecorder<TBase, TAlign>::pop_back() { fTailBlock = fTailBlock->fPrev; SkASSERT(fTailBlock); } - fLastItem = reinterpret_cast<TBase*>( - &(*fTailBlock)[fTailBlock->fBack - lastItemLength + length_of<Header>::kValue]); + fLastItem = &(*fTailBlock)[fTailBlock->fBack - lastItemLength + length_of<Header>::kValue]; } template<typename TBase, typename TAlign> template<typename TItem> -TItem* GrTRecorder<TBase, TAlign>::alloc_back(int dataLength) { +void* GrTRecorder<TBase, TAlign>::alloc_back(int dataLength) { // Find the header of the previous entry and get its length. We need to store that in the new // header for backwards iteration (pop_back()). int prevLength = 0; @@ -221,8 +220,7 @@ TItem* GrTRecorder<TBase, TAlign>::alloc_back(int dataLength) { } Header* header = reinterpret_cast<Header*>(&(*fTailBlock)[fTailBlock->fBack]); - TItem* rawPtr = reinterpret_cast<TItem*>( - &(*fTailBlock)[fTailBlock->fBack + length_of<Header>::kValue]); + void* rawPtr = &(*fTailBlock)[fTailBlock->fBack + length_of<Header>::kValue]; header->fTotalLength = totalLength; header->fPrevLength = prevLength; |