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 GrClampFragmentProcessor.fp; do not modify.
10 **************************************************************************************************/
11#ifndef GrClampFragmentProcessor_DEFINED
12#define GrClampFragmentProcessor_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 GrClampFragmentProcessor : public GrFragmentProcessor {
19public:
20 SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override {
21 float clampedAlpha = SkTPin(input.fA, 0.f, 1.f);
22 float clampVal = clampToPremul ? clampedAlpha : 1.f;
23 return {SkTPin(input.fR, 0.f, clampVal), SkTPin(input.fG, 0.f, clampVal),
24 SkTPin(input.fB, 0.f, clampVal), clampedAlpha};
25 }
26 static std::unique_ptr<GrFragmentProcessor> Make(bool clampToPremul) {
27 return std::unique_ptr<GrFragmentProcessor>(new GrClampFragmentProcessor(clampToPremul));
28 }
29 GrClampFragmentProcessor(const GrClampFragmentProcessor& src);
30 std::unique_ptr<GrFragmentProcessor> clone() const override;
31 const char* name() const override { return "ClampFragmentProcessor"; }
32 bool clampToPremul;
33
34private:
35 GrClampFragmentProcessor(bool clampToPremul)
36 : INHERITED(kGrClampFragmentProcessor_ClassID,
37 (OptimizationFlags)kConstantOutputForConstantInput_OptimizationFlag |
38 kPreservesOpaqueInput_OptimizationFlag)
39 , clampToPremul(clampToPremul) {}
40 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
41 void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
42 bool onIsEqual(const GrFragmentProcessor&) const override;
43 GR_DECLARE_FRAGMENT_PROCESSOR_TEST
44 typedef GrFragmentProcessor INHERITED;
45};
46#endif
47