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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 */ | 50 */ |
51 bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation); | 51 bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation); |
52 | 52 |
53 /** | 53 /** |
54 * Returns a string to include at the beginning of a shader to declare the GLSL | 54 * Returns a string to include at the beginning of a shader to declare the GLSL |
55 * version. | 55 * version. |
56 */ | 56 */ |
57 const char* GrGetGLSLVersionDecl(const GrGLContextInfo&); | 57 const char* GrGetGLSLVersionDecl(const GrGLContextInfo&); |
58 | 58 |
59 /** | 59 /** |
| 60 * Adds a line of GLSL code to declare the default precision for float types. |
| 61 */ |
| 62 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision, GrGLStandard, S
kString* out); |
| 63 |
| 64 /** |
| 65 * Gets the name of the function that should be used to sample a 2D texture. Coo
rd type is used |
| 66 * to indicate whether the texture is sampled using projective textured (kVec3f)
or not (kVec2f). |
| 67 */ |
| 68 inline const char* GrGLSLTexture2DFunctionName(GrSLType coordType, GrGLSLGenerat
ion glslGen) { |
| 69 if (kVec2f_GrSLType == coordType) { |
| 70 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; |
| 71 } else { |
| 72 SkASSERT(kVec3f_GrSLType == coordType); |
| 73 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; |
| 74 } |
| 75 } |
| 76 |
| 77 /** |
60 * Converts a GrSLType to a string containing the name of the equivalent GLSL ty
pe. | 78 * Converts a GrSLType to a string containing the name of the equivalent GLSL ty
pe. |
61 */ | 79 */ |
62 static inline const char* GrGLSLTypeString(GrSLType t) { | 80 static inline const char* GrGLSLTypeString(GrSLType t) { |
63 switch (t) { | 81 switch (t) { |
64 case kVoid_GrSLType: | 82 case kVoid_GrSLType: |
65 return "void"; | 83 return "void"; |
66 case kFloat_GrSLType: | 84 case kFloat_GrSLType: |
67 return "float"; | 85 return "float"; |
68 case kVec2f_GrSLType: | 86 case kVec2f_GrSLType: |
69 return "vec2"; | 87 return "vec2"; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 336 |
319 /** | 337 /** |
320 * Does an inplace mul, *=, of vec4VarName by mulFactor. | 338 * Does an inplace mul, *=, of vec4VarName by mulFactor. |
321 * A semicolon is added after the assignment. | 339 * A semicolon is added after the assignment. |
322 */ | 340 */ |
323 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor); | 341 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor); |
324 | 342 |
325 #include "GrGLSL_impl.h" | 343 #include "GrGLSL_impl.h" |
326 | 344 |
327 #endif | 345 #endif |
OLD | NEW |