OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 GrSingleTextureEffect_DEFINED | 8 #ifndef GrSingleTextureEffect_DEFINED |
9 #define GrSingleTextureEffect_DEFINED | 9 #define GrSingleTextureEffect_DEFINED |
10 | 10 |
11 #include "GrFragmentProcessor.h" | 11 #include "GrFragmentProcessor.h" |
12 #include "GrCoordTransform.h" | 12 #include "GrCoordTransform.h" |
13 #include "GrInvariantOutput.h" | 13 #include "GrInvariantOutput.h" |
14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
15 | 15 |
16 class GrTexture; | 16 class GrTexture; |
17 | 17 |
18 /** | 18 /** |
19 * A base class for effects that draw a single texture with a texture matrix. Th
is effect has no | 19 * A base class for effects that draw a single texture with a texture matrix. Th
is effect has no |
20 * backend implementations. One must be provided by the subclass. | 20 * backend implementations. One must be provided by the subclass. |
21 */ | 21 */ |
22 class GrSingleTextureEffect : public GrFragmentProcessor { | 22 class GrSingleTextureEffect : public GrFragmentProcessor { |
23 public: | 23 public: |
24 virtual ~GrSingleTextureEffect(); | 24 virtual ~GrSingleTextureEffect(); |
25 | 25 |
26 protected: | 26 protected: |
27 /** unfiltered, clamp mode */ | 27 /** unfiltered, clamp mode */ |
28 GrSingleTextureEffect(GrProcessorDataManager*, GrTexture*, const SkMatrix&, | 28 GrSingleTextureEffect(GrTexture*, const SkMatrix&, GrCoordSet = kLocal_GrCoo
rdSet); |
| 29 /** clamp mode */ |
| 30 GrSingleTextureEffect(GrTexture*, const SkMatrix&, GrTextureParams::FilterMo
de filterMode, |
29 GrCoordSet = kLocal_GrCoordSet); | 31 GrCoordSet = kLocal_GrCoordSet); |
30 /** clamp mode */ | 32 GrSingleTextureEffect(GrTexture*, |
31 GrSingleTextureEffect(GrProcessorDataManager*, GrTexture*, const SkMatrix&, | |
32 GrTextureParams::FilterMode filterMode, | |
33 GrCoordSet = kLocal_GrCoordSet); | |
34 GrSingleTextureEffect(GrProcessorDataManager*, | |
35 GrTexture*, | |
36 const SkMatrix&, | 33 const SkMatrix&, |
37 const GrTextureParams&, | 34 const GrTextureParams&, |
38 GrCoordSet = kLocal_GrCoordSet); | 35 GrCoordSet = kLocal_GrCoordSet); |
39 | 36 |
40 /** | 37 /** |
41 * Can be used as a helper to implement subclass onComputeInvariantOutput().
It assumes that | 38 * Can be used as a helper to implement subclass onComputeInvariantOutput().
It assumes that |
42 * the subclass output color will be a modulation of the input color with a
value read from the | 39 * the subclass output color will be a modulation of the input color with a
value read from the |
43 * texture. | 40 * texture. |
44 */ | 41 */ |
45 void updateInvariantOutputForModulation(GrInvariantOutput* inout) const { | 42 void updateInvariantOutputForModulation(GrInvariantOutput* inout) const { |
46 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { | 43 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { |
47 inout->mulByUnknownSingleComponent(); | 44 inout->mulByUnknownSingleComponent(); |
48 } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) { | 45 } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) { |
49 inout->mulByUnknownOpaqueFourComponents(); | 46 inout->mulByUnknownOpaqueFourComponents(); |
50 } else { | 47 } else { |
51 inout->mulByUnknownFourComponents(); | 48 inout->mulByUnknownFourComponents(); |
52 } | 49 } |
53 } | 50 } |
54 | 51 |
55 private: | 52 private: |
56 GrCoordTransform fCoordTransform; | 53 GrCoordTransform fCoordTransform; |
57 GrTextureAccess fTextureAccess; | 54 GrTextureAccess fTextureAccess; |
58 | 55 |
59 typedef GrFragmentProcessor INHERITED; | 56 typedef GrFragmentProcessor INHERITED; |
60 }; | 57 }; |
61 | 58 |
62 #endif | 59 #endif |
OLD | NEW |