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. Gamma correction is handled via a texture LUT. |
22 */ | 22 */ |
23 class GrDistanceFieldTextureEffect : public GrVertexEffect { | 23 class GrDistanceFieldTextureEffect : public GrVertexEffect { |
24 public: | 24 public: |
25 #ifdef SK_GAMMA_APPLY_TO_A8 | 25 #ifdef SK_GAMMA_APPLY_TO_A8 |
26 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, | 26 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, |
27 GrTexture* gamma, const GrTextureParams& gammaPar
ams, float lum, | 27 GrTexture* gamma, const GrTextureParams& gammaPar
ams, float lum, |
28 bool similarity) { | 28 bool similarity) { |
29 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, pa
rams, | 29 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, gamma, gamm
aParams, lum, |
30 gamma,
gammaParams, lum, | 30 similarity)); |
31 similar
ity))); | 31 } |
32 #else | 32 #else |
33 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, | 33 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, |
34 bool similarity) { | 34 bool similarity) { |
35 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, pa
rams, | 35 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, similarit
y)); |
36 similar
ity))); | 36 } |
37 #endif | 37 #endif |
38 return CreateEffectRef(effect); | |
39 } | |
40 | 38 |
41 virtual ~GrDistanceFieldTextureEffect() {} | 39 virtual ~GrDistanceFieldTextureEffect() {} |
42 | 40 |
43 static const char* Name() { return "DistanceFieldTexture"; } | 41 static const char* Name() { return "DistanceFieldTexture"; } |
44 | 42 |
45 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 43 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
46 #ifdef SK_GAMMA_APPLY_TO_A8 | 44 #ifdef SK_GAMMA_APPLY_TO_A8 |
47 float getLuminance() const { return fLuminance; } | 45 float getLuminance() const { return fLuminance; } |
48 #endif | 46 #endif |
49 bool isSimilarity() const { return fIsSimilarity; } | 47 bool isSimilarity() const { return fIsSimilarity; } |
(...skipping 28 matching lines...) Expand all Loading... |
78 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. | 76 * 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 | 77 * 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. | 78 * coords are a custom attribute. Gamma correction is handled via a texture LUT. |
81 */ | 79 */ |
82 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { | 80 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { |
83 public: | 81 public: |
84 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, | 82 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, |
85 GrTexture* gamma, const GrTextureParams& gammaPar
ams, | 83 GrTexture* gamma, const GrTextureParams& gammaPar
ams, |
86 SkColor textColor, | 84 SkColor textColor, |
87 bool uniformScale, bool useBGR) { | 85 bool uniformScale, bool useBGR) { |
88 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, | 86 return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, |
89 (tex, params, gamma, gammaParams, text
Color, uniformScale, | 87 (tex, params, gamma, gammaParams, textColor, uniformSc
ale, useBGR)); |
90 useBGR))); | |
91 return CreateEffectRef(effect); | |
92 } | 88 } |
93 | 89 |
94 virtual ~GrDistanceFieldLCDTextureEffect() {} | 90 virtual ~GrDistanceFieldLCDTextureEffect() {} |
95 | 91 |
96 static const char* Name() { return "DistanceFieldLCDTexture"; } | 92 static const char* Name() { return "DistanceFieldLCDTexture"; } |
97 | 93 |
98 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 94 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
99 GrColor getTextColor() const { return fTextColor; } | 95 GrColor getTextColor() const { return fTextColor; } |
100 bool isUniformScale() const { return fUniformScale; } | 96 bool isUniformScale() const { return fUniformScale; } |
101 bool useBGR() const { return fUseBGR; } | 97 bool useBGR() const { return fUseBGR; } |
(...skipping 15 matching lines...) Expand all Loading... |
117 GrColor fTextColor; | 113 GrColor fTextColor; |
118 bool fUniformScale; | 114 bool fUniformScale; |
119 bool fUseBGR; | 115 bool fUseBGR; |
120 | 116 |
121 GR_DECLARE_EFFECT_TEST; | 117 GR_DECLARE_EFFECT_TEST; |
122 | 118 |
123 typedef GrVertexEffect INHERITED; | 119 typedef GrVertexEffect INHERITED; |
124 }; | 120 }; |
125 | 121 |
126 #endif | 122 #endif |
OLD | NEW |