SkSL 'key' variables can now be controlled by 'when' expressions
Bug: skia:8880
Change-Id: I075ef57035b37250196d85bc6767eb877e445aa2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206698
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/effects/GrMixerEffect.cpp b/src/gpu/effects/GrMixerEffect.cpp
index fb0e50e..98e9a47 100644
--- a/src/gpu/effects/GrMixerEffect.cpp
+++ b/src/gpu/effects/GrMixerEffect.cpp
@@ -22,34 +22,34 @@
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrMixerEffect& _outer = args.fFp.cast<GrMixerEffect>();
(void)_outer;
- auto weight = _outer.weight();
+ auto weight = _outer.weight;
(void)weight;
- fWeightVar =
+ weightVar =
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "weight");
SkString _input0 = SkStringPrintf("%s", args.fInputColor);
SkString _child0("_child0");
- this->emitChild(_outer.fp0_index(), _input0.c_str(), &_child0, args);
+ this->emitChild(_outer.fp0_index, _input0.c_str(), &_child0, args);
fragBuilder->codeAppendf("half4 in0 = %s;", _child0.c_str());
SkString _input1 = SkStringPrintf("%s", args.fInputColor);
SkString _child1("_child1");
- if (_outer.fp1_index() >= 0) {
- this->emitChild(_outer.fp1_index(), _input1.c_str(), &_child1, args);
+ if (_outer.fp1_index >= 0) {
+ this->emitChild(_outer.fp1_index, _input1.c_str(), &_child1, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _child1.c_str());
}
fragBuilder->codeAppendf("\nhalf4 in1 = %s ? %s : %s;\n%s = mix(in0, in1, %s);\n",
- _outer.fp1_index() >= 0 ? "true" : "false", _child1.c_str(),
+ _outer.fp1_index >= 0 ? "true" : "false", _child1.c_str(),
args.fInputColor, args.fOutputColor,
- args.fUniformHandler->getUniformCStr(fWeightVar));
+ args.fUniformHandler->getUniformCStr(weightVar));
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& _proc) override {
const GrMixerEffect& _outer = _proc.cast<GrMixerEffect>();
- { pdman.set1f(fWeightVar, (_outer.weight())); }
+ { pdman.set1f(weightVar, (_outer.weight)); }
}
- UniformHandle fWeightVar;
+ UniformHandle weightVar;
};
GrGLSLFragmentProcessor* GrMixerEffect::onCreateGLSLInstance() const {
return new GrGLSLMixerEffect();
@@ -59,17 +59,17 @@
bool GrMixerEffect::onIsEqual(const GrFragmentProcessor& other) const {
const GrMixerEffect& that = other.cast<GrMixerEffect>();
(void)that;
- if (fWeight != that.fWeight) return false;
+ if (weight != that.weight) return false;
return true;
}
GrMixerEffect::GrMixerEffect(const GrMixerEffect& src)
: INHERITED(kGrMixerEffect_ClassID, src.optimizationFlags())
- , fFp0_index(src.fFp0_index)
- , fFp1_index(src.fFp1_index)
- , fWeight(src.fWeight) {
- this->registerChildProcessor(src.childProcessor(fFp0_index).clone());
- if (fFp1_index >= 0) {
- this->registerChildProcessor(src.childProcessor(fFp1_index).clone());
+ , fp0_index(src.fp0_index)
+ , fp1_index(src.fp1_index)
+ , weight(src.weight) {
+ this->registerChildProcessor(src.childProcessor(fp0_index).clone());
+ if (fp1_index >= 0) {
+ this->registerChildProcessor(src.childProcessor(fp1_index).clone());
}
}
std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {