Remove unneeded features from GrBufferAllocPool
Review URL: https://codereview.chromium.org/1103423004
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index f233118..d1ae037 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/gpu/GrBufferAllocPool.cpp
@@ -37,18 +37,13 @@
GrBufferAllocPool::GrBufferAllocPool(GrGpu* gpu,
BufferType bufferType,
- bool frequentResetHint,
size_t blockSize,
int preallocBufferCnt) :
fBlocks(SkTMax(8, 2*preallocBufferCnt)) {
- SkASSERT(gpu);
- fGpu = gpu;
- fGpu->ref();
- fGpuIsReffed = true;
+ fGpu = SkRef(gpu);
fBufferType = bufferType;
- fFrequentResetHint = frequentResetHint;
fBufferPtr = NULL;
fMinBlockSize = SkTMax(GrBufferAllocPool_MIN_BLOCK_SIZE, blockSize);
@@ -76,14 +71,7 @@
destroyBlock();
}
fPreallocBuffers.unrefAll();
- releaseGpuRef();
-}
-
-void GrBufferAllocPool::releaseGpuRef() {
- if (fGpuIsReffed) {
- fGpu->unref();
- fGpuIsReffed = false;
- }
+ fGpu->unref();
}
void GrBufferAllocPool::reset() {
@@ -317,17 +305,11 @@
SkASSERT(NULL == fBufferPtr);
// If the buffer is CPU-backed we map it because it is free to do so and saves a copy.
- // Otherwise when buffer mapping is supported:
- // a) If the frequently reset hint is set we only map when the requested size meets a
- // threshold (since we don't expect it is likely that we will see more vertex data)
- // b) If the hint is not set we map if the buffer size is greater than the threshold.
+ // Otherwise when buffer mapping is supported we map if the buffer size is greater than the
+ // threshold.
bool attemptMap = block.fBuffer->isCPUBacked();
if (!attemptMap && GrDrawTargetCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags()) {
- if (fFrequentResetHint) {
- attemptMap = requestSize > GR_GEOM_BUFFER_MAP_THRESHOLD;
- } else {
- attemptMap = size > GR_GEOM_BUFFER_MAP_THRESHOLD;
- }
+ attemptMap = size > GR_GEOM_BUFFER_MAP_THRESHOLD;
}
if (attemptMap) {
@@ -395,12 +377,10 @@
////////////////////////////////////////////////////////////////////////////////
GrVertexBufferAllocPool::GrVertexBufferAllocPool(GrGpu* gpu,
- bool frequentResetHint,
size_t bufferSize,
int preallocBufferCnt)
: GrBufferAllocPool(gpu,
kVertex_BufferType,
- frequentResetHint,
bufferSize,
preallocBufferCnt) {
}
@@ -438,12 +418,10 @@
////////////////////////////////////////////////////////////////////////////////
GrIndexBufferAllocPool::GrIndexBufferAllocPool(GrGpu* gpu,
- bool frequentResetHint,
size_t bufferSize,
int preallocBufferCnt)
: GrBufferAllocPool(gpu,
kIndex_BufferType,
- frequentResetHint,
bufferSize,
preallocBufferCnt) {
}
diff --git a/src/gpu/GrBufferAllocPool.h b/src/gpu/GrBufferAllocPool.h
index 40904cf..9ea33f7 100644
--- a/src/gpu/GrBufferAllocPool.h
+++ b/src/gpu/GrBufferAllocPool.h
@@ -76,10 +76,6 @@
*
* @param gpu The GrGpu used to create the buffers.
* @param bufferType The type of buffers to create.
- * @param frequentResetHint A hint that indicates that the pool
- * should expect frequent unmap() calls
- * (as opposed to many makeSpace / acquires
- * between resets).
* @param bufferSize The minimum size of created buffers.
* This value will be clamped to some
* reasonable minimum.
@@ -89,7 +85,6 @@
*/
GrBufferAllocPool(GrGpu* gpu,
BufferType bufferType,
- bool frequentResetHint,
size_t bufferSize = 0,
int preallocBufferCnt = 0);
@@ -146,7 +141,6 @@
// The GrGpu must be able to clear the ref of pools it creates as members
friend class GrGpu;
- void releaseGpuRef();
struct BufferBlock {
size_t fBytesFree;
@@ -163,8 +157,6 @@
size_t fBytesInUse;
GrGpu* fGpu;
- bool fGpuIsReffed;
- bool fFrequentResetHint;
SkTDArray<GrGeometryBuffer*> fPreallocBuffers;
size_t fMinBlockSize;
BufferType fBufferType;
@@ -189,20 +181,13 @@
* Constructor
*
* @param gpu The GrGpu used to create the vertex buffers.
- * @param frequentResetHint A hint that indicates that the pool
- * should expect frequent unmap() calls
- * (as opposed to many makeSpace / acquires
- * between resets).
* @param bufferSize The minimum size of created VBs This value
* will be clamped to some reasonable minimum.
* @param preallocBufferCnt The pool will allocate this number of VBs at
* bufferSize and keep them until it is
* destroyed.
*/
- GrVertexBufferAllocPool(GrGpu* gpu,
- bool frequentResetHint,
- size_t bufferSize = 0,
- int preallocBufferCnt = 0);
+ GrVertexBufferAllocPool(GrGpu* gpu, size_t bufferSize = 0, int preallocBufferCnt = 0);
/**
* Returns a block of memory to hold vertices. A buffer designated to hold
@@ -268,10 +253,6 @@
* Constructor
*
* @param gpu The GrGpu used to create the index buffers.
- * @param frequentResetHint A hint that indicates that the pool
- * should expect frequent unmap() calls
- * (as opposed to many makeSpace / acquires
- * between resets).
* @param bufferSize The minimum size of created IBs This value
* will be clamped to some reasonable minimum.
* @param preallocBufferCnt The pool will allocate this number of VBs at
@@ -279,7 +260,6 @@
* destroyed.
*/
GrIndexBufferAllocPool(GrGpu* gpu,
- bool frequentResetHint,
size_t bufferSize = 0,
int preallocBufferCnt = 0);
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f9af6eb..c396f1d 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1905,13 +1905,13 @@
SkASSERT(NULL == fDrawBufferIBAllocPool);
fDrawBufferVBAllocPool =
- SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu, false,
- DRAW_BUFFER_VBPOOL_BUFFER_SIZE,
- DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS));
+ SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu,
+ DRAW_BUFFER_VBPOOL_BUFFER_SIZE,
+ DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS));
fDrawBufferIBAllocPool =
- SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu, false,
- DRAW_BUFFER_IBPOOL_BUFFER_SIZE,
- DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS));
+ SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu,
+ DRAW_BUFFER_IBPOOL_BUFFER_SIZE,
+ DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS));
fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (this,
fDrawBufferVBAllocPool,