aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/src/GrBufferAllocPool.h
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-29 20:52:23 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-29 20:52:23 +0000
commit11f0b519766dabed4ce882f3ee7c07a68d3ccb52 (patch)
treea24df14209f74dac930584f0cc22d8e72ae06517 /gpu/src/GrBufferAllocPool.h
parentcf3edc9c972ce1696d1fe21dcddbabbca2999361 (diff)
Fix ref leak on GrGpu.
Review URL: http://codereview.appspot.com/4323043/ git-svn-id: http://skia.googlecode.com/svn/trunk@1015 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/GrBufferAllocPool.h')
-rw-r--r--gpu/src/GrBufferAllocPool.h72
1 files changed, 39 insertions, 33 deletions
diff --git a/gpu/src/GrBufferAllocPool.h b/gpu/src/GrBufferAllocPool.h
index 80f16ab122..7d70ebb83b 100644
--- a/gpu/src/GrBufferAllocPool.h
+++ b/gpu/src/GrBufferAllocPool.h
@@ -39,38 +39,6 @@ class GrGpu;
* be allocated at the min size and kept around until the pool is destroyed.
*/
class GrBufferAllocPool : GrNoncopyable {
-protected:
-
- // We could make the createBuffer a virtual except that we want to use it
- // in the cons for pre-allocated buffers.
- enum BufferType {
- kVertex_BufferType,
- kIndex_BufferType,
- };
-
- /**
- * Constructor
- *
- * @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 unlock() 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.
- * @param preallocBufferCnt The pool will allocate this number of
- * buffers at bufferSize and keep them until it
- * is destroyed.
- */
- GrBufferAllocPool(GrGpu* gpu,
- BufferType bufferType,
- bool frequentResetHint,
- size_t bufferSize = 0,
- int preallocBufferCnt = 0);
-
- virtual ~GrBufferAllocPool();
public:
/**
@@ -94,7 +62,6 @@ public:
*/
int preallocatedBufferCount() const;
-
/**
* Frees data from makeSpaces in LIFO order.
*/
@@ -107,6 +74,40 @@ public:
protected:
/**
+ * Used to determine what type of buffers to create. We could make the
+ * createBuffer a virtual except that we want to use it in the cons for
+ * pre-allocated buffers.
+ */
+ enum BufferType {
+ kVertex_BufferType,
+ kIndex_BufferType,
+ };
+
+ /**
+ * Constructor
+ *
+ * @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 unlock() 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.
+ * @param preallocBufferCnt The pool will allocate this number of
+ * buffers at bufferSize and keep them until it
+ * is destroyed.
+ */
+ GrBufferAllocPool(GrGpu* gpu,
+ BufferType bufferType,
+ bool frequentResetHint,
+ size_t bufferSize = 0,
+ int preallocBufferCnt = 0);
+
+ virtual ~GrBufferAllocPool();
+
+ /**
* Gets the size of the preallocated buffers.
*
* @return the size of preallocated buffers.
@@ -155,6 +156,10 @@ protected:
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;
GrGeometryBuffer* fBuffer;
@@ -168,6 +173,7 @@ private:
#endif
GrGpu* fGpu;
+ bool fGpuIsReffed;
bool fFrequentResetHint;
GrTDArray<GrGeometryBuffer*> fPreallocBuffers;
size_t fMinBlockSize;