| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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/GrGLSLProgramBuilder.h" | 8 #include "glsl/GrGLSLProgramBuilder.h" |
| 9 | 9 |
| 10 #include "GrPipeline.h" | 10 #include "GrPipeline.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
oc, | 82 void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
oc, |
| 83 GrGLSLExpr4* outputColor, | 83 GrGLSLExpr4* outputColor, |
| 84 GrGLSLExpr4* outputCoverage) { | 84 GrGLSLExpr4* outputCoverage) { |
| 85 // Program builders have a bit of state we need to clear with each effect | 85 // Program builders have a bit of state we need to clear with each effect |
| 86 AutoStageAdvance adv(this); | 86 AutoStageAdvance adv(this); |
| 87 this->nameExpression(outputColor, "outputColor"); | 87 this->nameExpression(outputColor, "outputColor"); |
| 88 this->nameExpression(outputCoverage, "outputCoverage"); | 88 this->nameExpression(outputCoverage, "outputCoverage"); |
| 89 | 89 |
| 90 if (this->fPipeline.usesDistanceVectorField() && proc.implementsDistanceVect
or()) { |
| 91 fFS.codeAppend( "// Un-normalized vector to the closed geometric edge (i
n source space)\n"); |
| 92 fFS.codeAppendf("vec2 %s = vec2(0.0, 0.0);", fFS.distanceVectorName()); |
| 93 } |
| 94 |
| 90 // Enclose custom code in a block to avoid namespace conflicts | 95 // Enclose custom code in a block to avoid namespace conflicts |
| 91 SkString openBrace; | 96 SkString openBrace; |
| 92 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); | 97 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); |
| 93 fFS.codeAppend(openBrace.c_str()); | 98 fFS.codeAppend(openBrace.c_str()); |
| 94 fVS.codeAppendf("// Primitive Processor %s\n", proc.name()); | 99 fVS.codeAppendf("// Primitive Processor %s\n", proc.name()); |
| 95 | 100 |
| 96 SkASSERT(!fGeometryProcessor); | 101 SkASSERT(!fGeometryProcessor); |
| 97 fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps()); | 102 fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps()); |
| 98 | 103 |
| 99 SkSTArray<4, SamplerHandle> texSamplers(proc.numTextures()); | 104 SkSTArray<4, SamplerHandle> texSamplers(proc.numTextures()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 this->emitSamplers(fp, &texSamplers, &bufferSamplers); | 159 this->emitSamplers(fp, &texSamplers, &bufferSamplers); |
| 155 | 160 |
| 156 GrGLSLFragmentProcessor::EmitArgs args(&fFS, | 161 GrGLSLFragmentProcessor::EmitArgs args(&fFS, |
| 157 this->uniformHandler(), | 162 this->uniformHandler(), |
| 158 this->glslCaps(), | 163 this->glslCaps(), |
| 159 fp, | 164 fp, |
| 160 output->c_str(), | 165 output->c_str(), |
| 161 input.isOnes() ? nullptr : input.c_st
r(), | 166 input.isOnes() ? nullptr : input.c_st
r(), |
| 162 fOutCoords[index], | 167 fOutCoords[index], |
| 163 texSamplers.begin(), | 168 texSamplers.begin(), |
| 164 bufferSamplers.begin()); | 169 bufferSamplers.begin(), |
| 170 this->primitiveProcessor().implements
DistanceVector()); |
| 171 |
| 165 fragProc->emitCode(args); | 172 fragProc->emitCode(args); |
| 166 | 173 |
| 167 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 174 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 168 // asks for dst color, then the emit code needs to follow suit | 175 // asks for dst color, then the emit code needs to follow suit |
| 169 SkDEBUGCODE(verify(fp);) | 176 SkDEBUGCODE(verify(fp);) |
| 170 fFragmentProcessors.push_back(fragProc); | 177 fFragmentProcessors.push_back(fragProc); |
| 171 | 178 |
| 172 fFS.codeAppend("}"); | 179 fFS.codeAppend("}"); |
| 173 } | 180 } |
| 174 | 181 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 delete fFragmentProcessors[i]; | 408 delete fFragmentProcessors[i]; |
| 402 } | 409 } |
| 403 } | 410 } |
| 404 | 411 |
| 405 void GrGLSLProgramBuilder::finalizeShaders() { | 412 void GrGLSLProgramBuilder::finalizeShaders() { |
| 406 this->varyingHandler()->finalize(); | 413 this->varyingHandler()->finalize(); |
| 407 fVS.finalize(kVertex_GrShaderFlag); | 414 fVS.finalize(kVertex_GrShaderFlag); |
| 408 fFS.finalize(kFragment_GrShaderFlag); | 415 fFS.finalize(kFragment_GrShaderFlag); |
| 409 | 416 |
| 410 } | 417 } |
| OLD | NEW |