• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 GrConstColorProcessor.fp; do not modify.
10  **************************************************************************************************/
11 #ifndef GrConstColorProcessor_DEFINED
12 #define GrConstColorProcessor_DEFINED
13 #include "include/core/SkTypes.h"
14 
15 #include "src/gpu/GrCoordTransform.h"
16 #include "src/gpu/GrFragmentProcessor.h"
17 class GrConstColorProcessor : public GrFragmentProcessor {
18 public:
19     enum class InputMode { kIgnore = 0, kLast = 2, kModulateA = 2, kModulateRGBA = 1 };
20 
21     static const int kInputModeCnt = (int)InputMode::kLast + 1;
22 
OptFlags(const SkPMColor4f & color,InputMode mode)23     static OptimizationFlags OptFlags(const SkPMColor4f& color, InputMode mode) {
24         OptimizationFlags flags = kConstantOutputForConstantInput_OptimizationFlag;
25         if (mode != InputMode::kIgnore) {
26             flags |= kCompatibleWithCoverageAsAlpha_OptimizationFlag;
27         }
28         if (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         switch (mode) {
36             case InputMode::kIgnore:
37                 return color;
38             case InputMode::kModulateA:
39                 return color * input.fA;
40             case InputMode::kModulateRGBA:
41                 return color * input;
42         }
43         SK_ABORT("Unexpected mode");
44     }
Make(SkPMColor4f color,InputMode mode)45     static std::unique_ptr<GrFragmentProcessor> Make(SkPMColor4f color, InputMode mode) {
46         return std::unique_ptr<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
47     }
48     GrConstColorProcessor(const GrConstColorProcessor& src);
49     std::unique_ptr<GrFragmentProcessor> clone() const override;
name()50     const char* name() const override { return "ConstColorProcessor"; }
51     SkPMColor4f color;
52     InputMode mode;
53 
54 private:
GrConstColorProcessor(SkPMColor4f color,InputMode mode)55     GrConstColorProcessor(SkPMColor4f color, InputMode mode)
56             : INHERITED(kGrConstColorProcessor_ClassID, (OptimizationFlags)OptFlags(color, mode))
57             , color(color)
58             , mode(mode) {}
59     GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
60     void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
61     bool onIsEqual(const GrFragmentProcessor&) const override;
62     GR_DECLARE_FRAGMENT_PROCESSOR_TEST
63     typedef GrFragmentProcessor INHERITED;
64 };
65 #endif
66