blob: d75b411032de875628e60662826e49a3926c6c90 [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 Nicholas6ad52892019-05-03 13:13:42 +000026 SkString _child0("_child0");
Ethan Nicholasff4fb332019-04-09 16:28:19 -040027 if (_outer.child1_index >= 0) {
Ethan Nicholas6ad52892019-05-03 13:13:42 +000028 this->emitChild(_outer.child1_index, &_child0, args);
29 } else {
30 fragBuilder->codeAppendf("half4 %s;", _child0.c_str());
Ethan Nicholasff4fb332019-04-09 16:28:19 -040031 }
Ethan Nicholas6ad52892019-05-03 13:13:42 +000032 SkString _child1("_child1");
Ethan Nicholasff4fb332019-04-09 16:28:19 -040033 if (_outer.child2_index >= 0) {
Ethan Nicholas6ad52892019-05-03 13:13:42 +000034 this->emitChild(_outer.child2_index, &_child1, args);
35 } else {
36 fragBuilder->codeAppendf("half4 %s;", _child1.c_str());
Ethan Nicholasff4fb332019-04-09 16:28:19 -040037 }
Ethan Nicholas6ad52892019-05-03 13:13:42 +000038 SkString _child2("_child2");
39 this->emitChild(_outer.lerp_index, &_child2, args);
40 fragBuilder->codeAppendf("%s = mix(%s ? %s : %s, %s ? %s : %s, %s.x);\n", args.fOutputColor,
41 _outer.child1_index >= 0 ? "true" : "false", _child0.c_str(),
42 args.fInputColor, _outer.child2_index >= 0 ? "true" : "false",
43 _child1.c_str(), args.fInputColor, _child2.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}