| Index: src/gpu/gl/GrGLRenderTarget.cpp
|
| diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
|
| index 3eb2ae09fea489802fe38faa77523be8c6c17fc9..98101db774faad7281780ad7bb65d153a09ac315 100644
|
| --- a/src/gpu/gl/GrGLRenderTarget.cpp
|
| +++ b/src/gpu/gl/GrGLRenderTarget.cpp
|
| @@ -9,8 +9,30 @@
|
|
|
| #include "GrGLGpu.h"
|
|
|
| -#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
|
| -#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
|
| +void GrGLFBO::deleteIfValid(GrGLGpu* gpu) {
|
| + if (this->isValid()) {
|
| + gpu->willDeleteOrAbandonFramebuffer(this);
|
| + if (true /*fOwned*/) {
|
| + GR_GL_CALL(gpu->glInterface(), DeleteFramebuffers(1, &fID));
|
| + }
|
| + fGenID = SK_InvalidGenID;
|
| + }
|
| +}
|
| +
|
| +void GrGLFBO::abandon(GrGLGpu* gpu) {
|
| + if (this->isValid()) {
|
| + if (gpu) {
|
| + gpu->willDeleteOrAbandonFramebuffer(this);
|
| + }
|
| + fGenID = SK_InvalidGenID;
|
| + }
|
| +}
|
| +
|
| +
|
| +//////////////////////////////////////////////////////////////////////////////
|
| +
|
| +#define GLGPU static_cast<GrGLGpu*>(this->getGpu())
|
| +#define GL_CALL(X) GR_GL_CALL(GLGPU->glInterface(), X)
|
|
|
| // Because this class is virtually derived from GrSurface we must explicitly call its constructor.
|
| GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc)
|
| @@ -28,8 +50,8 @@ GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, cons
|
| }
|
|
|
| void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
|
| - fRTFBOID = idDesc.fRTFBOID;
|
| - fTexFBOID = idDesc.fTexFBOID;
|
| + fRenderFBO.reset(SkRef(idDesc.fRenderFBO.get()));
|
| + fTextureFBO.reset(SkSafeRef(idDesc.fTextureFBO.get()));
|
| fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
|
| fIsWrapped = kWrapped_LifeCycle == idDesc.fLifeCycle;
|
|
|
| @@ -40,7 +62,7 @@ void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
|
|
|
| // We own one color value for each MSAA sample.
|
| fColorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt);
|
| - if (fTexFBOID != fRTFBOID) {
|
| + if (fTextureFBO && fTextureFBO != fRenderFBO) {
|
| // If we own the resolve buffer then that is one more sample per pixel.
|
| fColorValuesPerPixel += 1;
|
| }
|
| @@ -55,28 +77,32 @@ size_t GrGLRenderTarget::onGpuMemorySize() const {
|
| }
|
|
|
| void GrGLRenderTarget::onRelease() {
|
| + GrGLGpu* gpu = GLGPU;
|
| if (!fIsWrapped) {
|
| - if (fTexFBOID) {
|
| - GL_CALL(DeleteFramebuffers(1, &fTexFBOID));
|
| - }
|
| - if (fRTFBOID && fRTFBOID != fTexFBOID) {
|
| - GL_CALL(DeleteFramebuffers(1, &fRTFBOID));
|
| + fRenderFBO->deleteIfValid(gpu);
|
| + if (fTextureFBO) {
|
| + fTextureFBO->deleteIfValid(gpu);
|
| }
|
| if (fMSColorRenderbufferID) {
|
| GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
|
| + fMSColorRenderbufferID = 0;
|
| }
|
| + } else {
|
| + fRenderFBO->abandon(gpu);
|
| + if (fTextureFBO) {
|
| + fTextureFBO->abandon(gpu);
|
| + }
|
| + fMSColorRenderbufferID = 0;
|
| }
|
| - fRTFBOID = 0;
|
| - fTexFBOID = 0;
|
| - fMSColorRenderbufferID = 0;
|
| - fIsWrapped = false;
|
| INHERITED::onRelease();
|
| }
|
|
|
| void GrGLRenderTarget::onAbandon() {
|
| - fRTFBOID = 0;
|
| - fTexFBOID = 0;
|
| + GrGLGpu* gpu = GLGPU;
|
| + fRenderFBO->abandon(gpu);
|
| + if (fTextureFBO) {
|
| + fTextureFBO->abandon(gpu);
|
| + }
|
| fMSColorRenderbufferID = 0;
|
| - fIsWrapped = false;
|
| INHERITED::onAbandon();
|
| }
|
|
|