aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-11-14 13:33:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-14 13:33:09 -0800
commit12299ab7a1be5f4b99284ecf289d46107ef0a946 (patch)
tree975b65e8d15cb7c7a6ffc3f1b2b820b4b0da978d /src/gpu/gl
parent85588344c3ef43768e27881f71079edb372119b5 (diff)
Make GrResourceCache2 responsible for calling release, abandon, and ~.
BUG=skia:2889 TBR=robertphillips@google.com NOTRY=true Review URL: https://codereview.chromium.org/729683002
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLIndexBuffer.h1
-rw-r--r--src/gpu/gl/GrGLPath.cpp4
-rw-r--r--src/gpu/gl/GrGLPath.h1
-rw-r--r--src/gpu/gl/GrGLPathRange.cpp4
-rw-r--r--src/gpu/gl/GrGLPathRange.h2
-rw-r--r--src/gpu/gl/GrGLRenderTarget.h2
-rw-r--r--src/gpu/gl/GrGLStencilBuffer.cpp4
-rw-r--r--src/gpu/gl/GrGLStencilBuffer.h2
-rw-r--r--src/gpu/gl/GrGLTexture.h2
-rw-r--r--src/gpu/gl/GrGLTextureRenderTarget.h2
-rw-r--r--src/gpu/gl/GrGLVertexBuffer.h1
-rw-r--r--src/gpu/gl/GrGpuGL.cpp31
12 files changed, 16 insertions, 40 deletions
diff --git a/src/gpu/gl/GrGLIndexBuffer.h b/src/gpu/gl/GrGLIndexBuffer.h
index 5d5de43eee..a62bba1d51 100644
--- a/src/gpu/gl/GrGLIndexBuffer.h
+++ b/src/gpu/gl/GrGLIndexBuffer.h
@@ -20,7 +20,6 @@ public:
typedef GrGLBufferImpl::Desc Desc;
GrGLIndexBuffer(GrGpuGL* gpu, const Desc& desc);
- virtual ~GrGLIndexBuffer() { this->release(); }
GrGLuint bufferID() const { return fImpl.bufferID(); }
size_t baseOffset() const { return fImpl.baseOffset(); }
diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp
index 6097f469db..fc5688114d 100644
--- a/src/gpu/gl/GrGLPath.cpp
+++ b/src/gpu/gl/GrGLPath.cpp
@@ -143,10 +143,6 @@ GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke)
this->registerWithCache();
}
-GrGLPath::~GrGLPath() {
- this->release();
-}
-
void GrGLPath::onRelease() {
if (0 != fPathID && !this->isWrapped()) {
static_cast<GrGpuGL*>(this->getGpu())->glPathRendering()->deletePaths(fPathID, 1);
diff --git a/src/gpu/gl/GrGLPath.h b/src/gpu/gl/GrGLPath.h
index b8bd8ad1a4..a7640d526a 100644
--- a/src/gpu/gl/GrGLPath.h
+++ b/src/gpu/gl/GrGLPath.h
@@ -28,7 +28,6 @@ public:
const SkStrokeRec&);
GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke);
- virtual ~GrGLPath();
GrGLuint pathID() const { return fPathID; }
protected:
diff --git a/src/gpu/gl/GrGLPathRange.cpp b/src/gpu/gl/GrGLPathRange.cpp
index 12c96c6a3f..5ff64f85af 100644
--- a/src/gpu/gl/GrGLPathRange.cpp
+++ b/src/gpu/gl/GrGLPathRange.cpp
@@ -29,10 +29,6 @@ GrGLPathRange::GrGLPathRange(GrGpuGL* gpu,
this->registerWithCache();
}
-GrGLPathRange::~GrGLPathRange() {
- this->release();
-}
-
void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const {
GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu());
if (NULL == gpu) {
diff --git a/src/gpu/gl/GrGLPathRange.h b/src/gpu/gl/GrGLPathRange.h
index 440ffbc0c9..8fde666e7e 100644
--- a/src/gpu/gl/GrGLPathRange.h
+++ b/src/gpu/gl/GrGLPathRange.h
@@ -39,8 +39,6 @@ public:
size_t gpuMemorySize,
const SkStrokeRec&);
- virtual ~GrGLPathRange();
-
GrGLuint basePathID() const { return fBasePathID; }
protected:
diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h
index b81bbed4b2..fd149b1185 100644
--- a/src/gpu/gl/GrGLRenderTarget.h
+++ b/src/gpu/gl/GrGLRenderTarget.h
@@ -30,8 +30,6 @@ public:
GrGLRenderTarget(GrGpuGL*, const GrSurfaceDesc&, const IDDesc&);
- virtual ~GrGLRenderTarget() { this->release(); }
-
void setViewport(const GrGLIRect& rect) { fViewport = rect; }
const GrGLIRect& getViewport() const { return fViewport; }
diff --git a/src/gpu/gl/GrGLStencilBuffer.cpp b/src/gpu/gl/GrGLStencilBuffer.cpp
index fd14ea01f2..2ec06d438c 100644
--- a/src/gpu/gl/GrGLStencilBuffer.cpp
+++ b/src/gpu/gl/GrGLStencilBuffer.cpp
@@ -9,10 +9,6 @@
#include "GrGLStencilBuffer.h"
#include "GrGpuGL.h"
-GrGLStencilBuffer::~GrGLStencilBuffer() {
- this->release();
-}
-
size_t GrGLStencilBuffer::onGpuMemorySize() const {
uint64_t size = this->width();
size *= this->height();
diff --git a/src/gpu/gl/GrGLStencilBuffer.h b/src/gpu/gl/GrGLStencilBuffer.h
index 53777e40c7..ff0d5cb4d0 100644
--- a/src/gpu/gl/GrGLStencilBuffer.h
+++ b/src/gpu/gl/GrGLStencilBuffer.h
@@ -35,8 +35,6 @@ public:
this->registerWithCache();
}
- virtual ~GrGLStencilBuffer();
-
GrGLuint renderbufferID() const {
return fRenderbufferID;
}
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index f23adae0d2..268fe9239e 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -33,8 +33,6 @@ public:
GrGLTexture(GrGpuGL*, const GrSurfaceDesc&, const IDDesc&);
- virtual ~GrGLTexture() { this->release(); }
-
virtual GrBackendObject getTextureHandle() const SK_OVERRIDE;
virtual void textureParamsModified() SK_OVERRIDE { fTexParams.invalidate(); }
diff --git a/src/gpu/gl/GrGLTextureRenderTarget.h b/src/gpu/gl/GrGLTextureRenderTarget.h
index 06080a8a36..11577b8dcf 100644
--- a/src/gpu/gl/GrGLTextureRenderTarget.h
+++ b/src/gpu/gl/GrGLTextureRenderTarget.h
@@ -34,8 +34,6 @@ public:
this->registerWithCache();
}
- virtual ~GrGLTextureRenderTarget() { this->release(); }
-
protected:
virtual void onAbandon() SK_OVERRIDE {
GrGLRenderTarget::onAbandon();
diff --git a/src/gpu/gl/GrGLVertexBuffer.h b/src/gpu/gl/GrGLVertexBuffer.h
index db413ac990..40f4af9091 100644
--- a/src/gpu/gl/GrGLVertexBuffer.h
+++ b/src/gpu/gl/GrGLVertexBuffer.h
@@ -20,7 +20,6 @@ public:
typedef GrGLBufferImpl::Desc Desc;
GrGLVertexBuffer(GrGpuGL* gpu, const Desc& desc);
- virtual ~GrGLVertexBuffer() { this->release(); }
GrGLuint bufferID() const { return fImpl.bufferID(); }
size_t baseOffset() const { return fImpl.baseOffset(); }
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 877c21fc7e..89f26efe22 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1131,21 +1131,22 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
SkASSERT(height >= rt->height());
int samples = rt->numSamples();
- GrGLuint sbID;
- GL_CALL(GenRenderbuffers(1, &sbID));
- if (!sbID) {
- return false;
- }
+ GrGLuint sbID = 0;
int stencilFmtCnt = this->glCaps().stencilFormats().count();
for (int i = 0; i < stencilFmtCnt; ++i) {
+ if (!sbID) {
+ GL_CALL(GenRenderbuffers(1, &sbID));
+ }
+ if (!sbID) {
+ return false;
+ }
GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbID));
// we start with the last stencil format that succeeded in hopes
// that we won't go through this loop more than once after the
// first (painful) stencil creation.
int sIdx = (i + fLastSuccessfulStencilFmtIdx) % stencilFmtCnt;
- const GrGLCaps::StencilFormat& sFmt =
- this->glCaps().stencilFormats()[sIdx];
+ const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats()[sIdx];
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
// we do this "if" so that we don't call the multisample
// version on a GL that doesn't have an MSAA extension.
@@ -1156,12 +1157,10 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
sFmt.fInternalFormat,
width, height);
} else {
- GL_ALLOC_CALL(this->glInterface(),
- RenderbufferStorage(GR_GL_RENDERBUFFER,
- sFmt.fInternalFormat,
- width, height));
- created =
- (GR_GL_NO_ERROR == check_alloc_error(rt->desc(), this->glInterface()));
+ GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERBUFFER,
+ sFmt.fInternalFormat,
+ width, height));
+ created = (GR_GL_NO_ERROR == check_alloc_error(rt->desc(), this->glInterface()));
}
if (created) {
// After sized formats we attempt an unsized format and take
@@ -1172,13 +1171,15 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
SkAutoTUnref<GrStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer,
(this, kIsWrapped, sbID, width, height,
samples, format)));
+ // If we fail we have to create a new render buffer ID since we gave this one to the
+ // GrGLStencilBuffer object.
+ sbID = 0;
if (this->attachStencilBufferToRenderTarget(sb, rt)) {
fLastSuccessfulStencilFmtIdx = sIdx;
sb->transferToCache();
rt->setStencilBuffer(sb);
return true;
- }
- sb->abandon(); // otherwise we lose sbID
+ }
}
}
GL_CALL(DeleteRenderbuffers(1, &sbID));