1 /*
2  * Copyright 2018 Google Inc.
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 GrAlphaThresholdFragmentProcessor.fp; do not modify.
10  **************************************************************************************************/
11 #ifndef GrAlphaThresholdFragmentProcessor_DEFINED
12 #define GrAlphaThresholdFragmentProcessor_DEFINED
13 #include "SkTypes.h"
14 #include "GrFragmentProcessor.h"
15 #include "GrCoordTransform.h"
16 class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor {
17 public:
18     inline OptimizationFlags optFlags(float outerThreshold);
innerThreshold()19     float innerThreshold() const { return fInnerThreshold; }
outerThreshold()20     float outerThreshold() const { return fOuterThreshold; }
21 
Make(sk_sp<GrTextureProxy> mask,float innerThreshold,float outerThreshold,const SkIRect & bounds)22     static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> mask,
23                                                      float innerThreshold,
24                                                      float outerThreshold,
25                                                      const SkIRect& bounds) {
26         return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(
27                 mask, innerThreshold, outerThreshold, bounds));
28     }
29     GrAlphaThresholdFragmentProcessor(const GrAlphaThresholdFragmentProcessor& src);
30     std::unique_ptr<GrFragmentProcessor> clone() const override;
name()31     const char* name() const override { return "AlphaThresholdFragmentProcessor"; }
32 
33 private:
GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> mask,float innerThreshold,float outerThreshold,const SkIRect & bounds)34     GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> mask, float innerThreshold,
35                                       float outerThreshold, const SkIRect& bounds)
36             : INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID, kNone_OptimizationFlags)
37             , fMask(std::move(mask))
38             , fInnerThreshold(innerThreshold)
39             , fOuterThreshold(outerThreshold)
40             , fMaskCoordTransform(
41                       SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())),
42                       fMask.proxy()) {
43         this->setTextureSamplerCnt(1);
44         this->addCoordTransform(&fMaskCoordTransform);
45     }
46     GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
47     void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
48     bool onIsEqual(const GrFragmentProcessor&) const override;
49     const TextureSampler& onTextureSampler(int) const override;
50     GR_DECLARE_FRAGMENT_PROCESSOR_TEST
51     TextureSampler fMask;
52     float fInnerThreshold;
53     float fOuterThreshold;
54     GrCoordTransform fMaskCoordTransform;
55     typedef GrFragmentProcessor INHERITED;
56 };
57 #endif
58