Index: src/gpu/GrBufferAllocPool.h |
diff --git a/src/gpu/GrBufferAllocPool.h b/src/gpu/GrBufferAllocPool.h |
index 8641bbbe87a54e723a3346a9b0ee112c8da28f05..df0a0ccd9c870facc61056278abf82fa78af8642 100644 |
--- a/src/gpu/GrBufferAllocPool.h |
+++ b/src/gpu/GrBufferAllocPool.h |
@@ -64,12 +64,16 @@ |
* @param bufferSize The minimum size of created buffers. |
* This value will be clamped to some |
* reasonable minimum. |
+ * @param preallocBufferCnt The pool will allocate this number of |
+ * buffers at bufferSize and keep them until it |
+ * is destroyed. |
*/ |
GrBufferAllocPool(GrGpu* gpu, |
BufferType bufferType, |
- size_t bufferSize = 0); |
- |
- virtual ~GrBufferAllocPool(); |
+ size_t bufferSize = 0, |
+ int preallocBufferCnt = 0); |
+ |
+ virtual ~GrBufferAllocPool(); |
/** |
* Returns a block of memory to hold data. A buffer designated to hold the |
@@ -95,7 +99,7 @@ |
const GrGeometryBuffer** buffer, |
size_t* offset); |
- GrGeometryBuffer* getBuffer(size_t size); |
+ GrGeometryBuffer* createBuffer(size_t size); |
private: |
struct BufferBlock { |
@@ -105,7 +109,6 @@ |
bool createBlock(size_t requestSize); |
void destroyBlock(); |
- void deleteBlocks(); |
void flushCpuData(const BufferBlock& block, size_t flushSize); |
#ifdef SK_DEBUG |
void validate(bool unusedBlockAllowed = false) const; |
@@ -114,10 +117,15 @@ |
size_t fBytesInUse; |
GrGpu* fGpu; |
+ SkTDArray<GrGeometryBuffer*> fPreallocBuffers; |
size_t fMinBlockSize; |
BufferType fBufferType; |
SkTArray<BufferBlock> fBlocks; |
+ int fPreallocBuffersInUse; |
+ // We attempt to cycle through the preallocated buffers rather than |
+ // always starting from the first. |
+ int fPreallocBufferStartIdx; |
SkAutoMalloc fCpuData; |
void* fBufferPtr; |
}; |
@@ -133,8 +141,13 @@ |
* Constructor |
* |
* @param gpu The GrGpu used to create the vertex buffers. |
- */ |
- GrVertexBufferAllocPool(GrGpu* gpu); |
+ * @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, size_t bufferSize = 0, int preallocBufferCnt = 0); |
/** |
* Returns a block of memory to hold vertices. A buffer designated to hold |
@@ -177,8 +190,15 @@ |
* Constructor |
* |
* @param gpu The GrGpu used to create the index buffers. |
- */ |
- GrIndexBufferAllocPool(GrGpu* gpu); |
+ * @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 |
+ * bufferSize and keep them until it is |
+ * destroyed. |
+ */ |
+ GrIndexBufferAllocPool(GrGpu* gpu, |
+ size_t bufferSize = 0, |
+ int preallocBufferCnt = 0); |
/** |
* Returns a block of memory to hold indices. A buffer designated to hold |