| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 const char* distanceVectorName = nullptr; | 90 const char* distanceVectorName = nullptr; |
| 91 if (this->fPipeline.usesDistanceVectorField() && proc.implementsDistanceVect
or()) { | 91 if (this->fPipeline.usesDistanceVectorField() && proc.implementsDistanceVect
or()) { |
| 92 // Each individual user (FP) of the distance vector must be able to hand
le having this |
| 93 // variable be undeclared. There is no single default value that will yi
eld a reasonable |
| 94 // result for all users. |
| 92 distanceVectorName = fFS.distanceVectorName(); | 95 distanceVectorName = fFS.distanceVectorName(); |
| 93 fFS.codeAppend( "// Normalized vector to the closest geometric edge (in
device space)\n"); | 96 fFS.codeAppend( "// Normalized vector to the closest geometric edge (in
device space)\n"); |
| 94 fFS.codeAppend( "// Distance to the edge encoded in the z-component\n"); | 97 fFS.codeAppend( "// Distance to the edge encoded in the z-component\n"); |
| 95 fFS.codeAppendf("vec4 %s;", distanceVectorName); | 98 fFS.codeAppendf("vec4 %s;", distanceVectorName); |
| 96 } | 99 } |
| 97 | 100 |
| 98 // Enclose custom code in a block to avoid namespace conflicts | 101 // Enclose custom code in a block to avoid namespace conflicts |
| 99 SkString openBrace; | 102 SkString openBrace; |
| 100 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); | 103 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); |
| 101 fFS.codeAppend(openBrace.c_str()); | 104 fFS.codeAppend(openBrace.c_str()); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 delete fFragmentProcessors[i]; | 415 delete fFragmentProcessors[i]; |
| 413 } | 416 } |
| 414 } | 417 } |
| 415 | 418 |
| 416 void GrGLSLProgramBuilder::finalizeShaders() { | 419 void GrGLSLProgramBuilder::finalizeShaders() { |
| 417 this->varyingHandler()->finalize(); | 420 this->varyingHandler()->finalize(); |
| 418 fVS.finalize(kVertex_GrShaderFlag); | 421 fVS.finalize(kVertex_GrShaderFlag); |
| 419 fFS.finalize(kFragment_GrShaderFlag); | 422 fFS.finalize(kFragment_GrShaderFlag); |
| 420 | 423 |
| 421 } | 424 } |
| OLD | NEW |