| Index: src/gpu/GrGpu.cpp
|
| diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
|
| index e1b8ed5c8522b54a84df49bbe31fc4b7835fc9a3..51102f4a577e6661c74a0d69425c72f0fe4a479b 100644
|
| --- a/src/gpu/GrGpu.cpp
|
| +++ b/src/gpu/GrGpu.cpp
|
| @@ -134,8 +134,9 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, bool budgeted,
|
| return tex;
|
| }
|
|
|
| -bool GrGpu::attachStencilAttachmentToRenderTarget(GrRenderTarget* rt) {
|
| +bool GrGpu::getStencilAttachment(const GrRenderTarget* rt, GrStencilAttachment** stencil) {
|
| SkASSERT(nullptr == rt->renderTargetPriv().getStencilAttachment());
|
| + SkASSERT(nullptr == *stencil);
|
| GrUniqueKey sbKey;
|
|
|
| int width = rt->width();
|
| @@ -149,31 +150,17 @@ bool GrGpu::attachStencilAttachmentToRenderTarget(GrRenderTarget* rt) {
|
|
|
| GrStencilAttachment::ComputeSharedStencilAttachmentKey(width, height,
|
| rt->numStencilSamples(), &sbKey);
|
| - SkAutoTUnref<GrStencilAttachment> sb(static_cast<GrStencilAttachment*>(
|
| - this->getContext()->getResourceCache()->findAndRefUniqueResource(sbKey)));
|
| - if (sb) {
|
| - if (this->attachStencilAttachmentToRenderTarget(sb, rt)) {
|
| - rt->renderTargetPriv().didAttachStencilAttachment(sb);
|
| - return true;
|
| - }
|
| + *stencil = static_cast<GrStencilAttachment*>(
|
| + this->getContext()->getResourceCache()->findAndRefUniqueResource(sbKey));
|
| + if (*stencil) {
|
| return false;
|
| }
|
| - if (this->createStencilAttachmentForRenderTarget(rt, width, 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
|
| - // be correct because it won't be guaranteed to clear the entire
|
| - // sb.
|
| - // We used to clear down in the GL subclass using a special purpose
|
| - // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported
|
| - // FBO status.
|
| - this->clearStencil(rt);
|
| - GrStencilAttachment* sb = rt->renderTargetPriv().getStencilAttachment();
|
| - sb->resourcePriv().setUniqueKey(sbKey);
|
| + *stencil = this->createStencilAttachmentForRenderTarget(rt, width, height);
|
| + if (*stencil) {
|
| + (*stencil)->resourcePriv().setUniqueKey(sbKey);
|
| return true;
|
| - } else {
|
| - return false;
|
| }
|
| + return false;
|
| }
|
|
|
| GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwnership ownership) {
|
| @@ -184,7 +171,7 @@ GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwn
|
| }
|
| // TODO: defer this and attach dynamically
|
| GrRenderTarget* tgt = tex->asRenderTarget();
|
| - if (tgt && !this->attachStencilAttachmentToRenderTarget(tgt)) {
|
| + if (tgt && !tgt->renderTargetPriv().attachStencilAttachment()) {
|
| tex->unref();
|
| return nullptr;
|
| } else {
|
|
|