| 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 "glsl/GrGLSLShaderBuilder.h" | 8 #include "glsl/GrGLSLShaderBuilder.h" |
| 9 #include "glsl/GrGLSLCaps.h" | 9 #include "glsl/GrGLSLCaps.h" |
| 10 #include "glsl/GrGLSLShaderVar.h" | 10 #include "glsl/GrGLSLShaderVar.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 this->functions().append(") {\n"); | 111 this->functions().append(") {\n"); |
| 112 this->functions().append(body); | 112 this->functions().append(body); |
| 113 this->functions().append("}\n\n"); | 113 this->functions().append("}\n\n"); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, | 116 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, |
| 117 const GrGLSLTextureSampler& sample
r, | 117 const GrGLSLTextureSampler& sample
r, |
| 118 const char* coordName, | 118 const char* coordName, |
| 119 GrSLType varyingType) const { | 119 GrSLType varyingType) const { |
| 120 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler(); |
| 120 append_texture_lookup(out, | 121 append_texture_lookup(out, |
| 121 fProgramBuilder->glslCaps(), | 122 fProgramBuilder->glslCaps(), |
| 122 fProgramBuilder->getUniformCStr(sampler.fSamplerUnifor
m), | 123 uniformHandler->getUniformCStr(sampler.fSamplerUniform
), |
| 123 coordName, | 124 coordName, |
| 124 sampler.config(), | 125 sampler.config(), |
| 125 sampler.swizzle(), | 126 sampler.swizzle(), |
| 126 varyingType); | 127 varyingType); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLTextureSampler& sample
r, | 130 void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLTextureSampler& sample
r, |
| 130 const char* coordName, | 131 const char* coordName, |
| 131 GrSLType varyingType) { | 132 GrSLType varyingType) { |
| 132 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType); | 133 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 181 |
| 181 GR_STATIC_ASSERT(0 == GrGLSLShaderBuilder::kOut_InterfaceQualifier); | 182 GR_STATIC_ASSERT(0 == GrGLSLShaderBuilder::kOut_InterfaceQualifier); |
| 182 GR_STATIC_ASSERT(SK_ARRAY_COUNT(interfaceQualifierNames) == kLastInterfaceQu
alifier + 1); | 183 GR_STATIC_ASSERT(SK_ARRAY_COUNT(interfaceQualifierNames) == kLastInterfaceQu
alifier + 1); |
| 183 } | 184 } |
| 184 | 185 |
| 185 void GrGLSLShaderBuilder::finalize(uint32_t visibility) { | 186 void GrGLSLShaderBuilder::finalize(uint32_t visibility) { |
| 186 SkASSERT(!fFinalized); | 187 SkASSERT(!fFinalized); |
| 187 this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString(); | 188 this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString(); |
| 188 this->compileAndAppendLayoutQualifiers(); | 189 this->compileAndAppendLayoutQualifiers(); |
| 189 SkASSERT(visibility); | 190 SkASSERT(visibility); |
| 190 fProgramBuilder->appendUniformDecls((GrGLSLProgramBuilder::ShaderVisibility)
visibility, | 191 fProgramBuilder->appendUniformDecls((GrGLSLUniformHandler::ShaderVisibility)
visibility, |
| 191 &this->uniforms()); | 192 &this->uniforms()); |
| 192 this->appendDecls(fInputs, &this->inputs()); | 193 this->appendDecls(fInputs, &this->inputs()); |
| 193 this->appendDecls(fOutputs, &this->outputs()); | 194 this->appendDecls(fOutputs, &this->outputs()); |
| 194 this->onFinalize(); | 195 this->onFinalize(); |
| 195 // append the 'footer' to code | 196 // append the 'footer' to code |
| 196 this->code().append("}"); | 197 this->code().append("}"); |
| 197 | 198 |
| 198 for (int i = 0; i <= fCodeIndex; i++) { | 199 for (int i = 0; i <= fCodeIndex; i++) { |
| 199 fCompilerStrings[i] = fShaderStrings[i].c_str(); | 200 fCompilerStrings[i] = fShaderStrings[i].c_str(); |
| 200 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); | 201 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); |
| 201 } | 202 } |
| 202 | 203 |
| 203 fFinalized = true; | 204 fFinalized = true; |
| 204 } | 205 } |
| 205 | 206 |
| OLD | NEW |