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 GrComposeLerpRedEffect.fp; do not modify. |
| 10 | **************************************************************************************************/ |
| 11 | #include "GrComposeLerpRedEffect.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 GrGLSLComposeLerpRedEffect : public GrGLSLFragmentProcessor { |
| 19 | public: |
| 20 | GrGLSLComposeLerpRedEffect() {} |
| 21 | void emitCode(EmitArgs& args) override { |
| 22 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 23 | const GrComposeLerpRedEffect& _outer = args.fFp.cast<GrComposeLerpRedEffect>(); |
| 24 | (void)_outer; |
| 25 | SkString _child0("_child0"); |
| 26 | if (_outer.child1_index >= 0) { |
| 27 | this->emitChild(_outer.child1_index, &_child0, args); |
| 28 | } else { |
| 29 | fragBuilder->codeAppendf("half4 %s;", _child0.c_str()); |
| 30 | } |
| 31 | SkString _child1("_child1"); |
| 32 | if (_outer.child2_index >= 0) { |
| 33 | this->emitChild(_outer.child2_index, &_child1, args); |
| 34 | } else { |
| 35 | fragBuilder->codeAppendf("half4 %s;", _child1.c_str()); |
| 36 | } |
| 37 | SkString _child2("_child2"); |
| 38 | this->emitChild(_outer.lerp_index, &_child2, args); |
| 39 | fragBuilder->codeAppendf( |
| 40 | "%s = mix(%s ? %s : %s, %s ? %s : %s, %s.x);\n%s = half4(1.0, 0.0, 1.0, 1.0);\n", |
| 41 | args.fOutputColor, _outer.child1_index >= 0 ? "true" : "false", _child0.c_str(), |
| 42 | args.fInputColor, _outer.child2_index >= 0 ? "true" : "false", _child1.c_str(), |
| 43 | args.fInputColor, _child2.c_str(), args.fOutputColor); |
| 44 | } |
| 45 | |
| 46 | private: |
| 47 | void onSetData(const GrGLSLProgramDataManager& pdman, |
| 48 | const GrFragmentProcessor& _proc) override {} |
| 49 | }; |
| 50 | GrGLSLFragmentProcessor* GrComposeLerpRedEffect::onCreateGLSLInstance() const { |
| 51 | return new GrGLSLComposeLerpRedEffect(); |
| 52 | } |
| 53 | void GrComposeLerpRedEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
| 54 | GrProcessorKeyBuilder* b) const {} |
| 55 | bool GrComposeLerpRedEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 56 | const GrComposeLerpRedEffect& that = other.cast<GrComposeLerpRedEffect>(); |
| 57 | (void)that; |
| 58 | return true; |
| 59 | } |
| 60 | GrComposeLerpRedEffect::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 | } |
| 73 | std::unique_ptr<GrFragmentProcessor> GrComposeLerpRedEffect::clone() const { |
| 74 | return std::unique_ptr<GrFragmentProcessor>(new GrComposeLerpRedEffect(*this)); |
| 75 | } |