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 GrDistanceFieldTextureEffect_DEFINED | 8 #ifndef GrDistanceFieldTextureEffect_DEFINED |
9 #define GrDistanceFieldTextureEffect_DEFINED | 9 #define GrDistanceFieldTextureEffect_DEFINED |
10 | 10 |
11 #include "GrEffect.h" | 11 #include "GrEffect.h" |
12 #include "GrVertexEffect.h" | 12 #include "GrVertexEffect.h" |
13 | 13 |
14 class GrGLDistanceFieldTextureEffect; | 14 class GrGLDistanceFieldTextureEffect; |
15 class GrGLDistanceFieldLCDTextureEffect; | 15 class GrGLDistanceFieldLCDTextureEffect; |
16 | 16 |
17 /** | 17 /** |
18 * The output color of this effect is a modulation of the input color and a samp
le from a | 18 * The output color of this effect is a modulation of the input color and a samp
le from a |
19 * distance field texture (using a smoothed step function near 0.5). | 19 * distance field texture (using a smoothed step function near 0.5). |
20 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input | 20 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
21 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 21 * coords are a custom attribute. |
22 */ | 22 */ |
23 class GrDistanceFieldTextureEffect : public GrVertexEffect { | 23 class GrDistanceFieldTextureEffect : public GrVertexEffect { |
24 public: | 24 public: |
25 #ifdef SK_GAMMA_APPLY_TO_A8 | 25 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, bo
ol similarity) { |
26 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, | 26 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, pa
rams, similarity))); |
27 GrTexture* gamma, const GrTextureParams& gammaPar
ams, float lum, | |
28 bool similarity) { | |
29 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, pa
rams, | |
30 gamma,
gammaParams, lum, | |
31 similar
ity))); | |
32 #else | |
33 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, | |
34 bool similarity) { | |
35 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, pa
rams, | |
36 similar
ity))); | |
37 #endif | |
38 return CreateEffectRef(effect); | 27 return CreateEffectRef(effect); |
39 } | 28 } |
40 | 29 |
41 virtual ~GrDistanceFieldTextureEffect() {} | 30 virtual ~GrDistanceFieldTextureEffect() {} |
42 | 31 |
43 static const char* Name() { return "DistanceFieldTexture"; } | 32 static const char* Name() { return "DistanceFieldTexture"; } |
44 | 33 |
45 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 34 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
46 #ifdef SK_GAMMA_APPLY_TO_A8 | |
47 float getLuminance() const { return fLuminance; } | |
48 #endif | |
49 bool isSimilarity() const { return fIsSimilarity; } | 35 bool isSimilarity() const { return fIsSimilarity; } |
50 | 36 |
51 typedef GrGLDistanceFieldTextureEffect GLEffect; | 37 typedef GrGLDistanceFieldTextureEffect GLEffect; |
52 | 38 |
53 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 39 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
54 | 40 |
55 private: | 41 private: |
56 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& para
ms, | 42 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& para
ms, |
57 #ifdef SK_GAMMA_APPLY_TO_A8 | |
58 GrTexture* gamma, const GrTextureParams& gammaP
arams, float lum, | |
59 #endif | |
60 bool uniformScale); | 43 bool uniformScale); |
61 | 44 |
62 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; | 45 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
63 | 46 |
64 GrTextureAccess fTextureAccess; | 47 GrTextureAccess fTextureAccess; |
65 #ifdef SK_GAMMA_APPLY_TO_A8 | |
66 GrTextureAccess fGammaTextureAccess; | |
67 float fLuminance; | |
68 #endif | |
69 bool fIsSimilarity; | 48 bool fIsSimilarity; |
70 | 49 |
71 GR_DECLARE_EFFECT_TEST; | 50 GR_DECLARE_EFFECT_TEST; |
72 | 51 |
73 typedef GrVertexEffect INHERITED; | 52 typedef GrVertexEffect INHERITED; |
74 }; | 53 }; |
75 | 54 |
76 /** | 55 /** |
77 * The output color of this effect is a modulation of the input color and sample
s from a | 56 * The output color of this effect is a modulation of the input color and sample
s from a |
78 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. | 57 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. |
79 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input | 58 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
80 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 59 * coords are a custom attribute. |
81 */ | 60 */ |
82 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { | 61 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { |
83 public: | 62 public: |
84 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, | 63 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, |
85 GrTexture* gamma, const GrTextureParams& gammaPar
ams, | |
86 SkColor textColor, | |
87 bool uniformScale, bool useBGR) { | 64 bool uniformScale, bool useBGR) { |
88 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, | 65 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, |
89 (tex, params, gamma, gammaParams, text
Color, uniformScale, | 66 (tex, params, uniformScale, useBGR))); |
90 useBGR))); | |
91 return CreateEffectRef(effect); | 67 return CreateEffectRef(effect); |
92 } | 68 } |
93 | 69 |
94 virtual ~GrDistanceFieldLCDTextureEffect() {} | 70 virtual ~GrDistanceFieldLCDTextureEffect() {} |
95 | 71 |
96 static const char* Name() { return "DistanceFieldLCDTexture"; } | 72 static const char* Name() { return "DistanceFieldLCDTexture"; } |
97 | 73 |
98 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 74 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
99 GrColor getTextColor() const { return fTextColor; } | |
100 bool isUniformScale() const { return fUniformScale; } | 75 bool isUniformScale() const { return fUniformScale; } |
101 bool useBGR() const { return fUseBGR; } | 76 bool useBGR() const { return fUseBGR; } |
102 | 77 |
103 typedef GrGLDistanceFieldLCDTextureEffect GLEffect; | 78 typedef GrGLDistanceFieldLCDTextureEffect GLEffect; |
104 | 79 |
105 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 80 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
106 | 81 |
107 private: | 82 private: |
108 GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& p
arams, | 83 GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& p
arams, |
109 GrTexture* gamma, const GrTextureParams& gam
maParams, | |
110 SkColor textColor, | |
111 bool uniformScale, bool useBGR); | 84 bool uniformScale, bool useBGR); |
112 | 85 |
113 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; | 86 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
114 | 87 |
115 GrTextureAccess fTextureAccess; | 88 GrTextureAccess fTextureAccess; |
116 GrTextureAccess fGammaTextureAccess; | |
117 GrColor fTextColor; | |
118 bool fUniformScale; | 89 bool fUniformScale; |
119 bool fUseBGR; | 90 bool fUseBGR; |
120 | 91 |
121 GR_DECLARE_EFFECT_TEST; | 92 GR_DECLARE_EFFECT_TEST; |
122 | 93 |
123 typedef GrVertexEffect INHERITED; | 94 typedef GrVertexEffect INHERITED; |
124 }; | 95 }; |
125 | 96 |
| 97 |
126 #endif | 98 #endif |
OLD | NEW |