| 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 | #include "GrHSLToRGBFilterEffect.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" |
| 19 | class GrGLSLHSLToRGBFilterEffect : public GrGLSLFragmentProcessor { |
| 20 | public: |
| 21 | GrGLSLHSLToRGBFilterEffect() {} |
| 22 | void emitCode(EmitArgs& args) override { |
| 23 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 24 | const GrHSLToRGBFilterEffect& _outer = args.fFp.cast<GrHSLToRGBFilterEffect>(); |
| 25 | (void)_outer; |
| 26 | fragBuilder->codeAppendf( |
| 27 | "half3 hsl = %s.xyz;\nhalf C = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;\nhalf3 p = " |
| 28 | "hsl.xxx + half3(0.0, 0.66666666666666663, 0.33333333333333331);\nhalf3 q = " |
| 29 | "clamp(abs(fract(p) * 6.0 - 3.0) - 1.0, 0.0, 1.0);\nhalf3 rgb = (q - 0.5) * C + " |
| 30 | "hsl.z;\n%s = clamp(half4(rgb, %s.w), 0.0, 1.0);\n%s.xyz *= %s.w;\n" , |
| 31 | args.fInputColor, args.fOutputColor, args.fInputColor, args.fOutputColor, |
| 32 | args.fOutputColor); |
| 33 | } |
| 34 | |
| 35 | private: |
| 36 | void onSetData(const GrGLSLProgramDataManager& pdman, |
| 37 | const GrFragmentProcessor& _proc) override {} |
| 38 | }; |
| 39 | GrGLSLFragmentProcessor* GrHSLToRGBFilterEffect::onCreateGLSLInstance() const { |
| 40 | return new GrGLSLHSLToRGBFilterEffect(); |
| 41 | } |
| 42 | void GrHSLToRGBFilterEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
| 43 | GrProcessorKeyBuilder* b) const {} |
| 44 | bool GrHSLToRGBFilterEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 45 | const GrHSLToRGBFilterEffect& that = other.cast<GrHSLToRGBFilterEffect>(); |
| 46 | (void)that; |
| 47 | return true; |
| 48 | } |
| 49 | GrHSLToRGBFilterEffect::GrHSLToRGBFilterEffect(const GrHSLToRGBFilterEffect& src) |
| 50 | : INHERITED(kGrHSLToRGBFilterEffect_ClassID, src.optimizationFlags()) {} |
| 51 | std::unique_ptr<GrFragmentProcessor> GrHSLToRGBFilterEffect::clone() const { |
| 52 | return std::unique_ptr<GrFragmentProcessor>(new GrHSLToRGBFilterEffect(*this)); |
| 53 | } |
| 54 | |