| 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 GrGLShaderVar_DEFINED | 8 #ifndef GrGLShaderVar_DEFINED |
| 9 #define GrGLShaderVar_DEFINED | 9 #define GrGLShaderVar_DEFINED |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 /** | 30 /** |
| 31 * Defaults to a float with no precision specifier | 31 * Defaults to a float with no precision specifier |
| 32 */ | 32 */ |
| 33 GrGLShaderVar() | 33 GrGLShaderVar() |
| 34 : GrShaderVar() | 34 : GrShaderVar() |
| 35 , fOrigin(kDefault_Origin) | 35 , fOrigin(kDefault_Origin) |
| 36 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { | 36 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 GrGLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray, | 39 GrGLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray, |
| 40 Precision precision = kDefault_Precision) | 40 GrSLPrecision precision = kDefault_GrSLPrecision) |
| 41 : GrShaderVar(name, type, arrayCount, precision) | 41 : GrShaderVar(name, type, arrayCount, precision) |
| 42 , fOrigin(kDefault_Origin) | 42 , fOrigin(kDefault_Origin) |
| 43 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { | 43 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { |
| 44 SkASSERT(kVoid_GrSLType != type); | 44 SkASSERT(kVoid_GrSLType != type); |
| 45 fOrigin = kDefault_Origin; | 45 fOrigin = kDefault_Origin; |
| 46 fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS; | 46 fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS; |
| 47 } | 47 } |
| 48 | 48 |
| 49 GrGLShaderVar(const char* name, GrSLType type, TypeModifier typeModifier, | 49 GrGLShaderVar(const char* name, GrSLType type, TypeModifier typeModifier, |
| 50 int arrayCount = kNonArray, Precision precision = kDefault_Pre
cision) | 50 int arrayCount = kNonArray, GrSLPrecision precision = kDefault
_GrSLPrecision) |
| 51 : GrShaderVar(name, type, typeModifier, arrayCount, precision) | 51 : GrShaderVar(name, type, typeModifier, arrayCount, precision) |
| 52 , fOrigin(kDefault_Origin) | 52 , fOrigin(kDefault_Origin) |
| 53 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { | 53 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { |
| 54 SkASSERT(kVoid_GrSLType != type); | 54 SkASSERT(kVoid_GrSLType != type); |
| 55 } | 55 } |
| 56 | 56 |
| 57 GrGLShaderVar(const GrShaderVar& var) | 57 GrGLShaderVar(const GrShaderVar& var) |
| 58 : GrShaderVar(var) | 58 : GrShaderVar(var) |
| 59 , fOrigin(kDefault_Origin) | 59 , fOrigin(kDefault_Origin) |
| 60 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { | 60 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 kNonArray = 0, // not an array | 76 kNonArray = 0, // not an array |
| 77 kUnsizedArray = -1, // an unsized array (declared with []) | 77 kUnsizedArray = -1, // an unsized array (declared with []) |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Sets as a non-array. | 81 * Sets as a non-array. |
| 82 */ | 82 */ |
| 83 void set(GrSLType type, | 83 void set(GrSLType type, |
| 84 TypeModifier typeModifier, | 84 TypeModifier typeModifier, |
| 85 const SkString& name, | 85 const SkString& name, |
| 86 Precision precision = kDefault_Precision, | 86 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 87 Origin origin = kDefault_Origin, | 87 Origin origin = kDefault_Origin, |
| 88 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 88 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
| 89 SkASSERT(kVoid_GrSLType != type); | 89 SkASSERT(kVoid_GrSLType != type); |
| 90 INHERITED::set(type, typeModifier, name, precision); | 90 INHERITED::set(type, typeModifier, name, precision); |
| 91 fOrigin = origin; | 91 fOrigin = origin; |
| 92 fUseUniformFloatArrays = useUniformFloatArrays; | 92 fUseUniformFloatArrays = useUniformFloatArrays; |
| 93 } | 93 } |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * Sets as a non-array. | 96 * Sets as a non-array. |
| 97 */ | 97 */ |
| 98 void set(GrSLType type, | 98 void set(GrSLType type, |
| 99 TypeModifier typeModifier, | 99 TypeModifier typeModifier, |
| 100 const char* name, | 100 const char* name, |
| 101 Precision precision = kDefault_Precision, | 101 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 102 Origin origin = kDefault_Origin, | 102 Origin origin = kDefault_Origin, |
| 103 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 103 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
| 104 SkASSERT(kVoid_GrSLType != type); | 104 SkASSERT(kVoid_GrSLType != type); |
| 105 INHERITED::set(type, typeModifier, name, precision); | 105 INHERITED::set(type, typeModifier, name, precision); |
| 106 fOrigin = origin; | 106 fOrigin = origin; |
| 107 fUseUniformFloatArrays = useUniformFloatArrays; | 107 fUseUniformFloatArrays = useUniformFloatArrays; |
| 108 } | 108 } |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * Set all var options | 111 * Set all var options |
| 112 */ | 112 */ |
| 113 void set(GrSLType type, | 113 void set(GrSLType type, |
| 114 TypeModifier typeModifier, | 114 TypeModifier typeModifier, |
| 115 const SkString& name, | 115 const SkString& name, |
| 116 int count, | 116 int count, |
| 117 Precision precision = kDefault_Precision, | 117 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 118 Origin origin = kDefault_Origin, | 118 Origin origin = kDefault_Origin, |
| 119 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 119 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
| 120 SkASSERT(kVoid_GrSLType != type); | 120 SkASSERT(kVoid_GrSLType != type); |
| 121 INHERITED::set(type, typeModifier, name, count, precision); | 121 INHERITED::set(type, typeModifier, name, count, precision); |
| 122 fOrigin = origin; | 122 fOrigin = origin; |
| 123 fUseUniformFloatArrays = useUniformFloatArrays; | 123 fUseUniformFloatArrays = useUniformFloatArrays; |
| 124 } | 124 } |
| 125 | 125 |
| 126 /** | 126 /** |
| 127 * Set all var options | 127 * Set all var options |
| 128 */ | 128 */ |
| 129 void set(GrSLType type, | 129 void set(GrSLType type, |
| 130 TypeModifier typeModifier, | 130 TypeModifier typeModifier, |
| 131 const char* name, | 131 const char* name, |
| 132 int count, | 132 int count, |
| 133 Precision precision = kDefault_Precision, | 133 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 134 Origin origin = kDefault_Origin, | 134 Origin origin = kDefault_Origin, |
| 135 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 135 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
| 136 SkASSERT(kVoid_GrSLType != type); | 136 SkASSERT(kVoid_GrSLType != type); |
| 137 INHERITED::set(type, typeModifier, name, count, precision); | 137 INHERITED::set(type, typeModifier, name, count, precision); |
| 138 fOrigin = origin; | 138 fOrigin = origin; |
| 139 fUseUniformFloatArrays = useUniformFloatArrays; | 139 fUseUniformFloatArrays = useUniformFloatArrays; |
| 140 } | 140 } |
| 141 | 141 |
| 142 /** | 142 /** |
| 143 * Get the origin of the var | 143 * Get the origin of the var |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 fUseUniformFloatArrays ? "" : ".x"); | 190 fUseUniformFloatArrays ? "" : ".x"); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void appendArrayAccess(const char* indexName, SkString* out) const { | 193 void appendArrayAccess(const char* indexName, SkString* out) const { |
| 194 out->appendf("%s[%s]%s", | 194 out->appendf("%s[%s]%s", |
| 195 this->getName().c_str(), | 195 this->getName().c_str(), |
| 196 indexName, | 196 indexName, |
| 197 fUseUniformFloatArrays ? "" : ".x"); | 197 fUseUniformFloatArrays ? "" : ".x"); |
| 198 } | 198 } |
| 199 | 199 |
| 200 static const char* PrecisionString(Precision p, GrGLStandard standard) { | 200 static const char* PrecisionString(GrSLPrecision p, GrGLStandard standard) { |
| 201 // Desktop GLSL has added precision qualifiers but they don't do anythin
g. | 201 // Desktop GLSL has added precision qualifiers but they don't do anythin
g. |
| 202 if (kGLES_GrGLStandard == standard) { | 202 if (kGLES_GrGLStandard == standard) { |
| 203 switch (p) { | 203 switch (p) { |
| 204 case kLow_Precision: | 204 case kLow_GrSLPrecision: |
| 205 return "lowp "; | 205 return "lowp "; |
| 206 case kMedium_Precision: | 206 case kMedium_GrSLPrecision: |
| 207 return "mediump "; | 207 return "mediump "; |
| 208 case kHigh_Precision: | 208 case kHigh_GrSLPrecision: |
| 209 return "highp "; | 209 return "highp "; |
| 210 default: | 210 default: |
| 211 SkFAIL("Unexpected precision type."); | 211 SkFAIL("Unexpected precision type."); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 return ""; | 214 return ""; |
| 215 } | 215 } |
| 216 | 216 |
| 217 private: | 217 private: |
| 218 static const char* TypeModifierString(TypeModifier t, GrGLSLGeneration gen)
{ | 218 static const char* TypeModifierString(TypeModifier t, GrGLSLGeneration gen)
{ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 241 | 241 |
| 242 Origin fOrigin; | 242 Origin fOrigin; |
| 243 /// Work around driver bugs on some hardware that don't correctly | 243 /// Work around driver bugs on some hardware that don't correctly |
| 244 /// support uniform float [] | 244 /// support uniform float [] |
| 245 bool fUseUniformFloatArrays; | 245 bool fUseUniformFloatArrays; |
| 246 | 246 |
| 247 typedef GrShaderVar INHERITED; | 247 typedef GrShaderVar INHERITED; |
| 248 }; | 248 }; |
| 249 | 249 |
| 250 #endif | 250 #endif |
| OLD | NEW |