aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-05 19:44:18 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-05 19:44:18 +0000
commitf2e93fc989129f11881919de99a3b8f12081beae (patch)
tree4b988327cefe02d72339cc39b251615c366e6f11 /src/gpu
parentd966ab9906027215698e8d6a488ef1cfb2346a9e (diff)
Resource cache now explicitly takes ref of managed resources
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrContext.cpp10
-rw-r--r--src/gpu/GrResourceCache.cpp1
-rw-r--r--src/gpu/GrStencilBuffer.h4
-rw-r--r--src/gpu/gl/GrGpuGL.cpp9
4 files changed, 11 insertions, 13 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index a2158e2e4f..edf45b8f51 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -381,13 +381,13 @@ GrTexture* GrContext::createAndLockTexture(
GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheData, false);
- GrTexture* texture = NULL;
+ SkAutoTUnref<GrTexture> texture;
if (GrTexture::NeedsResizing(resourceKey)) {
- texture = this->createResizedTexture(desc, cacheData,
+ texture.reset(this->createResizedTexture(desc, cacheData,
srcData, rowBytes,
- GrTexture::NeedsFiltering(resourceKey));
+ GrTexture::NeedsFiltering(resourceKey)));
} else {
- texture = fGpu->createTexture(desc, srcData, rowBytes);
+ texture.reset(fGpu->createTexture(desc, srcData, rowBytes));
}
if (NULL != texture) {
@@ -450,7 +450,7 @@ GrTexture* GrContext::lockScratchTexture(const GrTextureDesc& inDesc,
desc.fFlags = inDesc.fFlags;
desc.fWidth = origWidth;
desc.fHeight = origHeight;
- GrTexture* texture = fGpu->createTexture(desc, NULL, 0);
+ SkAutoTUnref<GrTexture> texture(fGpu->createTexture(desc, NULL, 0));
if (NULL != texture) {
GrResourceKey key = GrTexture::ComputeKey(fGpu, NULL,
texture->desc(),
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 4561aeaaa8..4b262d4b4d 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -17,6 +17,7 @@ GrResourceEntry::GrResourceEntry(const GrResourceKey& key, GrResource* resource)
// we assume ownership of the resource, and will unref it when we die
GrAssert(resource);
+ resource->ref();
}
GrResourceEntry::~GrResourceEntry() {
diff --git a/src/gpu/GrStencilBuffer.h b/src/gpu/GrStencilBuffer.h
index 27c0a0ca97..690fa329a8 100644
--- a/src/gpu/GrStencilBuffer.h
+++ b/src/gpu/GrStencilBuffer.h
@@ -59,8 +59,8 @@ public:
return fLastClipData;
}
- // places the sb in the cache and locks it. Caller transfers
- // a ref to the the cache which will unref when purged.
+ // Places the sb in the cache and locks it. The cache takes a ref
+ // of the stencil buffer.
void transferToCacheAndLock();
static GrResourceKey ComputeKey(int width, int height, int sampleCnt);
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 8d55abb017..74f9953657 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1105,19 +1105,16 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
// whatever sizes GL gives us. In that case we query for the size.
GrGLStencilBuffer::Format format = sFmt;
get_stencil_rb_sizes(this->glInterface(), sbID, &format);
- sb = SkNEW_ARGS(GrGLStencilBuffer,
- (this, sbID, width, height,
- samples, format));
+ SkAutoTUnref<GrStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer,
+ (this, sbID, width, height,
+ samples, format)));
if (this->attachStencilBufferToRenderTarget(sb, rt)) {
fLastSuccessfulStencilFmtIdx = sIdx;
- // This code transfers the creation ref to the
- // cache and then adds a ref for the render target
sb->transferToCacheAndLock();
rt->setStencilBuffer(sb);
return true;
}
sb->abandon(); // otherwise we lose sbID
- sb->unref();
}
}
GL_CALL(DeleteRenderbuffers(1, &sbID));