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