blob: 8a6bc6defc9b3733d95c3903b565c21fbe350406 [file] [log] [blame]
Ethan Nicholasff4fb332019-04-09 16:28:19 -04001/*
2 * Copyright 2019 Google LLC.
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 GrComposeLerpRedEffect.fp; do not modify.
10 **************************************************************************************************/
11#include "GrComposeLerpRedEffect.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"
Ethan Nicholasff4fb332019-04-09 16:28:19 -040019class GrGLSLComposeLerpRedEffect : public GrGLSLFragmentProcessor {
20public:
21 GrGLSLComposeLerpRedEffect() {}
22 void emitCode(EmitArgs& args) override {
23 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
24 const GrComposeLerpRedEffect& _outer = args.fFp.cast<GrComposeLerpRedEffect>();
25 (void)_outer;
Ethan Nicholas13863662019-07-29 13:05:15 -040026 SkString _sample292("_sample292");
Ethan Nicholasff4fb332019-04-09 16:28:19 -040027 if (_outer.child1_index >= 0) {
Ethan Nicholas13863662019-07-29 13:05:15 -040028 this->invokeChild(_outer.child1_index, &_sample292, args);
Ethan Nicholas6ad52892019-05-03 13:13:42 +000029 } else {
Ethan Nicholas13863662019-07-29 13:05:15 -040030 fragBuilder->codeAppendf("half4 %s;", _sample292.c_str());
Ethan Nicholasff4fb332019-04-09 16:28:19 -040031 }
Ethan Nicholas13863662019-07-29 13:05:15 -040032 SkString _sample360("_sample360");
Ethan Nicholasff4fb332019-04-09 16:28:19 -040033 if (_outer.child2_index >= 0) {
Ethan Nicholas13863662019-07-29 13:05:15 -040034 this->invokeChild(_outer.child2_index, &_sample360, args);
Ethan Nicholas6ad52892019-05-03 13:13:42 +000035 } else {
Ethan Nicholas13863662019-07-29 13:05:15 -040036 fragBuilder->codeAppendf("half4 %s;", _sample360.c_str());
Ethan Nicholasff4fb332019-04-09 16:28:19 -040037 }
Ethan Nicholas13863662019-07-29 13:05:15 -040038 SkString _sample411("_sample411");
39 this->invokeChild(_outer.lerp_index, &_sample411, args);
Ethan Nicholas6ad52892019-05-03 13:13:42 +000040 fragBuilder->codeAppendf("%s = mix(%s ? %s : %s, %s ? %s : %s, %s.x);\n", args.fOutputColor,
Ethan Nicholas13863662019-07-29 13:05:15 -040041 _outer.child1_index >= 0 ? "true" : "false", _sample292.c_str(),
Ethan Nicholas6ad52892019-05-03 13:13:42 +000042 args.fInputColor, _outer.child2_index >= 0 ? "true" : "false",
Ethan Nicholas13863662019-07-29 13:05:15 -040043 _sample360.c_str(), args.fInputColor, _sample411.c_str());
Ethan Nicholasff4fb332019-04-09 16:28:19 -040044 }
45
46private:
47 void onSetData(const GrGLSLProgramDataManager& pdman,
48 const GrFragmentProcessor& _proc) override {}
49};
50GrGLSLFragmentProcessor* GrComposeLerpRedEffect::onCreateGLSLInstance() const {
51 return new GrGLSLComposeLerpRedEffect();
52}
53void GrComposeLerpRedEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
54 GrProcessorKeyBuilder* b) const {}
55bool GrComposeLerpRedEffect::onIsEqual(const GrFragmentProcessor& other) const {
56 const GrComposeLerpRedEffect& that = other.cast<GrComposeLerpRedEffect>();
57 (void)that;
58 return true;
59}
60GrComposeLerpRedEffect::GrComposeLerpRedEffect(const GrComposeLerpRedEffect& src)
61 : INHERITED(kGrComposeLerpRedEffect_ClassID, src.optimizationFlags())
62 , child1_index(src.child1_index)
63 , child2_index(src.child2_index)
64 , lerp_index(src.lerp_index) {
65 if (child1_index >= 0) {
66 this->registerChildProcessor(src.childProcessor(child1_index).clone());
67 }
68 if (child2_index >= 0) {
69 this->registerChildProcessor(src.childProcessor(child2_index).clone());
70 }
71 this->registerChildProcessor(src.childProcessor(lerp_index).clone());
72}
73std::unique_ptr<GrFragmentProcessor> GrComposeLerpRedEffect::clone() const {
74 return std::unique_ptr<GrFragmentProcessor>(new GrComposeLerpRedEffect(*this));
75}