Make invokeChild just return a string containing the child function call

Also removes several unused chunks of code that were declaring unused
variables, etc.

Change-Id: I47458736b189d59c0448c6f58b60a9b4ab046db2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266565
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2020-01-24 14:52:10 -05:00 committed by Skia Commit-Bot
parent 44aa1ab584
commit 978693cdaa
20 changed files with 117 additions and 181 deletions

View File

@ -64,10 +64,8 @@ private:
class GLSLSampleCoordEffect : public GrGLSLFragmentProcessor {
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString sample1("sample1");
SkString sample2("sample2");
this->invokeChild(0, &sample1, args, "float2(sk_FragCoord.x, sk_FragCoord.y)");
this->invokeChild(0, &sample2, args, "float2(sk_FragCoord.x, 512 - sk_FragCoord.y)");
SkString sample1 = this->invokeChild(0, args, "float2(sk_FragCoord.x, sk_FragCoord.y)");
SkString sample2 = this->invokeChild(0, args, "float2(sk_FragCoord.x, 512-sk_FragCoord.y)");
fragBuilder->codeAppendf("%s = (%s + %s) / 2;\n", args.fOutputColor, sample1.c_str(),
sample2.c_str());
}

View File

@ -49,10 +49,9 @@ private:
fXformUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kFloat2x2_GrSLType,
"Xform", &xformUniName);
SkString dstNormalColorName("dstNormalColor");
this->invokeChild(0, &dstNormalColorName, args);
SkString dstNormalColor = this->invokeChild(0, args);
fragBuilder->codeAppendf("float3 normal = normalize(%s.rgb - float3(0.5));",
dstNormalColorName.c_str());
dstNormalColor.c_str());
// If there's no x & y components, return (0, 0, +/- 1) instead to avoid division by 0
fragBuilder->codeAppend( "if (abs(normal.z) > 0.999) {");

View File

@ -65,8 +65,7 @@ public:
fColorSpaceHelper.emitCode(uniformHandler, csxe.colorXform());
if (this->numChildProcessors()) {
SkString childColor("src_color");
this->invokeChild(0, &childColor, args);
SkString childColor = this->invokeChild(0, args);
SkString xformedColor;
fragBuilder->appendColorGamutXform(&xformedColor, childColor.c_str(), &fColorSpaceHelper);

View File

@ -244,8 +244,7 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MakeInputPremulAndMulB
public:
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString temp("inColor");
this->invokeChild(0, &temp, args);
SkString temp = this->invokeChild(0, args);
fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, temp.c_str());
fragBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColor,
args.fInputColor);
@ -322,16 +321,12 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(
public:
void emitCode(EmitArgs& args) override {
// First guy's input might be nil.
SkString temp("out0");
this->invokeChild(0, args.fInputColor, &temp, args);
SkString input = temp;
SkString result = this->invokeChild(0, args.fInputColor, args);
for (int i = 1; i < this->numChildProcessors(); ++i) {
temp.printf("out%d", i);
this->invokeChild(i, input.c_str(), &temp, args);
input = temp;
result = this->invokeChild(i, result.c_str(), args);
}
// Copy last output to our output variable
args.fFragBuilder->codeAppendf("%s = %s;", args.fOutputColor, input.c_str());
args.fFragBuilder->codeAppendf("%s = %s;", args.fOutputColor, result.c_str());
}
};
return new GLFP;

View File

@ -96,8 +96,7 @@ public:
: SkString("sk_FragCoord");
std::vector<SkString> childNames;
for (int i = 0; i < this->numChildProcessors(); ++i) {
childNames.push_back(SkStringPrintf("_child%d", i));
this->invokeChild(i, &childNames[i], args);
childNames.push_back(this->invokeChild(i, args));
}
for (const auto& f : fArgs.fFunctions) {
fFunctionNames.emplace_back();

View File

@ -93,9 +93,7 @@ void GrTextureDomain::GLDomain::sampleProcessor(const GrTextureDomain& textureDo
GrGLSLFragmentProcessor::EmitArgs& args,
int childIndex) {
auto appendProcessorSample = [parent, &args, childIndex, inColor](const char* coord) {
SkString outColor("childColor");
parent->invokeChild(childIndex, inColor, &outColor, args, coord);
return outColor;
return parent->invokeChild(childIndex, inColor, args, coord);
};
this->sample(args.fFragBuilder, args.fUniformHandler, textureDomain, outColor, inCoords,
appendProcessorSample);

View File

@ -220,11 +220,9 @@ void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
}
// declare outputColor and emit the code for each of the two children
SkString srcColor("xfer_src");
this->invokeChild(0, inputColor, &srcColor, args);
SkString srcColor = this->invokeChild(0, inputColor, args);
SkString dstColor("xfer_dst");
this->invokeChild(1, inputColor, &dstColor, args);
SkString dstColor = this->invokeChild(1, inputColor, args);
// emit blend code
SkBlendMode mode = cs.getMode();
@ -438,8 +436,7 @@ public:
SkBlendMode mode = args.fFp.cast<ComposeOneFragmentProcessor>().mode();
ComposeOneFragmentProcessor::Child child =
args.fFp.cast<ComposeOneFragmentProcessor>().child();
SkString childColor("child");
this->invokeChild(0, &childColor, args);
SkString childColor = this->invokeChild(0, args);
// emit blend code
fragBuilder->codeAppendf("// Compose Xfer Mode: %s\n", SkBlendMode_Name(mode));

View File

@ -126,9 +126,7 @@ GrGLSLFragmentProcessor* GrYUVtoRGBEffect::onCreateGLSLInstance() const {
SkString coords[4];
fragBuilder->codeAppendf("half4 planes[%d];", numPlanes);
for (int i = 0; i < numPlanes; ++i) {
SkString tempVar;
tempVar.printf("tmp%d", i);
this->invokeChild(i, &tempVar, args);
SkString tempVar = this->invokeChild(i, args);
fragBuilder->codeAppendf("planes[%d] = %s;", i, tempVar.c_str());
}

View File

@ -27,17 +27,17 @@ public:
(void)weight;
weightVar =
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat_GrSLType, "weight");
SkString _sample290("_sample290");
SkString _sample290;
if (_outer.child1_index >= 0) {
this->invokeChild(_outer.child1_index, &_sample290, args);
_sample290 = this->invokeChild(_outer.child1_index, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _sample290.c_str());
_sample290 = "half4(1)";
}
SkString _sample358("_sample358");
SkString _sample358;
if (_outer.child2_index >= 0) {
this->invokeChild(_outer.child2_index, &_sample358, args);
_sample358 = this->invokeChild(_outer.child2_index, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _sample358.c_str());
_sample358 = "half4(1)";
}
fragBuilder->codeAppendf("%s = mix(%s ? %s : %s, %s ? %s : %s, half(%s));\n",
args.fOutputColor, _outer.child1_index >= 0 ? "true" : "false",

View File

@ -23,20 +23,20 @@ public:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrComposeLerpRedEffect& _outer = args.fFp.cast<GrComposeLerpRedEffect>();
(void)_outer;
SkString _sample292("_sample292");
SkString _sample292;
if (_outer.child1_index >= 0) {
this->invokeChild(_outer.child1_index, &_sample292, args);
_sample292 = this->invokeChild(_outer.child1_index, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _sample292.c_str());
_sample292 = "half4(1)";
}
SkString _sample360("_sample360");
SkString _sample360;
if (_outer.child2_index >= 0) {
this->invokeChild(_outer.child2_index, &_sample360, args);
_sample360 = this->invokeChild(_outer.child2_index, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _sample360.c_str());
_sample360 = "half4(1)";
}
SkString _sample411("_sample411");
this->invokeChild(_outer.lerp_index, &_sample411, args);
SkString _sample411;
_sample411 = this->invokeChild(_outer.lerp_index, args);
fragBuilder->codeAppendf("%s = mix(%s ? %s : %s, %s ? %s : %s, %s.x);\n", args.fOutputColor,
_outer.child1_index >= 0 ? "true" : "false", _sample292.c_str(),
args.fInputColor, _outer.child2_index >= 0 ? "true" : "false",

View File

@ -28,15 +28,15 @@ public:
weightVar =
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "weight");
SkString _input1278 = SkStringPrintf("%s", args.fInputColor);
SkString _sample1278("_sample1278");
this->invokeChild(_outer.fp0_index, _input1278.c_str(), &_sample1278, args);
SkString _sample1278;
_sample1278 = this->invokeChild(_outer.fp0_index, _input1278.c_str(), args);
fragBuilder->codeAppendf("half4 in0 = %s;", _sample1278.c_str());
SkString _input1335 = SkStringPrintf("%s", args.fInputColor);
SkString _sample1335("_sample1335");
SkString _sample1335;
if (_outer.fp1_index >= 0) {
this->invokeChild(_outer.fp1_index, _input1335.c_str(), &_sample1335, args);
_sample1335 = this->invokeChild(_outer.fp1_index, _input1335.c_str(), args);
} else {
fragBuilder->codeAppendf("half4 %s;", _sample1335.c_str());
_sample1335 = "half4(1)";
}
fragBuilder->codeAppendf("\nhalf4 in1 = %s ? %s : %s;\n%s = mix(in0, in1, %s);\n",
_outer.fp1_index >= 0 ? "true" : "false", _sample1335.c_str(),

View File

@ -43,8 +43,8 @@ public:
_outer.literalColor.fR, _outer.literalColor.fG, _outer.literalColor.fB,
_outer.literalColor.fA);
SkString _input1992("constColor");
SkString _sample1992("_sample1992");
this->invokeChild(_outer.fp_index, _input1992.c_str(), &_sample1992, args);
SkString _sample1992;
_sample1992 = this->invokeChild(_outer.fp_index, _input1992.c_str(), args);
fragBuilder->codeAppendf("\n%s = %s;\n", args.fOutputColor, _sample1992.c_str());
}

View File

@ -17,94 +17,58 @@ void GrGLSLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman,
this->onSetData(pdman, processor);
}
void GrGLSLFragmentProcessor::writeChildCall(GrGLSLFPFragmentBuilder* fragBuilder, int childIndex,
TransformedCoordVars coordVars, const char* inputColor,
const char* outputColor, EmitArgs& args,
SkSL::String skslCoords) {
std::vector<SkString> coordParams;
for (int i = 0; i < coordVars.count(); ++i) {
coordParams.push_back(fragBuilder->ensureCoords2D(coordVars[i].fVaryingPoint));
}
// if the fragment processor is invoked with overridden coordinates, it must *always* be invoked
// with overridden coords
SkASSERT(args.fFp.coordTransformsApplyToLocalCoords() == (skslCoords.length() == 0));
fragBuilder->codeAppendf("%s = %s(%s", outputColor, fFunctionNames[childIndex].c_str(),
inputColor ? inputColor : "half4(1)");
if (skslCoords.length()) {
fragBuilder->codeAppendf(", %s", skslCoords.c_str());
}
fragBuilder->codeAppend(");\n");
}
void GrGLSLFragmentProcessor::invokeChild(int childIndex, const char* inputColor,
SkString* outputColor, EmitArgs& args,
SkSL::String skslCoords) {
SkASSERT(outputColor);
SkString GrGLSLFragmentProcessor::invokeChild(int childIndex, const char* inputColor,
EmitArgs& args, SkSL::String skslCoords) {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
outputColor->append(fragBuilder->getMangleString());
fragBuilder->codeAppendf("half4 %s;", outputColor->c_str());
while (childIndex >= (int) fFunctionNames.size()) {
fFunctionNames.emplace_back();
}
// Subtle bug workaround: If an FP (this) has a child, and wishes to sample it, but does not
// want to *force* explicit coord sampling, then the obvious solution is to call it with
// invokeChild and no coords. However, if this FP is then adopted as a child of another FP that
// does want to sample with explicit coords, that property is propagated (recursively) to all
// children, and we need to supply explicit coords. So we propagate our own "_coords" (this is
// the name of our explicit coords parameter generated in the helper function).
if (!args.fFp.coordTransformsApplyToLocalCoords() && skslCoords.length() == 0) {
skslCoords = "_coords";
}
const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex);
// Emit the child's helper function if this is the first time we've seen a call
if (fFunctionNames[childIndex].size() == 0) {
this->internalInvokeChild(childIndex, inputColor, outputColor->c_str(), args, skslCoords);
} else {
const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex);
fragBuilder->onBeforeChildProcEmitCode(); // call first so mangleString is updated
TransformedCoordVars coordVars = args.fTransformedCoords.childInputs(childIndex);
TextureSamplers textureSamplers = args.fTexSamplers.childInputs(childIndex);
EmitArgs childArgs(fragBuilder,
args.fUniformHandler,
args.fShaderCaps,
childProc,
outputColor->c_str(),
"_output",
"_input",
coordVars,
textureSamplers);
this->writeChildCall(fragBuilder, childIndex, coordVars, inputColor, outputColor->c_str(),
childArgs, skslCoords);
}
}
fFunctionNames[childIndex] =
fragBuilder->writeProcessorFunction(this->childProcessor(childIndex), childArgs);
void GrGLSLFragmentProcessor::internalInvokeChild(int childIndex, const char* inputColor,
const char* outputColor, EmitArgs& args,
SkSL::String skslCoords) {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->onBeforeChildProcEmitCode(); // call first so mangleString is updated
// Prepare a mangled input color variable if the default is not used,
// inputName remains the empty string if no variable is needed.
SkString inputName;
if (inputColor&& strcmp("half4(1.0)", inputColor) != 0 && strcmp("half4(1)", inputColor) != 0) {
// The input name is based off of the current mangle string, and
// since this is called after onBeforeChildProcEmitCode(), it will be
// unique to the child processor (exactly what we want for its input).
inputName.appendf("_childInput%s", fragBuilder->getMangleString().c_str());
fragBuilder->codeAppendf("half4 %s = %s;", inputName.c_str(), inputColor);
fragBuilder->onAfterChildProcEmitCode();
}
const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex);
TransformedCoordVars coordVars = args.fTransformedCoords.childInputs(childIndex);
TextureSamplers textureSamplers = args.fTexSamplers.childInputs(childIndex);
// If the fragment processor is invoked with overridden coordinates, it must *always* be invoked
// with overridden coords.
SkASSERT(childProc.coordTransformsApplyToLocalCoords() == (skslCoords.length() == 0));
EmitArgs childArgs(fragBuilder,
args.fUniformHandler,
args.fShaderCaps,
childProc,
outputColor,
"_input",
coordVars,
textureSamplers);
fFunctionNames[childIndex] = fragBuilder->writeProcessorFunction(
this->childProcessor(childIndex),
childArgs);
this->writeChildCall(fragBuilder, childIndex, coordVars, inputColor, outputColor, childArgs,
skslCoords);
fragBuilder->onAfterChildProcEmitCode();
// Produce a string containing the call to the helper function
SkString result = SkStringPrintf("%s(%s", fFunctionNames[childIndex].c_str(),
inputColor ? inputColor : "half4(1)");
if (skslCoords.length()) {
result.appendf(", %s", skslCoords.c_str());
}
result.append(")");
return result;
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -137,21 +137,20 @@ public:
GrGLSLFragmentProcessor* childProcessor(int index) const { return fChildProcessors[index]; }
// Invoke the child with the default input color (solid white)
inline void invokeChild(int childIndex, SkString* outputColor, EmitArgs& parentArgs,
SkSL::String skslCoords = "") {
this->invokeChild(childIndex, nullptr, outputColor, parentArgs, skslCoords);
inline SkString invokeChild(int childIndex, EmitArgs& parentArgs,
SkSL::String skslCoords = "") {
return this->invokeChild(childIndex, nullptr, parentArgs, skslCoords);
}
/** Invokes a child proc in its own scope. Pass in the parent's EmitArgs and invokeChild will
* automatically extract the coords and samplers of that child and pass them on to the child's
* emitCode(). Also, any uniforms or functions emitted by the child will have their names
* mangled to prevent redefinitions. The output color name is also mangled therefore in an
* in/out param. It will be declared in mangled form by invokeChild(). It is legal to pass
* nullptr as inputColor, since all fragment processors are required to work without an input
* color.
* mangled to prevent redefinitions. The returned string contains the output color (as a call
* to the child's helper function). It is legal to pass nullptr as inputColor, since all
* fragment processors are required to work without an input color.
*/
void invokeChild(int childIndex, const char* inputColor, SkString* outputColor,
EmitArgs& parentArgs, SkSL::String skslCoords = "");
SkString invokeChild(int childIndex, const char* inputColor, EmitArgs& parentArgs,
SkSL::String skslCoords = "");
/**
* Pre-order traversal of a GLSLFP hierarchy, or of multiple trees with roots in an array of
@ -185,13 +184,6 @@ protected:
virtual void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) {}
private:
void writeChildCall(GrGLSLFPFragmentBuilder* fragBuilder, int childIndex,
TransformedCoordVars coordVars, const char* inputColor,
const char* outputColor, EmitArgs& args,
SkSL::String skslCoords);
void internalInvokeChild(int, const char*, const char*, EmitArgs&, SkSL::String);
// one per child; either not present or empty string if not yet emitted
SkTArray<SkString> fFunctionNames;

View File

@ -35,8 +35,8 @@ public:
kHalf4_GrSLType, "leftBorderColor");
rightBorderColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
kHalf4_GrSLType, "rightBorderColor");
SkString _sample1099("_sample1099");
this->invokeChild(_outer.gradLayout_index, &_sample1099, args);
SkString _sample1099;
_sample1099 = this->invokeChild(_outer.gradLayout_index, args);
fragBuilder->codeAppendf(
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else if (t.x < "
"0.0) {\n %s = %s;\n} else if (t.x > 1.0) {\n %s = %s;\n} else {",
@ -47,8 +47,8 @@ public:
args.fUniformHandler->getUniformCStr(leftBorderColorVar), args.fOutputColor,
args.fUniformHandler->getUniformCStr(rightBorderColorVar));
SkString _input1767("t");
SkString _sample1767("_sample1767");
this->invokeChild(_outer.colorizer_index, _input1767.c_str(), &_sample1767, args);
SkString _sample1767;
_sample1767 = this->invokeChild(_outer.colorizer_index, _input1767.c_str(), args);
fragBuilder->codeAppendf("\n %s = %s;\n}\n@if (%s) {\n %s.xyz *= %s.w;\n}\n",
args.fOutputColor, _sample1767.c_str(),
(_outer.makePremul ? "true" : "false"), args.fOutputColor,

View File

@ -29,8 +29,8 @@ public:
(void)makePremul;
auto colorsAreOpaque = _outer.colorsAreOpaque;
(void)colorsAreOpaque;
SkString _sample453("_sample453");
this->invokeChild(_outer.gradLayout_index, &_sample453, args);
SkString _sample453;
_sample453 = this->invokeChild(_outer.gradLayout_index, args);
fragBuilder->codeAppendf(
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else {\n @if "
"(%s) {\n half t_1 = t.x - 1.0;\n half tiled_t = (t_1 - 2.0 * "
@ -42,8 +42,8 @@ public:
: "false"),
args.fOutputColor, (_outer.mirror ? "true" : "false"));
SkString _input1464("t");
SkString _sample1464("_sample1464");
this->invokeChild(_outer.colorizer_index, _input1464.c_str(), &_sample1464, args);
SkString _sample1464;
_sample1464 = this->invokeChild(_outer.colorizer_index, _input1464.c_str(), args);
fragBuilder->codeAppendf("\n %s = %s;\n}\n@if (%s) {\n %s.xyz *= %s.w;\n}\n",
args.fOutputColor, _sample1464.c_str(),
(_outer.makePremul ? "true" : "false"), args.fOutputColor,

View File

@ -165,8 +165,7 @@ private:
fragBuilder->codeAppendf("half4 diffuseColor = %s;", args.fInputColor);
SkString dstNormalName("dstNormal");
this->invokeChild(0, &dstNormalName, args);
SkString dstNormalName = this->invokeChild(0, args);
fragBuilder->codeAppendf("float3 normal = %s.xyz;", dstNormalName.c_str());

View File

@ -444,7 +444,7 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
// Write the output handling after the possible input handling
String childName = "_sample" + to_string(c.fOffset);
addExtraEmitCodeLine("SkString " + childName + "(\"" + childName + "\");");
addExtraEmitCodeLine("SkString " + childName + ";");
String coordsName;
if (hasCoords) {
coordsName = "_coords" + to_string(c.fOffset);
@ -454,23 +454,22 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
addExtraEmitCodeLine("if (_outer." + String(child.fName) + "_index >= 0) {\n ");
}
if (hasCoords) {
addExtraEmitCodeLine("this->invokeChild(_outer." + String(child.fName) + "_index" +
inputArg + ", &" + childName + ", args, " + coordsName +
".c_str());");
addExtraEmitCodeLine(childName + " = this->invokeChild(_outer." + String(child.fName) +
"_index" + inputArg + ", args, " + coordsName + ".c_str());");
} else {
addExtraEmitCodeLine("this->invokeChild(_outer." + String(child.fName) + "_index" +
inputArg + ", &" + childName + ", args);");
addExtraEmitCodeLine(childName + " = this->invokeChild(_outer." + String(child.fName) +
"_index" + inputArg + ", args);");
}
if (c.fArguments[0]->fType.kind() == Type::kNullable_Kind) {
// Null FPs are not emitted, but their output can still be referenced in dependent
// expressions - thus we always declare the variable.
// expressions - thus we always fill the variable with something.
// Note: this is essentially dead code required to satisfy the compiler, because
// 'process' function calls should always be guarded at a higher level, in the .fp
// source.
addExtraEmitCodeLine(
"} else {"
" fragBuilder->codeAppendf(\"half4 %s;\", " + childName + ".c_str());"
" " + childName + " = \"half4(1)\";"
"}");
}
this->write("%s");

View File

@ -115,8 +115,7 @@ private:
class GLFP : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs& args) override {
SkString temp("inColor");
this->invokeChild(0, &temp, args);
SkString temp = this->invokeChild(0, args);
args.fFragBuilder->codeAppendf("%s = %s;", args.fOutputColor, temp.c_str());
}

View File

@ -487,10 +487,10 @@ DEF_TEST(SkSLFPChildProcessors, r) {
"this->registerChildProcessor(std::move(child2));"
},
{
"SkString _sample93(\"_sample93\");\n",
"this->invokeChild(_outer.child1_index, &_sample93, args);\n",
"SkString _sample110(\"_sample110\");\n",
"this->invokeChild(_outer.child2_index, &_sample110, args);\n",
"SkString _sample93;\n",
"_sample93 = this->invokeChild(_outer.child1_index, args);\n",
"SkString _sample110;\n",
"_sample110 = this->invokeChild(_outer.child2_index, args);\n",
"fragBuilder->codeAppendf(\"%s = %s * %s;\\n\", args.fOutputColor, _sample93.c_str(), "
"_sample110.c_str());\n",
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
@ -515,12 +515,12 @@ DEF_TEST(SkSLFPChildProcessorsWithInput, r) {
},
{
"SkString _input128(\"childIn\");",
"SkString _sample128(\"_sample128\");",
"this->invokeChild(_outer.child1_index, _input128.c_str(), &_sample128, args);",
"SkString _sample128;",
"_sample128 = this->invokeChild(_outer.child1_index, _input128.c_str(), args);",
"fragBuilder->codeAppendf(\"\\nhalf4 childOut1 = %s;\", _sample128.c_str());",
"SkString _input174(\"childOut1\");",
"SkString _sample174(\"_sample174\");",
"this->invokeChild(_outer.child2_index, _input174.c_str(), &_sample174, args);",
"SkString _sample174;",
"_sample174 = this->invokeChild(_outer.child2_index, _input174.c_str(), args);",
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
});
@ -538,8 +538,8 @@ DEF_TEST(SkSLFPChildProcessorWithInputExpression, r) {
},
{
"SkString _input64 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
"SkString _sample64(\"_sample64\");",
"this->invokeChild(_outer.child_index, _input64.c_str(), &_sample64, args);",
"SkString _sample64;",
"_sample64 = this->invokeChild(_outer.child_index, _input64.c_str(), args);",
"fragBuilder->codeAppendf(\"%s = %s;\\n\", args.fOutputColor, _sample64.c_str());",
"this->registerChildProcessor(src.childProcessor(child_index).clone());",
});
@ -559,11 +559,11 @@ DEF_TEST(SkSLFPNestedChildProcessors, r) {
},
{
"SkString _input121 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
"SkString _sample121(\"_sample121\");",
"this->invokeChild(_outer.child1_index, _input121.c_str(), &_sample121, args);",
"SkString _sample121;",
"_sample121 = this->invokeChild(_outer.child1_index, _input121.c_str(), args);",
"SkString _input93 = SkStringPrintf(\"%s * %s\", args.fInputColor, _sample121.c_str());",
"SkString _sample93(\"_sample93\");",
"this->invokeChild(_outer.child2_index, _input93.c_str(), &_sample93, args);",
"SkString _sample93;",
"_sample93 = this->invokeChild(_outer.child2_index, _input93.c_str(), args);",
"fragBuilder->codeAppendf(\"%s = %s;\\n\", args.fOutputColor, _sample93.c_str());",
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
@ -590,8 +590,8 @@ DEF_TEST(SkSLFPChildFPAndGlobal, r) {
"fragBuilder->codeAppendf(\"bool hasCap = %s;\\nif (hasCap) {\", (hasCap ? \"true\" : "
"\"false\"));",
"SkString _input130 = SkStringPrintf(\"%s\", args.fInputColor);",
"SkString _sample130(\"_sample130\");",
"this->invokeChild(_outer.child_index, _input130.c_str(), &_sample130, args);",
"SkString _sample130;",
"_sample130 = this->invokeChild(_outer.child_index, _input130.c_str(), args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\","
" args.fOutputColor, _sample130.c_str(), args.fOutputColor);",
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
@ -616,8 +616,8 @@ DEF_TEST(SkSLFPChildProcessorInlineFieldAccess, r) {
"fragBuilder->codeAppendf(\"if (%s) {\", "
"(_outer.childProcessor(_outer.child_index).preservesOpaqueInput() ? ",
"SkString _input105 = SkStringPrintf(\"%s\", args.fInputColor);",
"SkString _sample105(\"_sample105\");",
"this->invokeChild(_outer.child_index, _input105.c_str(), &_sample105, args);",
"SkString _sample105;",
"_sample105 = this->invokeChild(_outer.child_index, _input105.c_str(), args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\","
" args.fOutputColor, _sample105.c_str(), args.fOutputColor);",
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
@ -643,8 +643,8 @@ DEF_TEST(SkSLFPChildProcessorFieldAccess, r) {
"opaque = _outer.childProcessor(_outer.child_index).preservesOpaqueInput();",
"fragBuilder->codeAppendf(\"bool opaque = %s;\\nif (opaque) {\", (opaque ? \"true\" : "
"\"false\"));",
"SkString _sample126(\"_sample126\");",
"this->invokeChild(_outer.child_index, &_sample126, args);",
"SkString _sample126;",
"_sample126 = this->invokeChild(_outer.child_index, args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\","
" args.fOutputColor, _sample126.c_str(), args.fOutputColor);",
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
@ -666,9 +666,9 @@ DEF_TEST(SkSLFPNullableChildProcessor, r) {
{
"fragBuilder->codeAppendf(\"if (%s) {\", _outer.child_index >= 0 ? \"true\" : "
"\"false\");",
"SkString _sample93(\"_sample93\");",
"SkString _sample93;",
"if (_outer.child_index >= 0) {",
"this->invokeChild(_outer.child_index, &_sample93, args);",
"_sample93 = this->invokeChild(_outer.child_index, args);",
"}",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\","
" args.fOutputColor, _sample93.c_str(), args.fOutputColor);"
@ -696,14 +696,14 @@ DEF_TEST(SkSLFPSampleCoords, r) {
*SkSL::ShaderCapsFactory::Default(),
{},
{
"SkString _sample94(\"_sample94\");\n",
"this->invokeChild(_outer.child_index, &_sample94, args);\n",
"SkString _sample110(\"_sample110\");\n",
"SkString _sample94;\n",
"_sample94 = this->invokeChild(_outer.child_index, args);\n",
"SkString _sample110;\n",
"SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D("
"args.fTransformedCoords[0].fVaryingPoint);\n",
"SkString _coords110 = SkStringPrintf(\"%s / 2.0\", "
"sk_TransformedCoords2D_0.c_str());\n",
"this->invokeChild(_outer.child_index, &_sample110, args, _coords110.c_str());\n",
"_sample110 = this->invokeChild(_outer.child_index, args, _coords110.c_str());\n",
"fragBuilder->codeAppendf(\"%s = %s + %s;\\n\", args.fOutputColor, _sample94.c_str(), "
"_sample110.c_str());\n"
});