| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 */ | 205 */ |
| 206 enum GrVertexAttribType { | 206 enum GrVertexAttribType { |
| 207 kFloat_GrVertexAttribType = 0, | 207 kFloat_GrVertexAttribType = 0, |
| 208 kVec2f_GrVertexAttribType, | 208 kVec2f_GrVertexAttribType, |
| 209 kVec3f_GrVertexAttribType, | 209 kVec3f_GrVertexAttribType, |
| 210 kVec4f_GrVertexAttribType, | 210 kVec4f_GrVertexAttribType, |
| 211 | 211 |
| 212 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage | 212 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage |
| 213 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors | 213 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors |
| 214 | 214 |
| 215 kVec2us_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinate
s | 215 kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates |
| 216 | 216 |
| 217 kInt_GrVertexAttribType, | 217 kInt_GrVertexAttribType, |
| 218 kUint_GrVertexAttribType, | 218 kUint_GrVertexAttribType, |
| 219 | 219 |
| 220 kLast_GrVertexAttribType = kUint_GrVertexAttribType | 220 kLast_GrVertexAttribType = kUint_GrVertexAttribType |
| 221 }; | 221 }; |
| 222 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; | 222 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; |
| 223 | 223 |
| 224 /** | 224 /** |
| 225 * Returns the vector size of the type. | 225 * Returns the vector size of the type. |
| 226 */ | 226 */ |
| 227 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { | 227 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { |
| 228 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); | 228 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); |
| 229 static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2, 1, 1 }; | 229 static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2, 1, 1 }; |
| 230 return kCounts[type]; | 230 return kCounts[type]; |
| 231 | 231 |
| 232 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); | 232 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| 233 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); | 233 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
| 234 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 234 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 235 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 235 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 236 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 236 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| 237 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 237 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| 238 GR_STATIC_ASSERT(6 == kVec2us_GrVertexAttribType); | 238 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); |
| 239 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); | 239 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); |
| 240 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); | 240 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); |
| 241 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); | 241 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); |
| 242 } | 242 } |
| 243 | 243 |
| 244 /** | 244 /** |
| 245 * Returns the size of the attrib type in bytes. | 245 * Returns the size of the attrib type in bytes. |
| 246 */ | 246 */ |
| 247 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { | 247 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { |
| 248 static const size_t kSizes[] = { | 248 static const size_t kSizes[] = { |
| 249 sizeof(float), // kFloat_GrVertexAttribType | 249 sizeof(float), // kFloat_GrVertexAttribType |
| 250 2*sizeof(float), // kVec2f_GrVertexAttribType | 250 2*sizeof(float), // kVec2f_GrVertexAttribType |
| 251 3*sizeof(float), // kVec3f_GrVertexAttribType | 251 3*sizeof(float), // kVec3f_GrVertexAttribType |
| 252 4*sizeof(float), // kVec4f_GrVertexAttribType | 252 4*sizeof(float), // kVec4f_GrVertexAttribType |
| 253 1*sizeof(char), // kUByte_GrVertexAttribType | 253 1*sizeof(char), // kUByte_GrVertexAttribType |
| 254 4*sizeof(char), // kVec4ub_GrVertexAttribType | 254 4*sizeof(char), // kVec4ub_GrVertexAttribType |
| 255 2*sizeof(int16_t), // kVec2us_GrVertexAttribType | 255 2*sizeof(int16_t), // kVec2s_GrVertexAttribType |
| 256 sizeof(int32_t), // kInt_GrVertexAttribType | 256 sizeof(int32_t), // kInt_GrVertexAttribType |
| 257 sizeof(uint32_t) // kUint_GrVertexAttribType | 257 sizeof(uint32_t) // kUint_GrVertexAttribType |
| 258 }; | 258 }; |
| 259 return kSizes[type]; | 259 return kSizes[type]; |
| 260 | 260 |
| 261 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); | 261 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| 262 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); | 262 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
| 263 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 263 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 264 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 264 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 265 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 265 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| 266 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 266 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| 267 GR_STATIC_ASSERT(6 == kVec2us_GrVertexAttribType); | 267 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); |
| 268 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); | 268 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); |
| 269 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); | 269 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); |
| 270 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); | 270 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); |
| 271 } | 271 } |
| 272 | 272 |
| 273 /** | 273 /** |
| 274 * Is the attrib type integral? | 274 * Is the attrib type integral? |
| 275 */ | 275 */ |
| 276 static inline bool GrVertexAttribTypeIsIntType(GrVertexAttribType type) { | 276 static inline bool GrVertexAttribTypeIsIntType(GrVertexAttribType type) { |
| 277 SkASSERT(type >= 0 && type < static_cast<GrVertexAttribType>(kGrVertexAttrib
TypeCount)); | 277 SkASSERT(type >= 0 && type < static_cast<GrVertexAttribType>(kGrVertexAttrib
TypeCount)); |
| 278 return type >= kInt_GrVertexAttribType; | 278 return type >= kInt_GrVertexAttribType; |
| 279 | 279 |
| 280 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); | 280 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| 281 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); | 281 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
| 282 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 282 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 283 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 283 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 284 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 284 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| 285 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 285 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| 286 GR_STATIC_ASSERT(6 == kVec2us_GrVertexAttribType); | 286 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); |
| 287 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); | 287 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); |
| 288 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); | 288 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); |
| 289 GR_STATIC_ASSERT(9 == kGrVertexAttribTypeCount); | 289 GR_STATIC_ASSERT(9 == kGrVertexAttribTypeCount); |
| 290 } | 290 } |
| 291 | 291 |
| 292 /** | 292 /** |
| 293 * converts a GrVertexAttribType to a GrSLType | 293 * converts a GrVertexAttribType to a GrSLType |
| 294 */ | 294 */ |
| 295 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { | 295 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { |
| 296 switch (type) { | 296 switch (type) { |
| 297 default: | 297 default: |
| 298 SkFAIL("Unsupported type conversion"); | 298 SkFAIL("Unsupported type conversion"); |
| 299 return kVoid_GrSLType; | 299 return kVoid_GrSLType; |
| 300 case kUByte_GrVertexAttribType: | 300 case kUByte_GrVertexAttribType: |
| 301 case kFloat_GrVertexAttribType: | 301 case kFloat_GrVertexAttribType: |
| 302 return kFloat_GrSLType; | 302 return kFloat_GrSLType; |
| 303 case kVec2us_GrVertexAttribType: | 303 case kVec2s_GrVertexAttribType: |
| 304 case kVec2f_GrVertexAttribType: | 304 case kVec2f_GrVertexAttribType: |
| 305 return kVec2f_GrSLType; | 305 return kVec2f_GrSLType; |
| 306 case kVec3f_GrVertexAttribType: | 306 case kVec3f_GrVertexAttribType: |
| 307 return kVec3f_GrSLType; | 307 return kVec3f_GrSLType; |
| 308 case kVec4ub_GrVertexAttribType: | 308 case kVec4ub_GrVertexAttribType: |
| 309 case kVec4f_GrVertexAttribType: | 309 case kVec4f_GrVertexAttribType: |
| 310 return kVec4f_GrSLType; | 310 return kVec4f_GrSLType; |
| 311 case kInt_GrVertexAttribType: | 311 case kInt_GrVertexAttribType: |
| 312 return kInt_GrSLType; | 312 return kInt_GrSLType; |
| 313 case kUint_GrVertexAttribType: | 313 case kUint_GrVertexAttribType: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // Takes a pointer to a GrCaps, and will suppress prints if required | 405 // Takes a pointer to a GrCaps, and will suppress prints if required |
| 406 #define GrCapsDebugf(caps, ...) \ | 406 #define GrCapsDebugf(caps, ...) \ |
| 407 if (!caps->suppressPrints()) { \ | 407 if (!caps->suppressPrints()) { \ |
| 408 SkDebugf(__VA_ARGS__); \ | 408 SkDebugf(__VA_ARGS__); \ |
| 409 } | 409 } |
| 410 #else | 410 #else |
| 411 #define GrCapsDebugf(caps, ...) | 411 #define GrCapsDebugf(caps, ...) |
| 412 #endif | 412 #endif |
| 413 | 413 |
| 414 #endif | 414 #endif |
| OLD | NEW |