Index: src/gpu/GrGpu.cpp |
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp |
index eef965e5b61f4353f665d2652c506829b5c05ad9..27fed3c5820f2a40a539007f1790418e8825ae52 100644 |
--- a/src/gpu/GrGpu.cpp |
+++ b/src/gpu/GrGpu.cpp |
@@ -66,7 +66,7 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, |
!(kNoStencil_GrSurfaceFlag & desc.fFlags)) { |
SkASSERT(tex->asRenderTarget()); |
// TODO: defer this and attach dynamically |
- if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget(), budgeted)) { |
+ if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget())) { |
tex->unref(); |
return NULL; |
} |
@@ -84,12 +84,13 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, |
return tex; |
} |
-bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt, bool budgeted) { |
+bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { |
SkASSERT(NULL == rt->getStencilBuffer()); |
- GrScratchKey sbKey; |
- GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sbKey); |
+ GrUniqueKey sbKey; |
+ GrStencilBuffer::ComputeSharedStencilBufferKey(rt->width(), rt->height(), rt->numSamples(), |
+ &sbKey); |
SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( |
- this->getContext()->getResourceCache()->findAndRefScratchResource(sbKey))); |
+ this->getContext()->getResourceCache()->findAndRefUniqueResource(sbKey))); |
if (sb) { |
rt->setStencilBuffer(sb); |
bool attached = this->attachStencilBufferToRenderTarget(sb, rt); |
@@ -98,7 +99,7 @@ bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt, bool budgeted) |
} |
return attached; |
} |
- if (this->createStencilBufferForRenderTarget(rt, budgeted, rt->width(), rt->height())) { |
+ if (this->createStencilBufferForRenderTarget(rt, rt->width(), rt->height())) { |
// Right now we're clearing the stencil buffer here after it is |
// attached to an RT for the first time. When we start matching |
// stencil buffers with smaller color targets this will no longer |
@@ -108,6 +109,7 @@ bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt, bool budgeted) |
// FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported |
// FBO status. |
this->clearStencil(rt); |
+ rt->getStencilBuffer()->resourcePriv().setUniqueKey(sbKey); |
return true; |
} else { |
return false; |
@@ -122,8 +124,7 @@ GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc) { |
} |
// TODO: defer this and attach dynamically |
GrRenderTarget* tgt = tex->asRenderTarget(); |
- if (tgt && |
- !this->attachStencilBufferToRenderTarget(tgt, true /*budgeted*/)) { |
+ if (tgt && !this->attachStencilBufferToRenderTarget(tgt)) { |
tex->unref(); |
return NULL; |
} else { |