| 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 "GrGpuResource.h" | 11 #include "GrGpuResource.h" |
| 12 #include "GrTypesPriv.h" | 12 #include "GrTypesPriv.h" |
| 13 #include "gl/GrGLDefines.h" | 13 #include "gl/GrGLDefines.h" |
| 14 #include "gl/GrGLFunctions.h" | 14 #include "gl/GrGLFunctions.h" |
| 15 | 15 |
| 16 #include "SkTArray.h" | 16 #include "SkTArray.h" |
| 17 | 17 |
| 18 class GrGLVertexBuffer; | 18 class GrGLVertexBuffer; |
| 19 class GrGLIndexBuffer; | 19 class GrGLIndexBuffer; |
| 20 class GrGpuGL; | 20 class GrGLGpu; |
| 21 | 21 |
| 22 struct GrGLAttribLayout { | 22 struct GrGLAttribLayout { |
| 23 GrGLint fCount; | 23 GrGLint fCount; |
| 24 GrGLenum fType; | 24 GrGLenum fType; |
| 25 GrGLboolean fNormalized; | 25 GrGLboolean fNormalized; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType
type) { | 28 static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType
type) { |
| 29 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); | 29 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); |
| 30 static const GrGLAttribLayout kLayouts[kGrVertexAttribTypeCount] = { | 30 static const GrGLAttribLayout kLayouts[kGrVertexAttribTypeCount] = { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 60 for (int i = 0; i < newCount; ++i) { | 60 for (int i = 0; i < newCount; ++i) { |
| 61 fAttribArrayStates[i].invalidate(); | 61 fAttribArrayStates[i].invalidate(); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * This function enables and sets vertex attrib state for the specified attr
ib index. It is | 66 * This function enables and sets vertex attrib state for the specified attr
ib index. It is |
| 67 * assumed that the GrGLAttribArrayState is tracking the state of the curren
tly bound vertex | 67 * assumed that the GrGLAttribArrayState is tracking the state of the curren
tly bound vertex |
| 68 * array object. | 68 * array object. |
| 69 */ | 69 */ |
| 70 void set(const GrGpuGL*, | 70 void set(const GrGLGpu*, |
| 71 int index, | 71 int index, |
| 72 GrGLVertexBuffer*, | 72 GrGLVertexBuffer*, |
| 73 GrGLint size, | 73 GrGLint size, |
| 74 GrGLenum type, | 74 GrGLenum type, |
| 75 GrGLboolean normalized, | 75 GrGLboolean normalized, |
| 76 GrGLsizei stride, | 76 GrGLsizei stride, |
| 77 GrGLvoid* offset); | 77 GrGLvoid* offset); |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * This function disables vertex attribs not present in the mask. It is assu
med that the | 80 * This function disables vertex attribs not present in the mask. It is assu
med that the |
| 81 * GrGLAttribArrayState is tracking the state of the currently bound vertex
array object. | 81 * GrGLAttribArrayState is tracking the state of the currently bound vertex
array object. |
| 82 */ | 82 */ |
| 83 void disableUnusedArrays(const GrGpuGL*, uint64_t usedAttribArrayMask); | 83 void disableUnusedArrays(const GrGLGpu*, uint64_t usedAttribArrayMask); |
| 84 | 84 |
| 85 void invalidate() { | 85 void invalidate() { |
| 86 int count = fAttribArrayStates.count(); | 86 int count = fAttribArrayStates.count(); |
| 87 for (int i = 0; i < count; ++i) { | 87 for (int i = 0; i < count; ++i) { |
| 88 fAttribArrayStates[i].invalidate(); | 88 fAttribArrayStates[i].invalidate(); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 void notifyVertexBufferDelete(GrGLuint id) { | 92 void notifyVertexBufferDelete(GrGLuint id) { |
| 93 int count = fAttribArrayStates.count(); | 93 int count = fAttribArrayStates.count(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 SkSTArray<16, AttribArrayState, true> fAttribArrayStates; | 128 SkSTArray<16, AttribArrayState, true> fAttribArrayStates; |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * This class represents an OpenGL vertex array object. It manages the lifetime
of the vertex array | 132 * This class represents an OpenGL vertex array object. It manages the lifetime
of the vertex array |
| 133 * and is used to track the state of the vertex array to avoid redundant GL call
s. | 133 * and is used to track the state of the vertex array to avoid redundant GL call
s. |
| 134 */ | 134 */ |
| 135 class GrGLVertexArray : public GrGpuResource { | 135 class GrGLVertexArray : public GrGpuResource { |
| 136 public: | 136 public: |
| 137 GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount); | 137 GrGLVertexArray(GrGLGpu* gpu, GrGLint id, int attribCount); |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * Binds this vertex array. If the ID has been deleted or abandoned then NUL
L is returned. | 140 * Binds this vertex array. If the ID has been deleted or abandoned then NUL
L is returned. |
| 141 * Otherwise, the GrGLAttribArrayState that is tracking this vertex array's
attrib bindings is | 141 * Otherwise, the GrGLAttribArrayState that is tracking this vertex array's
attrib bindings is |
| 142 * returned. | 142 * returned. |
| 143 */ | 143 */ |
| 144 GrGLAttribArrayState* bind(); | 144 GrGLAttribArrayState* bind(); |
| 145 | 145 |
| 146 /** | 146 /** |
| 147 * This is a version of the above function that also binds an index buffer t
o the vertex | 147 * This is a version of the above function that also binds an index buffer t
o the vertex |
| (...skipping 21 matching lines...) Expand all Loading... |
| 169 private: | 169 private: |
| 170 GrGLuint fID; | 170 GrGLuint fID; |
| 171 GrGLAttribArrayState fAttribArrays; | 171 GrGLAttribArrayState fAttribArrays; |
| 172 GrGLuint fIndexBufferID; | 172 GrGLuint fIndexBufferID; |
| 173 bool fIndexBufferIDIsValid; | 173 bool fIndexBufferIDIsValid; |
| 174 | 174 |
| 175 typedef GrGpuResource INHERITED; | 175 typedef GrGpuResource INHERITED; |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 #endif | 178 #endif |
| OLD | NEW |