| 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 "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 68 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 69 | 69 |
| 70 GrGLVertexArray::GrGLVertexArray(GrGLint id, int attribCount) | 70 GrGLVertexArray::GrGLVertexArray(GrGLint id, int attribCount) |
| 71 : fID(id) | 71 : fID(id) |
| 72 , fAttribArrays(attribCount) | 72 , fAttribArrays(attribCount) |
| 73 , fIndexBufferIDIsValid(false) { | 73 , fIndexBufferIDIsValid(false) { |
| 74 } | 74 } |
| 75 | 75 |
| 76 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) { | 76 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) { |
| 77 if (0 == fID) { | 77 if (0 == fID) { |
| 78 return NULL; | 78 return nullptr; |
| 79 } | 79 } |
| 80 gpu->bindVertexArray(fID); | 80 gpu->bindVertexArray(fID); |
| 81 return &fAttribArrays; | 81 return &fAttribArrays; |
| 82 } | 82 } |
| 83 | 83 |
| 84 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, GrGLuin
t ibufferID) { | 84 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, GrGLuin
t ibufferID) { |
| 85 GrGLAttribArrayState* state = this->bind(gpu); | 85 GrGLAttribArrayState* state = this->bind(gpu); |
| 86 if (state) { | 86 if (state) { |
| 87 if (!fIndexBufferIDIsValid || ibufferID != fIndexBufferID) { | 87 if (!fIndexBufferIDIsValid || ibufferID != fIndexBufferID) { |
| 88 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER
, ibufferID)); | 88 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER
, ibufferID)); |
| 89 fIndexBufferIDIsValid = true; | 89 fIndexBufferIDIsValid = true; |
| 90 fIndexBufferID = ibufferID; | 90 fIndexBufferID = ibufferID; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 return state; | 93 return state; |
| 94 } | 94 } |
| 95 | 95 |
| 96 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { | 96 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { |
| 97 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { | 97 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { |
| 98 fIndexBufferID = 0; | 98 fIndexBufferID = 0; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 void GrGLVertexArray::invalidateCachedState() { | 102 void GrGLVertexArray::invalidateCachedState() { |
| 103 fAttribArrays.invalidate(); | 103 fAttribArrays.invalidate(); |
| 104 fIndexBufferIDIsValid = false; | 104 fIndexBufferIDIsValid = false; |
| 105 } | 105 } |
| OLD | NEW |