| 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 30 matching lines...) Expand all Loading... |
| 41 */ | 41 */ |
| 42 k310es_GrGLSLGeneration, | 42 k310es_GrGLSLGeneration, |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration); | 45 bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration); |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Gets the name of the function that should be used to sample a 2D texture. Coo
rd type is used | 48 * Gets the name of the function that should be used to sample a 2D texture. Coo
rd type is used |
| 49 * to indicate whether the texture is sampled using projective textured (kVec3f)
or not (kVec2f). | 49 * to indicate whether the texture is sampled using projective textured (kVec3f)
or not (kVec2f). |
| 50 */ | 50 */ |
| 51 inline const char* GrGLSLTexture2DFunctionName(GrSLType coordType, GrGLSLGenerat
ion glslGen) { | 51 inline const char* GrGLSLTexture2DFunctionName(GrSLType coordType, GrSLType samp
lerType, |
| 52 GrGLSLGeneration glslGen) { |
| 53 SkASSERT(GrSLTypeIsSamplerType(samplerType)); |
| 54 SkASSERT(kVec2f_GrSLType == coordType || kVec3f_GrSLType == coordType); |
| 55 // GL_TEXTURE_RECTANGLE_ARB is written against OpenGL 2.0/GLSL 1.10. At that
time there were |
| 56 // separate texture*() functions. In OpenGL 3.0/GLSL 1.30 the different text
ure*() functions |
| 57 // were deprecated in favor or the unified texture() function. RECTANGLE tex
tures became |
| 58 // standard in OpenGL 3.2/GLSL 1.50 and use texture(). It isn't completely c
lear what function |
| 59 // should be used for RECTANGLE textures in GLSL versions >= 1.30 && < 1.50.
We're going with |
| 60 // using texture(). |
| 61 if (glslGen >= k130_GrGLSLGeneration) { |
| 62 return (kVec2f_GrSLType == coordType) ? "texture" : "textureProj"; |
| 63 } |
| 52 if (kVec2f_GrSLType == coordType) { | 64 if (kVec2f_GrSLType == coordType) { |
| 53 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; | 65 return (samplerType == kSampler2DRect_GrSLType) ? "texture2DRect" : "tex
ture2D"; |
| 54 } else { | 66 } else { |
| 55 SkASSERT(kVec3f_GrSLType == coordType); | 67 return (samplerType == kSampler2DRect_GrSLType) ? "texture2DRectProj" :
"texture2DProj"; |
| 56 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; | |
| 57 } | 68 } |
| 58 } | 69 } |
| 59 | 70 |
| 60 /** | 71 /** |
| 61 * Adds a line of GLSL code to declare the default precision for float types. | 72 * Adds a line of GLSL code to declare the default precision for float types. |
| 62 */ | 73 */ |
| 63 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision, | 74 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision, |
| 64 const GrGLSLCaps& glslCaps, | 75 const GrGLSLCaps& glslCaps, |
| 65 SkString* out); | 76 SkString* out); |
| 66 | 77 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 80 case kVec4f_GrSLType: | 91 case kVec4f_GrSLType: |
| 81 return "vec4"; | 92 return "vec4"; |
| 82 case kMat33f_GrSLType: | 93 case kMat33f_GrSLType: |
| 83 return "mat3"; | 94 return "mat3"; |
| 84 case kMat44f_GrSLType: | 95 case kMat44f_GrSLType: |
| 85 return "mat4"; | 96 return "mat4"; |
| 86 case kSampler2D_GrSLType: | 97 case kSampler2D_GrSLType: |
| 87 return "sampler2D"; | 98 return "sampler2D"; |
| 88 case kSamplerExternal_GrSLType: | 99 case kSamplerExternal_GrSLType: |
| 89 return "samplerExternalOES"; | 100 return "samplerExternalOES"; |
| 101 case kSampler2DRect_GrSLType: |
| 102 return "sampler2DRect"; |
| 90 default: | 103 default: |
| 91 SkFAIL("Unknown shader var type."); | 104 SkFAIL("Unknown shader var type."); |
| 92 return ""; // suppress warning | 105 return ""; // suppress warning |
| 93 } | 106 } |
| 94 } | 107 } |
| 95 | 108 |
| 96 /** A generic base-class representing a GLSL expression. | 109 /** A generic base-class representing a GLSL expression. |
| 97 * The instance can be a variable name, expression or vecN(0) or vecN(1). Does s
imple constant | 110 * The instance can be a variable name, expression or vecN(0) or vecN(1). Does s
imple constant |
| 98 * folding with help of 1 and 0. | 111 * folding with help of 1 and 0. |
| 99 * | 112 * |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 341 |
| 329 /** | 342 /** |
| 330 * Does an inplace mul, *=, of vec4VarName by mulFactor. | 343 * Does an inplace mul, *=, of vec4VarName by mulFactor. |
| 331 * A semicolon is added after the assignment. | 344 * A semicolon is added after the assignment. |
| 332 */ | 345 */ |
| 333 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor); | 346 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor); |
| 334 | 347 |
| 335 #include "GrGLSL_impl.h" | 348 #include "GrGLSL_impl.h" |
| 336 | 349 |
| 337 #endif | 350 #endif |
| OLD | NEW |