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 "include/core/SkTypes.h"
14 
15 #include "src/gpu/GrCoordTransform.h"
16 #include "src/gpu/GrFragmentProcessor.h"
17 class GrSimpleTextureEffect : public GrFragmentProcessor {
18 public:
Make(sk_sp<GrTextureProxy> proxy,GrColorType srcColorType,const SkMatrix & matrix)19     static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
20                                                      GrColorType srcColorType,
21                                                      const SkMatrix& matrix) {
22         return std::unique_ptr<GrFragmentProcessor>(
23                 new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType,
24                                           GrSamplerState(GrSamplerState::WrapMode::kClamp,
25                                                          GrSamplerState::Filter::kNearest)));
26     }
27 
28     /* clamp mode */
Make(sk_sp<GrTextureProxy> proxy,GrColorType srcColorType,const SkMatrix & matrix,GrSamplerState::Filter filter)29     static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
30                                                      GrColorType srcColorType,
31                                                      const SkMatrix& matrix,
32                                                      GrSamplerState::Filter filter) {
33         return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(
34                 std::move(proxy), matrix, srcColorType,
35                 GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
36     }
37 
Make(sk_sp<GrTextureProxy> proxy,GrColorType srcColorType,const SkMatrix & matrix,const GrSamplerState & p)38     static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
39                                                      GrColorType srcColorType,
40                                                      const SkMatrix& matrix,
41                                                      const GrSamplerState& p) {
42         return std::unique_ptr<GrFragmentProcessor>(
43                 new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType, p));
44     }
45     GrSimpleTextureEffect(const GrSimpleTextureEffect& src);
46     std::unique_ptr<GrFragmentProcessor> clone() const override;
name()47     const char* name() const override { return "SimpleTextureEffect"; }
48     GrCoordTransform imageCoordTransform;
49     TextureSampler image;
50     SkMatrix44 matrix;
51 
52 private:
GrSimpleTextureEffect(sk_sp<GrTextureProxy> image,SkMatrix44 matrix,GrColorType srcColorType,GrSamplerState samplerParams)53     GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix, GrColorType srcColorType,
54                           GrSamplerState samplerParams)
55             : INHERITED(kGrSimpleTextureEffect_ClassID,
56                         (OptimizationFlags)ModulateForSamplerOptFlags(
57                                 srcColorType,
58                                 samplerParams.wrapModeX() ==
59                                                 GrSamplerState::WrapMode::kClampToBorder ||
60                                         samplerParams.wrapModeY() ==
61                                                 GrSamplerState::WrapMode::kClampToBorder))
62             , imageCoordTransform(matrix, image.get())
63             , image(std::move(image), samplerParams)
64             , matrix(matrix) {
65         this->setTextureSamplerCnt(1);
66         this->addCoordTransform(&imageCoordTransform);
67     }
68     GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
69     void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
70     bool onIsEqual(const GrFragmentProcessor&) const override;
71     const TextureSampler& onTextureSampler(int) const override;
72     GR_DECLARE_FRAGMENT_PROCESSOR_TEST
73     typedef GrFragmentProcessor INHERITED;
74 };
75 #endif
76