From e90d7c4b152c56919d963987e2503f9909a666d2 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Mon, 17 Mar 2014 20:13:37 +0100 Subject: Cherry-Pick: Delay setting initial memory block until it officially exists. BUG=323017 R=robertphillips@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/99833002 Not submitting a separate patch to QtWebEngine. This change is known to be contained in our next snapshot. Change-Id: Id267513b61ebc89446808206755661ae946e0a45 Reviewed-by: Andras Becsi --- chromium/third_party/skia/src/gpu/GrAllocator.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/chromium/third_party/skia/src/gpu/GrAllocator.h b/chromium/third_party/skia/src/gpu/GrAllocator.h index 57ca03cd329..d3580e776bd 100755 --- a/chromium/third_party/skia/src/gpu/GrAllocator.h +++ b/chromium/third_party/skia/src/gpu/GrAllocator.h @@ -39,6 +39,14 @@ public: SkDEBUGCODE(if (!fOwnFirstBlock) {*((char*)initialBlock+fBlockSize-1)='a';} ); } + void setInitialBlock(void* initialBlock) { + SkASSERT(0 == fCount); + SkASSERT(1 == fBlocks.count()); + SkASSERT(NULL == fBlocks.back()); + fOwnFirstBlock = false; + fBlocks.back() = initialBlock; + } + /** * Adds an item and returns pointer to it. * @@ -223,8 +231,8 @@ public: } protected: - GrTAllocator(int itemsPerBlock, void* initialBlock) - : fAllocator(sizeof(T), itemsPerBlock, initialBlock) { + void setInitialBlock(void* initialBlock) { + fAllocator.setInitialBlock(initialBlock); } private: @@ -236,8 +244,10 @@ template class GrSTAllocator : public GrTAllocator { private: typedef GrTAllocator INHERITED; + public: - GrSTAllocator() : INHERITED(N, fStorage.get()) { + GrSTAllocator() : INHERITED(N) { + this->setInitialBlock(fStorage.get()); } private: -- cgit v1.2.1