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 GrGLSLShaderVar_DEFINED | 8 #ifndef GrGLSLShaderVar_DEFINED |
9 #define GrGLSLShaderVar_DEFINED | 9 #define GrGLSLShaderVar_DEFINED |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecisio
n(fType)); | 167 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecisio
n(fType)); |
168 if (!fLayoutQualifier.isEmpty()) { | 168 if (!fLayoutQualifier.isEmpty()) { |
169 out->appendf("layout(%s) ", fLayoutQualifier.c_str()); | 169 out->appendf("layout(%s) ", fLayoutQualifier.c_str()); |
170 } | 170 } |
171 out->append(fExtraModifiers); | 171 out->append(fExtraModifiers); |
172 if (this->getTypeModifier() != kNone_TypeModifier) { | 172 if (this->getTypeModifier() != kNone_TypeModifier) { |
173 out->append(TypeModifierString(glslCaps, this->getTypeModifier())); | 173 out->append(TypeModifierString(glslCaps, this->getTypeModifier())); |
174 out->append(" "); | 174 out->append(" "); |
175 } | 175 } |
176 GrSLType effectiveType = this->getType(); | 176 GrSLType effectiveType = this->getType(); |
177 if (GrSLTypeAcceptsPrecision(effectiveType)) { | 177 if (glslCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effec
tiveType)) { |
178 out->append(PrecisionString(glslCaps, fPrecision)); | 178 // Desktop GLSL has added precision qualifiers but they don't do any
thing. |
| 179 out->appendf("%s ", GrGLSLPrecisionString(fPrecision)); |
179 } | 180 } |
180 if (this->isArray()) { | 181 if (this->isArray()) { |
181 if (this->isUnsizedArray()) { | 182 if (this->isUnsizedArray()) { |
182 out->appendf("%s %s[]", | 183 out->appendf("%s %s[]", |
183 GrGLSLTypeString(effectiveType), | 184 GrGLSLTypeString(effectiveType), |
184 this->getName().c_str()); | 185 this->getName().c_str()); |
185 } else { | 186 } else { |
186 SkASSERT(this->getArrayCount() > 0); | 187 SkASSERT(this->getArrayCount() > 0); |
187 out->appendf("%s %s[%d]", | 188 out->appendf("%s %s[%d]", |
188 GrGLSLTypeString(effectiveType), | 189 GrGLSLTypeString(effectiveType), |
(...skipping 14 matching lines...) Expand all Loading... |
203 fUseUniformFloatArrays ? "" : ".x"); | 204 fUseUniformFloatArrays ? "" : ".x"); |
204 } | 205 } |
205 | 206 |
206 void appendArrayAccess(const char* indexName, SkString* out) const { | 207 void appendArrayAccess(const char* indexName, SkString* out) const { |
207 out->appendf("%s[%s]%s", | 208 out->appendf("%s[%s]%s", |
208 this->getName().c_str(), | 209 this->getName().c_str(), |
209 indexName, | 210 indexName, |
210 fUseUniformFloatArrays ? "" : ".x"); | 211 fUseUniformFloatArrays ? "" : ".x"); |
211 } | 212 } |
212 | 213 |
213 static const char* PrecisionString(const GrGLSLCaps* glslCaps, GrSLPrecision
p) { | |
214 // Desktop GLSL has added precision qualifiers but they don't do anythin
g. | |
215 if (glslCaps->usesPrecisionModifiers()) { | |
216 switch (p) { | |
217 case kLow_GrSLPrecision: | |
218 return "lowp "; | |
219 case kMedium_GrSLPrecision: | |
220 return "mediump "; | |
221 case kHigh_GrSLPrecision: | |
222 return "highp "; | |
223 default: | |
224 SkFAIL("Unexpected precision type."); | |
225 } | |
226 } | |
227 return ""; | |
228 } | |
229 | |
230 private: | 214 private: |
231 static const char* TypeModifierString(const GrGLSLCaps* glslCaps, TypeModifi
er t) { | 215 static const char* TypeModifierString(const GrGLSLCaps* glslCaps, TypeModifi
er t) { |
232 GrGLSLGeneration gen = glslCaps->generation(); | 216 GrGLSLGeneration gen = glslCaps->generation(); |
233 switch (t) { | 217 switch (t) { |
234 case kNone_TypeModifier: | 218 case kNone_TypeModifier: |
235 return ""; | 219 return ""; |
236 case kIn_TypeModifier: | 220 case kIn_TypeModifier: |
237 return "in"; | 221 return "in"; |
238 case kInOut_TypeModifier: | 222 case kInOut_TypeModifier: |
239 return "inout"; | 223 return "inout"; |
(...skipping 17 matching lines...) Expand all Loading... |
257 /// support uniform float [] | 241 /// support uniform float [] |
258 bool fUseUniformFloatArrays; | 242 bool fUseUniformFloatArrays; |
259 | 243 |
260 SkString fLayoutQualifier; | 244 SkString fLayoutQualifier; |
261 SkString fExtraModifiers; | 245 SkString fExtraModifiers; |
262 | 246 |
263 typedef GrShaderVar INHERITED; | 247 typedef GrShaderVar INHERITED; |
264 }; | 248 }; |
265 | 249 |
266 #endif | 250 #endif |
OLD | NEW |