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 GrTypesPriv_DEFINED | 8 #ifndef GrTypesPriv_DEFINED |
9 #define GrTypesPriv_DEFINED | 9 #define GrTypesPriv_DEFINED |
10 | 10 |
| 11 #include "SkTArray.h" |
| 12 |
11 /** | 13 /** |
12 * Types of shader-language-specific boxed variables we can create. | 14 * Types of shader-language-specific boxed variables we can create. |
13 * (Currently only GrGLShaderVars, but should be applicable to other shader | 15 * (Currently only GrGLShaderVars, but should be applicable to other shader |
14 * languages.) | 16 * languages.) |
15 */ | 17 */ |
16 enum GrSLType { | 18 enum GrSLType { |
17 kVoid_GrSLType, | 19 kVoid_GrSLType, |
18 kFloat_GrSLType, | 20 kFloat_GrSLType, |
19 kVec2f_GrSLType, | 21 kVec2f_GrSLType, |
20 kVec3f_GrSLType, | 22 kVec3f_GrSLType, |
21 kVec4f_GrSLType, | 23 kVec4f_GrSLType, |
22 kMat33f_GrSLType, | 24 kMat33f_GrSLType, |
23 kMat44f_GrSLType, | 25 kMat44f_GrSLType, |
24 kSampler2D_GrSLType | 26 kSampler2D_GrSLType |
25 }; | 27 }; |
26 | 28 |
| 29 /** |
| 30 * Types used to describe format of vertices in arrays |
| 31 */ |
| 32 enum GrVertexAttribType { |
| 33 kFloat_GrVertexAttribType = 0, |
| 34 kVec2f_GrVertexAttribType, |
| 35 kVec3f_GrVertexAttribType, |
| 36 kVec4f_GrVertexAttribType, |
| 37 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors |
| 38 |
| 39 kLast_GrVertexAttribType = kVec4ub_GrVertexAttribType |
| 40 }; |
| 41 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; |
| 42 |
| 43 struct GrVertexAttrib { |
| 44 inline void set(GrVertexAttribType type, size_t offset) { |
| 45 fType = type; fOffset = offset; |
| 46 } |
| 47 bool operator==(const GrVertexAttrib& other) const { |
| 48 return fType == other.fType && fOffset == other.fOffset; |
| 49 }; |
| 50 bool operator!=(const GrVertexAttrib& other) const { return !(*this == other
); } |
| 51 |
| 52 GrVertexAttribType fType; |
| 53 size_t fOffset; |
| 54 }; |
| 55 |
| 56 template <int N> |
| 57 class GrVertexAttribArray : public SkSTArray<N, GrVertexAttrib, true> {}; |
| 58 |
27 #endif | 59 #endif |
OLD | NEW |