OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrSimpleTextureEffect_DEFINED | 8 #ifndef GrSimpleTextureEffect_DEFINED |
9 #define GrSimpleTextureEffect_DEFINED | 9 #define GrSimpleTextureEffect_DEFINED |
10 | 10 |
11 #include "GrSingleTextureEffect.h" | 11 #include "GrSingleTextureEffect.h" |
12 | 12 |
13 class GrInvariantOutput; | 13 class GrInvariantOutput; |
14 | 14 |
15 /** | 15 /** |
16 * The output color of this effect is a modulation of the input color and a samp
le from a texture. | 16 * The output color of this effect is a modulation of the input color and a samp
le from a texture. |
17 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). It can use | 17 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). It can use |
18 * local coords or device space coords as input texture coords. The input coords
may be transformed | 18 * local coords or device space coords as input texture coords. The input coords
may be transformed |
19 * by a matrix. | 19 * by a matrix. |
20 */ | 20 */ |
21 class GrSimpleTextureEffect : public GrSingleTextureEffect { | 21 class GrSimpleTextureEffect : public GrSingleTextureEffect { |
22 public: | 22 public: |
23 /* unfiltered, clamp mode */ | 23 /* unfiltered, clamp mode */ |
24 static const GrFragmentProcessor* Create(GrProcessorDataManager* procDataMan
ager, | 24 static const GrFragmentProcessor* Create(GrTexture* tex, |
25 GrTexture* tex, | |
26 const SkMatrix& matrix, | 25 const SkMatrix& matrix, |
27 GrCoordSet coordSet = kLocal_GrCoor
dSet) { | 26 GrCoordSet coordSet = kLocal_GrCoor
dSet) { |
28 return new GrSimpleTextureEffect(procDataManager, tex, matrix, | 27 return new GrSimpleTextureEffect(tex, matrix, GrTextureParams::kNone_Fil
terMode, coordSet); |
29 GrTextureParams::kNone_FilterMode, coor
dSet); | |
30 } | 28 } |
31 | 29 |
32 /* clamp mode */ | 30 /* clamp mode */ |
33 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, | 31 static GrFragmentProcessor* Create(GrTexture* tex, |
34 GrTexture* tex, | |
35 const SkMatrix& matrix, | 32 const SkMatrix& matrix, |
36 GrTextureParams::FilterMode filterMode, | 33 GrTextureParams::FilterMode filterMode, |
37 GrCoordSet coordSet = kLocal_GrCoordSet)
{ | 34 GrCoordSet coordSet = kLocal_GrCoordSet)
{ |
38 return new GrSimpleTextureEffect(procDataManager, tex, matrix, filterMod
e, coordSet); | 35 return new GrSimpleTextureEffect(tex, matrix, filterMode, coordSet); |
39 } | 36 } |
40 | 37 |
41 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, | 38 static GrFragmentProcessor* Create(GrTexture* tex, |
42 GrTexture* tex, | |
43 const SkMatrix& matrix, | 39 const SkMatrix& matrix, |
44 const GrTextureParams& p, | 40 const GrTextureParams& p, |
45 GrCoordSet coordSet = kLocal_GrCoordSet)
{ | 41 GrCoordSet coordSet = kLocal_GrCoordSet)
{ |
46 return new GrSimpleTextureEffect(procDataManager, tex, matrix, p, coordS
et); | 42 return new GrSimpleTextureEffect(tex, matrix, p, coordSet); |
47 } | 43 } |
48 | 44 |
49 virtual ~GrSimpleTextureEffect() {} | 45 virtual ~GrSimpleTextureEffect() {} |
50 | 46 |
51 const char* name() const override { return "SimpleTexture"; } | 47 const char* name() const override { return "SimpleTexture"; } |
52 | 48 |
53 private: | 49 private: |
54 GrSimpleTextureEffect(GrProcessorDataManager* procDataManager, | 50 GrSimpleTextureEffect(GrTexture* texture, |
55 GrTexture* texture, | |
56 const SkMatrix& matrix, | 51 const SkMatrix& matrix, |
57 GrTextureParams::FilterMode filterMode, | 52 GrTextureParams::FilterMode filterMode, |
58 GrCoordSet coordSet) | 53 GrCoordSet coordSet) |
59 : GrSingleTextureEffect(procDataManager, texture, matrix, filterMode, co
ordSet) { | 54 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) { |
60 this->initClassID<GrSimpleTextureEffect>(); | 55 this->initClassID<GrSimpleTextureEffect>(); |
61 } | 56 } |
62 | 57 |
63 GrSimpleTextureEffect(GrProcessorDataManager* procDataManager, | 58 GrSimpleTextureEffect(GrTexture* texture, |
64 GrTexture* texture, | |
65 const SkMatrix& matrix, | 59 const SkMatrix& matrix, |
66 const GrTextureParams& params, | 60 const GrTextureParams& params, |
67 GrCoordSet coordSet) | 61 GrCoordSet coordSet) |
68 : GrSingleTextureEffect(procDataManager, texture, matrix, params, coordS
et) { | 62 : GrSingleTextureEffect(texture, matrix, params, coordSet) { |
69 this->initClassID<GrSimpleTextureEffect>(); | 63 this->initClassID<GrSimpleTextureEffect>(); |
70 } | 64 } |
71 | 65 |
72 GrGLFragmentProcessor* onCreateGLInstance() const override; | 66 GrGLFragmentProcessor* onCreateGLInstance() const override; |
73 | 67 |
74 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; | 68 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; |
75 | 69 |
76 bool onIsEqual(const GrFragmentProcessor& other) const override { return tru
e; } | 70 bool onIsEqual(const GrFragmentProcessor& other) const override { return tru
e; } |
77 | 71 |
78 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 72 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
79 | 73 |
80 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 74 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
81 | 75 |
82 typedef GrSingleTextureEffect INHERITED; | 76 typedef GrSingleTextureEffect INHERITED; |
83 }; | 77 }; |
84 | 78 |
85 #endif | 79 #endif |
OLD | NEW |