| Index: src/gpu/gl/GrGLRenderTarget.cpp
|
| diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
|
| index cb9d310010b596fb7a90cf2d58b3064cca9cccbe..12e7d06d1d865629e4d01eccff5d93a32fd857fa 100644
|
| --- a/src/gpu/gl/GrGLRenderTarget.cpp
|
| +++ b/src/gpu/gl/GrGLRenderTarget.cpp
|
| @@ -7,7 +7,9 @@
|
|
|
| #include "GrGLRenderTarget.h"
|
|
|
| +#include "GrRenderTargetPriv.h"
|
| #include "GrGLGpu.h"
|
| +#include "GrGLUtil.h"
|
|
|
| #define GPUGL static_cast<GrGLGpu*>(this->getGpu())
|
| #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
|
| @@ -60,6 +62,54 @@ size_t GrGLRenderTarget::onGpuMemorySize() const {
|
| return fGpuMemorySize;
|
| }
|
|
|
| +bool GrGLRenderTarget::completeStencilAttachment() {
|
| + GrGLGpu* gpu = this->getGLGpu();
|
| + 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));
|
| +#ifdef SK_DEBUG
|
| + 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);
|
| + GrGLuint rb = glStencil->renderbufferID();
|
| +
|
| + gpu->invalidateBoundRenderTarget();
|
| + gpu->stats()->incRenderTargetBinds();
|
| + GR_GL_CALL(interface, BindFramebuffer(GR_GL_FRAMEBUFFER, this->renderFBOID()));
|
| + GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
|
| + GR_GL_STENCIL_ATTACHMENT,
|
| + GR_GL_RENDERBUFFER, rb));
|
| + if (glStencil->format().fPacked) {
|
| + GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
|
| + GR_GL_DEPTH_ATTACHMENT,
|
| + GR_GL_RENDERBUFFER, rb));
|
| + } else {
|
| + 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);
|
| +#endif
|
| + return true;
|
| + }
|
| +}
|
| +
|
| void GrGLRenderTarget::onRelease() {
|
| if (kBorrowed_LifeCycle != fRTLifecycle) {
|
| if (fTexFBOID) {
|
| @@ -84,3 +134,9 @@ void GrGLRenderTarget::onAbandon() {
|
| fMSColorRenderbufferID = 0;
|
| INHERITED::onAbandon();
|
| }
|
| +
|
| +GrGLGpu* GrGLRenderTarget::getGLGpu() const {
|
| + SkASSERT(!this->wasDestroyed());
|
| + return static_cast<GrGLGpu*>(this->getGpu());
|
| +}
|
| +
|
|
|