aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpu.cpp
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-09-14 12:56:10 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-14 12:56:10 -0700
commitec00d94199fad7723b5987b86c1abef8ddafe2d8 (patch)
tree4161bb293ffe433cbe0fd41a4ad0263b36eedffd /src/gpu/GrGpu.cpp
parent37497dc9de9cf8df4f9dd972b50cbd35b9da6682 (diff)
Move some of the adding stencil attachment logic of Gpu and into Render Target.
The new flow of calls for attaching a Stencil looks like: Client rt->attachStencilAttachment() gpu->getStencilAttachment() glgpu->createStencilAttachment() glrt->completeStencilAttachment() //actually attaches BUG=skia: Review URL: https://codereview.chromium.org/1333383002
Diffstat (limited to 'src/gpu/GrGpu.cpp')
-rw-r--r--src/gpu/GrGpu.cpp45
1 files changed, 2 insertions, 43 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index e1b8ed5c85..96728f3ba8 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -16,6 +16,7 @@
#include "GrPathRendering.h"
#include "GrPipeline.h"
#include "GrResourceCache.h"
+#include "GrResourceProvider.h"
#include "GrRenderTargetPriv.h"
#include "GrStencilAttachment.h"
#include "GrSurfacePriv.h"
@@ -134,48 +135,6 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, bool budgeted,
return tex;
}
-bool GrGpu::attachStencilAttachmentToRenderTarget(GrRenderTarget* rt) {
- SkASSERT(nullptr == rt->renderTargetPriv().getStencilAttachment());
- GrUniqueKey sbKey;
-
- int width = rt->width();
- int height = rt->height();
-#if 0
- if (this->caps()->oversizedStencilSupport()) {
- width = SkNextPow2(width);
- height = SkNextPow2(height);
- }
-#endif
-
- 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;
- }
- 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);
- return true;
- } else {
- return false;
- }
-}
-
GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwnership ownership) {
this->handleDirtyContext();
GrTexture* tex = this->onWrapBackendTexture(desc, ownership);
@@ -184,7 +143,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 && !fContext->resourceProvider()->attachStencilAttachment(tgt)) {
tex->unref();
return nullptr;
} else {