aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrSurfaceProxy.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-08-10 08:44:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-10 12:47:25 +0000
commit65048139bd26c8edbc6796f220e79b6c848151d7 (patch)
tree3870d39758c3bd26843c754c3d491999632528d2 /src/gpu/GrSurfaceProxy.cpp
parent2ef3b0fe3a02513cf0fea519bb67027a6809b7a8 (diff)
Remove accessRenderTarget calls in service of binding stencil buffer
Change-Id: Ifca6e21c619a0433ecf0b8699d92661f8c3068a8 Reviewed-on: https://skia-review.googlesource.com/31243 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrSurfaceProxy.cpp')
-rw-r--r--src/gpu/GrSurfaceProxy.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index f8639406d6..6a55270b34 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -43,8 +43,26 @@ GrSurfaceProxy::~GrSurfaceProxy() {
SkASSERT(!fLastOpList);
}
+static bool attach_stencil_if_needed(GrResourceProvider* resourceProvider,
+ GrSurface* surface, bool needsStencil) {
+ if (needsStencil) {
+ GrRenderTarget* rt = surface->asRenderTarget();
+ if (!rt) {
+ SkASSERT(0);
+ return false;
+ }
+
+ if (!resourceProvider->attachStencilAttachment(rt)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(
- GrResourceProvider* resourceProvider, int sampleCnt,
+ GrResourceProvider* resourceProvider,
+ int sampleCnt, bool needsStencil,
GrSurfaceFlags flags, bool isMipMapped,
SkDestinationSurfaceColorMode mipColorMode) const {
GrSurfaceDesc desc;
@@ -65,8 +83,14 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(
} else {
surface.reset(resourceProvider->createTexture(desc, fBudgeted, fFlags).release());
}
- if (surface) {
- surface->asTexture()->texturePriv().setMipColorMode(mipColorMode);
+ if (!surface) {
+ return nullptr;
+ }
+
+ surface->asTexture()->texturePriv().setMipColorMode(mipColorMode);
+
+ if (!attach_stencil_if_needed(resourceProvider, surface.get(), needsStencil)) {
+ return nullptr;
}
return surface;
@@ -85,14 +109,14 @@ void GrSurfaceProxy::assign(sk_sp<GrSurface> surface) {
}
bool GrSurfaceProxy::instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt,
- GrSurfaceFlags flags, bool isMipMapped,
+ bool needsStencil, GrSurfaceFlags flags, bool isMipMapped,
SkDestinationSurfaceColorMode mipColorMode) {
if (fTarget) {
- return true;
+ return attach_stencil_if_needed(resourceProvider, fTarget, needsStencil);
}
- sk_sp<GrSurface> surface = this->createSurfaceImpl(resourceProvider, sampleCnt, flags,
- isMipMapped, mipColorMode);
+ sk_sp<GrSurface> surface = this->createSurfaceImpl(resourceProvider, sampleCnt, needsStencil,
+ flags, isMipMapped, mipColorMode);
if (!surface) {
return false;
}