| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); | 113 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| 114 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); | 114 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
| 115 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 115 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 116 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 116 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 117 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 117 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| 118 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 118 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| 119 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); | 119 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); |
| 120 } | 120 } |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * Semantic bindings for vertex attributes. kEffect means that the attribute is
input to a | 123 * converts a GrVertexAttribType to a GrSLType |
| 124 * GrProcessor. Each binding other than kEffect may not appear more than once in
the current set of | |
| 125 * attributes. kPosition must be appear for exactly one attribute. | |
| 126 */ | 124 */ |
| 127 enum GrVertexAttribBinding { | 125 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { |
| 128 kPosition_GrVertexAttribBinding, // required, must have vector count of 2 | 126 switch (type) { |
| 129 kLocalCoord_GrVertexAttribBinding, // must have vector count of 2 | 127 default: |
| 130 kColor_GrVertexAttribBinding, // must have vector count of 4 | 128 SkFAIL("Unsupported type conversion"); |
| 131 kCoverage_GrVertexAttribBinding, // must have a single byte | 129 case kUByte_GrVertexAttribType: |
| 132 | 130 case kFloat_GrVertexAttribType: |
| 133 kLastFixedFunction_GrVertexAttribBinding = kCoverage_GrVertexAttribBinding, | 131 return kFloat_GrSLType; |
| 134 | 132 case kVec2f_GrVertexAttribType: |
| 135 kGeometryProcessor_GrVertexAttribBinding, // vector length must agree w
ith | 133 return kVec2f_GrSLType; |
| 136 // GrProcessor::vertexAttribType() for e
ach effect input to | 134 case kVec3f_GrVertexAttribType: |
| 137 // which the attribute is mapped by GrDr
awState::setEffect() | 135 return kVec3f_GrSLType; |
| 138 kLast_GrVertexAttribBinding = kGeometryProcessor_GrVertexAttribBinding | 136 case kVec4ub_GrVertexAttribType: |
| 139 }; | 137 case kVec4f_GrVertexAttribType: |
| 140 | 138 return kVec4f_GrSLType; |
| 141 static const int kGrVertexAttribBindingCnt = kLast_GrVertexAttribBinding + 1; | 139 } |
| 142 static const int kGrFixedFunctionVertexAttribBindingCnt = | |
| 143 kLastFixedFunction_GrVertexAttribBinding + 1; | |
| 144 | |
| 145 static inline int GrFixedFunctionVertexAttribVectorCount(GrVertexAttribBinding b
inding) { | |
| 146 SkASSERT(binding >= 0 && binding < kGrFixedFunctionVertexAttribBindingCnt); | |
| 147 static const int kVecCounts[] = { 2, 2, 4, 1 }; | |
| 148 | |
| 149 return kVecCounts[binding]; | |
| 150 | |
| 151 GR_STATIC_ASSERT(0 == kPosition_GrVertexAttribBinding); | |
| 152 GR_STATIC_ASSERT(1 == kLocalCoord_GrVertexAttribBinding); | |
| 153 GR_STATIC_ASSERT(2 == kColor_GrVertexAttribBinding); | |
| 154 GR_STATIC_ASSERT(3 == kCoverage_GrVertexAttribBinding); | |
| 155 GR_STATIC_ASSERT(kGrFixedFunctionVertexAttribBindingCnt == SK_ARRAY_COUNT(kV
ecCounts)); | |
| 156 } | 140 } |
| 157 | 141 |
| 158 struct GrVertexAttrib { | |
| 159 inline void set(GrVertexAttribType type, size_t offset, GrVertexAttribBindin
g binding) { | |
| 160 fType = type; | |
| 161 fOffset = offset; | |
| 162 fBinding = binding; | |
| 163 } | |
| 164 bool operator==(const GrVertexAttrib& other) const { | |
| 165 return fType == other.fType && fOffset == other.fOffset && fBinding == o
ther.fBinding; | |
| 166 }; | |
| 167 bool operator!=(const GrVertexAttrib& other) const { return !(*this == other
); } | |
| 168 | |
| 169 GrVertexAttribType fType; | |
| 170 size_t fOffset; | |
| 171 GrVertexAttribBinding fBinding; | |
| 172 }; | |
| 173 | |
| 174 template <int N> class GrVertexAttribArray : public SkSTArray<N, GrVertexAttrib,
true> {}; | |
| 175 | |
| 176 ////////////////////////////////////////////////////////////////////////////// | 142 ////////////////////////////////////////////////////////////////////////////// |
| 177 | 143 |
| 178 /** | 144 /** |
| 179 * We have coverage effects that clip rendering to the edge of some geometric pri
mitive. | 145 * We have coverage effects that clip rendering to the edge of some geometric pri
mitive. |
| 180 * This enum specifies how that clipping is performed. Not all factories that tak
e a | 146 * This enum specifies how that clipping is performed. Not all factories that tak
e a |
| 181 * GrProcessorEdgeType will succeed with all values and it is up to the caller to
check for | 147 * GrProcessorEdgeType will succeed with all values and it is up to the caller to
check for |
| 182 * a NULL return. | 148 * a NULL return. |
| 183 */ | 149 */ |
| 184 enum GrPrimitiveEdgeType { | 150 enum GrPrimitiveEdgeType { |
| 185 kFillBW_GrProcessorEdgeType, | 151 kFillBW_GrProcessorEdgeType, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 /** | 191 /** |
| 226 * Indicates the type of pending IO operations that can be recorded for gpu reso
urces. | 192 * Indicates the type of pending IO operations that can be recorded for gpu reso
urces. |
| 227 */ | 193 */ |
| 228 enum GrIOType { | 194 enum GrIOType { |
| 229 kRead_GrIOType, | 195 kRead_GrIOType, |
| 230 kWrite_GrIOType, | 196 kWrite_GrIOType, |
| 231 kRW_GrIOType | 197 kRW_GrIOType |
| 232 }; | 198 }; |
| 233 | 199 |
| 234 #endif | 200 #endif |
| OLD | NEW |