Create fragment processor for performing input color blend with child processor
[platform/upstream/libSkiaSharp.git] / src / gpu / effects / GrSimpleTextureEffect.h
1 /*
2  * Copyright 2013 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 #ifndef GrSimpleTextureEffect_DEFINED
9 #define GrSimpleTextureEffect_DEFINED
10
11 #include "GrSingleTextureEffect.h"
12
13 class GrInvariantOutput;
14
15 /**
16  * The output color of this effect is a modulation of the input color and a sample from a texture.
17  * It allows explicit specification of the filtering and wrap modes (GrTextureParams). It can use
18  * local coords or device space coords as input texture coords. The input coords may be transformed
19  * by a matrix.
20  */
21 class GrSimpleTextureEffect : public GrSingleTextureEffect {
22 public:
23     /* unfiltered, clamp mode */
24     static const GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
25                                              GrTexture* tex,
26                                              const SkMatrix& matrix,
27                                              GrCoordSet coordSet = kLocal_GrCoordSet) {
28         return new GrSimpleTextureEffect(procDataManager, tex, matrix,
29                                          GrTextureParams::kNone_FilterMode, coordSet);
30     }
31
32     /* clamp mode */
33     static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
34                                        GrTexture* tex,
35                                        const SkMatrix& matrix,
36                                        GrTextureParams::FilterMode filterMode,
37                                        GrCoordSet coordSet = kLocal_GrCoordSet) {
38         return new GrSimpleTextureEffect(procDataManager, tex, matrix, filterMode, coordSet);
39     }
40
41     static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
42                                        GrTexture* tex,
43                                        const SkMatrix& matrix,
44                                        const GrTextureParams& p,
45                                        GrCoordSet coordSet = kLocal_GrCoordSet) {
46         return new GrSimpleTextureEffect(procDataManager, tex, matrix, p, coordSet);
47     }
48
49     virtual ~GrSimpleTextureEffect() {}
50
51     const char* name() const override { return "SimpleTexture"; }
52
53 private:
54     GrSimpleTextureEffect(GrProcessorDataManager* procDataManager,
55                           GrTexture* texture,
56                           const SkMatrix& matrix,
57                           GrTextureParams::FilterMode filterMode,
58                           GrCoordSet coordSet)
59         : GrSingleTextureEffect(procDataManager, texture, matrix, filterMode, coordSet) {
60         this->initClassID<GrSimpleTextureEffect>();
61     }
62
63     GrSimpleTextureEffect(GrProcessorDataManager* procDataManager,
64                           GrTexture* texture,
65                           const SkMatrix& matrix,
66                           const GrTextureParams& params,
67                           GrCoordSet coordSet)
68         : GrSingleTextureEffect(procDataManager, texture, matrix, params, coordSet) {
69         this->initClassID<GrSimpleTextureEffect>();
70     }
71
72     GrGLFragmentProcessor* onCreateGLInstance() const override;
73
74     void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
75
76     bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
77
78     void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
79
80     GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
81
82     typedef GrSingleTextureEffect INHERITED;
83 };
84
85 #endif