| 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 | 13 |
| 14 /** | 14 /** |
| 15 * Types of shader-language-specific boxed variables we can create. (Currently o
nly GrGLShaderVars, | 15 * Types of shader-language-specific boxed variables we can create. (Currently o
nly GrGLShaderVars, |
| 16 * but should be applicable to other shader languages.) | 16 * but should be applicable to other shader languages.) |
| 17 */ | 17 */ |
| 18 enum GrSLType { | 18 enum GrSLType { |
| 19 kVoid_GrSLType, | 19 kVoid_GrSLType, |
| 20 kFloat_GrSLType, | 20 kFloat_GrSLType, |
| 21 kVec2f_GrSLType, | 21 kVec2f_GrSLType, |
| 22 kVec3f_GrSLType, | 22 kVec3f_GrSLType, |
| 23 kVec4f_GrSLType, | 23 kVec4f_GrSLType, |
| 24 kMat33f_GrSLType, | 24 kMat33f_GrSLType, |
| 25 kMat44f_GrSLType, | 25 kMat44f_GrSLType, |
| 26 kSampler2D_GrSLType, | 26 kSampler2D_GrSLType, |
| 27 kSampler3D_GrSLType, |
| 27 | 28 |
| 28 kLast_GrSLType = kSampler2D_GrSLType | 29 kLast_GrSLType = kSampler3D_GrSLType |
| 29 }; | 30 }; |
| 30 static const int kGrSLTypeCount = kLast_GrSLType + 1; | 31 static const int kGrSLTypeCount = kLast_GrSLType + 1; |
| 31 | 32 |
| 32 /** | 33 /** |
| 33 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample
rs. | 34 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample
rs. |
| 34 */ | 35 */ |
| 35 static inline int GrSLTypeVectorCount(GrSLType type) { | 36 static inline int GrSLTypeVectorCount(GrSLType type) { |
| 36 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); | 37 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); |
| 37 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1 }; | 38 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1 }; |
| 38 return kCounts[type]; | 39 return kCounts[type]; |
| 39 | 40 |
| 40 GR_STATIC_ASSERT(0 == kVoid_GrSLType); | 41 GR_STATIC_ASSERT(0 == kVoid_GrSLType); |
| 41 GR_STATIC_ASSERT(1 == kFloat_GrSLType); | 42 GR_STATIC_ASSERT(1 == kFloat_GrSLType); |
| 42 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); | 43 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); |
| 43 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); | 44 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); |
| 44 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); | 45 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); |
| 45 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); | 46 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); |
| 46 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); | 47 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); |
| 47 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); | 48 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); |
| 49 GR_STATIC_ASSERT(8 == kSampler3D_GrSLType); |
| 48 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); | 50 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); |
| 49 } | 51 } |
| 50 | 52 |
| 51 /** Return the type enum for a vector of floats of length n (1..4), | 53 /** Return the type enum for a vector of floats of length n (1..4), |
| 52 e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */ | 54 e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */ |
| 53 static inline GrSLType GrSLFloatVectorType(int count) { | 55 static inline GrSLType GrSLFloatVectorType(int count) { |
| 54 SkASSERT(count > 0 && count <= 4); | 56 SkASSERT(count > 0 && count <= 4); |
| 55 return (GrSLType)(count); | 57 return (GrSLType)(count); |
| 56 | 58 |
| 57 GR_STATIC_ASSERT(kFloat_GrSLType == 1); | 59 GR_STATIC_ASSERT(kFloat_GrSLType == 1); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return kFillBW_GrEffectEdgeType; | 213 return kFillBW_GrEffectEdgeType; |
| 212 case kInverseFillAA_GrEffectEdgeType: | 214 case kInverseFillAA_GrEffectEdgeType: |
| 213 return kFillAA_GrEffectEdgeType; | 215 return kFillAA_GrEffectEdgeType; |
| 214 case kHairlineAA_GrEffectEdgeType: | 216 case kHairlineAA_GrEffectEdgeType: |
| 215 SkFAIL("Hairline fill isn't invertible."); | 217 SkFAIL("Hairline fill isn't invertible."); |
| 216 } | 218 } |
| 217 return kFillAA_GrEffectEdgeType; // suppress warning. | 219 return kFillAA_GrEffectEdgeType; // suppress warning. |
| 218 } | 220 } |
| 219 | 221 |
| 220 #endif | 222 #endif |
| OLD | NEW |