Make invokeChild default to fInputColor, rather than half4(1)
By extension, this changes the default behavior of sample() in .fp files. This lets us remove the explicit fInputColor/sk_InColor arguments everywhere. Most sites that were using the default no longer care what's passed, as the child is known to be a texture effect that will ignore the input color. The few remaining sites now explicitly pass half4(1) when necessary. Change-Id: Ie4691b049f905d098e9befe8bd07706a496f2968 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303356 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
parent
a7d9f30f4a
commit
6b5dbb4814
@ -307,7 +307,7 @@ GrGLSLFragmentProcessor* ColorTableEffect::onCreateGLSLInstance() const {
|
||||
public:
|
||||
void emitCode(EmitArgs& args) override {
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString inputColor = this->invokeChild(kInputFPIndex, args.fInputColor, args);
|
||||
SkString inputColor = this->invokeChild(kInputFPIndex, args);
|
||||
SkString a = this->invokeChild(kTexEffectFPIndex, args, "half2(coord.a, 0.5)");
|
||||
SkString r = this->invokeChild(kTexEffectFPIndex, args, "half2(coord.r, 1.5)");
|
||||
SkString g = this->invokeChild(kTexEffectFPIndex, args, "half2(coord.g, 2.5)");
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
|
||||
fColorSpaceHelper.emitCode(uniformHandler, proc.colorXform());
|
||||
|
||||
SkString childColor = this->invokeChild(0, args.fInputColor, args);
|
||||
SkString childColor = this->invokeChild(0, args);
|
||||
|
||||
SkString xformedColor;
|
||||
fragBuilder->appendColorGamutXform(&xformedColor, childColor.c_str(), &fColorSpaceHelper);
|
||||
|
@ -260,7 +260,7 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::SwizzleOutput(
|
||||
class GLFP : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
void emitCode(EmitArgs& args) override {
|
||||
SkString childColor = this->invokeChild(0, args.fInputColor, args);
|
||||
SkString childColor = this->invokeChild(0, args);
|
||||
|
||||
const SwizzleFragmentProcessor& sfp = args.fFp.cast<SwizzleFragmentProcessor>();
|
||||
const GrSwizzle& swizzle = sfp.swizzle();
|
||||
@ -327,7 +327,7 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MakeInputPremulAndMulB
|
||||
public:
|
||||
void emitCode(EmitArgs& args) override {
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString temp = this->invokeChild(0, args);
|
||||
SkString temp = this->invokeChild(0, "half4(1)", args);
|
||||
fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, temp.c_str());
|
||||
fragBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColor,
|
||||
args.fInputColor);
|
||||
@ -407,8 +407,7 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(
|
||||
class GLFP : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
void emitCode(EmitArgs& args) override {
|
||||
// First guy's input might be nil.
|
||||
SkString result = this->invokeChild(0, args.fInputColor, args);
|
||||
SkString result = this->invokeChild(0, args);
|
||||
for (int i = 1; i < this->numChildProcessors(); ++i) {
|
||||
result = this->invokeChild(i, result.c_str(), args);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
|
||||
constexpr int kInputFPIndex = 1;
|
||||
SkString inputColor = this->invokeChild(kInputFPIndex, args.fInputColor, args);
|
||||
SkString inputColor = this->invokeChild(kInputFPIndex, args);
|
||||
|
||||
f->codeAppendf("%s = %s * coverage;", args.fOutputColor, inputColor.c_str());
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void main() {
|
||||
@if (edgeType == GrClipEdgeType::kInverseFillBW || edgeType == GrClipEdgeType::kInverseFillAA) {
|
||||
alpha = 1.0 - alpha;
|
||||
}
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
sk_OutColor = inputColor * alpha;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ in uniform half outerThreshold;
|
||||
}
|
||||
|
||||
void main() {
|
||||
half4 color = sample(inputFP, sk_InColor);
|
||||
half4 color = sample(inputFP);
|
||||
half4 mask_color = sample(maskFP);
|
||||
if (mask_color.a < 0.5) {
|
||||
if (color.a > outerThreshold) {
|
||||
|
@ -15,7 +15,7 @@ layout(ctype=SkV4) in uniform float4 k;
|
||||
layout(key) in bool enforcePMColor;
|
||||
|
||||
void main() {
|
||||
half4 src = sample(srcFP, sk_InColor);
|
||||
half4 src = sample(srcFP);
|
||||
half4 dst = sample(dstFP);
|
||||
sk_OutColor = saturate(half(k.x) * src * dst +
|
||||
half(k.y) * src +
|
||||
|
@ -14,7 +14,7 @@ in fragmentProcessor? inputFP;
|
||||
layout(key) in Mode mode;
|
||||
|
||||
void main() {
|
||||
half inputAlpha = sample(inputFP, sk_InColor).a;
|
||||
half inputAlpha = sample(inputFP).a;
|
||||
half factor = 1.0 - inputAlpha;
|
||||
@switch (mode) {
|
||||
case Mode::kGaussian:
|
||||
|
@ -297,7 +297,7 @@ void main() {
|
||||
// rearrange to avoid passing large values to length() that would overflow.
|
||||
half2 vec = half2((sk_FragCoord.xy - circleData.xy) * circleData.w);
|
||||
half dist = length(vec) + (0.5 - circleData.z) * circleData.w;
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
sk_OutColor = inputColor * sample(blurProfile, half2(dist, 0.5)).a;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ void main() {
|
||||
} else {
|
||||
d = half((1.0 - length((circle.xy - sk_FragCoord.xy) * circle.w)) * circle.z);
|
||||
}
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
@if (edgeType == GrClipEdgeType::kFillAA ||
|
||||
edgeType == GrClipEdgeType::kInverseFillAA) {
|
||||
sk_OutColor = inputColor * saturate(d);
|
||||
|
@ -15,7 +15,7 @@ layout(key) in bool clampToPremul;
|
||||
}
|
||||
|
||||
void main() {
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
@if (clampToPremul) {
|
||||
half alpha = saturate(inputColor.a);
|
||||
sk_OutColor = half4(clamp(inputColor.rgb, 0, alpha), alpha);
|
||||
|
@ -18,7 +18,7 @@ layout(key) in bool premulOutput;
|
||||
}
|
||||
|
||||
void main() {
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
@if (unpremulInput) {
|
||||
inputColor = unpremul(inputColor);
|
||||
}
|
||||
|
@ -10,7 +10,5 @@ in fragmentProcessor? child2;
|
||||
in uniform float weight;
|
||||
|
||||
void main() {
|
||||
sk_OutColor = mix(child1 != null ? sample(child1) : sk_InColor,
|
||||
child2 != null ? sample(child2) : sk_InColor,
|
||||
half(weight));
|
||||
sk_OutColor = mix(sample(child1), sample(child2), half(weight));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppend("\talpha = 1.0 - alpha;\n");
|
||||
}
|
||||
|
||||
SkString inputSample = this->invokeChild(/*childIndex=*/0, args.fInputColor, args);
|
||||
SkString inputSample = this->invokeChild(/*childIndex=*/0, args);
|
||||
|
||||
fragBuilder->codeAppendf("\t%s = %s * alpha;\n", args.fOutputColor, inputSample.c_str());
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
in fragmentProcessor fp;
|
||||
|
||||
void main() {
|
||||
sk_OutColor = sample(fp, sk_InColor, sk_FragCoord.xy);
|
||||
sk_OutColor = sample(fp, sk_FragCoord.xy);
|
||||
}
|
||||
|
||||
@optimizationFlags {
|
||||
|
@ -11,7 +11,7 @@ in fragmentProcessor inputFP;
|
||||
in uniform half range;
|
||||
|
||||
void main() {
|
||||
half4 color = sample(inputFP, sk_InColor);
|
||||
half4 color = sample(inputFP);
|
||||
half value;
|
||||
@if (sk_Caps.integerSupport)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ void main() {
|
||||
// hairline not supported
|
||||
discard;
|
||||
}
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
sk_OutColor = inputColor * alpha;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
in fragmentProcessor? inputFP;
|
||||
|
||||
void main() {
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
half3 hsl = inputColor.rgb;
|
||||
|
||||
half C = (1 - abs(2 * hsl.z - 1)) * hsl.y;
|
||||
|
@ -32,7 +32,7 @@ half HSLToRGB(half p, half q, half t) {
|
||||
void main() {
|
||||
const half3 SK_ITU_BT709_LUM_COEFF = half3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
half4 inColor = sample(inputFP, sk_InColor);
|
||||
half4 inColor = sample(inputFP);
|
||||
half4 color = unpremul(inColor);
|
||||
|
||||
@if (linearize) {
|
||||
|
@ -25,7 +25,7 @@ in fragmentProcessor? inputFP;
|
||||
}
|
||||
|
||||
void main() {
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
const half3 SK_ITU_BT709_LUM_COEFF = half3(0.2126, 0.7152, 0.0722);
|
||||
half luma = saturate(dot(SK_ITU_BT709_LUM_COEFF, inputColor.rgb));
|
||||
sk_OutColor = half4(0, 0, 0, luma);
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
void emitCode(EmitArgs& args) override {
|
||||
fMatrixVar = args.fUniformHandler->addUniform(&args.fFp, kFragment_GrShaderFlag,
|
||||
kFloat3x3_GrSLType, "matrix");
|
||||
SkString child = this->invokeChildWithMatrix(0, args.fInputColor, args);
|
||||
SkString child = this->invokeChildWithMatrix(0, args);
|
||||
args.fFragBuilder->codeAppendf("%s = %s;\n", args.fOutputColor, child.c_str());
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,6 @@ in uniform half weight;
|
||||
}
|
||||
|
||||
void main() {
|
||||
half4 inColor = sample(inputFP, sk_InColor);
|
||||
half4 inColor = sample(inputFP);
|
||||
sk_OutColor = mix(sample(fp0, inColor), sample(fp1, inColor), weight);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
in fragmentProcessor? inputFP;
|
||||
|
||||
void main() {
|
||||
half4 c = sample(inputFP, sk_InColor);
|
||||
half4 c = sample(inputFP);
|
||||
half4 p = (c.g < c.b) ? half4(c.bg, -1, 2/3.0)
|
||||
: half4(c.gb, 0, -1/3.0);
|
||||
half4 q = (c.r < p.x) ? half4(p.x, c.r, p.yw)
|
||||
|
@ -214,7 +214,7 @@ void main() {
|
||||
half2 proxyDims = half2(2.0 * edgeSize);
|
||||
half2 texCoord = translatedFragPos / proxyDims;
|
||||
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
sk_OutColor = inputColor * sample(ninePatchFP, texCoord);
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppend("alpha = 1.0 - alpha;");
|
||||
}
|
||||
|
||||
SkString inputSample = this->invokeChild(/*childIndex=*/0, args.fInputColor, args);
|
||||
SkString inputSample = this->invokeChild(/*childIndex=*/0, args);
|
||||
|
||||
fragBuilder->codeAppendf("%s = %s * alpha;", args.fOutputColor, inputSample.c_str());
|
||||
}
|
||||
@ -623,7 +623,7 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppend("half alpha = clamp(0.5 + approx_dist, 0.0, 1.0);");
|
||||
}
|
||||
|
||||
SkString inputSample = this->invokeChild(/*childIndex=*/0, args.fInputColor, args);
|
||||
SkString inputSample = this->invokeChild(/*childIndex=*/0, args);
|
||||
|
||||
fragBuilder->codeAppendf("%s = %s * alpha;", args.fOutputColor, inputSample.c_str());
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ void main() {
|
||||
yCoverage = 1 - sample(integral, half2(rect.T, 0.5)).a
|
||||
- sample(integral, half2(rect.B, 0.5)).a;
|
||||
}
|
||||
half4 inputColor = sample(inputFP, sk_InColor);
|
||||
half4 inputColor = sample(inputFP);
|
||||
sk_OutColor = inputColor * xCoverage * yCoverage;
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,7 @@ public:
|
||||
break;
|
||||
case SkSL::Compiler::FormatArg::Kind::kChildProcessor: {
|
||||
SkSL::String coords = this->expandFormatArgs(arg.fCoords, args, fmtArg);
|
||||
result += this->invokeChild(arg.fIndex, args.fInputColor, args, coords)
|
||||
.c_str();
|
||||
result += this->invokeChild(arg.fIndex, args, coords).c_str();
|
||||
break;
|
||||
}
|
||||
case SkSL::Compiler::FormatArg::Kind::kChildProcessorWithMatrix: {
|
||||
@ -60,7 +59,7 @@ public:
|
||||
|
||||
SkSL::String coords = this->expandFormatArgs(arg.fCoords, args, fmtArg);
|
||||
result += this->invokeChildWithMatrix(
|
||||
arg.fIndex, args.fInputColor, args,
|
||||
arg.fIndex, args,
|
||||
sampleUsage.hasUniformMatrix() ? "" : coords)
|
||||
.c_str();
|
||||
break;
|
||||
|
@ -281,9 +281,9 @@ void GLComposeFragmentProcessor::emitCode(EmitArgs& args) {
|
||||
switch (behavior) {
|
||||
case ComposeBehavior::kComposeOneBehavior:
|
||||
// Compose-one operations historically leave the alpha on the input color.
|
||||
srcColor = cs.childProcessor(0) ? this->invokeChild(0, args)
|
||||
srcColor = cs.childProcessor(0) ? this->invokeChild(0, "half4(1)", args)
|
||||
: SkString(args.fInputColor);
|
||||
dstColor = cs.childProcessor(1) ? this->invokeChild(1, args)
|
||||
dstColor = cs.childProcessor(1) ? this->invokeChild(1, "half4(1)", args)
|
||||
: SkString(args.fInputColor);
|
||||
break;
|
||||
|
||||
@ -296,7 +296,7 @@ void GLComposeFragmentProcessor::emitCode(EmitArgs& args) {
|
||||
|
||||
case ComposeBehavior::kSkModeBehavior:
|
||||
// SkModeColorFilter operations act like ComposeOne, but pass the input color to dst.
|
||||
srcColor = cs.childProcessor(0) ? this->invokeChild(0, args)
|
||||
srcColor = cs.childProcessor(0) ? this->invokeChild(0, "half4(1)", args)
|
||||
: SkString(args.fInputColor);
|
||||
dstColor = cs.childProcessor(1) ? this->invokeChild(1, args.fInputColor, args)
|
||||
: SkString(args.fInputColor);
|
||||
|
@ -57,8 +57,7 @@ half alpha;
|
||||
args.fUniformHandler->getUniformCStr(rectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(rectUniformVar), (int)_outer.edgeType,
|
||||
(int)_outer.edgeType);
|
||||
SkString _input1677(args.fInputColor);
|
||||
SkString _sample1677 = this->invokeChild(0, _input1677.c_str(), args);
|
||||
SkString _sample1677 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 inputColor = %s;
|
||||
|
@ -32,11 +32,10 @@ public:
|
||||
kHalf_GrSLType, "innerThreshold");
|
||||
outerThresholdVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag,
|
||||
kHalf_GrSLType, "outerThreshold");
|
||||
SkString _input515(args.fInputColor);
|
||||
SkString _sample515 = this->invokeChild(0, _input515.c_str(), args);
|
||||
SkString _sample515 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 color = %s;)SkSL", _sample515.c_str());
|
||||
SkString _sample567 = this->invokeChild(1, args);
|
||||
SkString _sample555 = this->invokeChild(1, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 mask_color = %s;
|
||||
@ -53,7 +52,7 @@ if (mask_color.w < 0.5) {
|
||||
}
|
||||
%s = color;
|
||||
)SkSL",
|
||||
_sample567.c_str(), args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||
_sample555.c_str(), args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(innerThresholdVar),
|
||||
|
@ -29,11 +29,10 @@ public:
|
||||
(void)enforcePMColor;
|
||||
kVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"k");
|
||||
SkString _input385(args.fInputColor);
|
||||
SkString _sample385 = this->invokeChild(0, _input385.c_str(), args);
|
||||
SkString _sample385 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 src = %s;)SkSL", _sample385.c_str());
|
||||
SkString _sample428 = this->invokeChild(1, args);
|
||||
SkString _sample416 = this->invokeChild(1, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 dst = %s;
|
||||
@ -42,7 +41,7 @@ half4 dst = %s;
|
||||
%s.xyz = min(%s.xyz, %s.w);
|
||||
}
|
||||
)SkSL",
|
||||
_sample428.c_str(), args.fOutputColor, args.fUniformHandler->getUniformCStr(kVar),
|
||||
_sample416.c_str(), args.fOutputColor, args.fUniformHandler->getUniformCStr(kVar),
|
||||
args.fUniformHandler->getUniformCStr(kVar),
|
||||
args.fUniformHandler->getUniformCStr(kVar),
|
||||
args.fUniformHandler->getUniformCStr(kVar),
|
||||
|
@ -26,8 +26,7 @@ public:
|
||||
(void)_outer;
|
||||
auto mode = _outer.mode;
|
||||
(void)mode;
|
||||
SkString _input308(args.fInputColor);
|
||||
SkString _sample308 = this->invokeChild(0, _input308.c_str(), args);
|
||||
SkString _sample308 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half inputAlpha = %s.w;
|
||||
half factor = 1.0 - inputAlpha;
|
||||
|
@ -303,19 +303,18 @@ half dist = length(vec) + (0.5 - %s.z) * %s.w;)SkSL",
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar));
|
||||
SkString _input13902(args.fInputColor);
|
||||
SkString _sample13902 = this->invokeChild(0, _input13902.c_str(), args);
|
||||
SkString _sample13902 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 inputColor = %s;)SkSL",
|
||||
_sample13902.c_str());
|
||||
SkString _coords13962("float2(half2(dist, 0.5))");
|
||||
SkString _sample13962 = this->invokeChild(1, args, _coords13962.c_str());
|
||||
SkString _coords13950("float2(half2(dist, 0.5))");
|
||||
SkString _sample13950 = this->invokeChild(1, args, _coords13950.c_str());
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
%s = inputColor * %s.w;
|
||||
)SkSL",
|
||||
args.fOutputColor, _sample13962.c_str());
|
||||
args.fOutputColor, _sample13950.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -48,8 +48,7 @@ half d;
|
||||
args.fUniformHandler->getUniformCStr(circleVar),
|
||||
args.fUniformHandler->getUniformCStr(circleVar),
|
||||
args.fUniformHandler->getUniformCStr(circleVar));
|
||||
SkString _input2509(args.fInputColor);
|
||||
SkString _sample2509 = this->invokeChild(0, _input2509.c_str(), args);
|
||||
SkString _sample2509 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 inputColor = %s;
|
||||
|
@ -25,8 +25,7 @@ public:
|
||||
(void)_outer;
|
||||
auto clampToPremul = _outer.clampToPremul;
|
||||
(void)clampToPremul;
|
||||
SkString _input464(args.fInputColor);
|
||||
SkString _sample464 = this->invokeChild(0, _input464.c_str(), args);
|
||||
SkString _sample464 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 inputColor = %s;
|
||||
@if (%s) {
|
||||
|
@ -38,8 +38,7 @@ public:
|
||||
"m");
|
||||
vVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
"v");
|
||||
SkString _input585(args.fInputColor);
|
||||
SkString _sample585 = this->invokeChild(0, _input585.c_str(), args);
|
||||
SkString _sample585 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 inputColor = %s;
|
||||
@if (%s) {
|
||||
|
@ -27,14 +27,13 @@ public:
|
||||
(void)weight;
|
||||
weightVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag,
|
||||
kFloat_GrSLType, "weight");
|
||||
SkString _sample290 = this->invokeChild(0, args);
|
||||
SkString _sample358 = this->invokeChild(1, args);
|
||||
SkString _sample273 = this->invokeChild(0, args);
|
||||
SkString _sample289 = this->invokeChild(1, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(%s = mix(%s ? %s : %s, %s ? %s : %s, half(%s));
|
||||
R"SkSL(%s = mix(%s, %s, half(%s));
|
||||
)SkSL",
|
||||
args.fOutputColor, _outer.childProcessor(0) ? "true" : "false", _sample290.c_str(),
|
||||
args.fInputColor, _outer.childProcessor(1) ? "true" : "false", _sample358.c_str(),
|
||||
args.fInputColor, args.fUniformHandler->getUniformCStr(weightVar));
|
||||
args.fOutputColor, _sample273.c_str(), _sample289.c_str(),
|
||||
args.fUniformHandler->getUniformCStr(weightVar));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -23,9 +23,8 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrDeviceSpaceEffect& _outer = args.fFp.cast<GrDeviceSpaceEffect>();
|
||||
(void)_outer;
|
||||
SkString _input203(args.fInputColor);
|
||||
SkString _coords203("sk_FragCoord.xy");
|
||||
SkString _sample203 = this->invokeChild(0, _input203.c_str(), args, _coords203.c_str());
|
||||
SkString _sample203 = this->invokeChild(0, args, _coords203.c_str());
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(%s = %s;
|
||||
)SkSL",
|
||||
|
@ -27,8 +27,7 @@ public:
|
||||
(void)range;
|
||||
rangeVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
"range");
|
||||
SkString _input302(args.fInputColor);
|
||||
SkString _sample302 = this->invokeChild(0, _input302.c_str(), args);
|
||||
SkString _sample302 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 color = %s;
|
||||
half value;
|
||||
|
@ -80,8 +80,7 @@ half alpha;
|
||||
args.fUniformHandler->getUniformCStr(ellipseVar),
|
||||
scaleVar.isValid() ? args.fUniformHandler->getUniformCStr(scaleVar) : "float2(0)",
|
||||
(int)_outer.edgeType);
|
||||
SkString _input4481(args.fInputColor);
|
||||
SkString _sample4481 = this->invokeChild(0, _input4481.c_str(), args);
|
||||
SkString _sample4481 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 inputColor = %s;
|
||||
|
@ -23,8 +23,7 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrHSLToRGBFilterEffect& _outer = args.fFp.cast<GrHSLToRGBFilterEffect>();
|
||||
(void)_outer;
|
||||
SkString _input523(args.fInputColor);
|
||||
SkString _sample523 = this->invokeChild(0, _input523.c_str(), args);
|
||||
SkString _sample523 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 inputColor = %s;
|
||||
half3 hsl = inputColor.xyz;
|
||||
|
@ -47,8 +47,7 @@ if (t > 1.0) t -= 1.0;
|
||||
return t < 0.16666666666666666 ? p + ((q - p) * 6.0) * t : (t < 0.5 ? q : (t < 0.66666666666666663 ? p + ((q - p) * (0.66666666666666663 - t)) * 6.0 : p));
|
||||
)SkSL",
|
||||
&HSLToRGB_name);
|
||||
SkString _input896(args.fInputColor);
|
||||
SkString _sample896 = this->invokeChild(0, _input896.c_str(), args);
|
||||
SkString _sample896 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 inColor = %s;
|
||||
|
@ -23,8 +23,7 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrLumaColorFilterEffect& _outer = args.fFp.cast<GrLumaColorFilterEffect>();
|
||||
(void)_outer;
|
||||
SkString _input870(args.fInputColor);
|
||||
SkString _sample870 = this->invokeChild(0, _input870.c_str(), args);
|
||||
SkString _sample870 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 inputColor = %s;
|
||||
|
||||
|
@ -27,19 +27,18 @@ public:
|
||||
(void)weight;
|
||||
weightVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag,
|
||||
kHalf_GrSLType, "weight");
|
||||
SkString _input1099(args.fInputColor);
|
||||
SkString _sample1099 = this->invokeChild(0, _input1099.c_str(), args);
|
||||
SkString _sample1099 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 inColor = %s;)SkSL", _sample1099.c_str());
|
||||
SkString _input1150("inColor");
|
||||
SkString _sample1150 = this->invokeChild(1, _input1150.c_str(), args);
|
||||
SkString _input1172("inColor");
|
||||
SkString _sample1172 = this->invokeChild(2, _input1172.c_str(), args);
|
||||
SkString _input1138("inColor");
|
||||
SkString _sample1138 = this->invokeChild(1, _input1138.c_str(), args);
|
||||
SkString _input1160("inColor");
|
||||
SkString _sample1160 = this->invokeChild(2, _input1160.c_str(), args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
%s = mix(%s, %s, %s);
|
||||
)SkSL",
|
||||
args.fOutputColor, _sample1150.c_str(), _sample1172.c_str(),
|
||||
args.fOutputColor, _sample1138.c_str(), _sample1160.c_str(),
|
||||
args.fUniformHandler->getUniformCStr(weightVar));
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,7 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrRGBToHSLFilterEffect& _outer = args.fFp.cast<GrRGBToHSLFilterEffect>();
|
||||
(void)_outer;
|
||||
SkString _input1173(args.fInputColor);
|
||||
SkString _sample1173 = this->invokeChild(0, _input1173.c_str(), args);
|
||||
SkString _sample1173 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(half4 c = %s;
|
||||
half4 p = c.y < c.z ? half4(c.zy, -1.0, 0.66666666666666663) : half4(c.yz, 0.0, -0.33333333333333331);
|
||||
|
@ -94,19 +94,18 @@ half2 texCoord = translatedFragPos / proxyDims;)SkSL",
|
||||
args.fUniformHandler->getUniformCStr(proxyRectVar),
|
||||
args.fUniformHandler->getUniformCStr(blurRadiusVar),
|
||||
args.fUniformHandler->getUniformCStr(cornerRadiusVar));
|
||||
SkString _input9561(args.fInputColor);
|
||||
SkString _sample9561 = this->invokeChild(0, _input9561.c_str(), args);
|
||||
SkString _sample9561 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 inputColor = %s;)SkSL",
|
||||
_sample9561.c_str());
|
||||
SkString _coords9621("float2(texCoord)");
|
||||
SkString _sample9621 = this->invokeChild(1, args, _coords9621.c_str());
|
||||
SkString _coords9609("float2(texCoord)");
|
||||
SkString _sample9609 = this->invokeChild(1, args, _coords9609.c_str());
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
%s = inputColor * %s;
|
||||
)SkSL",
|
||||
args.fOutputColor, _sample9621.c_str());
|
||||
args.fOutputColor, _sample9609.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -95,8 +95,7 @@ half xCoverage, yCoverage;
|
||||
yCoverage = (1.0 - %s.w) - %s.w;
|
||||
})SkSL",
|
||||
_sample8728.c_str(), _sample8791.c_str());
|
||||
SkString _input8860(args.fInputColor);
|
||||
SkString _sample8860 = this->invokeChild(0, _input8860.c_str(), args);
|
||||
SkString _sample8860 = this->invokeChild(0, args);
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(
|
||||
half4 inputColor = %s;
|
||||
|
@ -43,7 +43,7 @@ void GrGLSLFragmentProcessor::emitChildFunction(int childIndex, EmitArgs& args)
|
||||
SkString GrGLSLFragmentProcessor::invokeChild(int childIndex, const char* inputColor,
|
||||
EmitArgs& args, SkSL::String skslCoords) {
|
||||
if (!inputColor) {
|
||||
inputColor = "half4(1)";
|
||||
inputColor = args.fInputColor;
|
||||
}
|
||||
|
||||
SkASSERT(childIndex >= 0);
|
||||
@ -78,7 +78,7 @@ SkString GrGLSLFragmentProcessor::invokeChildWithMatrix(int childIndex, const ch
|
||||
EmitArgs& args,
|
||||
SkSL::String skslMatrix) {
|
||||
if (!inputColor) {
|
||||
inputColor = "half4(1)";
|
||||
inputColor = args.fInputColor;
|
||||
}
|
||||
|
||||
SkASSERT(childIndex >= 0);
|
||||
|
@ -880,8 +880,10 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
|
||||
if (floorVal.w >= stitchData.y) { floorVal.w -= stitchData.y; };)");
|
||||
}
|
||||
|
||||
SkString sampleX = this->invokeChild(0, args, "half2(floorVal.x, 0.5)");
|
||||
SkString sampleY = this->invokeChild(0, args, "half2(floorVal.z, 0.5)");
|
||||
// NOTE: We need to explicitly pass half4(1) as input color here, because the helper function
|
||||
// can't see fInputColor (which is "_input" in the FP's outer function). skbug.com/10506
|
||||
SkString sampleX = this->invokeChild(0, "half4(1)", args, "half2(floorVal.x, 0.5)");
|
||||
SkString sampleY = this->invokeChild(0, "half4(1)", args, "half2(floorVal.z, 0.5)");
|
||||
noiseCode.appendf("half2 latticeIdx = half2(%s.r, %s.r);", sampleX.c_str(), sampleY.c_str());
|
||||
|
||||
#if defined(SK_BUILD_FOR_ANDROID)
|
||||
@ -907,10 +909,10 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
|
||||
SkString dotLattice =
|
||||
SkStringPrintf("dot((lattice.ga + lattice.rb*%s)*2 - half2(1), fractVal)", inc8bit);
|
||||
|
||||
SkString sampleA = this->invokeChild(1, args, "half2(bcoords.x, chanCoord)");
|
||||
SkString sampleB = this->invokeChild(1, args, "half2(bcoords.y, chanCoord)");
|
||||
SkString sampleC = this->invokeChild(1, args, "half2(bcoords.w, chanCoord)");
|
||||
SkString sampleD = this->invokeChild(1, args, "half2(bcoords.z, chanCoord)");
|
||||
SkString sampleA = this->invokeChild(1, "half4(1)", args, "half2(bcoords.x, chanCoord)");
|
||||
SkString sampleB = this->invokeChild(1, "half4(1)", args, "half2(bcoords.y, chanCoord)");
|
||||
SkString sampleC = this->invokeChild(1, "half4(1)", args, "half2(bcoords.w, chanCoord)");
|
||||
SkString sampleD = this->invokeChild(1, "half4(1)", args, "half2(bcoords.z, chanCoord)");
|
||||
|
||||
// Compute u, at offset (0,0)
|
||||
noiseCode.appendf("half4 lattice = %s;", sampleA.c_str());
|
||||
@ -1217,7 +1219,7 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
const GrShaderVar permArgs[] = {
|
||||
{"x", kHalf_GrSLType}
|
||||
};
|
||||
SkString samplePerm = this->invokeChild(0, args, "float2(x, 0.5)");
|
||||
SkString samplePerm = this->invokeChild(0, "half4(1)", args, "float2(x, 0.5)");
|
||||
SkString permFuncName;
|
||||
SkString permCode = SkStringPrintf("return %s.r * 255;", samplePerm.c_str());
|
||||
fragBuilder->emitFunction(kHalf_GrSLType, "perm", SK_ARRAY_COUNT(permArgs), permArgs,
|
||||
@ -1228,7 +1230,7 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
{"x", kHalf_GrSLType},
|
||||
{"p", kHalf3_GrSLType}
|
||||
};
|
||||
SkString sampleGrad = this->invokeChild(1, args, "float2(x, 0.5)");
|
||||
SkString sampleGrad = this->invokeChild(1, "half4(1)", args, "float2(x, 0.5)");
|
||||
SkString gradFuncName;
|
||||
SkString gradCode = SkStringPrintf("return half(dot(%s.rgb * 255.0 - float3(1.0), p));",
|
||||
sampleGrad.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user