1 | /* |
2 | * Copyright 2019 Google LLC |
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 GrHSLToRGBFilterEffect.fp; do not modify. |
10 | **************************************************************************************************/ |
11 | #ifndef GrHSLToRGBFilterEffect_DEFINED |
12 | #define GrHSLToRGBFilterEffect_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 GrHSLToRGBFilterEffect : public GrFragmentProcessor { |
19 | public: |
20 | #include "include/private/SkColorData.h" |
21 | #include "include/private/SkNx.h" |
22 | |
23 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& c) const override { |
24 | const auto H = c[0], S = c[1], L = c[2], C = (1 - std::abs(2 * L - 1)) * S; |
25 | |
26 | const auto p = H + Sk4f(0, 2 / 3.f, 1 / 3.f, 0), |
27 | q = Sk4f::Min(Sk4f::Max(((p - p.floor()) * 6 - 3).abs() - 1, 0), 1), |
28 | rgb = (q - 0.5f) * C + L, |
29 | rgba = Sk4f::Min(Sk4f::Max(Sk4f(rgb[0], rgb[1], rgb[2], c.fA), 0), 1); |
30 | |
31 | return SkColor4f{rgba[0], rgba[1], rgba[2], rgba[3]}.premul(); |
32 | } |
33 | static std::unique_ptr<GrFragmentProcessor> Make() { |
34 | return std::unique_ptr<GrFragmentProcessor>(new GrHSLToRGBFilterEffect()); |
35 | } |
36 | GrHSLToRGBFilterEffect(const GrHSLToRGBFilterEffect& src); |
37 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
38 | const char* name() const override { return "HSLToRGBFilterEffect" ; } |
39 | |
40 | private: |
41 | GrHSLToRGBFilterEffect() |
42 | : INHERITED(kGrHSLToRGBFilterEffect_ClassID, |
43 | (OptimizationFlags)(kConstantOutputForConstantInput_OptimizationFlag | |
44 | kPreservesOpaqueInput_OptimizationFlag)) {} |
45 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
46 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; |
47 | bool onIsEqual(const GrFragmentProcessor&) const override; |
48 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
49 | typedef GrFragmentProcessor INHERITED; |
50 | }; |
51 | #endif |
52 | |