blob: aca71b6359b7966fc0a7f2e7619244c1a901accc [file] [log] [blame]
/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/**************************************************************************************************
*** This file was autogenerated from GrMixerEffect.fp; do not modify.
**************************************************************************************************/
#include "GrMixerEffect.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
class GrGLSLMixerEffect : public GrGLSLFragmentProcessor {
public:
GrGLSLMixerEffect() {}
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrMixerEffect& _outer = args.fFp.cast<GrMixerEffect>();
(void)_outer;
auto weight = _outer.weight;
(void)weight;
weightVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag,
kHalf_GrSLType, "weight");
SkString _sample1099 = this->invokeChild(0, args);
fragBuilder->codeAppendf(
R"SkSL(half4 inColor = %s;)SkSL", _sample1099.c_str());
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, _sample1138.c_str(), _sample1160.c_str(),
args.fUniformHandler->getUniformCStr(weightVar));
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& _proc) override {
const GrMixerEffect& _outer = _proc.cast<GrMixerEffect>();
{ pdman.set1f(weightVar, (_outer.weight)); }
}
UniformHandle weightVar;
};
GrGLSLFragmentProcessor* GrMixerEffect::onCreateGLSLInstance() const {
return new GrGLSLMixerEffect();
}
void GrMixerEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {}
bool GrMixerEffect::onIsEqual(const GrFragmentProcessor& other) const {
const GrMixerEffect& that = other.cast<GrMixerEffect>();
(void)that;
if (weight != that.weight) return false;
return true;
}
bool GrMixerEffect::usesExplicitReturn() const { return false; }
GrMixerEffect::GrMixerEffect(const GrMixerEffect& src)
: INHERITED(kGrMixerEffect_ClassID, src.optimizationFlags()), weight(src.weight) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {
return std::make_unique<GrMixerEffect>(*this);
}
#if GR_TEST_UTILS
SkString GrMixerEffect::onDumpInfo() const { return SkStringPrintf("(weight=%f)", weight); }
#endif