| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 const char* c_str() const { | 99 const char* c_str() const { |
| 100 if (kZeros_ExprType == fType) { | 100 if (kZeros_ExprType == fType) { |
| 101 return Self::ZerosStr(); | 101 return Self::ZerosStr(); |
| 102 } else if (kOnes_ExprType == fType) { | 102 } else if (kOnes_ExprType == fType) { |
| 103 return Self::OnesStr(); | 103 return Self::OnesStr(); |
| 104 } | 104 } |
| 105 SkASSERT(!fExpr.isEmpty()); // Empty expressions should not be used. | 105 SkASSERT(!fExpr.isEmpty()); // Empty expressions should not be used. |
| 106 return fExpr.c_str(); | 106 return fExpr.c_str(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool isValid() const { |
| 110 return kFullExpr_ExprType != fType || !fExpr.isEmpty(); |
| 111 } |
| 112 |
| 109 protected: | 113 protected: |
| 110 /** Constructs an invalid expression. | 114 /** Constructs an invalid expression. |
| 111 * Useful only as a return value from functions that never actually return | 115 * Useful only as a return value from functions that never actually return |
| 112 * this and instances that will be assigned to later. */ | 116 * this and instances that will be assigned to later. */ |
| 113 GrGLSLExpr() | 117 GrGLSLExpr() |
| 114 : fType(kFullExpr_ExprType) { | 118 : fType(kFullExpr_ExprType) { |
| 115 // The only constructor that is allowed to build an empty expression. | 119 // The only constructor that is allowed to build an empty expression. |
| 116 SkASSERT(!this->isValid()); | 120 SkASSERT(!this->isValid()); |
| 117 } | 121 } |
| 118 | 122 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 : fType(kFullExpr_ExprType) { | 163 : fType(kFullExpr_ExprType) { |
| 160 fExpr.appendf(format, in0); | 164 fExpr.appendf(format, in0); |
| 161 } | 165 } |
| 162 | 166 |
| 163 /** Constructs an expression from a string with two substitutions. */ | 167 /** Constructs an expression from a string with two substitutions. */ |
| 164 GrGLSLExpr(const char format[], const char in0[], const char in1[]) | 168 GrGLSLExpr(const char format[], const char in0[], const char in1[]) |
| 165 : fType(kFullExpr_ExprType) { | 169 : fType(kFullExpr_ExprType) { |
| 166 fExpr.appendf(format, in0, in1); | 170 fExpr.appendf(format, in0, in1); |
| 167 } | 171 } |
| 168 | 172 |
| 169 bool isValid() const { | |
| 170 return kFullExpr_ExprType != fType || !fExpr.isEmpty(); | |
| 171 } | |
| 172 | |
| 173 /** Returns expression casted to another type. | 173 /** Returns expression casted to another type. |
| 174 * Generic implementation that is called for non-trivial cases of casts. */ | 174 * Generic implementation that is called for non-trivial cases of casts. */ |
| 175 template <typename T> | 175 template <typename T> |
| 176 static Self VectorCastImpl(const T& other); | 176 static Self VectorCastImpl(const T& other); |
| 177 | 177 |
| 178 /** Returns a GLSL multiplication: component-wise or component-by-scalar. | 178 /** Returns a GLSL multiplication: component-wise or component-by-scalar. |
| 179 * The multiplication will be component-wise or multiply each component by a
scalar. | 179 * The multiplication will be component-wise or multiply each component by a
scalar. |
| 180 * | 180 * |
| 181 * The returned expression will compute the value of: | 181 * The returned expression will compute the value of: |
| 182 * vecN(in0.x * in1.x, ...) if dim(T0) == dim(T1) (component-wise) | 182 * vecN(in0.x * in1.x, ...) if dim(T0) == dim(T1) (component-wise) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 318 |
| 319 /** | 319 /** |
| 320 * Does an inplace mul, *=, of vec4VarName by mulFactor. | 320 * Does an inplace mul, *=, of vec4VarName by mulFactor. |
| 321 * A semicolon is added after the assignment. | 321 * A semicolon is added after the assignment. |
| 322 */ | 322 */ |
| 323 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor); | 323 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor); |
| 324 | 324 |
| 325 #include "GrGLSL_impl.h" | 325 #include "GrGLSL_impl.h" |
| 326 | 326 |
| 327 #endif | 327 #endif |
| OLD | NEW |