1 /*
2  * Copyright 2017 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 GrSimpleTextureEffect.fp; do not modify.
10  **************************************************************************************************/
11 #ifndef GrSimpleTextureEffect_DEFINED
12 #define GrSimpleTextureEffect_DEFINED
13 #include "SkTypes.h"
14 #if SK_SUPPORT_GPU
15 #include "GrFragmentProcessor.h"
16 #include "GrCoordTransform.h"
17 class GrSimpleTextureEffect : public GrFragmentProcessor {
18 public:
19     SkMatrix44 matrix() const { return fMatrix; }
20 
21     static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
22                                                      const SkMatrix& matrix) {
23         return std::unique_ptr<GrFragmentProcessor>(
24                 new GrSimpleTextureEffect(std::move(proxy), matrix,
25                                           GrSamplerState(GrSamplerState::WrapMode::kClamp,
26                                                          GrSamplerState::Filter::kNearest)));
27     }
28 
29     /* clamp mode */
30     static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
31                                                      const SkMatrix& matrix,
32                                                      GrSamplerState::Filter filter) {
33         return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(
34                 std::move(proxy), matrix,
35                 GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
36     }
37 
38     static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
39                                                      const SkMatrix& matrix,
40                                                      const GrSamplerState& p) {
41         return std::unique_ptr<GrFragmentProcessor>(
42                 new GrSimpleTextureEffect(std::move(proxy), matrix, p));
43     }
44     GrSimpleTextureEffect(const GrSimpleTextureEffect& src);
45     std::unique_ptr<GrFragmentProcessor> clone() const override;
46     const char* name() const override { return "SimpleTextureEffect"; }
47 
48 private:
49     GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix,
50                           GrSamplerState samplerParams)
51             : INHERITED(kGrSimpleTextureEffect_ClassID,
52                         (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag |
53                                 (GrPixelConfigIsOpaque(image->config())
54                                          ? kPreservesOpaqueInput_OptimizationFlag
55                                          : kNone_OptimizationFlags))
56             , fImage(std::move(image), samplerParams)
57             , fMatrix(matrix)
58             , fImageCoordTransform(matrix, fImage.proxy()) {
59         this->addTextureSampler(&fImage);
60         this->addCoordTransform(&fImageCoordTransform);
61     }
62     GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
63     void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
64     bool onIsEqual(const GrFragmentProcessor&) const override;
65     GR_DECLARE_FRAGMENT_PROCESSOR_TEST
66     TextureSampler fImage;
67     SkMatrix44 fMatrix;
68     GrCoordTransform fImageCoordTransform;
69     typedef GrFragmentProcessor INHERITED;
70 };
71 #endif
72 #endif
73