Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: src/gpu/glsl/GrGLSLProgramBuilder.cpp

Issue 2326503002: Add default version of fsDistanceVector if it is required but not implemented (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const char* distanceVectorName = nullptr; 90 const char* distanceVectorName = nullptr;
91 if (this->fPipeline.usesDistanceVectorField() && proc.implementsDistanceVect or()) { 91 if (this->fPipeline.usesDistanceVectorField()) {
92 distanceVectorName = fFS.distanceVectorName(); 92 distanceVectorName = fFS.distanceVectorName();
93 fFS.codeAppend( "// Normalized vector to the closest geometric edge (in device space)\n"); 93 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"); 94 fFS.codeAppend( "// Distance to the edge encoded in the z-component\n");
95 fFS.codeAppendf("vec4 %s;", distanceVectorName); 95
96 if (proc.implementsDistanceVector()) {
97 fFS.codeAppendf("vec4 %s;", distanceVectorName);
98 } else {
99 fFS.codeAppendf("vec4 %s = vec4(1,0,0,0); // not implemented by prim itive processor\n",
100 distanceVectorName);
101 }
96 } 102 }
97 103
98 // Enclose custom code in a block to avoid namespace conflicts 104 // Enclose custom code in a block to avoid namespace conflicts
99 SkString openBrace; 105 SkString openBrace;
100 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); 106 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name());
101 fFS.codeAppend(openBrace.c_str()); 107 fFS.codeAppend(openBrace.c_str());
102 fVS.codeAppendf("// Primitive Processor %s\n", proc.name()); 108 fVS.codeAppendf("// Primitive Processor %s\n", proc.name());
103 109
104 SkASSERT(!fGeometryProcessor); 110 SkASSERT(!fGeometryProcessor);
105 fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps()); 111 fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps());
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 delete fFragmentProcessors[i]; 418 delete fFragmentProcessors[i];
413 } 419 }
414 } 420 }
415 421
416 void GrGLSLProgramBuilder::finalizeShaders() { 422 void GrGLSLProgramBuilder::finalizeShaders() {
417 this->varyingHandler()->finalize(); 423 this->varyingHandler()->finalize();
418 fVS.finalize(kVertex_GrShaderFlag); 424 fVS.finalize(kVertex_GrShaderFlag);
419 fFS.finalize(kFragment_GrShaderFlag); 425 fFS.finalize(kFragment_GrShaderFlag);
420 426
421 } 427 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698