Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / 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 GrGLSimpleTextureEffect;
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(GrTexture* tex,
27                                        const SkMatrix& matrix,
28                                        GrCoordSet coordSet = kLocal_GrCoordSet) {
29         return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, GrTextureParams::kNone_FilterMode,
30                                                   coordSet));
31     }
32
33     /* clamp mode */
34     static GrFragmentProcessor* Create(GrTexture* tex,
35                                        const SkMatrix& matrix,
36                                        GrTextureParams::FilterMode filterMode,
37                                        GrCoordSet coordSet = kLocal_GrCoordSet) {
38         return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, filterMode, coordSet));
39     }
40
41     static GrFragmentProcessor* Create(GrTexture* tex,
42                                        const SkMatrix& matrix,
43                                        const GrTextureParams& p,
44                                        GrCoordSet coordSet = kLocal_GrCoordSet) {
45         return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p, coordSet));
46     }
47
48     virtual ~GrSimpleTextureEffect() {}
49
50     static const char* Name() { return "Texture"; }
51
52     typedef GrGLSimpleTextureEffect GLProcessor;
53
54     virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
55
56 private:
57     GrSimpleTextureEffect(GrTexture* texture,
58                           const SkMatrix& matrix,
59                           GrTextureParams::FilterMode filterMode,
60                           GrCoordSet coordSet)
61         : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) {
62     }
63
64     GrSimpleTextureEffect(GrTexture* texture,
65                           const SkMatrix& matrix,
66                           const GrTextureParams& params,
67                           GrCoordSet coordSet)
68         : GrSingleTextureEffect(texture, matrix, params, coordSet) {
69     }
70
71     virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE { return true; }
72
73     virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
74
75     GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
76
77     typedef GrSingleTextureEffect INHERITED;
78 };
79
80 #endif