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

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 747043004: Use scratch keys for stencil buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 6 years 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrStencilBuffer.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
11 #include "GrGLTextureRenderTarget.h" 11 #include "GrGLTextureRenderTarget.h"
12 #include "GrGpuResourceCacheAccess.h"
12 #include "GrOptDrawState.h" 13 #include "GrOptDrawState.h"
13 #include "GrSurfacePriv.h" 14 #include "GrSurfacePriv.h"
14 #include "GrTemplates.h" 15 #include "GrTemplates.h"
15 #include "GrTexturePriv.h" 16 #include "GrTexturePriv.h"
16 #include "GrTypes.h" 17 #include "GrTypes.h"
17 #include "SkStrokeRec.h" 18 #include "SkStrokeRec.h"
18 #include "SkTemplates.h" 19 #include "SkTemplates.h"
19 20
20 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) 21 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
21 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) 22 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X)
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 GR_GL_RENDERBUFFER_DEPTH_SIZE, 1115 GR_GL_RENDERBUFFER_DEPTH_SIZE,
1115 (GrGLint*)&format->fTotalBits); 1116 (GrGLint*)&format->fTotalBits);
1116 format->fTotalBits += format->fStencilBits; 1117 format->fTotalBits += format->fStencilBits;
1117 } else { 1118 } else {
1118 format->fTotalBits = format->fStencilBits; 1119 format->fTotalBits = format->fStencilBits;
1119 } 1120 }
1120 } 1121 }
1121 } 1122 }
1122 } 1123 }
1123 1124
1124 bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt, 1125 bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) {
1125 int width, int height) {
1126 1126
1127 // All internally created RTs are also textures. We don't create 1127 // All internally created RTs are also textures. We don't create
1128 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . 1128 // SBs for a client's standalone RT (that is a RT that isn't also a texture) .
1129 SkASSERT(rt->asTexture()); 1129 SkASSERT(rt->asTexture());
1130 SkASSERT(width >= rt->width()); 1130 SkASSERT(width >= rt->width());
1131 SkASSERT(height >= rt->height()); 1131 SkASSERT(height >= rt->height());
1132 1132
1133 int samples = rt->numSamples(); 1133 int samples = rt->numSamples();
1134 GrGLuint sbID = 0; 1134 GrGLuint sbID = 0;
1135 1135
(...skipping 28 matching lines...) Expand all
1164 } 1164 }
1165 if (created) { 1165 if (created) {
1166 // After sized formats we attempt an unsized format and take 1166 // After sized formats we attempt an unsized format and take
1167 // whatever sizes GL gives us. In that case we query for the size. 1167 // whatever sizes GL gives us. In that case we query for the size.
1168 GrGLStencilBuffer::Format format = sFmt; 1168 GrGLStencilBuffer::Format format = sFmt;
1169 get_stencil_rb_sizes(this->glInterface(), &format); 1169 get_stencil_rb_sizes(this->glInterface(), &format);
1170 static const bool kIsWrapped = false; 1170 static const bool kIsWrapped = false;
1171 SkAutoTUnref<GrStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer, 1171 SkAutoTUnref<GrStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer,
1172 (this, kIsWrapped, sbID, width , height, 1172 (this, kIsWrapped, sbID, width , height,
1173 samples, format))); 1173 samples, format)));
1174 // If we fail we have to create a new render buffer ID since we gave this one to the
1175 // GrGLStencilBuffer object.
1176 sbID = 0;
1177 if (this->attachStencilBufferToRenderTarget(sb, rt)) { 1174 if (this->attachStencilBufferToRenderTarget(sb, rt)) {
1178 fLastSuccessfulStencilFmtIdx = sIdx; 1175 fLastSuccessfulStencilFmtIdx = sIdx;
1179 sb->transferToCache();
1180 rt->setStencilBuffer(sb); 1176 rt->setStencilBuffer(sb);
1181 return true; 1177 return true;
1182 } 1178 }
1179 // Remove the scratch key from this resource so we don't grab it fro m the cache ever
1180 // again.
1181 sb->cacheAccess().removeScratchKey();
1182 // Set this to 0 since we handed the valid ID off to the failed sten cil buffer resource.
1183 sbID = 0;
1183 } 1184 }
1184 } 1185 }
1185 GL_CALL(DeleteRenderbuffers(1, &sbID)); 1186 GL_CALL(DeleteRenderbuffers(1, &sbID));
1186 return false; 1187 return false;
1187 } 1188 }
1188 1189
1189 bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar get* rt) { 1190 bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar get* rt) {
1190 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt); 1191 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt);
1191 1192
1192 GrGLuint fbo = glrt->renderFBOID(); 1193 GrGLuint fbo = glrt->renderFBOID();
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 this->setVertexArrayID(gpu, 0); 2556 this->setVertexArrayID(gpu, 0);
2556 } 2557 }
2557 int attrCount = gpu->glCaps().maxVertexAttributes(); 2558 int attrCount = gpu->glCaps().maxVertexAttributes();
2558 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2559 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2559 fDefaultVertexArrayAttribState.resize(attrCount); 2560 fDefaultVertexArrayAttribState.resize(attrCount);
2560 } 2561 }
2561 attribState = &fDefaultVertexArrayAttribState; 2562 attribState = &fDefaultVertexArrayAttribState;
2562 } 2563 }
2563 return attribState; 2564 return attribState;
2564 } 2565 }
OLDNEW
« no previous file with comments | « src/gpu/GrStencilBuffer.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698