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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (this->getTypeModifier() != kNone_TypeModifier) { | 261 if (this->getTypeModifier() != kNone_TypeModifier) { |
262 out->append(TypeModifierString(this->getTypeModifier(), | 262 out->append(TypeModifierString(this->getTypeModifier(), |
263 ctxInfo.glslGeneration())); | 263 ctxInfo.glslGeneration())); |
264 out->append(" "); | 264 out->append(" "); |
265 } | 265 } |
266 out->append(PrecisionString(fPrecision, ctxInfo.binding())); | 266 out->append(PrecisionString(fPrecision, ctxInfo.binding())); |
267 GrSLType effectiveType = this->getType(); | 267 GrSLType effectiveType = this->getType(); |
268 if (this->isArray()) { | 268 if (this->isArray()) { |
269 if (this->isUnsizedArray()) { | 269 if (this->isUnsizedArray()) { |
270 out->appendf("%s %s[]", | 270 out->appendf("%s %s[]", |
271 TypeString(effectiveType), | 271 GrGLSLTypeString(effectiveType), |
272 this->getName().c_str()); | 272 this->getName().c_str()); |
273 } else { | 273 } else { |
274 GrAssert(this->getArrayCount() > 0); | 274 GrAssert(this->getArrayCount() > 0); |
275 out->appendf("%s %s[%d]", | 275 out->appendf("%s %s[%d]", |
276 TypeString(effectiveType), | 276 GrGLSLTypeString(effectiveType), |
277 this->getName().c_str(), | 277 this->getName().c_str(), |
278 this->getArrayCount()); | 278 this->getArrayCount()); |
279 } | 279 } |
280 } else { | 280 } else { |
281 out->appendf("%s %s", | 281 out->appendf("%s %s", |
282 TypeString(effectiveType), | 282 GrGLSLTypeString(effectiveType), |
283 this->getName().c_str()); | 283 this->getName().c_str()); |
284 } | 284 } |
285 } | 285 } |
286 | 286 |
287 static const char* TypeString(GrSLType t) { | |
288 switch (t) { | |
289 case kVoid_GrSLType: | |
290 return "void"; | |
291 case kFloat_GrSLType: | |
292 return "float"; | |
293 case kVec2f_GrSLType: | |
294 return "vec2"; | |
295 case kVec3f_GrSLType: | |
296 return "vec3"; | |
297 case kVec4f_GrSLType: | |
298 return "vec4"; | |
299 case kMat33f_GrSLType: | |
300 return "mat3"; | |
301 case kMat44f_GrSLType: | |
302 return "mat4"; | |
303 case kSampler2D_GrSLType: | |
304 return "sampler2D"; | |
305 default: | |
306 GrCrash("Unknown shader var type."); | |
307 return ""; // suppress warning | |
308 } | |
309 } | |
310 | |
311 void appendArrayAccess(int index, SkString* out) const { | 287 void appendArrayAccess(int index, SkString* out) const { |
312 out->appendf("%s[%d]%s", | 288 out->appendf("%s[%d]%s", |
313 this->getName().c_str(), | 289 this->getName().c_str(), |
314 index, | 290 index, |
315 fUseUniformFloatArrays ? "" : ".x"); | 291 fUseUniformFloatArrays ? "" : ".x"); |
316 } | 292 } |
317 | 293 |
318 void appendArrayAccess(const char* indexName, SkString* out) const { | 294 void appendArrayAccess(const char* indexName, SkString* out) const { |
319 out->appendf("%s[%s]%s", | 295 out->appendf("%s[%s]%s", |
320 this->getName().c_str(), | 296 this->getName().c_str(), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 SkString fName; | 341 SkString fName; |
366 int fCount; | 342 int fCount; |
367 Precision fPrecision; | 343 Precision fPrecision; |
368 Origin fOrigin; | 344 Origin fOrigin; |
369 /// Work around driver bugs on some hardware that don't correctly | 345 /// Work around driver bugs on some hardware that don't correctly |
370 /// support uniform float [] | 346 /// support uniform float [] |
371 bool fUseUniformFloatArrays; | 347 bool fUseUniformFloatArrays; |
372 }; | 348 }; |
373 | 349 |
374 #endif | 350 #endif |
OLD | NEW |