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