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 "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2827 | 2827 |
2828 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw( | 2828 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw( |
2829 GrGLGpu* gpu, | 2829 GrGLGpu* gpu, |
2830 const GrGLVertexBuffer* vbuffer, | 2830 const GrGLVertexBuffer* vbuffer, |
2831 const GrGLIndexBuffer* ibuffer)
{ | 2831 const GrGLIndexBuffer* ibuffer)
{ |
2832 SkASSERT(vbuffer); | 2832 SkASSERT(vbuffer); |
2833 GrGLAttribArrayState* attribState; | 2833 GrGLAttribArrayState* attribState; |
2834 | 2834 |
2835 // We use a vertex array if we're on a core profile and the verts are in a V
BO. | 2835 // We use a vertex array if we're on a core profile and the verts are in a V
BO. |
2836 if (gpu->glCaps().isCoreProfile() && !vbuffer->isCPUBacked()) { | 2836 if (gpu->glCaps().isCoreProfile() && !vbuffer->isCPUBacked()) { |
2837 if (NULL == fVBOVertexArray || fVBOVertexArray->wasDestroyed()) { | 2837 if (!fVBOVertexArray) { |
2838 SkSafeUnref(fVBOVertexArray); | |
2839 GrGLuint arrayID; | 2838 GrGLuint arrayID; |
2840 GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID)); | 2839 GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID)); |
2841 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2840 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2842 fVBOVertexArray = SkNEW_ARGS(GrGLVertexArray, (gpu, arrayID, attrCou
nt)); | 2841 fVBOVertexArray = SkNEW_ARGS(GrGLVertexArray, (arrayID, attrCount)); |
2843 } | 2842 } |
2844 attribState = fVBOVertexArray->bindWithIndexBuffer(ibuffer); | 2843 attribState = fVBOVertexArray->bindWithIndexBuffer(gpu, ibuffer); |
2845 } else { | 2844 } else { |
2846 if (ibuffer) { | 2845 if (ibuffer) { |
2847 this->setIndexBufferIDOnDefaultVertexArray(gpu, ibuffer->bufferID())
; | 2846 this->setIndexBufferIDOnDefaultVertexArray(gpu, ibuffer->bufferID())
; |
2848 } else { | 2847 } else { |
2849 this->setVertexArrayID(gpu, 0); | 2848 this->setVertexArrayID(gpu, 0); |
2850 } | 2849 } |
2851 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2850 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2852 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2851 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2853 fDefaultVertexArrayAttribState.resize(attrCount); | 2852 fDefaultVertexArrayAttribState.resize(attrCount); |
2854 } | 2853 } |
2855 attribState = &fDefaultVertexArrayAttribState; | 2854 attribState = &fDefaultVertexArrayAttribState; |
2856 } | 2855 } |
2857 return attribState; | 2856 return attribState; |
2858 } | 2857 } |
OLD | NEW |