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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 static inline GrSLType GrSLFloatVectorType(int count) { | 53 static inline GrSLType GrSLFloatVectorType(int count) { |
54 SkASSERT(count > 0 && count <= 4); | 54 SkASSERT(count > 0 && count <= 4); |
55 return (GrSLType)(count); | 55 return (GrSLType)(count); |
56 | 56 |
57 GR_STATIC_ASSERT(kFloat_GrSLType == 1); | 57 GR_STATIC_ASSERT(kFloat_GrSLType == 1); |
58 GR_STATIC_ASSERT(kVec2f_GrSLType == 2); | 58 GR_STATIC_ASSERT(kVec2f_GrSLType == 2); |
59 GR_STATIC_ASSERT(kVec3f_GrSLType == 3); | 59 GR_STATIC_ASSERT(kVec3f_GrSLType == 3); |
60 GR_STATIC_ASSERT(kVec4f_GrSLType == 4); | 60 GR_STATIC_ASSERT(kVec4f_GrSLType == 4); |
61 } | 61 } |
62 | 62 |
| 63 ////////////////////////////////////////////////////////////////////////////// |
| 64 |
63 /** | 65 /** |
64 * Types used to describe format of vertices in arrays. | 66 * Types used to describe format of vertices in arrays. |
65 */ | 67 */ |
66 enum GrVertexAttribType { | 68 enum GrVertexAttribType { |
67 kFloat_GrVertexAttribType = 0, | 69 kFloat_GrVertexAttribType = 0, |
68 kVec2f_GrVertexAttribType, | 70 kVec2f_GrVertexAttribType, |
69 kVec3f_GrVertexAttribType, | 71 kVec3f_GrVertexAttribType, |
70 kVec4f_GrVertexAttribType, | 72 kVec4f_GrVertexAttribType, |
71 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors | 73 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors |
72 | 74 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 }; | 161 }; |
160 bool operator!=(const GrVertexAttrib& other) const { return !(*this == other
); } | 162 bool operator!=(const GrVertexAttrib& other) const { return !(*this == other
); } |
161 | 163 |
162 GrVertexAttribType fType; | 164 GrVertexAttribType fType; |
163 size_t fOffset; | 165 size_t fOffset; |
164 GrVertexAttribBinding fBinding; | 166 GrVertexAttribBinding fBinding; |
165 }; | 167 }; |
166 | 168 |
167 template <int N> class GrVertexAttribArray : public SkSTArray<N, GrVertexAttrib,
true> {}; | 169 template <int N> class GrVertexAttribArray : public SkSTArray<N, GrVertexAttrib,
true> {}; |
168 | 170 |
| 171 ////////////////////////////////////////////////////////////////////////////// |
| 172 |
| 173 /** |
| 174 * We have coverage effects that clip rendering to the edge of some geometric pri
mitive. |
| 175 * This enum specifies how that clipping is performed. Not all factories that tak
e a |
| 176 * GrEffectEdgeType will succeed with all values and it is up to the caller to ch
eck for |
| 177 * a NULL return. |
| 178 */ |
| 179 enum GrEffectEdgeType { |
| 180 kFillBW_GrEffectEdgeType, |
| 181 kFillAA_GrEffectEdgeType, |
| 182 kInverseFillBW_GrEffectEdgeType, |
| 183 kInverseFillAA_GrEffectEdgeType, |
| 184 kHairlineAA_GrEffectEdgeType, |
| 185 |
| 186 kLast_GrEffectEdgeType = kHairlineAA_GrEffectEdgeType |
| 187 }; |
| 188 |
| 189 static const int kGrEffectEdgeTypeCnt = kLast_GrEffectEdgeType + 1; |
| 190 |
| 191 static inline bool GrEffectEdgeTypeIsFill(const GrEffectEdgeType edgeType) { |
| 192 return (kFillAA_GrEffectEdgeType == edgeType || kFillBW_GrEffectEdgeType ==
edgeType); |
| 193 } |
| 194 |
| 195 static inline bool GrEffectEdgeTypeIsInverseFill(const GrEffectEdgeType edgeType
) { |
| 196 return (kInverseFillAA_GrEffectEdgeType == edgeType || |
| 197 kInverseFillBW_GrEffectEdgeType == edgeType); |
| 198 } |
| 199 |
| 200 static inline bool GrEffectEdgeTypeIsAA(const GrEffectEdgeType edgeType) { |
| 201 return (kFillBW_GrEffectEdgeType != edgeType && kInverseFillBW_GrEffectEdgeT
ype != edgeType); |
| 202 } |
| 203 |
| 204 static inline GrEffectEdgeType GrInvertEffectEdgeType(const GrEffectEdgeType edg
eType) { |
| 205 switch (edgeType) { |
| 206 case kFillBW_GrEffectEdgeType: |
| 207 return kInverseFillBW_GrEffectEdgeType; |
| 208 case kFillAA_GrEffectEdgeType: |
| 209 return kInverseFillAA_GrEffectEdgeType; |
| 210 case kInverseFillBW_GrEffectEdgeType: |
| 211 return kFillBW_GrEffectEdgeType; |
| 212 case kInverseFillAA_GrEffectEdgeType: |
| 213 return kFillAA_GrEffectEdgeType; |
| 214 case kHairlineAA_GrEffectEdgeType: |
| 215 GrCrash("Hairline fill isn't invertible."); |
| 216 } |
| 217 return kFillAA_GrEffectEdgeType; // suppress warning. |
| 218 } |
| 219 |
169 #endif | 220 #endif |
OLD | NEW |