| 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 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 } | 2229 } |
| 2230 } | 2230 } |
| 2231 | 2231 |
| 2232 /////////////////////////////////////////////////////////////////////////////// | 2232 /////////////////////////////////////////////////////////////////////////////// |
| 2233 | 2233 |
| 2234 GrGLAttribArrayState* GrGpuGL::HWGeometryState::bindArrayAndBuffersToDraw( | 2234 GrGLAttribArrayState* GrGpuGL::HWGeometryState::bindArrayAndBuffersToDraw( |
| 2235 GrGpuGL* gpu, | 2235 GrGpuGL* gpu, |
| 2236 const GrGLVertexBuffer* vbuffer, | 2236 const GrGLVertexBuffer* vbuffer, |
| 2237 const GrGLIndexBuffer* ibuffer)
{ | 2237 const GrGLIndexBuffer* ibuffer)
{ |
| 2238 GrAssert(NULL != vbuffer); | 2238 GrAssert(NULL != vbuffer); |
| 2239 GrGLAttribArrayState* attribState = &fDefaultVertexArrayAttribState; | 2239 GrGLAttribArrayState* attribState; |
| 2240 |
| 2240 // We use a vertex array if we're on a core profile and the verts are in a V
BO. | 2241 // We use a vertex array if we're on a core profile and the verts are in a V
BO. |
| 2241 if (gpu->glCaps().isCoreProfile() && !vbuffer->isCPUBacked()) { | 2242 if (gpu->glCaps().isCoreProfile() && !vbuffer->isCPUBacked()) { |
| 2242 if (NULL == fVBOVertexArray || !fVBOVertexArray->isValid()) { | 2243 if (NULL == fVBOVertexArray || !fVBOVertexArray->isValid()) { |
| 2243 SkSafeUnref(fVBOVertexArray); | 2244 SkSafeUnref(fVBOVertexArray); |
| 2244 GrGLuint arrayID; | 2245 GrGLuint arrayID; |
| 2245 GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID)); | 2246 GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID)); |
| 2246 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2247 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2247 fVBOVertexArray = SkNEW_ARGS(GrGLVertexArray, (gpu, arrayID, attrCou
nt)); | 2248 fVBOVertexArray = SkNEW_ARGS(GrGLVertexArray, (gpu, arrayID, attrCou
nt)); |
| 2248 } | 2249 } |
| 2249 attribState = fVBOVertexArray->bindWithIndexBuffer(ibuffer); | 2250 attribState = fVBOVertexArray->bindWithIndexBuffer(ibuffer); |
| 2250 } else { | 2251 } else { |
| 2251 if (NULL != ibuffer) { | 2252 if (NULL != ibuffer) { |
| 2252 this->setIndexBufferIDOnDefaultVertexArray(gpu, ibuffer->bufferID())
; | 2253 this->setIndexBufferIDOnDefaultVertexArray(gpu, ibuffer->bufferID())
; |
| 2253 } else { | 2254 } else { |
| 2254 this->setVertexArrayID(gpu, 0); | 2255 this->setVertexArrayID(gpu, 0); |
| 2255 } | 2256 } |
| 2256 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2257 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2257 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2258 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2258 fDefaultVertexArrayAttribState.resize(attrCount); | 2259 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2259 } | 2260 } |
| 2260 attribState = &fDefaultVertexArrayAttribState; | 2261 attribState = &fDefaultVertexArrayAttribState; |
| 2261 } | 2262 } |
| 2262 return attribState; | 2263 return attribState; |
| 2263 } | 2264 } |
| OLD | NEW |