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