| 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 "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 | 10 |
| 11 #define GPUGL static_cast<GrGpuGL*>(this->getGpu()) | 11 #define GPUGL static_cast<GrGLGpu*>(this->getGpu()) |
| 12 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X); | 12 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X); |
| 13 | 13 |
| 14 void GrGLAttribArrayState::set(const GrGpuGL* gpu, | 14 void GrGLAttribArrayState::set(const GrGLGpu* gpu, |
| 15 int index, | 15 int index, |
| 16 GrGLVertexBuffer* buffer, | 16 GrGLVertexBuffer* buffer, |
| 17 GrGLint size, | 17 GrGLint size, |
| 18 GrGLenum type, | 18 GrGLenum type, |
| 19 GrGLboolean normalized, | 19 GrGLboolean normalized, |
| 20 GrGLsizei stride, | 20 GrGLsizei stride, |
| 21 GrGLvoid* offset) { | 21 GrGLvoid* offset) { |
| 22 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); | 22 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); |
| 23 AttribArrayState* array = &fAttribArrayStates[index]; | 23 AttribArrayState* array = &fAttribArrayStates[index]; |
| 24 if (!array->fEnableIsValid || !array->fEnabled) { | 24 if (!array->fEnableIsValid || !array->fEnabled) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 42 offset)); | 42 offset)); |
| 43 array->fAttribPointerIsValid = true; | 43 array->fAttribPointerIsValid = true; |
| 44 array->fVertexBufferID = buffer->bufferID(); | 44 array->fVertexBufferID = buffer->bufferID(); |
| 45 array->fSize = size; | 45 array->fSize = size; |
| 46 array->fNormalized = normalized; | 46 array->fNormalized = normalized; |
| 47 array->fStride = stride; | 47 array->fStride = stride; |
| 48 array->fOffset = offset; | 48 array->fOffset = offset; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 void GrGLAttribArrayState::disableUnusedArrays(const GrGpuGL* gpu, uint64_t used
Mask) { | 52 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used
Mask) { |
| 53 int count = fAttribArrayStates.count(); | 53 int count = fAttribArrayStates.count(); |
| 54 for (int i = 0; i < count; ++i) { | 54 for (int i = 0; i < count; ++i) { |
| 55 if (!(usedMask & 0x1)) { | 55 if (!(usedMask & 0x1)) { |
| 56 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f
Enabled) { | 56 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f
Enabled) { |
| 57 GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i)); | 57 GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i)); |
| 58 fAttribArrayStates[i].fEnableIsValid = true; | 58 fAttribArrayStates[i].fEnableIsValid = true; |
| 59 fAttribArrayStates[i].fEnabled = false; | 59 fAttribArrayStates[i].fEnabled = false; |
| 60 } | 60 } |
| 61 } else { | 61 } else { |
| 62 SkASSERT(fAttribArrayStates[i].fEnableIsValid && fAttribArrayStates[
i].fEnabled); | 62 SkASSERT(fAttribArrayStates[i].fEnableIsValid && fAttribArrayStates[
i].fEnabled); |
| 63 } | 63 } |
| 64 // if the count is greater than 64 then this will become 0 and we will d
isable arrays 64+. | 64 // if the count is greater than 64 then this will become 0 and we will d
isable arrays 64+. |
| 65 usedMask >>= 1; | 65 usedMask >>= 1; |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 69 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 70 | 70 |
| 71 GrGLVertexArray::GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount) | 71 GrGLVertexArray::GrGLVertexArray(GrGLGpu* gpu, GrGLint id, int attribCount) |
| 72 : INHERITED(gpu, false) | 72 : INHERITED(gpu, false) |
| 73 , fID(id) | 73 , fID(id) |
| 74 , fAttribArrays(attribCount) | 74 , fAttribArrays(attribCount) |
| 75 , fIndexBufferIDIsValid(false) { | 75 , fIndexBufferIDIsValid(false) { |
| 76 this->registerWithCache(); | 76 this->registerWithCache(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void GrGLVertexArray::onAbandon() { | 79 void GrGLVertexArray::onAbandon() { |
| 80 fID = 0; | 80 fID = 0; |
| 81 INHERITED::onAbandon(); | 81 INHERITED::onAbandon(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { | 114 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { |
| 115 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { | 115 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { |
| 116 fIndexBufferID = 0; | 116 fIndexBufferID = 0; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void GrGLVertexArray::invalidateCachedState() { | 120 void GrGLVertexArray::invalidateCachedState() { |
| 121 fAttribArrays.invalidate(); | 121 fAttribArrays.invalidate(); |
| 122 fIndexBufferIDIsValid = false; | 122 fIndexBufferIDIsValid = false; |
| 123 } | 123 } |
| OLD | NEW |