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 "GrResource.h" | 11 #include "GrResource.h" |
| 12 #include "GrTypesPriv.h" |
| 13 #include "gl/GrGLDefines.h" |
12 #include "gl/GrGLFunctions.h" | 14 #include "gl/GrGLFunctions.h" |
13 | 15 |
14 #include "SkTArray.h" | 16 #include "SkTArray.h" |
15 | 17 |
16 class GrGLVertexBuffer; | 18 class GrGLVertexBuffer; |
17 class GrGLIndexBuffer; | 19 class GrGLIndexBuffer; |
18 class GrGpuGL; | 20 class GrGpuGL; |
19 | 21 |
| 22 struct GrGLAttribLayout { |
| 23 GrGLint fCount; |
| 24 GrGLenum fType; |
| 25 GrGLboolean fNormalized; |
| 26 }; |
| 27 |
| 28 static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType
type) { |
| 29 GrAssert(type >= 0 && type < kGrVertexAttribTypeCount); |
| 30 const GrGLAttribLayout kLayouts[kGrVertexAttribTypeCount] = { |
| 31 {1, GR_GL_FLOAT, false}, // kFloat_GrVertexAttribType |
| 32 {2, GR_GL_FLOAT, false}, // kVec2f_GrVertexAttribType |
| 33 {3, GR_GL_FLOAT, false}, // kVec3f_GrVertexAttribType |
| 34 {4, GR_GL_FLOAT, false}, // kVec4f_GrVertexAttribType |
| 35 {4, GR_GL_UNSIGNED_BYTE, true}, // kVec4ub_GrVertexAttribType |
| 36 }; |
| 37 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| 38 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
| 39 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 40 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 41 GR_STATIC_ASSERT(4 == kVec4ub_GrVertexAttribType); |
| 42 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayouts) == kGrVertexAttribTypeCount); |
| 43 return kLayouts[type]; |
| 44 } |
| 45 |
20 /** | 46 /** |
21 * This sets and tracks the vertex attribute array state. It is used internally
by GrGLVertexArray | 47 * This sets and tracks the vertex attribute array state. It is used internally
by GrGLVertexArray |
22 * (below) but is separate because it is also used to track the state of vertex
array object 0. | 48 * (below) but is separate because it is also used to track the state of vertex
array object 0. |
23 */ | 49 */ |
24 class GrGLAttribArrayState { | 50 class GrGLAttribArrayState { |
25 public: | 51 public: |
26 explicit GrGLAttribArrayState(int arrayCount = 0) { this->resize(arrayCount)
; } | 52 explicit GrGLAttribArrayState(int arrayCount = 0) { this->resize(arrayCount)
; } |
27 | 53 |
28 void resize(int newCount) { | 54 void resize(int newCount) { |
29 fAttribArrayStates.resize_back(newCount); | 55 fAttribArrayStates.resize_back(newCount); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 private: | 165 private: |
140 GrGLuint fID; | 166 GrGLuint fID; |
141 GrGLAttribArrayState fAttribArrays; | 167 GrGLAttribArrayState fAttribArrays; |
142 GrGLuint fIndexBufferID; | 168 GrGLuint fIndexBufferID; |
143 bool fIndexBufferIDIsValid; | 169 bool fIndexBufferIDIsValid; |
144 | 170 |
145 typedef GrResource INHERITED; | 171 typedef GrResource INHERITED; |
146 }; | 172 }; |
147 | 173 |
148 #endif | 174 #endif |
OLD | NEW |