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 | #ifndef GrMixerEffect_DEFINED |
12 | #define GrMixerEffect_DEFINED |
13 | #include "include/core/SkTypes.h" |
14 | #include "include/core/SkM44.h" |
15 | |
16 | #include "src/gpu/GrCoordTransform.h" |
17 | #include "src/gpu/GrFragmentProcessor.h" |
18 | class GrMixerEffect : public GrFragmentProcessor { |
19 | public: |
20 | static OptimizationFlags OptFlags(const std::unique_ptr<GrFragmentProcessor>& fp0, |
21 | const std::unique_ptr<GrFragmentProcessor>& fp1) { |
22 | auto flags = ProcessorOptimizationFlags(fp0.get()); |
23 | if (fp1) { |
24 | flags &= ProcessorOptimizationFlags(fp1.get()); |
25 | } |
26 | return flags; |
27 | } |
28 | |
29 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override { |
30 | const auto c0 = ConstantOutputForConstantInput(this->childProcessor(0), input), |
31 | c1 = (this->numChildProcessors() > 1) |
32 | ? ConstantOutputForConstantInput(this->childProcessor(1), input) |
33 | : input; |
34 | return {c0.fR + (c1.fR - c0.fR) * weight, c0.fG + (c1.fG - c0.fG) * weight, |
35 | c0.fB + (c1.fB - c0.fB) * weight, c0.fA + (c1.fA - c0.fA) * weight}; |
36 | } |
37 | static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp0, |
38 | std::unique_ptr<GrFragmentProcessor> fp1, |
39 | float weight) { |
40 | return std::unique_ptr<GrFragmentProcessor>( |
41 | new GrMixerEffect(std::move(fp0), std::move(fp1), weight)); |
42 | } |
43 | GrMixerEffect(const GrMixerEffect& src); |
44 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
45 | const char* name() const override { return "MixerEffect" ; } |
46 | int fp0_index = -1; |
47 | int fp1_index = -1; |
48 | float weight; |
49 | |
50 | private: |
51 | GrMixerEffect(std::unique_ptr<GrFragmentProcessor> fp0, |
52 | std::unique_ptr<GrFragmentProcessor> fp1, |
53 | float weight) |
54 | : INHERITED(kGrMixerEffect_ClassID, (OptimizationFlags)OptFlags(fp0, fp1)) |
55 | , weight(weight) { |
56 | SkASSERT(fp0); |
57 | fp0_index = this->numChildProcessors(); |
58 | this->registerChildProcessor(std::move(fp0)); |
59 | if (fp1) { |
60 | fp1_index = this->numChildProcessors(); |
61 | this->registerChildProcessor(std::move(fp1)); |
62 | } |
63 | } |
64 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
65 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; |
66 | bool onIsEqual(const GrFragmentProcessor&) const override; |
67 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
68 | typedef GrFragmentProcessor INHERITED; |
69 | }; |
70 | #endif |
71 | |