blob: f0da5b3d47aef3b5b82c16bd877dfefb8f9c4a90 [file] [log] [blame]
Florin Malita6041d312019-03-05 15:03:20 +00001/*
2 * Copyright 2019 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8/**************************************************************************************************
9 *** This file was autogenerated from GrMixerEffect.fp; do not modify.
10 **************************************************************************************************/
11#include "GrMixerEffect.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012
13#include "include/gpu/GrTexture.h"
14#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
15#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
16#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
17#include "src/sksl/SkSLCPP.h"
18#include "src/sksl/SkSLUtil.h"
Florin Malita6041d312019-03-05 15:03:20 +000019class GrGLSLMixerEffect : public GrGLSLFragmentProcessor {
20public:
21 GrGLSLMixerEffect() {}
22 void emitCode(EmitArgs& args) override {
23 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
Mike Kleind6ab77a2019-03-21 08:18:24 -050024 const GrMixerEffect& _outer = args.fFp.cast<GrMixerEffect>();
Florin Malita6041d312019-03-05 15:03:20 +000025 (void)_outer;
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040026 auto weight = _outer.weight;
Florin Malita6041d312019-03-05 15:03:20 +000027 (void)weight;
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040028 weightVar =
Ethan Nicholas858fecc2019-03-07 13:19:18 -050029 args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "weight");
Florin Malita6041d312019-03-05 15:03:20 +000030 SkString _input0 = SkStringPrintf("%s", args.fInputColor);
Ethan Nicholas6ad52892019-05-03 13:13:42 +000031 SkString _child0("_child0");
Ethan Nicholasc6dce5a2019-07-24 16:51:36 -040032 this->invokeChild(_outer.fp0_index, _input0.c_str(), &_child0, args);
Ethan Nicholas6ad52892019-05-03 13:13:42 +000033 fragBuilder->codeAppendf("half4 in0 = %s;", _child0.c_str());
Florin Malita6041d312019-03-05 15:03:20 +000034 SkString _input1 = SkStringPrintf("%s", args.fInputColor);
Ethan Nicholas6ad52892019-05-03 13:13:42 +000035 SkString _child1("_child1");
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040036 if (_outer.fp1_index >= 0) {
Ethan Nicholasc6dce5a2019-07-24 16:51:36 -040037 this->invokeChild(_outer.fp1_index, _input1.c_str(), &_child1, args);
Ethan Nicholas6ad52892019-05-03 13:13:42 +000038 } else {
39 fragBuilder->codeAppendf("half4 %s;", _child1.c_str());
Florin Malita6041d312019-03-05 15:03:20 +000040 }
Ethan Nicholas6ad52892019-05-03 13:13:42 +000041 fragBuilder->codeAppendf("\nhalf4 in1 = %s ? %s : %s;\n%s = mix(in0, in1, %s);\n",
42 _outer.fp1_index >= 0 ? "true" : "false", _child1.c_str(),
43 args.fInputColor, args.fOutputColor,
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040044 args.fUniformHandler->getUniformCStr(weightVar));
Florin Malita6041d312019-03-05 15:03:20 +000045 }
46
47private:
48 void onSetData(const GrGLSLProgramDataManager& pdman,
Mike Kleind6ab77a2019-03-21 08:18:24 -050049 const GrFragmentProcessor& _proc) override {
Florin Malita6041d312019-03-05 15:03:20 +000050 const GrMixerEffect& _outer = _proc.cast<GrMixerEffect>();
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040051 { pdman.set1f(weightVar, (_outer.weight)); }
Florin Malita6041d312019-03-05 15:03:20 +000052 }
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040053 UniformHandle weightVar;
Florin Malita6041d312019-03-05 15:03:20 +000054};
55GrGLSLFragmentProcessor* GrMixerEffect::onCreateGLSLInstance() const {
56 return new GrGLSLMixerEffect();
57}
Mike Kleind6ab77a2019-03-21 08:18:24 -050058void GrMixerEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
Florin Malita6041d312019-03-05 15:03:20 +000059 GrProcessorKeyBuilder* b) const {}
60bool GrMixerEffect::onIsEqual(const GrFragmentProcessor& other) const {
61 const GrMixerEffect& that = other.cast<GrMixerEffect>();
62 (void)that;
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040063 if (weight != that.weight) return false;
Florin Malita6041d312019-03-05 15:03:20 +000064 return true;
65}
66GrMixerEffect::GrMixerEffect(const GrMixerEffect& src)
67 : INHERITED(kGrMixerEffect_ClassID, src.optimizationFlags())
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040068 , fp0_index(src.fp0_index)
69 , fp1_index(src.fp1_index)
70 , weight(src.weight) {
71 this->registerChildProcessor(src.childProcessor(fp0_index).clone());
72 if (fp1_index >= 0) {
73 this->registerChildProcessor(src.childProcessor(fp1_index).clone());
Florin Malita6041d312019-03-05 15:03:20 +000074 }
75}
76std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {
77 return std::unique_ptr<GrFragmentProcessor>(new GrMixerEffect(*this));
78}