| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "GrGLVertexArray.h" | 8 #include "GrGLVertexArray.h" |
| 9 #include "GrGLBuffer.h" | 9 #include "GrGLBuffer.h" |
| 10 #include "GrGLGpu.h" | 10 #include "GrGLGpu.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 32 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 33 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 33 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 34 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 34 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| 35 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 35 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| 36 GR_STATIC_ASSERT(6 == kVec2us_GrVertexAttribType); | 36 GR_STATIC_ASSERT(6 == kVec2us_GrVertexAttribType); |
| 37 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); | 37 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); |
| 38 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); | 38 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); |
| 39 | 39 |
| 40 void GrGLAttribArrayState::set(GrGLGpu* gpu, | 40 void GrGLAttribArrayState::set(GrGLGpu* gpu, |
| 41 int index, | 41 int index, |
| 42 const GrGLBuffer* vertexBuffer, | 42 const GrBuffer* vertexBuffer, |
| 43 GrVertexAttribType type, | 43 GrVertexAttribType type, |
| 44 GrGLsizei stride, | 44 GrGLsizei stride, |
| 45 GrGLvoid* offset) { | 45 GrGLvoid* offset) { |
| 46 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); | 46 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); |
| 47 AttribArrayState* array = &fAttribArrayStates[index]; | 47 AttribArrayState* array = &fAttribArrayStates[index]; |
| 48 if (!array->fEnableIsValid || !array->fEnabled) { | 48 if (!array->fEnableIsValid || !array->fEnabled) { |
| 49 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index)); | 49 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index)); |
| 50 array->fEnableIsValid = true; | 50 array->fEnableIsValid = true; |
| 51 array->fEnabled = true; | 51 array->fEnabled = true; |
| 52 } | 52 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 105 } |
| 106 | 106 |
| 107 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) { | 107 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) { |
| 108 if (0 == fID) { | 108 if (0 == fID) { |
| 109 return nullptr; | 109 return nullptr; |
| 110 } | 110 } |
| 111 gpu->bindVertexArray(fID); | 111 gpu->bindVertexArray(fID); |
| 112 return &fAttribArrays; | 112 return &fAttribArrays; |
| 113 } | 113 } |
| 114 | 114 |
| 115 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const G
rGLBuffer* ibuff) { | 115 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const G
rBuffer* ibuff) { |
| 116 GrGLAttribArrayState* state = this->bind(gpu); | 116 GrGLAttribArrayState* state = this->bind(gpu); |
| 117 if (state && fIndexBufferUniqueID != ibuff->getUniqueID()) { | 117 if (state && fIndexBufferUniqueID != ibuff->getUniqueID()) { |
| 118 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, ib
uff->bufferID())); | 118 if (ibuff->isCPUBacked()) { |
| 119 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER
, 0)); |
| 120 } else { |
| 121 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(ibuff); |
| 122 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER
, |
| 123 glBuffer->bufferID())); |
| 124 } |
| 119 fIndexBufferUniqueID = ibuff->getUniqueID(); | 125 fIndexBufferUniqueID = ibuff->getUniqueID(); |
| 120 } | 126 } |
| 121 return state; | 127 return state; |
| 122 } | 128 } |
| 123 | 129 |
| 124 void GrGLVertexArray::invalidateCachedState() { | 130 void GrGLVertexArray::invalidateCachedState() { |
| 125 fAttribArrays.invalidate(); | 131 fAttribArrays.invalidate(); |
| 126 fIndexBufferUniqueID = SK_InvalidUniqueID; | 132 fIndexBufferUniqueID = SK_InvalidUniqueID; |
| 127 } | 133 } |
| OLD | NEW |