More threading of GrProcessorDataManager
[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, positions, or a custom vertex attribute as input texture coords. The input coords
19  * can have a matrix applied in the VS in both the local and position cases but not with a custom
20  * attribute coords at this time. It will add a varying to input interpolate texture coords to the
21  * FS.
22  */
23 class GrSimpleTextureEffect : public GrSingleTextureEffect {
24 public:
25     /* unfiltered, clamp mode */
26     static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
27                                        GrTexture* tex,
28                                        const SkMatrix& matrix,
29                                        GrCoordSet coordSet = kLocal_GrCoordSet) {
30         return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix,
31                                                   GrTextureParams::kNone_FilterMode, coordSet));
32     }
33
34     /* clamp mode */
35     static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
36                                        GrTexture* tex,
37                                        const SkMatrix& matrix,
38                                        GrTextureParams::FilterMode filterMode,
39                                        GrCoordSet coordSet = kLocal_GrCoordSet) {
40         return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix, filterMode,
41                                                   coordSet));
42     }
43
44     static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
45                                        GrTexture* tex,
46                                        const SkMatrix& matrix,
47                                        const GrTextureParams& p,
48                                        GrCoordSet coordSet = kLocal_GrCoordSet) {
49         return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix, p, coordSet));
50     }
51
52     virtual ~GrSimpleTextureEffect() {}
53
54     const char* name() const override { return "SimpleTexture"; }
55
56     void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
57
58     GrGLFragmentProcessor* createGLInstance() const override;
59
60 private:
61     GrSimpleTextureEffect(GrProcessorDataManager* procDataManager,
62                           GrTexture* texture,
63                           const SkMatrix& matrix,
64                           GrTextureParams::FilterMode filterMode,
65                           GrCoordSet coordSet)
66         : GrSingleTextureEffect(procDataManager, texture, matrix, filterMode, coordSet) {
67         this->initClassID<GrSimpleTextureEffect>();
68     }
69
70     GrSimpleTextureEffect(GrProcessorDataManager* procDataManager,
71                           GrTexture* texture,
72                           const SkMatrix& matrix,
73                           const GrTextureParams& params,
74                           GrCoordSet coordSet)
75         : GrSingleTextureEffect(procDataManager, texture, matrix, params, coordSet) {
76         this->initClassID<GrSimpleTextureEffect>();
77     }
78
79     bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
80
81     void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
82
83     GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
84
85     typedef GrSingleTextureEffect INHERITED;
86 };
87
88 #endif