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 GrOverrideInputFragmentProcessor.fp; do not modify. |
10 | **************************************************************************************************/ |
11 | #ifndef GrOverrideInputFragmentProcessor_DEFINED |
12 | #define GrOverrideInputFragmentProcessor_DEFINED |
13 | |
14 | #include "include/core/SkM44.h" |
15 | #include "include/core/SkTypes.h" |
16 | |
17 | #include "src/gpu/GrFragmentProcessor.h" |
18 | |
19 | class GrOverrideInputFragmentProcessor : public GrFragmentProcessor { |
20 | public: |
21 | static OptimizationFlags OptFlags(const std::unique_ptr<GrFragmentProcessor>& fp, |
22 | const SkPMColor4f& color) { |
23 | auto childFlags = ProcessorOptimizationFlags(fp.get()); |
24 | auto flags = kNone_OptimizationFlags; |
25 | if (childFlags & kConstantOutputForConstantInput_OptimizationFlag) { |
26 | flags |= kConstantOutputForConstantInput_OptimizationFlag; |
27 | } |
28 | if ((childFlags & kPreservesOpaqueInput_OptimizationFlag) && color.isOpaque()) { |
29 | flags |= kPreservesOpaqueInput_OptimizationFlag; |
30 | } |
31 | return flags; |
32 | } |
33 | |
34 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override { |
35 | return ConstantOutputForConstantInput(this->childProcessor(0), uniformColor); |
36 | } |
37 | |
38 | static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp, |
39 | const SkPMColor4f& color, |
40 | bool useUniform = true) { |
41 | return std::unique_ptr<GrFragmentProcessor>( |
42 | new GrOverrideInputFragmentProcessor(std::move(fp), useUniform, color, color)); |
43 | } |
44 | GrOverrideInputFragmentProcessor(const GrOverrideInputFragmentProcessor& src); |
45 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
46 | const char* name() const override { return "OverrideInputFragmentProcessor" ; } |
47 | bool useUniform; |
48 | SkPMColor4f uniformColor; |
49 | SkPMColor4f literalColor; |
50 | |
51 | private: |
52 | GrOverrideInputFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp, |
53 | bool useUniform, |
54 | SkPMColor4f uniformColor, |
55 | SkPMColor4f literalColor) |
56 | : INHERITED(kGrOverrideInputFragmentProcessor_ClassID, |
57 | (OptimizationFlags)OptFlags(fp, useUniform ? uniformColor : literalColor)) |
58 | , useUniform(useUniform) |
59 | , uniformColor(uniformColor) |
60 | , literalColor(literalColor) { |
61 | SkASSERT(fp); |
62 | this->registerChild(std::move(fp), SkSL::SampleUsage::PassThrough()); |
63 | } |
64 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
65 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; |
66 | bool onIsEqual(const GrFragmentProcessor&) const override; |
67 | #if GR_TEST_UTILS |
68 | SkString onDumpInfo() const override; |
69 | #endif |
70 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
71 | typedef GrFragmentProcessor INHERITED; |
72 | }; |
73 | #endif |
74 | |