| 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 "GrSwizzle.h" | 8 #include "GrSwizzle.h" |
| 9 #include "glsl/GrGLSLShaderBuilder.h" | 9 #include "glsl/GrGLSLShaderBuilder.h" |
| 10 #include "glsl/GrGLSLCaps.h" | 10 #include "glsl/GrGLSLCaps.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 this->functions().append(body); | 61 this->functions().append(body); |
| 62 this->functions().append("}\n\n"); | 62 this->functions().append("}\n\n"); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, | 65 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, |
| 66 const GrGLSLSampler& sampler, | 66 const GrGLSLSampler& sampler, |
| 67 const char* coordName, | 67 const char* coordName, |
| 68 GrSLType varyingType) const { | 68 GrSLType varyingType) const { |
| 69 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); | 69 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); |
| 70 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler(); | 70 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler(); |
| 71 GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUn
iform).getType(); | 71 GrSLType samplerType = sampler.type(); |
| 72 if (samplerType == kSampler2DRect_GrSLType) { | 72 if (samplerType == kSampler2DRect_GrSLType) { |
| 73 if (varyingType == kVec2f_GrSLType) { | 73 if (varyingType == kVec2f_GrSLType) { |
| 74 out->appendf("%s(%s, textureSize(%s) * %s)", | 74 out->appendf("%s(%s, textureSize(%s) * %s)", |
| 75 GrGLSLTexture2DFunctionName(varyingType, samplerType, | 75 GrGLSLTexture2DFunctionName(varyingType, samplerType, |
| 76 glslCaps->generation()), | 76 glslCaps->generation()), |
| 77 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, | 77 sampler.getSamplerFunctionName(), |
| 78 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, | 78 sampler.getSamplerFunctionName(), |
| 79 coordName); | 79 coordName); |
| 80 } else { | 80 } else { |
| 81 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))", | 81 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))", |
| 82 GrGLSLTexture2DFunctionName(varyingType, samplerType, | 82 GrGLSLTexture2DFunctionName(varyingType, samplerType, |
| 83 glslCaps->generation()), | 83 glslCaps->generation()), |
| 84 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, | 84 sampler.getSamplerFunctionName(), |
| 85 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, | 85 sampler.getSamplerFunctionName(), |
| 86 coordName, | 86 coordName, |
| 87 coordName); | 87 coordName); |
| 88 } | 88 } |
| 89 } else { | 89 } else { |
| 90 out->appendf("%s(%s, %s)", | 90 out->appendf("%s(%s, %s)", |
| 91 GrGLSLTexture2DFunctionName(varyingType, samplerType, glslC
aps->generation()), | 91 GrGLSLTexture2DFunctionName(varyingType, samplerType, glslC
aps->generation()), |
| 92 uniformHandler->getUniformCStr(sampler.fSamplerUniform), | 92 sampler.getSamplerFunctionName(), |
| 93 coordName); | 93 coordName); |
| 94 } | 94 } |
| 95 | 95 |
| 96 this->appendTextureSwizzle(out, sampler.config()); | 96 this->appendTextureSwizzle(out, sampler.config()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLSampler& sampler, | 99 void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLSampler& sampler, |
| 100 const char* coordName, | 100 const char* coordName, |
| 101 GrSLType varyingType) { | 101 GrSLType varyingType) { |
| 102 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType); | 102 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // append the 'footer' to code | 193 // append the 'footer' to code |
| 194 this->code().append("}"); | 194 this->code().append("}"); |
| 195 | 195 |
| 196 for (int i = 0; i <= fCodeIndex; i++) { | 196 for (int i = 0; i <= fCodeIndex; i++) { |
| 197 fCompilerStrings[i] = fShaderStrings[i].c_str(); | 197 fCompilerStrings[i] = fShaderStrings[i].c_str(); |
| 198 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); | 198 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 fFinalized = true; | 201 fFinalized = true; |
| 202 } | 202 } |
| OLD | NEW |