OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "GrGLShaderBuilder.h" | 8 #include "GrGLShaderBuilder.h" |
9 #include "GrGLProgramBuilder.h" | 9 #include "GrGLProgramBuilder.h" |
10 #include "GrGLShaderStringBuilder.h" | 10 #include "GrGLShaderStringBuilder.h" |
11 #include "../GrGLGpu.h" | 11 #include "../GrGLGpu.h" |
12 #include "../GrGLShaderVar.h" | 12 #include "../GrGLShaderVar.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen)
{ | |
16 if (kVec2f_GrSLType == type) { | |
17 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; | |
18 } else { | |
19 SkASSERT(kVec3f_GrSLType == type); | |
20 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; | |
21 } | |
22 } | |
23 void append_texture_lookup(SkString* out, | 15 void append_texture_lookup(SkString* out, |
24 GrGLGpu* gpu, | 16 GrGLGpu* gpu, |
25 const char* samplerName, | 17 const char* samplerName, |
26 const char* coordName, | 18 const char* coordName, |
27 uint32_t configComponentMask, | 19 uint32_t configComponentMask, |
28 const char* swizzle, | 20 const char* swizzle, |
29 GrSLType varyingType = kVec2f_GrSLType) { | 21 GrSLType varyingType = kVec2f_GrSLType) { |
30 SkASSERT(coordName); | 22 SkASSERT(coordName); |
31 | 23 |
32 out->appendf("%s(%s, %s)", | 24 out->appendf("%s(%s, %s)", |
33 sample_function_name(varyingType, gpu->glslGeneration()), | 25 GrGLSLTexture2DFunctionName(varyingType, gpu->glslGeneration())
, |
34 samplerName, | 26 samplerName, |
35 coordName); | 27 coordName); |
36 | 28 |
37 char mangledSwizzle[5]; | 29 char mangledSwizzle[5]; |
38 | 30 |
39 // The swizzling occurs using texture params instead of shader-mangling if A
RB_texture_swizzle | 31 // The swizzling occurs using texture params instead of shader-mangling if A
RB_texture_swizzle |
40 // is available. | 32 // is available. |
41 if (!gpu->glCaps().textureSwizzleSupport() && | 33 if (!gpu->glCaps().textureSwizzleSupport() && |
42 (kA_GrColorComponentFlag == configComponentMask)) { | 34 (kA_GrColorComponentFlag == configComponentMask)) { |
43 char alphaChar = gpu->glCaps().textureRedSupport() ? 'r' : 'a'; | 35 char alphaChar = gpu->glCaps().textureRedSupport() ? 'r' : 'a'; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 fFinalized = true; | 214 fFinalized = true; |
223 | 215 |
224 if (!shaderId) { | 216 if (!shaderId) { |
225 return false; | 217 return false; |
226 } | 218 } |
227 | 219 |
228 *shaderIds->append() = shaderId; | 220 *shaderIds->append() = shaderId; |
229 | 221 |
230 return true; | 222 return true; |
231 } | 223 } |
OLD | NEW |