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 "GrGLProgramBuilder.h" | 10 #include "GrGLProgramBuilder.h" |
11 #include "../GrGpuGL.h" | 11 #include "../GrGpuGL.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)
{ | 15 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen)
{ |
16 if (kVec2f_GrSLType == type) { | 16 if (kVec2f_GrSLType == type) { |
17 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; | 17 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; |
18 } else { | 18 } else { |
19 SkASSERT(kVec3f_GrSLType == type); | 19 SkASSERT(kVec3f_GrSLType == type); |
20 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; | 20 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; |
21 } | 21 } |
22 } | 22 } |
23 void append_texture_lookup(SkString* out, | 23 void append_texture_lookup(SkString* out, |
24 GrGpuGL* gpu, | 24 GrGLGpu* gpu, |
25 const char* samplerName, | 25 const char* samplerName, |
26 const char* coordName, | 26 const char* coordName, |
27 uint32_t configComponentMask, | 27 uint32_t configComponentMask, |
28 const char* swizzle, | 28 const char* swizzle, |
29 GrSLType varyingType = kVec2f_GrSLType) { | 29 GrSLType varyingType = kVec2f_GrSLType) { |
30 SkASSERT(coordName); | 30 SkASSERT(coordName); |
31 | 31 |
32 out->appendf("%s(%s, %s)", | 32 out->appendf("%s(%s, %s)", |
33 sample_function_name(varyingType, gpu->glslGeneration()), | 33 sample_function_name(varyingType, gpu->glslGeneration()), |
34 samplerName, | 34 samplerName, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 uint32_t configComponentMask, | 154 uint32_t configComponentMask, |
155 const char* swizzle) { | 155 const char* swizzle) { |
156 append_texture_lookup(&fCode, | 156 append_texture_lookup(&fCode, |
157 fProgramBuilder->gpu(), | 157 fProgramBuilder->gpu(), |
158 samplerName, | 158 samplerName, |
159 coordName, | 159 coordName, |
160 configComponentMask, | 160 configComponentMask, |
161 swizzle, | 161 swizzle, |
162 kVec2f_GrSLType); | 162 kVec2f_GrSLType); |
163 } | 163 } |
OLD | NEW |