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 GrGLVertexBuffer; | 16 class GrGLVertexBuffer; |
17 class GrGLIndexBuffer; | 17 class GrGLIndexBuffer; |
18 class GrGLGpu; | 18 class GrGLGpu; |
19 | 19 |
20 struct GrGLAttribLayout { | 20 struct GrGLAttribLayout { |
21 GrGLint fCount; | 21 GrGLint fCount; |
22 GrGLenum fType; | 22 GrGLenum fType; |
23 GrGLboolean fNormalized; | 23 GrGLboolean fNormalized; |
24 }; | 24 }; |
25 | 25 |
26 static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType
type) { | 26 static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType
type) { |
27 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); | |
28 static const GrGLAttribLayout kLayouts[kGrVertexAttribTypeCount] = { | 27 static const GrGLAttribLayout kLayouts[kGrVertexAttribTypeCount] = { |
29 {1, GR_GL_FLOAT, false}, // kFloat_GrVertexAttribType | 28 {1, GR_GL_FLOAT, false}, // kFloat_GrVertexAttribType |
30 {2, GR_GL_FLOAT, false}, // kVec2f_GrVertexAttribType | 29 {2, GR_GL_FLOAT, false}, // kVec2f_GrVertexAttribType |
31 {3, GR_GL_FLOAT, false}, // kVec3f_GrVertexAttribType | 30 {3, GR_GL_FLOAT, false}, // kVec3f_GrVertexAttribType |
32 {4, GR_GL_FLOAT, false}, // kVec4f_GrVertexAttribType | 31 {4, GR_GL_FLOAT, false}, // kVec4f_GrVertexAttribType |
33 {1, GR_GL_UNSIGNED_BYTE, true}, // kUByte_GrVertexAttribType | 32 {1, GR_GL_UNSIGNED_BYTE, true}, // kUByte_GrVertexAttribType |
34 {4, GR_GL_UNSIGNED_BYTE, true}, // kVec4ub_GrVertexAttribType | 33 {4, GR_GL_UNSIGNED_BYTE, true}, // kVec4ub_GrVertexAttribType |
35 {2, GR_GL_SHORT, false}, // kVec2s_GrVertexAttribType | 34 {2, GR_GL_SHORT, false}, // kVec2s_GrVertexAttribType |
| 35 {4, GR_GL_INT, false}, // kInt_GrVertexAttribType |
36 }; | 36 }; |
37 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); | 37 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
38 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); | 38 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
39 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 39 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
40 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 40 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
41 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 41 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
42 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 42 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
43 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); | 43 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); |
| 44 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); |
44 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayouts) == kGrVertexAttribTypeCount); | 45 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayouts) == kGrVertexAttribTypeCount); |
45 return kLayouts[type]; | 46 return kLayouts[type]; |
46 } | 47 } |
47 | 48 |
48 /** | 49 /** |
49 * This sets and tracks the vertex attribute array state. It is used internally
by GrGLVertexArray | 50 * This sets and tracks the vertex attribute array state. It is used internally
by GrGLVertexArray |
50 * (below) but is separate because it is also used to track the state of vertex
array object 0. | 51 * (below) but is separate because it is also used to track the state of vertex
array object 0. |
51 */ | 52 */ |
52 class GrGLAttribArrayState { | 53 class GrGLAttribArrayState { |
53 public: | 54 public: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 void invalidateCachedState(); | 161 void invalidateCachedState(); |
161 | 162 |
162 private: | 163 private: |
163 GrGLuint fID; | 164 GrGLuint fID; |
164 GrGLAttribArrayState fAttribArrays; | 165 GrGLAttribArrayState fAttribArrays; |
165 GrGLuint fIndexBufferID; | 166 GrGLuint fIndexBufferID; |
166 bool fIndexBufferIDIsValid; | 167 bool fIndexBufferIDIsValid; |
167 }; | 168 }; |
168 | 169 |
169 #endif | 170 #endif |
OLD | NEW |