Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: src/gpu/gl/GrGpuGL.cpp

Issue 729683002: Make GrResourceCache2 responsible for calling release, abandon, and ~. (Closed) Base URL: https://skia.googlesource.com/skia.git@revrev
Patch Set: tiny cleanup Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLVertexBuffer.h ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGpuGL.cpp
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 877c21fc7e29e7ff28ad3ef2c8493feec44b5a9b..89f26efe22b619d72c16dcedf94ea94b99e5766b 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));
« no previous file with comments | « src/gpu/gl/GrGLVertexBuffer.h ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698