Minor fix to attaching stencils
BUG=skia:
Review URL: https://codereview.chromium.org/1344033002
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index c16738e..4bb0143 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -69,6 +69,11 @@
///////////////////////////////////////////////////////////////////////////////
bool GrRenderTargetPriv::attachStencilAttachment(GrStencilAttachment* stencil) {
+ if (!stencil && !fRenderTarget->fStencilAttachment) {
+ // No need to do any work since we currently don't have a stencil attachment and
+ // we're not acctually adding one.
+ return true;
+ }
fRenderTarget->fStencilAttachment = stencil;
if (!fRenderTarget->completeStencilAttachment()) {
SkSafeSetNull(fRenderTarget->fStencilAttachment);
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index dfb4e88..e5210fa 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -89,19 +89,17 @@
const GrGLInterface* interface = gpu->glInterface();
GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment();
if (nullptr == stencil) {
- if (this->renderTargetPriv().getStencilAttachment()) {
- GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
- GR_GL_STENCIL_ATTACHMENT,
- GR_GL_RENDERBUFFER, 0));
- GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
- GR_GL_DEPTH_ATTACHMENT,
- GR_GL_RENDERBUFFER, 0));
+ GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
+ GR_GL_STENCIL_ATTACHMENT,
+ GR_GL_RENDERBUFFER, 0));
+ GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
+ GR_GL_DEPTH_ATTACHMENT,
+ GR_GL_RENDERBUFFER, 0));
#ifdef SK_DEBUG
- GrGLenum status;
- GR_GL_CALL_RET(interface, status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
- SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status);
+ GrGLenum status;
+ GR_GL_CALL_RET(interface, status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
+ SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status);
#endif
- }
return true;
} else {
const GrGLStencilAttachment* glStencil = static_cast<const GrGLStencilAttachment*>(stencil);