diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-05-03 09:49:07 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-03 14:13:41 +0000 |
commit | 796001c82eca5651bc6a221204f6186918781daf (patch) | |
tree | 6afce852c893eab7c313cb3c5f869c56e3a6d5e1 /src/gpu/glsl/GrGLSLProgramBuilder.cpp | |
parent | 131154be103d3706470aa3ce2c17fafde3493490 (diff) |
Revert "Revert "eliminated GrGLSLExpr""
This reverts commit 5e550ab57e0204bfadd2cb69c47d2a85e38d6a4c.
Bug: skia:
Change-Id: I4705e47dbd209aa8f43db3d28c856bd3aa9e49ab
Reviewed-on: https://skia-review.googlesource.com/15187
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu/glsl/GrGLSLProgramBuilder.cpp')
-rw-r--r-- | src/gpu/glsl/GrGLSLProgramBuilder.cpp | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp index 12e7ca2c1d..3094f194ec 100644 --- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp +++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp @@ -53,24 +53,24 @@ void GrGLSLProgramBuilder::addFeature(GrShaderFlags shaders, } } -bool GrGLSLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, - GrGLSLExpr4* inputCoverage) { +bool GrGLSLProgramBuilder::emitAndInstallProcs() { // First we loop over all of the installed processors and collect coord transforms. These will // be sent to the GrGLSLPrimitiveProcessor in its emitCode function const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); - this->emitAndInstallPrimProc(primProc, inputColor, inputCoverage); - - this->emitAndInstallFragProcs(inputColor, inputCoverage); - this->emitAndInstallXferProc(*inputColor, *inputCoverage); + SkString inputColor; + SkString inputCoverage; + this->emitAndInstallPrimProc(primProc, &inputColor, &inputCoverage); + this->emitAndInstallFragProcs(&inputColor, &inputCoverage); + this->emitAndInstallXferProc(inputColor, inputCoverage); this->emitFSOutputSwizzle(this->pipeline().getXferProcessor().hasSecondaryOutput()); return this->checkSamplerCounts() && this->checkImageStorageCounts(); } void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& proc, - GrGLSLExpr4* outputColor, - GrGLSLExpr4* outputCoverage) { + SkString* outputColor, + SkString* outputCoverage) { // Program builders have a bit of state we need to clear with each effect AutoStageAdvance adv(this); this->nameExpression(outputColor, "outputColor"); @@ -139,16 +139,16 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr fFS.codeAppend("}"); } -void GrGLSLProgramBuilder::emitAndInstallFragProcs(GrGLSLExpr4* color, GrGLSLExpr4* coverage) { +void GrGLSLProgramBuilder::emitAndInstallFragProcs(SkString* color, SkString* coverage) { int transformedCoordVarsIdx = 0; - GrGLSLExpr4** inOut = &color; + SkString** inOut = &color; for (int i = 0; i < this->pipeline().numFragmentProcessors(); ++i) { if (i == this->pipeline().numColorFragmentProcessors()) { inOut = &coverage; } - GrGLSLExpr4 output; + SkString output; const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i); - this->emitAndInstallFragProc(fp, i, transformedCoordVarsIdx, **inOut, &output); + output = this->emitAndInstallFragProc(fp, i, transformedCoordVarsIdx, **inOut, output); GrFragmentProcessor::Iter iter(&fp); while (const GrFragmentProcessor* fp = iter.next()) { transformedCoordVarsIdx += fp->numCoordTransforms(); @@ -158,15 +158,16 @@ void GrGLSLProgramBuilder::emitAndInstallFragProcs(GrGLSLExpr4* color, GrGLSLExp } // TODO Processors cannot output zeros because an empty string is all 1s -// the fix is to allow effects to take the GrGLSLExpr4 directly -void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp, - int index, - int transformedCoordVarsIdx, - const GrGLSLExpr4& input, - GrGLSLExpr4* output) { +// the fix is to allow effects to take the SkString directly +SkString GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp, + int index, + int transformedCoordVarsIdx, + const SkString& input, + SkString output) { + SkASSERT(input.size()); // Program builders have a bit of state we need to clear with each effect AutoStageAdvance adv(this); - this->nameExpression(output, "output"); + this->nameExpression(&output, "output"); // Enclose custom code in a block to avoid namespace conflicts SkString openBrace; @@ -193,8 +194,8 @@ void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp, this->uniformHandler(), this->shaderCaps(), fp, - output->c_str(), - input.isOnes() ? nullptr : input.c_str(), + output.c_str(), + input.c_str(), coords, textureSamplers, bufferSamplers, @@ -209,10 +210,11 @@ void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp, fFragmentProcessors.push_back(fragProc); fFS.codeAppend("}"); + return output; } -void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrGLSLExpr4& colorIn, - const GrGLSLExpr4& coverageIn) { +void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn, + const SkString& coverageIn) { // Program builders have a bit of state we need to clear with each effect AutoStageAdvance adv(this); @@ -249,8 +251,8 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrGLSLExpr4& colorIn, this->uniformHandler(), this->shaderCaps(), xp, - colorIn.c_str(), - coverageIn.c_str(), + colorIn.size() ? colorIn.c_str() : "vec4(1)", + coverageIn.size() ? coverageIn.c_str() : "vec4(1)", fFS.getPrimaryColorOutputName(), fFS.getSecondaryColorOutputName(), dstTextureSamplerHandle, @@ -445,12 +447,12 @@ void GrGLSLProgramBuilder::nameVariable(SkString* out, char prefix, const char* } } -void GrGLSLProgramBuilder::nameExpression(GrGLSLExpr4* output, const char* baseName) { +void GrGLSLProgramBuilder::nameExpression(SkString* output, const char* baseName) { // create var to hold stage result. If we already have a valid output name, just use that // otherwise create a new mangled one. This name is only valid if we are reordering stages // and have to tell stage exactly where to put its output. SkString outName; - if (output->isValid()) { + if (output->size()) { outName = output->c_str(); } else { this->nameVariable(&outName, '\0', baseName); |