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 GrRGBToHSLFilterEffect.fp; do not modify.
10 **************************************************************************************************/
11#include "GrRGBToHSLFilterEffect.h"
12
13#include "src/gpu/GrTexture.h"
14#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
15#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
16#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
17#include "src/sksl/SkSLCPP.h"
18#include "src/sksl/SkSLUtil.h"
19class GrGLSLRGBToHSLFilterEffect : public GrGLSLFragmentProcessor {
20public:
21 GrGLSLRGBToHSLFilterEffect() {}
22 void emitCode(EmitArgs& args) override {
23 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
24 const GrRGBToHSLFilterEffect& _outer = args.fFp.cast<GrRGBToHSLFilterEffect>();
25 (void)_outer;
26 fragBuilder->codeAppendf(
27 "half4 c = %s;\nhalf4 p = c.y < c.z ? half4(c.zy, -1.0, 0.66666666666666663) : "
28 "half4(c.yz, 0.0, -0.33333333333333331);\nhalf4 q = c.x < p.x ? half4(p.x, c.x, "
29 "p.yw) : half4(c.x, p.x, p.yz);\n\nhalf pmV = q.x;\nhalf pmC = pmV - min(q.y, "
30 "q.z);\nhalf pmL = pmV - pmC * 0.5;\nhalf H = abs(q.w + (q.y - q.z) / (pmC * 6.0 + "
31 "9.9999997473787516e-05));\nhalf S = pmC / ((c.w + 9.9999997473787516e-05) - "
32 "abs(pmL * 2.0 - c.w));\nhalf L = pmL / (c.w + 9.9999997473787516e-05);\n%s = "
33 "half4(H, S, L, c.w);\n",
34 args.fInputColor, args.fOutputColor);
35 }
36
37private:
38 void onSetData(const GrGLSLProgramDataManager& pdman,
39 const GrFragmentProcessor& _proc) override {}
40};
41GrGLSLFragmentProcessor* GrRGBToHSLFilterEffect::onCreateGLSLInstance() const {
42 return new GrGLSLRGBToHSLFilterEffect();
43}
44void GrRGBToHSLFilterEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
45 GrProcessorKeyBuilder* b) const {}
46bool GrRGBToHSLFilterEffect::onIsEqual(const GrFragmentProcessor& other) const {
47 const GrRGBToHSLFilterEffect& that = other.cast<GrRGBToHSLFilterEffect>();
48 (void)that;
49 return true;
50}
51GrRGBToHSLFilterEffect::GrRGBToHSLFilterEffect(const GrRGBToHSLFilterEffect& src)
52 : INHERITED(kGrRGBToHSLFilterEffect_ClassID, src.optimizationFlags()) {}
53std::unique_ptr<GrFragmentProcessor> GrRGBToHSLFilterEffect::clone() const {
54 return std::unique_ptr<GrFragmentProcessor>(new GrRGBToHSLFilterEffect(*this));
55}
56