Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: src/gpu/gl/GrGLShaderVar.h

Issue 16818013: Enabling Perlin Noise on Android (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Update Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 */ 60 */
61 GrGLShaderVar() { 61 GrGLShaderVar() {
62 fType = kFloat_GrSLType; 62 fType = kFloat_GrSLType;
63 fTypeModifier = kNone_TypeModifier; 63 fTypeModifier = kNone_TypeModifier;
64 fCount = kNonArray; 64 fCount = kNonArray;
65 fPrecision = kDefault_Precision; 65 fPrecision = kDefault_Precision;
66 fOrigin = kDefault_Origin; 66 fOrigin = kDefault_Origin;
67 fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS; 67 fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
68 } 68 }
69 69
70 GrGLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray) { 70 GrGLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
71 Precision precision = kDefault_Precision) {
71 GrAssert(kVoid_GrSLType != type); 72 GrAssert(kVoid_GrSLType != type);
72 fType = type; 73 fType = type;
73 fTypeModifier = kNone_TypeModifier; 74 fTypeModifier = kNone_TypeModifier;
74 fCount = arrayCount; 75 fCount = arrayCount;
75 fPrecision = kDefault_Precision; 76 fPrecision = precision;
76 fOrigin = kDefault_Origin; 77 fOrigin = kDefault_Origin;
77 fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS; 78 fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
78 fName = name; 79 fName = name;
79 } 80 }
80 81
81 GrGLShaderVar(const GrGLShaderVar& var) 82 GrGLShaderVar(const GrGLShaderVar& var)
82 : fType(var.fType) 83 : fType(var.fType)
83 , fTypeModifier(var.fTypeModifier) 84 , fTypeModifier(var.fTypeModifier)
84 , fName(var.fName) 85 , fName(var.fName)
85 , fCount(var.fCount) 86 , fCount(var.fCount)
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 fUseUniformFloatArrays ? "" : ".x"); 295 fUseUniformFloatArrays ? "" : ".x");
295 } 296 }
296 297
297 void appendArrayAccess(const char* indexName, SkString* out) const { 298 void appendArrayAccess(const char* indexName, SkString* out) const {
298 out->appendf("%s[%s]%s", 299 out->appendf("%s[%s]%s",
299 this->getName().c_str(), 300 this->getName().c_str(),
300 indexName, 301 indexName,
301 fUseUniformFloatArrays ? "" : ".x"); 302 fUseUniformFloatArrays ? "" : ".x");
302 } 303 }
303 304
305 static const char* PrecisionString(Precision p, GrGLBinding binding) {
306 // Desktop GLSL has added precision qualifiers but they don't do anythin g.
307 if (kES2_GrGLBinding == binding) {
308 switch (p) {
309 case kLow_Precision:
310 return "lowp ";
311 case kMedium_Precision:
312 return "mediump ";
313 case kHigh_Precision:
314 return "highp ";
315 case kDefault_Precision:
316 return "";
317 default:
318 GrCrash("Unexpected precision type.");
319 }
320 }
321 return "";
322 }
323
304 private: 324 private:
305 static const char* TypeModifierString(TypeModifier t, GrGLSLGeneration gen) { 325 static const char* TypeModifierString(TypeModifier t, GrGLSLGeneration gen) {
306 switch (t) { 326 switch (t) {
307 case kNone_TypeModifier: 327 case kNone_TypeModifier:
308 return ""; 328 return "";
309 case kIn_TypeModifier: 329 case kIn_TypeModifier:
310 return "in"; 330 return "in";
311 case kInOut_TypeModifier: 331 case kInOut_TypeModifier:
312 return "inout"; 332 return "inout";
313 case kOut_TypeModifier: 333 case kOut_TypeModifier:
314 return "out"; 334 return "out";
315 case kUniform_TypeModifier: 335 case kUniform_TypeModifier:
316 return "uniform"; 336 return "uniform";
317 case kAttribute_TypeModifier: 337 case kAttribute_TypeModifier:
318 return k110_GrGLSLGeneration == gen ? "attribute" : "in"; 338 return k110_GrGLSLGeneration == gen ? "attribute" : "in";
319 case kVaryingIn_TypeModifier: 339 case kVaryingIn_TypeModifier:
320 return k110_GrGLSLGeneration == gen ? "varying" : "in"; 340 return k110_GrGLSLGeneration == gen ? "varying" : "in";
321 case kVaryingOut_TypeModifier: 341 case kVaryingOut_TypeModifier:
322 return k110_GrGLSLGeneration == gen ? "varying" : "out"; 342 return k110_GrGLSLGeneration == gen ? "varying" : "out";
323 default: 343 default:
324 GrCrash("Unknown shader variable type modifier."); 344 GrCrash("Unknown shader variable type modifier.");
325 return ""; // suppress warning 345 return ""; // suppress warning
326 } 346 }
327 } 347 }
328 348
329 static const char* PrecisionString(Precision p, GrGLBinding binding) {
330 // Desktop GLSL has added precision qualifiers but they don't do anythin g.
331 if (kES2_GrGLBinding == binding) {
332 switch (p) {
333 case kLow_Precision:
334 return "lowp ";
335 case kMedium_Precision:
336 return "mediump ";
337 case kHigh_Precision:
338 return "highp ";
339 case kDefault_Precision:
340 return "";
341 default:
342 GrCrash("Unexpected precision type.");
343 }
344 }
345 return "";
346 }
347
348 GrSLType fType; 349 GrSLType fType;
349 TypeModifier fTypeModifier; 350 TypeModifier fTypeModifier;
350 SkString fName; 351 SkString fName;
351 int fCount; 352 int fCount;
352 Precision fPrecision; 353 Precision fPrecision;
353 Origin fOrigin; 354 Origin fOrigin;
354 /// Work around driver bugs on some hardware that don't correctly 355 /// Work around driver bugs on some hardware that don't correctly
355 /// support uniform float [] 356 /// support uniform float []
356 bool fUseUniformFloatArrays; 357 bool fUseUniformFloatArrays;
357 }; 358 };
358 359
359 #endif 360 #endif
OLDNEW
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698