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" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 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" |
Ethan Nicholas | ff4fb33 | 2019-04-09 16:28:19 -0400 | [diff] [blame] | 19 | class GrGLSLComposeLerpRedEffect : public GrGLSLFragmentProcessor { |
| 20 | public: |
| 21 | GrGLSLComposeLerpRedEffect() {} |
| 22 | void emitCode(EmitArgs& args) override { |
| 23 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 24 | const GrComposeLerpRedEffect& _outer = args.fFp.cast<GrComposeLerpRedEffect>(); |
| 25 | (void)_outer; |
Ethan Nicholas | 0364bde | 2019-05-02 16:16:30 -0400 | [diff] [blame] | 26 | fragBuilder->codeAppendf("half4 _process286;"); |
Ethan Nicholas | ff4fb33 | 2019-04-09 16:28:19 -0400 | [diff] [blame] | 27 | if (_outer.child1_index >= 0) { |
Ethan Nicholas | 0364bde | 2019-05-02 16:16:30 -0400 | [diff] [blame] | 28 | this->invokeChild(_outer.child1_index, "_process286", args); |
Ethan Nicholas | ff4fb33 | 2019-04-09 16:28:19 -0400 | [diff] [blame] | 29 | } |
Ethan Nicholas | 0364bde | 2019-05-02 16:16:30 -0400 | [diff] [blame] | 30 | fragBuilder->codeAppendf("half4 _process355;"); |
Ethan Nicholas | ff4fb33 | 2019-04-09 16:28:19 -0400 | [diff] [blame] | 31 | if (_outer.child2_index >= 0) { |
Ethan Nicholas | 0364bde | 2019-05-02 16:16:30 -0400 | [diff] [blame] | 32 | this->invokeChild(_outer.child2_index, "_process355", args); |
Ethan Nicholas | ff4fb33 | 2019-04-09 16:28:19 -0400 | [diff] [blame] | 33 | } |
Ethan Nicholas | 0364bde | 2019-05-02 16:16:30 -0400 | [diff] [blame] | 34 | fragBuilder->codeAppendf("half4 _process407;"); |
| 35 | this->invokeChild(_outer.lerp_index, "_process407", args); |
| 36 | fragBuilder->codeAppendf( |
| 37 | "%s = mix(%s ? _process286 : %s, %s ? _process355 : %s, _process407.x);\n", |
| 38 | args.fOutputColor, _outer.child1_index >= 0 ? "true" : "false", args.fInputColor, |
| 39 | _outer.child2_index >= 0 ? "true" : "false", args.fInputColor); |
Ethan Nicholas | ff4fb33 | 2019-04-09 16:28:19 -0400 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | private: |
| 43 | void onSetData(const GrGLSLProgramDataManager& pdman, |
| 44 | const GrFragmentProcessor& _proc) override {} |
| 45 | }; |
| 46 | GrGLSLFragmentProcessor* GrComposeLerpRedEffect::onCreateGLSLInstance() const { |
| 47 | return new GrGLSLComposeLerpRedEffect(); |
| 48 | } |
| 49 | void GrComposeLerpRedEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
| 50 | GrProcessorKeyBuilder* b) const {} |
| 51 | bool GrComposeLerpRedEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 52 | const GrComposeLerpRedEffect& that = other.cast<GrComposeLerpRedEffect>(); |
| 53 | (void)that; |
| 54 | return true; |
| 55 | } |
| 56 | GrComposeLerpRedEffect::GrComposeLerpRedEffect(const GrComposeLerpRedEffect& src) |
| 57 | : INHERITED(kGrComposeLerpRedEffect_ClassID, src.optimizationFlags()) |
| 58 | , child1_index(src.child1_index) |
| 59 | , child2_index(src.child2_index) |
| 60 | , lerp_index(src.lerp_index) { |
| 61 | if (child1_index >= 0) { |
| 62 | this->registerChildProcessor(src.childProcessor(child1_index).clone()); |
| 63 | } |
| 64 | if (child2_index >= 0) { |
| 65 | this->registerChildProcessor(src.childProcessor(child2_index).clone()); |
| 66 | } |
| 67 | this->registerChildProcessor(src.childProcessor(lerp_index).clone()); |
| 68 | } |
| 69 | std::unique_ptr<GrFragmentProcessor> GrComposeLerpRedEffect::clone() const { |
| 70 | return std::unique_ptr<GrFragmentProcessor>(new GrComposeLerpRedEffect(*this)); |
| 71 | } |