• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
14 #include "include/core/SkM44.h"
15 #include "include/core/SkTypes.h"
16 
17 #include "src/gpu/GrFragmentProcessor.h"
18 
19 class GrClampFragmentProcessor : public GrFragmentProcessor {
20 public:
constantOutputForConstantInput(const SkPMColor4f & inColor)21     SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& inColor) const override {
22         SkPMColor4f input = ConstantOutputForConstantInput(this->childProcessor(0), inColor);
23         float clampedAlpha = SkTPin(input.fA, 0.f, 1.f);
24         float clampVal = clampToPremul ? clampedAlpha : 1.f;
25         return {SkTPin(input.fR, 0.f, clampVal),
26                 SkTPin(input.fG, 0.f, clampVal),
27                 SkTPin(input.fB, 0.f, clampVal),
28                 clampedAlpha};
29     }
Make(std::unique_ptr<GrFragmentProcessor> inputFP,bool clampToPremul)30     static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> inputFP,
31                                                      bool clampToPremul) {
32         return std::unique_ptr<GrFragmentProcessor>(
33                 new GrClampFragmentProcessor(std::move(inputFP), clampToPremul));
34     }
35     GrClampFragmentProcessor(const GrClampFragmentProcessor& src);
36     std::unique_ptr<GrFragmentProcessor> clone() const override;
name()37     const char* name() const override { return "ClampFragmentProcessor"; }
38     bool clampToPremul;
39 
40 private:
GrClampFragmentProcessor(std::unique_ptr<GrFragmentProcessor> inputFP,bool clampToPremul)41     GrClampFragmentProcessor(std::unique_ptr<GrFragmentProcessor> inputFP, bool clampToPremul)
42             : INHERITED(kGrClampFragmentProcessor_ClassID,
43                         (OptimizationFlags)ProcessorOptimizationFlags(inputFP.get()) &
44                                 (kConstantOutputForConstantInput_OptimizationFlag |
45                                  kPreservesOpaqueInput_OptimizationFlag))
46             , clampToPremul(clampToPremul) {
47         this->registerChild(std::move(inputFP), SkSL::SampleUsage::PassThrough());
48     }
49     std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
50     void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
51     bool onIsEqual(const GrFragmentProcessor&) const override;
52 #if GR_TEST_UTILS
53     SkString onDumpInfo() const override;
54 #endif
55     GR_DECLARE_FRAGMENT_PROCESSOR_TEST
56     using INHERITED = GrFragmentProcessor;
57 };
58 #endif
59