| 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 #ifndef GrGLVertexArray_DEFINED | 8 #ifndef GrGLVertexArray_DEFINED |
| 9 #define GrGLVertexArray_DEFINED | 9 #define GrGLVertexArray_DEFINED |
| 10 | 10 |
| 11 #include "GrTypesPriv.h" | 11 #include "GrTypesPriv.h" |
| 12 #include "gl/GrGLDefines.h" | 12 #include "gl/GrGLDefines.h" |
| 13 #include "gl/GrGLTypes.h" | 13 #include "gl/GrGLTypes.h" |
| 14 #include "SkTArray.h" | 14 #include "SkTArray.h" |
| 15 | 15 |
| 16 class GrGLBuffer; | 16 class GrBuffer; |
| 17 class GrGLGpu; | 17 class GrGLGpu; |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * This sets and tracks the vertex attribute array state. It is used internally
by GrGLVertexArray | 20 * This sets and tracks the vertex attribute array state. It is used internally
by GrGLVertexArray |
| 21 * (below) but is separate because it is also used to track the state of vertex
array object 0. | 21 * (below) but is separate because it is also used to track the state of vertex
array object 0. |
| 22 */ | 22 */ |
| 23 class GrGLAttribArrayState { | 23 class GrGLAttribArrayState { |
| 24 public: | 24 public: |
| 25 explicit GrGLAttribArrayState(int arrayCount = 0) { | 25 explicit GrGLAttribArrayState(int arrayCount = 0) { |
| 26 this->resize(arrayCount); | 26 this->resize(arrayCount); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void resize(int newCount) { | 29 void resize(int newCount) { |
| 30 fAttribArrayStates.resize_back(newCount); | 30 fAttribArrayStates.resize_back(newCount); |
| 31 for (int i = 0; i < newCount; ++i) { | 31 for (int i = 0; i < newCount; ++i) { |
| 32 fAttribArrayStates[i].invalidate(); | 32 fAttribArrayStates[i].invalidate(); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * This function enables and sets vertex attrib state for the specified attr
ib index. It is | 37 * This function enables and sets vertex attrib state for the specified attr
ib index. It is |
| 38 * assumed that the GrGLAttribArrayState is tracking the state of the curren
tly bound vertex | 38 * assumed that the GrGLAttribArrayState is tracking the state of the curren
tly bound vertex |
| 39 * array object. | 39 * array object. |
| 40 */ | 40 */ |
| 41 void set(GrGLGpu*, | 41 void set(GrGLGpu*, |
| 42 int attribIndex, | 42 int attribIndex, |
| 43 const GrGLBuffer* vertexBuffer, | 43 const GrBuffer* vertexBuffer, |
| 44 GrVertexAttribType type, | 44 GrVertexAttribType type, |
| 45 GrGLsizei stride, | 45 GrGLsizei stride, |
| 46 GrGLvoid* offset); | 46 GrGLvoid* offset); |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * This function disables vertex attribs not present in the mask. It is assu
med that the | 49 * This function disables vertex attribs not present in the mask. It is assu
med that the |
| 50 * GrGLAttribArrayState is tracking the state of the currently bound vertex
array object. | 50 * GrGLAttribArrayState is tracking the state of the currently bound vertex
array object. |
| 51 */ | 51 */ |
| 52 void disableUnusedArrays(const GrGLGpu*, uint64_t usedAttribArrayMask); | 52 void disableUnusedArrays(const GrGLGpu*, uint64_t usedAttribArrayMask); |
| 53 | 53 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 * Binds this vertex array. If the ID has been deleted or abandoned then nul
lptr is returned. | 96 * Binds this vertex array. If the ID has been deleted or abandoned then nul
lptr is returned. |
| 97 * Otherwise, the GrGLAttribArrayState that is tracking this vertex array's
attrib bindings is | 97 * Otherwise, the GrGLAttribArrayState that is tracking this vertex array's
attrib bindings is |
| 98 * returned. | 98 * returned. |
| 99 */ | 99 */ |
| 100 GrGLAttribArrayState* bind(GrGLGpu*); | 100 GrGLAttribArrayState* bind(GrGLGpu*); |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * This is a version of the above function that also binds an index buffer t
o the vertex | 103 * This is a version of the above function that also binds an index buffer t
o the vertex |
| 104 * array object. | 104 * array object. |
| 105 */ | 105 */ |
| 106 GrGLAttribArrayState* bindWithIndexBuffer(GrGLGpu* gpu, const GrGLBuffer* in
dexBuffer); | 106 GrGLAttribArrayState* bindWithIndexBuffer(GrGLGpu* gpu, const GrBuffer* inde
xBuffer); |
| 107 | 107 |
| 108 GrGLuint arrayID() const { return fID; } | 108 GrGLuint arrayID() const { return fID; } |
| 109 | 109 |
| 110 void invalidateCachedState(); | 110 void invalidateCachedState(); |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 GrGLuint fID; | 113 GrGLuint fID; |
| 114 GrGLAttribArrayState fAttribArrays; | 114 GrGLAttribArrayState fAttribArrays; |
| 115 uint32_t fIndexBufferUniqueID; | 115 uint32_t fIndexBufferUniqueID; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 #endif | 118 #endif |
| OLD | NEW |