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