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#include "include/core/SkM44.h"
15
16#include "src/gpu/GrCoordTransform.h"
17#include "src/gpu/GrFragmentProcessor.h"
18class GrConstColorProcessor : public GrFragmentProcessor {
19public:
20 enum class InputMode { kIgnore = 0, kLast = 2, kModulateA = 2, kModulateRGBA = 1 };
21
22 static const int kInputModeCnt = (int)InputMode::kLast + 1;
23
24 static OptimizationFlags OptFlags(const SkPMColor4f& color, InputMode mode) {
25 OptimizationFlags flags = kConstantOutputForConstantInput_OptimizationFlag;
26 if (mode != InputMode::kIgnore) {
27 flags |= kCompatibleWithCoverageAsAlpha_OptimizationFlag;
28 }
29 if (color.isOpaque()) {
30 flags |= kPreservesOpaqueInput_OptimizationFlag;
31 }
32 return flags;
33 }
34
35 SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override {
36 switch (mode) {
37 case InputMode::kIgnore:
38 return color;
39 case InputMode::kModulateA:
40 return color * input.fA;
41 case InputMode::kModulateRGBA:
42 return color * input;
43 }
44 SK_ABORT("Unexpected mode");
45 }
46 static std::unique_ptr<GrFragmentProcessor> Make(SkPMColor4f color, InputMode mode) {
47 return std::unique_ptr<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
48 }
49 GrConstColorProcessor(const GrConstColorProcessor& src);
50 std::unique_ptr<GrFragmentProcessor> clone() const override;
51 const char* name() const override { return "ConstColorProcessor"; }
52 SkPMColor4f color;
53 InputMode mode;
54
55private:
56 GrConstColorProcessor(SkPMColor4f color, InputMode mode)
57 : INHERITED(kGrConstColorProcessor_ClassID, (OptimizationFlags)OptFlags(color, mode))
58 , color(color)
59 , mode(mode) {}
60 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
61 void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
62 bool onIsEqual(const GrFragmentProcessor&) const override;
63 GR_DECLARE_FRAGMENT_PROCESSOR_TEST
64 typedef GrFragmentProcessor INHERITED;
65};
66#endif
67