| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 this->functions().append(") {\n"); | 54 this->functions().append(") {\n"); |
| 55 this->functions().append(body); | 55 this->functions().append(body); |
| 56 this->functions().append("}\n\n"); | 56 this->functions().append("}\n\n"); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, | 59 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, |
| 60 const GrGLSLTextureSampler& sample
r, | 60 const GrGLSLTextureSampler& sample
r, |
| 61 const char* coordName, | 61 const char* coordName, |
| 62 GrSLType varyingType) const { | 62 GrSLType coordType) const { |
| 63 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); | 63 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); |
| 64 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler(); | 64 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler(); |
| 65 GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUn
iform).getType(); | 65 GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUn
iform).getType(); |
| 66 if (samplerType == kSampler2DRect_GrSLType) { | 66 if (samplerType == kSampler2DRect_GrSLType) { |
| 67 if (varyingType == kVec2f_GrSLType) { | 67 if (coordType == kVec2f_GrSLType) { |
| 68 out->appendf("%s(%s, textureSize(%s) * %s)", | 68 out->appendf("%s(%s, textureSize(%s) * %s)", |
| 69 GrGLSLTexture2DFunctionName(varyingType, samplerType, | 69 GrGLSLTextureFunctionName(coordType, samplerType, glslC
aps->generation()), |
| 70 glslCaps->generation()), | |
| 71 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, | 70 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, |
| 72 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, | 71 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, |
| 73 coordName); | 72 coordName); |
| 74 } else { | 73 } else { |
| 75 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))", | 74 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))", |
| 76 GrGLSLTexture2DFunctionName(varyingType, samplerType, | 75 GrGLSLTextureFunctionName(coordType, samplerType, glslC
aps->generation()), |
| 77 glslCaps->generation()), | |
| 78 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, | 76 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, |
| 79 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, | 77 uniformHandler->getUniformCStr(sampler.fSamplerUniform)
, |
| 80 coordName, | 78 coordName, |
| 81 coordName); | 79 coordName); |
| 82 } | 80 } |
| 83 } else { | 81 } else { |
| 84 out->appendf("%s(%s, %s)", | 82 out->appendf("%s(%s, %s)", |
| 85 GrGLSLTexture2DFunctionName(varyingType, samplerType, glslC
aps->generation()), | 83 GrGLSLTextureFunctionName(coordType, samplerType, glslCaps-
>generation()), |
| 86 uniformHandler->getUniformCStr(sampler.fSamplerUniform), | 84 uniformHandler->getUniformCStr(sampler.fSamplerUniform), |
| 87 coordName); | 85 coordName); |
| 88 } | 86 } |
| 89 | 87 |
| 90 // This refers to any swizzling we may need to get from some backend interna
l format to the | 88 // This refers to any swizzling we may need to get from some backend interna
l format to the |
| 91 // format used in GrPixelConfig. If this is implemented by the GrGpu object,
then swizzle will | 89 // format used in GrPixelConfig. If this is implemented by the GrGpu object,
then swizzle will |
| 92 // be rgba. For shader prettiness we omit the swizzle rather than appending
".rgba". | 90 // be rgba. For shader prettiness we omit the swizzle rather than appending
".rgba". |
| 93 const GrSwizzle& configSwizzle = glslCaps->configTextureSwizzle(sampler.conf
ig()); | 91 const GrSwizzle& configSwizzle = glslCaps->configTextureSwizzle(sampler.conf
ig()); |
| 94 | 92 |
| 95 if (configSwizzle != GrSwizzle::RGBA()) { | 93 if (configSwizzle != GrSwizzle::RGBA()) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 this->code().append("}"); | 166 this->code().append("}"); |
| 169 | 167 |
| 170 for (int i = 0; i <= fCodeIndex; i++) { | 168 for (int i = 0; i <= fCodeIndex; i++) { |
| 171 fCompilerStrings[i] = fShaderStrings[i].c_str(); | 169 fCompilerStrings[i] = fShaderStrings[i].c_str(); |
| 172 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); | 170 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); |
| 173 } | 171 } |
| 174 | 172 |
| 175 fFinalized = true; | 173 fFinalized = true; |
| 176 } | 174 } |
| 177 | 175 |
| OLD | NEW |