• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 GrComposeLerpEffect.fp; do not modify.
10  **************************************************************************************************/
11 #include "GrComposeLerpEffect.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 GrGLSLComposeLerpEffect : public GrGLSLFragmentProcessor {
20 public:
GrGLSLComposeLerpEffect()21     GrGLSLComposeLerpEffect() {}
emitCode(EmitArgs & args)22     void emitCode(EmitArgs& args) override {
23         GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
24         const GrComposeLerpEffect& _outer = args.fFp.cast<GrComposeLerpEffect>();
25         (void)_outer;
26         auto weight = _outer.weight;
27         (void)weight;
28         weightVar =
29                 args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat_GrSLType, "weight");
30         SkString _sample290("_sample290");
31         if (_outer.child1_index >= 0) {
32             this->invokeChild(_outer.child1_index, &_sample290, args);
33         } else {
34             fragBuilder->codeAppendf("half4 %s;", _sample290.c_str());
35         }
36         SkString _sample358("_sample358");
37         if (_outer.child2_index >= 0) {
38             this->invokeChild(_outer.child2_index, &_sample358, args);
39         } else {
40             fragBuilder->codeAppendf("half4 %s;", _sample358.c_str());
41         }
42         fragBuilder->codeAppendf("%s = mix(%s ? %s : %s, %s ? %s : %s, half(%s));\n",
43                                  args.fOutputColor, _outer.child1_index >= 0 ? "true" : "false",
44                                  _sample290.c_str(), args.fInputColor,
45                                  _outer.child2_index >= 0 ? "true" : "false", _sample358.c_str(),
46                                  args.fInputColor, args.fUniformHandler->getUniformCStr(weightVar));
47     }
48 
49 private:
onSetData(const GrGLSLProgramDataManager & pdman,const GrFragmentProcessor & _proc)50     void onSetData(const GrGLSLProgramDataManager& pdman,
51                    const GrFragmentProcessor& _proc) override {
52         const GrComposeLerpEffect& _outer = _proc.cast<GrComposeLerpEffect>();
53         { pdman.set1f(weightVar, (_outer.weight)); }
54     }
55     UniformHandle weightVar;
56 };
onCreateGLSLInstance() const57 GrGLSLFragmentProcessor* GrComposeLerpEffect::onCreateGLSLInstance() const {
58     return new GrGLSLComposeLerpEffect();
59 }
onGetGLSLProcessorKey(const GrShaderCaps & caps,GrProcessorKeyBuilder * b) const60 void GrComposeLerpEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
61                                                 GrProcessorKeyBuilder* b) const {}
onIsEqual(const GrFragmentProcessor & other) const62 bool GrComposeLerpEffect::onIsEqual(const GrFragmentProcessor& other) const {
63     const GrComposeLerpEffect& that = other.cast<GrComposeLerpEffect>();
64     (void)that;
65     if (weight != that.weight) return false;
66     return true;
67 }
GrComposeLerpEffect(const GrComposeLerpEffect & src)68 GrComposeLerpEffect::GrComposeLerpEffect(const GrComposeLerpEffect& src)
69         : INHERITED(kGrComposeLerpEffect_ClassID, src.optimizationFlags())
70         , child1_index(src.child1_index)
71         , child2_index(src.child2_index)
72         , weight(src.weight) {
73     if (child1_index >= 0) {
74         this->registerChildProcessor(src.childProcessor(child1_index).clone());
75     }
76     if (child2_index >= 0) {
77         this->registerChildProcessor(src.childProcessor(child2_index).clone());
78     }
79 }
clone() const80 std::unique_ptr<GrFragmentProcessor> GrComposeLerpEffect::clone() const {
81     return std::unique_ptr<GrFragmentProcessor>(new GrComposeLerpEffect(*this));
82 }
83