• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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"
12 
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"
19 class GrGLSLMixerEffect : public GrGLSLFragmentProcessor {
20 public:
GrGLSLMixerEffect()21     GrGLSLMixerEffect() {}
emitCode(EmitArgs & args)22     void emitCode(EmitArgs& args) override {
23         GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
24         const GrMixerEffect& _outer = args.fFp.cast<GrMixerEffect>();
25         (void)_outer;
26         auto weight = _outer.weight;
27         (void)weight;
28         weightVar =
29                 args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "weight");
30         SkString _input1278 = SkStringPrintf("%s", args.fInputColor);
31         SkString _sample1278;
32         _sample1278 = this->invokeChild(_outer.fp0_index, _input1278.c_str(), args);
33         fragBuilder->codeAppendf("half4 in0 = %s;", _sample1278.c_str());
34         SkString _input1335 = SkStringPrintf("%s", args.fInputColor);
35         SkString _sample1335;
36         if (_outer.fp1_index >= 0) {
37             _sample1335 = this->invokeChild(_outer.fp1_index, _input1335.c_str(), args);
38         } else {
39             _sample1335 = "half4(1)";
40         }
41         fragBuilder->codeAppendf("\nhalf4 in1 = %s ? %s : %s;\n%s = mix(in0, in1, %s);\n",
42                                  _outer.fp1_index >= 0 ? "true" : "false", _sample1335.c_str(),
43                                  args.fInputColor, args.fOutputColor,
44                                  args.fUniformHandler->getUniformCStr(weightVar));
45     }
46 
47 private:
onSetData(const GrGLSLProgramDataManager & pdman,const GrFragmentProcessor & _proc)48     void onSetData(const GrGLSLProgramDataManager& pdman,
49                    const GrFragmentProcessor& _proc) override {
50         const GrMixerEffect& _outer = _proc.cast<GrMixerEffect>();
51         { pdman.set1f(weightVar, (_outer.weight)); }
52     }
53     UniformHandle weightVar;
54 };
onCreateGLSLInstance() const55 GrGLSLFragmentProcessor* GrMixerEffect::onCreateGLSLInstance() const {
56     return new GrGLSLMixerEffect();
57 }
onGetGLSLProcessorKey(const GrShaderCaps & caps,GrProcessorKeyBuilder * b) const58 void GrMixerEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
59                                           GrProcessorKeyBuilder* b) const {}
onIsEqual(const GrFragmentProcessor & other) const60 bool GrMixerEffect::onIsEqual(const GrFragmentProcessor& other) const {
61     const GrMixerEffect& that = other.cast<GrMixerEffect>();
62     (void)that;
63     if (weight != that.weight) return false;
64     return true;
65 }
GrMixerEffect(const GrMixerEffect & src)66 GrMixerEffect::GrMixerEffect(const GrMixerEffect& src)
67         : INHERITED(kGrMixerEffect_ClassID, src.optimizationFlags())
68         , fp0_index(src.fp0_index)
69         , fp1_index(src.fp1_index)
70         , weight(src.weight) {
71     {
72         auto clone = src.childProcessor(fp0_index).clone();
73         clone->setSampledWithExplicitCoords(
74                 src.childProcessor(fp0_index).isSampledWithExplicitCoords());
75         this->registerChildProcessor(std::move(clone));
76     }
77     if (fp1_index >= 0) {
78         auto clone = src.childProcessor(fp1_index).clone();
79         clone->setSampledWithExplicitCoords(
80                 src.childProcessor(fp1_index).isSampledWithExplicitCoords());
81         this->registerChildProcessor(std::move(clone));
82     }
83 }
clone() const84 std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {
85     return std::unique_ptr<GrFragmentProcessor>(new GrMixerEffect(*this));
86 }
87