Remove unneeded features from GrBufferAllocPool

Review URL: https://codereview.chromium.org/1103423004
This commit is contained in:
bsalomon 2015-04-29 04:33:52 -07:00 committed by Commit bot
parent 280a9c81aa
commit ecb8e3e394
3 changed files with 12 additions and 54 deletions

View File

@ -37,18 +37,13 @@ do {
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 @@ GrBufferAllocPool::~GrBufferAllocPool() {
destroyBlock();
}
fPreallocBuffers.unrefAll();
releaseGpuRef();
}
void GrBufferAllocPool::releaseGpuRef() {
if (fGpuIsReffed) {
fGpu->unref();
fGpuIsReffed = false;
}
fGpu->unref();
}
void GrBufferAllocPool::reset() {
@ -317,17 +305,11 @@ bool GrBufferAllocPool::createBlock(size_t requestSize) {
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 @@ GrGeometryBuffer* GrBufferAllocPool::createBuffer(size_t size) {
////////////////////////////////////////////////////////////////////////////////
GrVertexBufferAllocPool::GrVertexBufferAllocPool(GrGpu* gpu,
bool frequentResetHint,
size_t bufferSize,
int preallocBufferCnt)
: GrBufferAllocPool(gpu,
kVertex_BufferType,
frequentResetHint,
bufferSize,
preallocBufferCnt) {
}
@ -438,12 +418,10 @@ int GrVertexBufferAllocPool::currentBufferVertices(size_t vertexSize) const {
////////////////////////////////////////////////////////////////////////////////
GrIndexBufferAllocPool::GrIndexBufferAllocPool(GrGpu* gpu,
bool frequentResetHint,
size_t bufferSize,
int preallocBufferCnt)
: GrBufferAllocPool(gpu,
kIndex_BufferType,
frequentResetHint,
bufferSize,
preallocBufferCnt) {
}

View File

@ -76,10 +76,6 @@ protected:
*
* @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 @@ protected:
*/
GrBufferAllocPool(GrGpu* gpu,
BufferType bufferType,
bool frequentResetHint,
size_t bufferSize = 0,
int preallocBufferCnt = 0);
@ -146,7 +141,6 @@ private:
// 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 @@ private:
size_t fBytesInUse;
GrGpu* fGpu;
bool fGpuIsReffed;
bool fFrequentResetHint;
SkTDArray<GrGeometryBuffer*> fPreallocBuffers;
size_t fMinBlockSize;
BufferType fBufferType;
@ -189,20 +181,13 @@ public:
* 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 @@ public:
* 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 @@ public:
* destroyed.
*/
GrIndexBufferAllocPool(GrGpu* gpu,
bool frequentResetHint,
size_t bufferSize = 0,
int preallocBufferCnt = 0);

View File

@ -1905,13 +1905,13 @@ void GrContext::setupDrawBuffer() {
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,