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()) { | |
91 SkString outputDistanceVectorStr; | |
92 this->nameVariable(&outputDistanceVectorStr, '\0', "outputDistanceVector "); | |
egdaniel
2016/07/12 13:46:42
I think I would prefer hard coding the name we wan
dvonbeck
2016/07/13 15:17:13
The thing is, the Geometry Processors get their va
egdaniel
2016/07/13 15:47:02
I don't think there is any need for mangling the v
dvonbeck
2016/07/13 16:57:49
Done.
| |
93 fFS.enableDistanceVector(outputDistanceVectorStr); | |
94 | |
robertphillips
2016/07/11 17:55:40
Maybe emit a comment:
// Un-normalized vector to
dvonbeck
2016/07/13 15:17:13
Done.
| |
95 fFS.codeAppendf("vec2 %s = vec2(0.0, 0.0);", fFS.distanceVectorName()); | |
96 } | |
97 | |
90 // Enclose custom code in a block to avoid namespace conflicts | 98 // Enclose custom code in a block to avoid namespace conflicts |
91 SkString openBrace; | 99 SkString openBrace; |
92 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); | 100 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); |
93 fFS.codeAppend(openBrace.c_str()); | 101 fFS.codeAppend(openBrace.c_str()); |
94 fVS.codeAppendf("// Primitive Processor %s\n", proc.name()); | 102 fVS.codeAppendf("// Primitive Processor %s\n", proc.name()); |
95 | 103 |
96 SkASSERT(!fGeometryProcessor); | 104 SkASSERT(!fGeometryProcessor); |
97 fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps()); | 105 fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps()); |
98 | 106 |
99 SkSTArray<4, SamplerHandle> texSamplers(proc.numTextures()); | 107 SkSTArray<4, SamplerHandle> texSamplers(proc.numTextures()); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 delete fFragmentProcessors[i]; | 409 delete fFragmentProcessors[i]; |
402 } | 410 } |
403 } | 411 } |
404 | 412 |
405 void GrGLSLProgramBuilder::finalizeShaders() { | 413 void GrGLSLProgramBuilder::finalizeShaders() { |
406 this->varyingHandler()->finalize(); | 414 this->varyingHandler()->finalize(); |
407 fVS.finalize(kVertex_GrShaderFlag); | 415 fVS.finalize(kVertex_GrShaderFlag); |
408 fFS.finalize(kFragment_GrShaderFlag); | 416 fFS.finalize(kFragment_GrShaderFlag); |
409 | 417 |
410 } | 418 } |
OLD | NEW |