| 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 "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "SkTArray.h" | 12 #include "SkTArray.h" |
| 13 #include "SkRect.h" | 13 #include "SkRect.h" |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Types of shader-language-specific boxed variables we can create. (Currently
only GrGLShaderVars, | 16 * Types of shader-language-specific boxed variables we can create. (Currently
only GrGLShaderVars, |
| 17 * but should be applicable to other shader languages.) | 17 * but should be applicable to other shader languages.) |
| 18 */ | 18 */ |
| 19 enum GrSLType { | 19 enum GrSLType { |
| 20 kVoid_GrSLType, | 20 kVoid_GrSLType, |
| 21 kFloat_GrSLType, | 21 kFloat_GrSLType, |
| 22 kVec2f_GrSLType, | 22 kVec2f_GrSLType, |
| 23 kVec3f_GrSLType, | 23 kVec3f_GrSLType, |
| 24 kVec4f_GrSLType, | 24 kVec4f_GrSLType, |
| 25 kMat33f_GrSLType, | 25 kMat33f_GrSLType, |
| 26 kMat44f_GrSLType, | 26 kMat44f_GrSLType, |
| 27 kSampler2D_GrSLType, | 27 kSampler2D_GrSLType, |
| 28 kSamplerExternal_GrSLType, | 28 kSamplerExternal_GrSLType, |
| 29 kSampler2DRect_GrSLType, | 29 kSampler2DRect_GrSLType, |
| 30 kBool_GrSLType, | |
| 31 kInt_GrSLType, | |
| 32 | 30 |
| 33 kLast_GrSLType = kInt_GrSLType | 31 kLast_GrSLType = kSampler2DRect_GrSLType |
| 34 }; | 32 }; |
| 35 static const int kGrSLTypeCount = kLast_GrSLType + 1; | 33 static const int kGrSLTypeCount = kLast_GrSLType + 1; |
| 36 | 34 |
| 37 enum GrShaderType { | 35 enum GrShaderType { |
| 38 kVertex_GrShaderType, | 36 kVertex_GrShaderType, |
| 39 kGeometry_GrShaderType, | 37 kGeometry_GrShaderType, |
| 40 kFragment_GrShaderType, | 38 kFragment_GrShaderType, |
| 41 | 39 |
| 42 kLastkFragment_GrShaderType = kFragment_GrShaderType | 40 kLastkFragment_GrShaderType = kFragment_GrShaderType |
| 43 }; | 41 }; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 60 kLast_GrSLPrecision = kHigh_GrSLPrecision | 58 kLast_GrSLPrecision = kHigh_GrSLPrecision |
| 61 }; | 59 }; |
| 62 | 60 |
| 63 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; | 61 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; |
| 64 | 62 |
| 65 /** | 63 /** |
| 66 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample
rs. | 64 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample
rs. |
| 67 */ | 65 */ |
| 68 static inline int GrSLTypeVectorCount(GrSLType type) { | 66 static inline int GrSLTypeVectorCount(GrSLType type) { |
| 69 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); | 67 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); |
| 70 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1 }; | 68 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1 }; |
| 71 return kCounts[type]; | 69 return kCounts[type]; |
| 72 | 70 |
| 73 GR_STATIC_ASSERT(0 == kVoid_GrSLType); | 71 GR_STATIC_ASSERT(0 == kVoid_GrSLType); |
| 74 GR_STATIC_ASSERT(1 == kFloat_GrSLType); | 72 GR_STATIC_ASSERT(1 == kFloat_GrSLType); |
| 75 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); | 73 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); |
| 76 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); | 74 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); |
| 77 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); | 75 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); |
| 78 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); | 76 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); |
| 79 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); | 77 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); |
| 80 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); | 78 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); |
| 81 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); | 79 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); |
| 82 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); | 80 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); |
| 83 GR_STATIC_ASSERT(10 == kBool_GrSLType); | |
| 84 GR_STATIC_ASSERT(11 == kInt_GrSLType); | |
| 85 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); | 81 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); |
| 86 } | 82 } |
| 87 | 83 |
| 88 /** Return the type enum for a vector of floats of length n (1..4), | 84 /** Return the type enum for a vector of floats of length n (1..4), |
| 89 e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */ | 85 e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */ |
| 90 static inline GrSLType GrSLFloatVectorType(int count) { | 86 static inline GrSLType GrSLFloatVectorType(int count) { |
| 91 SkASSERT(count > 0 && count <= 4); | 87 SkASSERT(count > 0 && count <= 4); |
| 92 return (GrSLType)(count); | 88 return (GrSLType)(count); |
| 93 | 89 |
| 94 GR_STATIC_ASSERT(kFloat_GrSLType == 1); | 90 GR_STATIC_ASSERT(kFloat_GrSLType == 1); |
| 95 GR_STATIC_ASSERT(kVec2f_GrSLType == 2); | 91 GR_STATIC_ASSERT(kVec2f_GrSLType == 2); |
| 96 GR_STATIC_ASSERT(kVec3f_GrSLType == 3); | 92 GR_STATIC_ASSERT(kVec3f_GrSLType == 3); |
| 97 GR_STATIC_ASSERT(kVec4f_GrSLType == 4); | 93 GR_STATIC_ASSERT(kVec4f_GrSLType == 4); |
| 98 } | 94 } |
| 99 | 95 |
| 100 /** Is the shading language type float (including vectors/matrices)? */ | 96 /** Is the shading language type floating point (or vector/matrix of fp)? */ |
| 101 static inline bool GrSLTypeIsFloatType(GrSLType type) { | 97 static inline bool GrSLTypeIsFloatType(GrSLType type) { |
| 102 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); | 98 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); |
| 103 return (type >= 1 && type <= 6); | 99 return type >= 1 && type <= 6; |
| 104 | 100 |
| 105 GR_STATIC_ASSERT(0 == kVoid_GrSLType); | 101 GR_STATIC_ASSERT(0 == kVoid_GrSLType); |
| 106 GR_STATIC_ASSERT(1 == kFloat_GrSLType); | 102 GR_STATIC_ASSERT(1 == kFloat_GrSLType); |
| 107 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); | 103 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); |
| 108 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); | 104 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); |
| 109 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); | 105 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); |
| 110 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); | 106 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); |
| 111 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); | 107 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); |
| 112 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); | 108 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); |
| 113 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); | 109 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); |
| 114 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); | 110 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); |
| 115 GR_STATIC_ASSERT(10 == kBool_GrSLType); | 111 GR_STATIC_ASSERT(10 == kGrSLTypeCount); |
| 116 GR_STATIC_ASSERT(11 == kInt_GrSLType); | |
| 117 GR_STATIC_ASSERT(12 == kGrSLTypeCount); | |
| 118 } | |
| 119 | |
| 120 /** Is the shading language type integral (including vectors/matrices)? */ | |
| 121 static inline bool GrSLTypeIsIntType(GrSLType type) { | |
| 122 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); | |
| 123 return type == kInt_GrSLType; | |
| 124 | |
| 125 GR_STATIC_ASSERT(0 == kVoid_GrSLType); | |
| 126 GR_STATIC_ASSERT(1 == kFloat_GrSLType); | |
| 127 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); | |
| 128 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); | |
| 129 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); | |
| 130 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); | |
| 131 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); | |
| 132 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); | |
| 133 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); | |
| 134 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); | |
| 135 GR_STATIC_ASSERT(10 == kBool_GrSLType); | |
| 136 GR_STATIC_ASSERT(11 == kInt_GrSLType); | |
| 137 GR_STATIC_ASSERT(12 == kGrSLTypeCount); | |
| 138 } | |
| 139 | |
| 140 /** Is the shading language type numeric (including vectors/matrices)? */ | |
| 141 static inline bool GrSLTypeIsNumeric(GrSLType type) { | |
| 142 return GrSLTypeIsFloatType(type) || GrSLTypeIsIntType(type); | |
| 143 } | 112 } |
| 144 | 113 |
| 145 /** Returns the size in bytes for floating point GrSLTypes. For non floating poi
nt type returns 0 */ | 114 /** Returns the size in bytes for floating point GrSLTypes. For non floating poi
nt type returns 0 */ |
| 146 static inline size_t GrSLTypeSize(GrSLType type) { | 115 static inline size_t GrSLTypeSize(GrSLType type) { |
| 147 SkASSERT(GrSLTypeIsFloatType(type)); | 116 SkASSERT(GrSLTypeIsFloatType(type)); |
| 148 static const size_t kSizes[] = { | 117 static const size_t kSizes[] = { |
| 149 0, // kVoid_GrSLType | 118 0, // kVoid_GrSLType |
| 150 sizeof(float), // kFloat_GrSLType | 119 sizeof(float), // kFloat_GrSLType |
| 151 2 * sizeof(float), // kVec2f_GrSLType | 120 2 * sizeof(float), // kVec2f_GrSLType |
| 152 3 * sizeof(float), // kVec3f_GrSLType | 121 3 * sizeof(float), // kVec3f_GrSLType |
| 153 4 * sizeof(float), // kVec4f_GrSLType | 122 4 * sizeof(float), // kVec4f_GrSLType |
| 154 9 * sizeof(float), // kMat33f_GrSLType | 123 9 * sizeof(float), // kMat33f_GrSLType |
| 155 16 * sizeof(float), // kMat44f_GrSLType | 124 16 * sizeof(float), // kMat44f_GrSLType |
| 156 0, // kSampler2D_GrSLType | 125 0, // kSampler2D_GrSLType |
| 157 0, // kSamplerExternal_GrSLType | 126 0, // kSamplerExternal_GrSLType |
| 158 0, // kSampler2DRect_GrSLType | 127 0 // kSampler2DRect_GrSLType |
| 159 0, // kBool_GrSLType | |
| 160 0, // kInt_GrSLType | |
| 161 }; | 128 }; |
| 162 return kSizes[type]; | 129 return kSizes[type]; |
| 163 | 130 |
| 164 GR_STATIC_ASSERT(0 == kVoid_GrSLType); | 131 GR_STATIC_ASSERT(0 == kVoid_GrSLType); |
| 165 GR_STATIC_ASSERT(1 == kFloat_GrSLType); | 132 GR_STATIC_ASSERT(1 == kFloat_GrSLType); |
| 166 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); | 133 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); |
| 167 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); | 134 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); |
| 168 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); | 135 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); |
| 169 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); | 136 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); |
| 170 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); | 137 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); |
| 171 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); | 138 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); |
| 172 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); | 139 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); |
| 173 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); | 140 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); |
| 174 GR_STATIC_ASSERT(10 == kBool_GrSLType); | 141 GR_STATIC_ASSERT(10 == kGrSLTypeCount); |
| 175 GR_STATIC_ASSERT(11 == kInt_GrSLType); | |
| 176 GR_STATIC_ASSERT(12 == kGrSLTypeCount); | |
| 177 } | 142 } |
| 178 | 143 |
| 179 static inline bool GrSLTypeIsSamplerType(GrSLType type) { | 144 static inline bool GrSLTypeIsSamplerType(GrSLType type) { |
| 180 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); | 145 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); |
| 181 return type >= 7 && type <= 9; | 146 return type >= 7 && type <= 9; |
| 182 | 147 |
| 183 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); | 148 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); |
| 184 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); | 149 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); |
| 185 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); | 150 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); |
| 186 } | 151 } |
| 187 | 152 |
| 188 ////////////////////////////////////////////////////////////////////////////// | 153 ////////////////////////////////////////////////////////////////////////////// |
| 189 | 154 |
| 190 /** | 155 /** |
| 191 * Types used to describe format of vertices in arrays. | 156 * Types used to describe format of vertices in arrays. |
| 192 */ | 157 */ |
| 193 enum GrVertexAttribType { | 158 enum GrVertexAttribType { |
| 194 kFloat_GrVertexAttribType = 0, | 159 kFloat_GrVertexAttribType = 0, |
| 195 kVec2f_GrVertexAttribType, | 160 kVec2f_GrVertexAttribType, |
| 196 kVec3f_GrVertexAttribType, | 161 kVec3f_GrVertexAttribType, |
| 197 kVec4f_GrVertexAttribType, | 162 kVec4f_GrVertexAttribType, |
| 198 | 163 |
| 199 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage | 164 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage |
| 200 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors | 165 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors |
| 201 | 166 |
| 202 kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates | 167 kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates |
| 203 | |
| 204 kInt_GrVertexAttribType, | |
| 205 | 168 |
| 206 kLast_GrVertexAttribType = kInt_GrVertexAttribType | 169 kLast_GrVertexAttribType = kVec2s_GrVertexAttribType |
| 207 }; | 170 }; |
| 208 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; | 171 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; |
| 209 | 172 |
| 210 /** | 173 /** |
| 211 * Returns the vector size of the type. | 174 * Returns the vector size of the type. |
| 212 */ | 175 */ |
| 213 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { | 176 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { |
| 214 static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2, 1 }; | 177 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); |
| 178 static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2 }; |
| 215 return kCounts[type]; | 179 return kCounts[type]; |
| 216 | 180 |
| 217 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); | 181 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| 218 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); | 182 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
| 219 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 183 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 220 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 184 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 221 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 185 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| 222 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 186 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| 223 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); | 187 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); |
| 224 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); | |
| 225 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); | 188 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); |
| 226 } | 189 } |
| 227 | 190 |
| 228 /** | 191 /** |
| 229 * Returns the size of the attrib type in bytes. | 192 * Returns the size of the attrib type in bytes. |
| 230 */ | 193 */ |
| 231 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { | 194 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { |
| 195 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); |
| 232 static const size_t kSizes[] = { | 196 static const size_t kSizes[] = { |
| 233 sizeof(float), // kFloat_GrVertexAttribType | 197 sizeof(float), // kFloat_GrVertexAttribType |
| 234 2*sizeof(float), // kVec2f_GrVertexAttribType | 198 2*sizeof(float), // kVec2f_GrVertexAttribType |
| 235 3*sizeof(float), // kVec3f_GrVertexAttribType | 199 3*sizeof(float), // kVec3f_GrVertexAttribType |
| 236 4*sizeof(float), // kVec4f_GrVertexAttribType | 200 4*sizeof(float), // kVec4f_GrVertexAttribType |
| 237 1*sizeof(char), // kUByte_GrVertexAttribType | 201 1*sizeof(char), // kUByte_GrVertexAttribType |
| 238 4*sizeof(char), // kVec4ub_GrVertexAttribType | 202 4*sizeof(char), // kVec4ub_GrVertexAttribType |
| 239 2*sizeof(int16_t), // kVec2s_GrVertexAttribType | 203 2*sizeof(int16_t) // kVec2s_GrVertexAttribType |
| 240 sizeof(int32_t) // kInt_GrVertexAttribType | |
| 241 }; | 204 }; |
| 242 return kSizes[type]; | 205 return kSizes[type]; |
| 243 | 206 |
| 244 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); | 207 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| 245 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); | 208 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
| 246 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 209 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 247 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 210 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 248 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 211 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| 249 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 212 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| 250 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); | 213 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); |
| 251 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); | |
| 252 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); | 214 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); |
| 253 } | 215 } |
| 254 | 216 |
| 255 /** | 217 /** |
| 256 * converts a GrVertexAttribType to a GrSLType | 218 * converts a GrVertexAttribType to a GrSLType |
| 257 */ | 219 */ |
| 258 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { | 220 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { |
| 259 switch (type) { | 221 switch (type) { |
| 260 default: | 222 default: |
| 261 SkFAIL("Unsupported type conversion"); | 223 SkFAIL("Unsupported type conversion"); |
| 262 return kVoid_GrSLType; | 224 return kVoid_GrSLType; |
| 263 case kUByte_GrVertexAttribType: | 225 case kUByte_GrVertexAttribType: |
| 264 case kFloat_GrVertexAttribType: | 226 case kFloat_GrVertexAttribType: |
| 265 return kFloat_GrSLType; | 227 return kFloat_GrSLType; |
| 266 case kVec2s_GrVertexAttribType: | 228 case kVec2s_GrVertexAttribType: |
| 267 case kVec2f_GrVertexAttribType: | 229 case kVec2f_GrVertexAttribType: |
| 268 return kVec2f_GrSLType; | 230 return kVec2f_GrSLType; |
| 269 case kVec3f_GrVertexAttribType: | 231 case kVec3f_GrVertexAttribType: |
| 270 return kVec3f_GrSLType; | 232 return kVec3f_GrSLType; |
| 271 case kVec4ub_GrVertexAttribType: | 233 case kVec4ub_GrVertexAttribType: |
| 272 case kVec4f_GrVertexAttribType: | 234 case kVec4f_GrVertexAttribType: |
| 273 return kVec4f_GrSLType; | 235 return kVec4f_GrSLType; |
| 274 case kInt_GrVertexAttribType: | |
| 275 return kInt_GrSLType; | |
| 276 } | 236 } |
| 277 } | 237 } |
| 278 | 238 |
| 279 ////////////////////////////////////////////////////////////////////////////// | 239 ////////////////////////////////////////////////////////////////////////////// |
| 280 | 240 |
| 281 /** | 241 /** |
| 282 * We have coverage effects that clip rendering to the edge of some geometric pri
mitive. | 242 * We have coverage effects that clip rendering to the edge of some geometric pri
mitive. |
| 283 * This enum specifies how that clipping is performed. Not all factories that tak
e a | 243 * This enum specifies how that clipping is performed. Not all factories that tak
e a |
| 284 * GrProcessorEdgeType will succeed with all values and it is up to the caller to
check for | 244 * GrProcessorEdgeType will succeed with all values and it is up to the caller to
check for |
| 285 * a NULL return. | 245 * a NULL return. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 // Takes a pointer to a GrCaps, and will suppress prints if required | 326 // Takes a pointer to a GrCaps, and will suppress prints if required |
| 367 #define GrCapsDebugf(caps, ...) \ | 327 #define GrCapsDebugf(caps, ...) \ |
| 368 if (!caps->suppressPrints()) { \ | 328 if (!caps->suppressPrints()) { \ |
| 369 SkDebugf(__VA_ARGS__); \ | 329 SkDebugf(__VA_ARGS__); \ |
| 370 } | 330 } |
| 371 #else | 331 #else |
| 372 #define GrCapsDebugf(caps, ...) | 332 #define GrCapsDebugf(caps, ...) |
| 373 #endif | 333 #endif |
| 374 | 334 |
| 375 #endif | 335 #endif |
| OLD | NEW |