OLD | NEW |
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" |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 GR_GL_RENDERBUFFER_DEPTH_SIZE, | 1114 GR_GL_RENDERBUFFER_DEPTH_SIZE, |
1115 (GrGLint*)&format->fTotalBits); | 1115 (GrGLint*)&format->fTotalBits); |
1116 format->fTotalBits += format->fStencilBits; | 1116 format->fTotalBits += format->fStencilBits; |
1117 } else { | 1117 } else { |
1118 format->fTotalBits = format->fStencilBits; | 1118 format->fTotalBits = format->fStencilBits; |
1119 } | 1119 } |
1120 } | 1120 } |
1121 } | 1121 } |
1122 } | 1122 } |
1123 | 1123 |
1124 bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width,
int height) { | 1124 bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt, |
| 1125 int width, int height) { |
1125 | 1126 |
1126 // All internally created RTs are also textures. We don't create | 1127 // All internally created RTs are also textures. We don't create |
1127 // 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)
. |
1128 SkASSERT(rt->asTexture()); | 1129 SkASSERT(rt->asTexture()); |
1129 SkASSERT(width >= rt->width()); | 1130 SkASSERT(width >= rt->width()); |
1130 SkASSERT(height >= rt->height()); | 1131 SkASSERT(height >= rt->height()); |
1131 | 1132 |
1132 int samples = rt->numSamples(); | 1133 int samples = rt->numSamples(); |
1133 GrGLuint sbID = 0; | 1134 GrGLuint sbID = 0; |
1134 | 1135 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 get_stencil_rb_sizes(this->glInterface(), &format); | 1169 get_stencil_rb_sizes(this->glInterface(), &format); |
1169 static const bool kIsWrapped = false; | 1170 static const bool kIsWrapped = false; |
1170 SkAutoTUnref<GrStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer, | 1171 SkAutoTUnref<GrStencilBuffer> sb(SkNEW_ARGS(GrGLStencilBuffer, |
1171 (this, kIsWrapped, sbID, width
, height, | 1172 (this, kIsWrapped, sbID, width
, height, |
1172 samples, format))); | 1173 samples, format))); |
1173 // If we fail we have to create a new render buffer ID since we gave
this one to the | 1174 // If we fail we have to create a new render buffer ID since we gave
this one to the |
1174 // GrGLStencilBuffer object. | 1175 // GrGLStencilBuffer object. |
1175 sbID = 0; | 1176 sbID = 0; |
1176 if (this->attachStencilBufferToRenderTarget(sb, rt)) { | 1177 if (this->attachStencilBufferToRenderTarget(sb, rt)) { |
1177 fLastSuccessfulStencilFmtIdx = sIdx; | 1178 fLastSuccessfulStencilFmtIdx = sIdx; |
| 1179 sb->transferToCache(); |
1178 rt->setStencilBuffer(sb); | 1180 rt->setStencilBuffer(sb); |
1179 return true; | 1181 return true; |
1180 } | 1182 } |
1181 } | 1183 } |
1182 } | 1184 } |
1183 GL_CALL(DeleteRenderbuffers(1, &sbID)); | 1185 GL_CALL(DeleteRenderbuffers(1, &sbID)); |
1184 return false; | 1186 return false; |
1185 } | 1187 } |
1186 | 1188 |
1187 bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar
get* rt) { | 1189 bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar
get* rt) { |
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2553 this->setVertexArrayID(gpu, 0); | 2555 this->setVertexArrayID(gpu, 0); |
2554 } | 2556 } |
2555 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2557 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2556 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2558 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2557 fDefaultVertexArrayAttribState.resize(attrCount); | 2559 fDefaultVertexArrayAttribState.resize(attrCount); |
2558 } | 2560 } |
2559 attribState = &fDefaultVertexArrayAttribState; | 2561 attribState = &fDefaultVertexArrayAttribState; |
2560 } | 2562 } |
2561 return attribState; | 2563 return attribState; |
2562 } | 2564 } |
OLD | NEW |