1
2
3 /**************************************************************************************************
4 *** This file was autogenerated from GrDSLFPTest_Ternary.fp; do not modify.
5 **************************************************************************************************/
6 /* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
7 #include "GrDSLFPTest_Ternary.h"
8
9 #include "src/core/SkUtils.h"
10 #include "src/gpu/GrTexture.h"
11 #include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
12 #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
13 #include "src/gpu/glsl/GrGLSLProgramBuilder.h"
14 #include "src/sksl/SkSLCPP.h"
15 #include "src/sksl/SkSLUtil.h"
16 #include "src/sksl/dsl/priv/DSLFPs.h"
17 #include "src/sksl/dsl/priv/DSLWriter.h"
18
19 class GrGLSLDSLFPTest_Ternary : public GrGLSLFragmentProcessor {
20 public:
GrGLSLDSLFPTest_Ternary()21 GrGLSLDSLFPTest_Ternary() {}
emitCode(EmitArgs & args)22 void emitCode(EmitArgs& args) override {
23 [[maybe_unused]] const GrDSLFPTest_Ternary& _outer = args.fFp.cast<GrDSLFPTest_Ternary>();
24
25 using namespace SkSL::dsl;
26 StartFragmentProcessor(this, &args);
27 [[maybe_unused]] const auto& primaryColors = _outer.primaryColors;
28 Var _primaryColors(kConst_Modifier, DSLType(kBool_Type), "primaryColors", Bool(!!(primaryColors)));
29 Declare(_primaryColors);
30 Var _colorGreen;
31 if (primaryColors) {
32 Var(kUniform_Modifier, DSLType(kHalf4_Type), "colorGreen").swap(_colorGreen);
33 colorGreenVar = VarUniformHandle(_colorGreen);
34 DeclareGlobal(_colorGreen);
35 } else {
36 Var(kConst_Modifier, DSLType(kHalf4_Type), "colorGreen", Half4(0)).swap(_colorGreen);
37 Declare(_colorGreen);
38 }
39 Var _colorRed;
40 if (primaryColors) {
41 Var(kUniform_Modifier, DSLType(kHalf4_Type), "colorRed").swap(_colorRed);
42 colorRedVar = VarUniformHandle(_colorRed);
43 DeclareGlobal(_colorRed);
44 } else {
45 Var(kConst_Modifier, DSLType(kHalf4_Type), "colorRed", Half4(0)).swap(_colorRed);
46 Declare(_colorRed);
47 }
48 Var _colorOrange;
49 if (!primaryColors) {
50 Var(kUniform_Modifier, DSLType(kHalf4_Type), "colorOrange").swap(_colorOrange);
51 colorOrangeVar = VarUniformHandle(_colorOrange);
52 DeclareGlobal(_colorOrange);
53 } else {
54 Var(kConst_Modifier, DSLType(kHalf4_Type), "colorOrange", Half4(0)).swap(_colorOrange);
55 Declare(_colorOrange);
56 }
57 Var _colorPurple;
58 if (!primaryColors) {
59 Var(kUniform_Modifier, DSLType(kHalf4_Type), "colorPurple").swap(_colorPurple);
60 colorPurpleVar = VarUniformHandle(_colorPurple);
61 DeclareGlobal(_colorPurple);
62 } else {
63 Var(kConst_Modifier, DSLType(kHalf4_Type), "colorPurple", Half4(0)).swap(_colorPurple);
64 Declare(_colorPurple);
65 }
66 Var _green(kNo_Modifier, DSLType(kHalf4_Type), "green", Select(_primaryColors, /*If True:*/ _colorGreen, /*If False:*/ _colorOrange));
67 Var _red(kNo_Modifier, DSLType(kHalf4_Type), "red", Select(_primaryColors, /*If True:*/ _colorRed, /*If False:*/ _colorPurple));
68 Var _t(kNo_Modifier, DSLType(kBool_Type), "t", true);
69 Var _f(kNo_Modifier, DSLType(kBool_Type), "f", false);
70 Declare(_green);
71 Declare(_red);
72 Declare(_t);
73 Declare(_f);
74 Return(Half4(Select(_t, /*If True:*/ _green.x(), /*If False:*/ _red.x()), Select(_f, /*If True:*/ _red.y(), /*If False:*/ _green.y()), Select(_green.y() == _red.x(), /*If True:*/ _green.z(), /*If False:*/ _red.x()), Select(_green.w() != _red.w(), /*If True:*/ _red.y(), /*If False:*/ _green.w())));
75 EndFragmentProcessor();
76 }
77 private:
onSetData(const GrGLSLProgramDataManager & pdman,const GrFragmentProcessor & _proc)78 void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
79 const GrDSLFPTest_Ternary& _outer = _proc.cast<GrDSLFPTest_Ternary>();
80 {
81 if (colorGreenVar.isValid()) {
82 pdman.set4fv(colorGreenVar, 1, (_outer.colorGreen).vec());
83 }
84 if (colorRedVar.isValid()) {
85 pdman.set4fv(colorRedVar, 1, (_outer.colorRed).vec());
86 }
87 if (colorOrangeVar.isValid()) {
88 pdman.set4fv(colorOrangeVar, 1, (_outer.colorOrange).vec());
89 }
90 if (colorPurpleVar.isValid()) {
91 pdman.set4fv(colorPurpleVar, 1, (_outer.colorPurple).vec());
92 }
93 }
94 }
95 UniformHandle colorGreenVar;
96 UniformHandle colorRedVar;
97 UniformHandle colorOrangeVar;
98 UniformHandle colorPurpleVar;
99 };
onMakeProgramImpl() const100 std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_Ternary::onMakeProgramImpl() const {
101 return std::make_unique<GrGLSLDSLFPTest_Ternary>();
102 }
onGetGLSLProcessorKey(const GrShaderCaps & caps,GrProcessorKeyBuilder * b) const103 void GrDSLFPTest_Ternary::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
104 b->addBool(primaryColors, "primaryColors");
105 }
onIsEqual(const GrFragmentProcessor & other) const106 bool GrDSLFPTest_Ternary::onIsEqual(const GrFragmentProcessor& other) const {
107 const GrDSLFPTest_Ternary& that = other.cast<GrDSLFPTest_Ternary>();
108 (void) that;
109 if (primaryColors != that.primaryColors) return false;
110 if (colorGreen != that.colorGreen) return false;
111 if (colorRed != that.colorRed) return false;
112 if (colorOrange != that.colorOrange) return false;
113 if (colorPurple != that.colorPurple) return false;
114 return true;
115 }
GrDSLFPTest_Ternary(const GrDSLFPTest_Ternary & src)116 GrDSLFPTest_Ternary::GrDSLFPTest_Ternary(const GrDSLFPTest_Ternary& src)
117 : INHERITED(kGrDSLFPTest_Ternary_ClassID, src.optimizationFlags())
118 , primaryColors(src.primaryColors)
119 , colorGreen(src.colorGreen)
120 , colorRed(src.colorRed)
121 , colorOrange(src.colorOrange)
122 , colorPurple(src.colorPurple) {
123 this->cloneAndRegisterAllChildProcessors(src);
124 }
clone() const125 std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_Ternary::clone() const {
126 return std::make_unique<GrDSLFPTest_Ternary>(*this);
127 }
128 #if GR_TEST_UTILS
onDumpInfo() const129 SkString GrDSLFPTest_Ternary::onDumpInfo() const {
130 return SkStringPrintf("(primaryColors=%d, colorGreen=half4(%f, %f, %f, %f), colorRed=half4(%f, %f, %f, %f), colorOrange=half4(%f, %f, %f, %f), colorPurple=half4(%f, %f, %f, %f))", !!(primaryColors), colorGreen.fR, colorGreen.fG, colorGreen.fB, colorGreen.fA, colorRed.fR, colorRed.fG, colorRed.fB, colorRed.fA, colorOrange.fR, colorOrange.fG, colorOrange.fB, colorOrange.fA, colorPurple.fR, colorPurple.fG, colorPurple.fB, colorPurple.fA);
131 }
132 #endif
133