aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-11-21 09:03:45 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-21 09:03:45 -0800
commit947556f6583e62b1ae19dcda94e0dea78babda2b (patch)
treeab160c43ac1568bc4656c95cc49a6e9d42e45265
parent42ddcd49060f64be57f00e651650154f9b4f3a08 (diff)
remove GrAllocPool
-rw-r--r--gyp/gpu.gypi2
-rwxr-xr-xsrc/gpu/GrAADistanceFieldPathRenderer.h1
-rw-r--r--src/gpu/GrAllocPool.cpp116
-rw-r--r--src/gpu/GrAllocPool.h60
-rw-r--r--src/gpu/GrTextStrike.cpp4
-rw-r--r--src/gpu/GrTextStrike.h10
6 files changed, 7 insertions, 186 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 4690f62fc2..0cef7c7be0 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -52,8 +52,6 @@
'<(skia_src_path)/gpu/GrAARectRenderer.h',
'<(skia_src_path)/gpu/GrAddPathRenderers_default.cpp',
'<(skia_src_path)/gpu/GrAllocator.h',
- '<(skia_src_path)/gpu/GrAllocPool.h',
- '<(skia_src_path)/gpu/GrAllocPool.cpp',
'<(skia_src_path)/gpu/GrAtlas.cpp',
'<(skia_src_path)/gpu/GrAtlas.h',
'<(skia_src_path)/gpu/GrBitmapTextContext.cpp',
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.h b/src/gpu/GrAADistanceFieldPathRenderer.h
index e9a32dc07b..88c9d328cc 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.h
+++ b/src/gpu/GrAADistanceFieldPathRenderer.h
@@ -9,7 +9,6 @@
#ifndef GrAADistanceFieldPathRenderer_DEFINED
#define GrAADistanceFieldPathRenderer_DEFINED
-#include "GrAllocPool.h"
#include "GrAtlas.h"
#include "GrPathRenderer.h"
#include "GrRect.h"
diff --git a/src/gpu/GrAllocPool.cpp b/src/gpu/GrAllocPool.cpp
deleted file mode 100644
index 9594c94057..0000000000
--- a/src/gpu/GrAllocPool.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrAllocPool.h"
-
-#include "GrTypes.h"
-
-#define GrAllocPool_MIN_BLOCK_SIZE ((size_t)128)
-
-struct GrAllocPool::Block {
- Block* fNext;
- char* fPtr;
- size_t fBytesFree;
- size_t fBytesTotal;
-
- static Block* Create(size_t size, Block* next) {
- SkASSERT(size >= GrAllocPool_MIN_BLOCK_SIZE);
-
- Block* block = (Block*)sk_malloc_throw(sizeof(Block) + size);
- block->fNext = next;
- block->fPtr = (char*)block + sizeof(Block);
- block->fBytesFree = size;
- block->fBytesTotal = size;
- return block;
- }
-
- bool canAlloc(size_t bytes) const {
- return bytes <= fBytesFree;
- }
-
- void* alloc(size_t bytes) {
- SkASSERT(bytes <= fBytesFree);
- fBytesFree -= bytes;
- void* ptr = fPtr;
- fPtr += bytes;
- return ptr;
- }
-
- size_t release(size_t bytes) {
- SkASSERT(bytes > 0);
- size_t free = SkTMin(bytes, fBytesTotal - fBytesFree);
- fBytesFree += free;
- fPtr -= free;
- return bytes - free;
- }
-
- bool empty() const { return fBytesTotal == fBytesFree; }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-GrAllocPool::GrAllocPool(size_t blockSize) {
- fBlock = NULL;
- fMinBlockSize = SkTMax(blockSize, GrAllocPool_MIN_BLOCK_SIZE);
- SkDEBUGCODE(fBlocksAllocated = 0;)
-}
-
-GrAllocPool::~GrAllocPool() {
- this->reset();
-}
-
-void GrAllocPool::reset() {
- this->validate();
-
- Block* block = fBlock;
- while (block) {
- Block* next = block->fNext;
- sk_free(block);
- block = next;
- }
- fBlock = NULL;
- SkDEBUGCODE(fBlocksAllocated = 0;)
-}
-
-void* GrAllocPool::alloc(size_t size) {
- this->validate();
-
- if (!fBlock || !fBlock->canAlloc(size)) {
- size_t blockSize = SkTMax(fMinBlockSize, size);
- fBlock = Block::Create(blockSize, fBlock);
- SkDEBUGCODE(fBlocksAllocated += 1;)
- }
- return fBlock->alloc(size);
-}
-
-void GrAllocPool::release(size_t bytes) {
- this->validate();
-
- while (bytes && fBlock) {
- bytes = fBlock->release(bytes);
- if (fBlock->empty()) {
- Block* next = fBlock->fNext;
- sk_free(fBlock);
- fBlock = next;
- SkDEBUGCODE(fBlocksAllocated -= 1;)
- }
- }
-}
-
-#ifdef SK_DEBUG
-
-void GrAllocPool::validate() const {
- Block* block = fBlock;
- int count = 0;
- while (block) {
- count += 1;
- block = block->fNext;
- }
- SkASSERT(fBlocksAllocated == count);
-}
-
-#endif
diff --git a/src/gpu/GrAllocPool.h b/src/gpu/GrAllocPool.h
deleted file mode 100644
index 4fc826569e..0000000000
--- a/src/gpu/GrAllocPool.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrAllocPool_DEFINED
-#define GrAllocPool_DEFINED
-
-#include "SkTypes.h"
-
-class GrAllocPool : SkNoncopyable {
-public:
- GrAllocPool(size_t blockSize = 0);
- ~GrAllocPool();
-
- /**
- * Frees all blocks that have been allocated with alloc().
- */
- void reset();
-
- /**
- * Returns a block of memory bytes size big. This address must not be
- * passed to realloc/free/delete or any other function that assumes the
- * address was allocated by malloc or new (because it hasn't).
- */
- void* alloc(size_t bytes);
-
- /**
- * Releases the most recently allocated bytes back to allocpool.
- */
- void release(size_t bytes);
-
-private:
- struct Block;
-
- Block* fBlock;
- size_t fMinBlockSize;
-
-#ifdef SK_DEBUG
- int fBlocksAllocated;
- void validate() const;
-#else
- void validate() const {}
-#endif
-};
-
-template <typename T> class GrTAllocPool {
-public:
- GrTAllocPool(int count) : fPool(count * sizeof(T)) {}
-
- void reset() { fPool.reset(); }
- T* alloc() { return (T*)fPool.alloc(sizeof(T)); }
-
-private:
- GrAllocPool fPool;
-};
-
-#endif
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index 0186af1f63..aa5cd94a60 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -227,7 +227,7 @@ void GrFontCache::dump() const {
atlas and a position within that texture.
*/
-GrTextStrike::GrTextStrike(GrFontCache* cache, const GrFontDescKey* key) : fPool(64) {
+GrTextStrike::GrTextStrike(GrFontCache* cache, const GrFontDescKey* key) {
fFontScalerKey = key;
fFontScalerKey->ref();
@@ -267,7 +267,7 @@ GrGlyph* GrTextStrike::generateGlyph(GrGlyph::PackedID packed,
}
GrMaskFormat format = scaler->getPackedGlyphMaskFormat(packed);
- GrGlyph* glyph = fPool.alloc();
+ GrGlyph* glyph = (GrGlyph*)fPool.alloc(sizeof(GrGlyph), SK_MALLOC_THROW);
glyph->init(packed, bounds, format);
fCache.add(glyph);
return glyph;
diff --git a/src/gpu/GrTextStrike.h b/src/gpu/GrTextStrike.h
index 779d676e43..09d7323179 100644
--- a/src/gpu/GrTextStrike.h
+++ b/src/gpu/GrTextStrike.h
@@ -11,12 +11,12 @@
#ifndef GrTextStrike_DEFINED
#define GrTextStrike_DEFINED
-#include "GrAllocPool.h"
+#include "GrAtlas.h"
+#include "GrDrawTarget.h"
#include "GrFontScaler.h"
-#include "SkTDynamicHash.h"
#include "GrGlyph.h"
-#include "GrDrawTarget.h"
-#include "GrAtlas.h"
+#include "SkTDynamicHash.h"
+#include "SkVarAlloc.h"
class GrFontCache;
class GrGpu;
@@ -62,7 +62,7 @@ public:
private:
SkTDynamicHash<GrGlyph, GrGlyph::PackedID> fCache;
const GrFontDescKey* fFontScalerKey;
- GrTAllocPool<GrGlyph> fPool;
+ SkVarAlloc fPool;
GrFontCache* fFontCache;
bool fUseDistanceField;