OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrGLSL_DEFINED | 8 #ifndef GrGLSL_DEFINED |
9 #define GrGLSL_DEFINED | 9 #define GrGLSL_DEFINED |
10 | 10 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } else if (kOnes_ExprType == fType) { | 190 } else if (kOnes_ExprType == fType) { |
191 return this->onesStr(); | 191 return this->onesStr(); |
192 } | 192 } |
193 SkASSERT(!fExpr.isEmpty()); // Empty expressions should not be used. | 193 SkASSERT(!fExpr.isEmpty()); // Empty expressions should not be used. |
194 return fExpr.c_str(); | 194 return fExpr.c_str(); |
195 } | 195 } |
196 | 196 |
197 static const char* zerosStr(); | 197 static const char* zerosStr(); |
198 static const char* onesStr(); | 198 static const char* onesStr(); |
199 | 199 |
| 200 bool isValid() const { |
| 201 return kFullExpr_ExprType != fType || !fExpr.isEmpty(); |
| 202 } |
| 203 |
200 private: | 204 private: |
201 GrGLSLExpr(const char format[], const char in0[]) | 205 GrGLSLExpr(const char format[], const char in0[]) |
202 : fType(kFullExpr_ExprType) { | 206 : fType(kFullExpr_ExprType) { |
203 fExpr.appendf(format, in0); | 207 fExpr.appendf(format, in0); |
204 } | 208 } |
205 | 209 |
206 GrGLSLExpr(const char format[], const char in0[], const char in1[]) | 210 GrGLSLExpr(const char format[], const char in0[], const char in1[]) |
207 : fType(kFullExpr_ExprType) { | 211 : fType(kFullExpr_ExprType) { |
208 fExpr.appendf(format, in0, in1); | 212 fExpr.appendf(format, in0, in1); |
209 } | 213 } |
210 | 214 |
211 GrGLSLExpr(const char format[], const char in0[], const char in1) | 215 GrGLSLExpr(const char format[], const char in0[], const char in1) |
212 : fType(kFullExpr_ExprType) { | 216 : fType(kFullExpr_ExprType) { |
213 fExpr.appendf(format, in0, in1); | 217 fExpr.appendf(format, in0, in1); |
214 } | 218 } |
215 | 219 |
216 /** Given an expression of vecM, cast it to vecN. */ | 220 /** Given an expression of vecM, cast it to vecN. */ |
217 template<int M> | 221 template<int M> |
218 static GrGLSLExpr<N> VectorCast(const GrGLSLExpr<M>&); | 222 static GrGLSLExpr<N> VectorCast(const GrGLSLExpr<M>&); |
219 | 223 |
220 bool isValid() const { | |
221 return kFullExpr_ExprType != fType || !fExpr.isEmpty(); | |
222 } | |
223 | |
224 static const char* expandComponentStr(); | 224 static const char* expandComponentStr(); |
225 static const char* castStr(); | 225 static const char* castStr(); |
226 | 226 |
227 | 227 |
228 SkString fExpr; | 228 SkString fExpr; |
229 enum ExprType { | 229 enum ExprType { |
230 kZeros_ExprType, | 230 kZeros_ExprType, |
231 kOnes_ExprType, | 231 kOnes_ExprType, |
232 kFullExpr_ExprType, | 232 kFullExpr_ExprType, |
233 }; | 233 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 /** | 272 /** |
273 * Does an inplace mul, *=, of vec4VarName by mulFactor. | 273 * Does an inplace mul, *=, of vec4VarName by mulFactor. |
274 * A semicolon and newline are added after the assignment. | 274 * A semicolon and newline are added after the assignment. |
275 */ | 275 */ |
276 void GrGLSLMulVarBy4f(SkString* outAppend, unsigned tabCnt, | 276 void GrGLSLMulVarBy4f(SkString* outAppend, unsigned tabCnt, |
277 const char* vec4VarName, const GrGLSLExpr<4>& mulFactor); | 277 const char* vec4VarName, const GrGLSLExpr<4>& mulFactor); |
278 | 278 |
279 #include "GrGLSL_impl.h" | 279 #include "GrGLSL_impl.h" |
280 | 280 |
281 #endif | 281 #endif |
OLD | NEW |