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  *** NOTE: This was generated in origin/master and cherry-picked to android/next-release.
11  *** The .fp file that generated it relies on SkSL .fp features that are not present in
12  *** in android/next-release and thus were not cherry-picked.
13  **************************************************************************************************/
14 #ifndef GrOverrideInputFragmentProcessor_DEFINED
15 #define GrOverrideInputFragmentProcessor_DEFINED
16 #include "SkTypes.h"
17 #include "GrFragmentProcessor.h"
18 #include "GrCoordTransform.h"
19 class GrOverrideInputFragmentProcessor : public GrFragmentProcessor {
20 public:
OptFlags(const std::unique_ptr<GrFragmentProcessor> & fp,const SkPMColor4f & color)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 
constantOutputForConstantInput(const SkPMColor4f & input)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;
name()46     const char* name() const override { return "OverrideInputFragmentProcessor"; }
47     int fp_index = -1;
48     bool useUniform;
49     SkPMColor4f uniformColor;
50     SkPMColor4f literalColor;
51 
52 private:
GrOverrideInputFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp,bool useUniform,SkPMColor4f uniformColor,SkPMColor4f literalColor)53     GrOverrideInputFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp,
54                                      bool useUniform,
55                                      SkPMColor4f uniformColor,
56                                      SkPMColor4f literalColor)
57             : INHERITED(kGrOverrideInputFragmentProcessor_ClassID,
58                         (OptimizationFlags)OptFlags(fp, useUniform ? uniformColor : literalColor))
59             , useUniform(useUniform)
60             , uniformColor(uniformColor)
61             , literalColor(literalColor) {
62         SkASSERT(fp);
63         fp_index = this->numChildProcessors();
64         this->registerChildProcessor(std::move(fp));
65     }
66     GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
67     void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
68     bool onIsEqual(const GrFragmentProcessor&) const override;
69     GR_DECLARE_FRAGMENT_PROCESSOR_TEST
70     typedef GrFragmentProcessor INHERITED;
71 };
72 #endif
73