blob: 6a9d989a290bb0814b838dcc592e7097faaeef54 [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
John Stiles45f5b032020-07-27 17:31:29 -040013#include "src/core/SkUtils.h"
Greg Daniel456f9b52020-03-05 19:14:18 +000014#include "src/gpu/GrTexture.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
16#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
17#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
18#include "src/sksl/SkSLCPP.h"
19#include "src/sksl/SkSLUtil.h"
Florin Malita6041d312019-03-05 15:03:20 +000020class GrGLSLMixerEffect : public GrGLSLFragmentProcessor {
21public:
22 GrGLSLMixerEffect() {}
23 void emitCode(EmitArgs& args) override {
24 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
Mike Kleind6ab77a2019-03-21 08:18:24 -050025 const GrMixerEffect& _outer = args.fFp.cast<GrMixerEffect>();
Florin Malita6041d312019-03-05 15:03:20 +000026 (void)_outer;
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040027 auto weight = _outer.weight;
Florin Malita6041d312019-03-05 15:03:20 +000028 (void)weight;
Ethan Nicholas16464c32020-04-06 13:53:05 -040029 weightVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag,
30 kHalf_GrSLType, "weight");
Brian Osman6b5dbb42020-07-15 15:31:05 -040031 SkString _sample1099 = this->invokeChild(0, args);
John Stiles50819422020-06-18 13:00:38 -040032 fragBuilder->codeAppendf(
Brian Osman12c5d292020-07-13 16:11:35 -040033 R"SkSL(half4 inColor = %s;)SkSL", _sample1099.c_str());
Brian Osman6b5dbb42020-07-15 15:31:05 -040034 SkString _input1138("inColor");
35 SkString _sample1138 = this->invokeChild(1, _input1138.c_str(), args);
36 SkString _input1160("inColor");
37 SkString _sample1160 = this->invokeChild(2, _input1160.c_str(), args);
John Stiles894ddb02020-07-07 14:59:32 -040038 fragBuilder->codeAppendf(
39 R"SkSL(
40%s = mix(%s, %s, %s);
John Stiles50819422020-06-18 13:00:38 -040041)SkSL",
Brian Osman6b5dbb42020-07-15 15:31:05 -040042 args.fOutputColor, _sample1138.c_str(), _sample1160.c_str(),
John Stilesc05b2de2020-07-06 11:45:20 -040043 args.fUniformHandler->getUniformCStr(weightVar));
Florin Malita6041d312019-03-05 15:03:20 +000044 }
45
46private:
47 void onSetData(const GrGLSLProgramDataManager& pdman,
Mike Kleind6ab77a2019-03-21 08:18:24 -050048 const GrFragmentProcessor& _proc) override {
Florin Malita6041d312019-03-05 15:03:20 +000049 const GrMixerEffect& _outer = _proc.cast<GrMixerEffect>();
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040050 { pdman.set1f(weightVar, (_outer.weight)); }
Florin Malita6041d312019-03-05 15:03:20 +000051 }
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040052 UniformHandle weightVar;
Florin Malita6041d312019-03-05 15:03:20 +000053};
54GrGLSLFragmentProcessor* GrMixerEffect::onCreateGLSLInstance() const {
55 return new GrGLSLMixerEffect();
56}
Mike Kleind6ab77a2019-03-21 08:18:24 -050057void GrMixerEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
Florin Malita6041d312019-03-05 15:03:20 +000058 GrProcessorKeyBuilder* b) const {}
59bool GrMixerEffect::onIsEqual(const GrFragmentProcessor& other) const {
60 const GrMixerEffect& that = other.cast<GrMixerEffect>();
61 (void)that;
Ethan Nicholasbcd51e82019-04-09 10:40:41 -040062 if (weight != that.weight) return false;
Florin Malita6041d312019-03-05 15:03:20 +000063 return true;
64}
65GrMixerEffect::GrMixerEffect(const GrMixerEffect& src)
John Stiles88183902020-06-10 16:40:38 -040066 : INHERITED(kGrMixerEffect_ClassID, src.optimizationFlags()), weight(src.weight) {
Brian Osman12c5d292020-07-13 16:11:35 -040067 this->cloneAndRegisterAllChildProcessors(src);
Florin Malita6041d312019-03-05 15:03:20 +000068}
69std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {
70 return std::unique_ptr<GrFragmentProcessor>(new GrMixerEffect(*this));
71}