Ethan Nicholas | ff4fb33 | 2019-04-09 16:28:19 -0400 | [diff] [blame^] | 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 | #include "glsl/GrGLSLFragmentProcessor.h" |
| 13 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 14 | #include "glsl/GrGLSLProgramBuilder.h" |
| 15 | #include "GrTexture.h" |
| 16 | #include "SkSLCPP.h" |
| 17 | #include "SkSLUtil.h" |
| 18 | class GrGLSLComposeLerpEffect : public GrGLSLFragmentProcessor { |
| 19 | public: |
| 20 | GrGLSLComposeLerpEffect() {} |
| 21 | void emitCode(EmitArgs& args) override { |
| 22 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 23 | const GrComposeLerpEffect& _outer = args.fFp.cast<GrComposeLerpEffect>(); |
| 24 | (void)_outer; |
| 25 | auto weight = _outer.weight; |
| 26 | (void)weight; |
| 27 | weightVar = |
| 28 | args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat_GrSLType, "weight"); |
| 29 | SkString _child0("_child0"); |
| 30 | if (_outer.child1_index >= 0) { |
| 31 | this->emitChild(_outer.child1_index, &_child0, args); |
| 32 | } else { |
| 33 | fragBuilder->codeAppendf("half4 %s;", _child0.c_str()); |
| 34 | } |
| 35 | SkString _child1("_child1"); |
| 36 | if (_outer.child2_index >= 0) { |
| 37 | this->emitChild(_outer.child2_index, &_child1, args); |
| 38 | } else { |
| 39 | fragBuilder->codeAppendf("half4 %s;", _child1.c_str()); |
| 40 | } |
| 41 | fragBuilder->codeAppendf("%s = mix(%s ? %s : %s, %s ? %s : %s, half(%s));\n", |
| 42 | args.fOutputColor, _outer.child1_index >= 0 ? "true" : "false", |
| 43 | _child0.c_str(), args.fInputColor, |
| 44 | _outer.child2_index >= 0 ? "true" : "false", _child1.c_str(), |
| 45 | args.fInputColor, args.fUniformHandler->getUniformCStr(weightVar)); |
| 46 | } |
| 47 | |
| 48 | private: |
| 49 | void onSetData(const GrGLSLProgramDataManager& pdman, |
| 50 | const GrFragmentProcessor& _proc) override { |
| 51 | const GrComposeLerpEffect& _outer = _proc.cast<GrComposeLerpEffect>(); |
| 52 | { pdman.set1f(weightVar, (_outer.weight)); } |
| 53 | } |
| 54 | UniformHandle weightVar; |
| 55 | }; |
| 56 | GrGLSLFragmentProcessor* GrComposeLerpEffect::onCreateGLSLInstance() const { |
| 57 | return new GrGLSLComposeLerpEffect(); |
| 58 | } |
| 59 | void GrComposeLerpEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
| 60 | GrProcessorKeyBuilder* b) const {} |
| 61 | bool GrComposeLerpEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 62 | const GrComposeLerpEffect& that = other.cast<GrComposeLerpEffect>(); |
| 63 | (void)that; |
| 64 | if (weight != that.weight) return false; |
| 65 | return true; |
| 66 | } |
| 67 | GrComposeLerpEffect::GrComposeLerpEffect(const GrComposeLerpEffect& src) |
| 68 | : INHERITED(kGrComposeLerpEffect_ClassID, src.optimizationFlags()) |
| 69 | , child1_index(src.child1_index) |
| 70 | , child2_index(src.child2_index) |
| 71 | , weight(src.weight) { |
| 72 | if (child1_index >= 0) { |
| 73 | this->registerChildProcessor(src.childProcessor(child1_index).clone()); |
| 74 | } |
| 75 | if (child2_index >= 0) { |
| 76 | this->registerChildProcessor(src.childProcessor(child2_index).clone()); |
| 77 | } |
| 78 | } |
| 79 | std::unique_ptr<GrFragmentProcessor> GrComposeLerpEffect::clone() const { |
| 80 | return std::unique_ptr<GrFragmentProcessor>(new GrComposeLerpEffect(*this)); |
| 81 | } |