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 "GrGeometryProcessor.h" |
13 | 13 |
14 class GrGLDistanceFieldTextureEffect; | 14 class GrGLDistanceFieldTextureEffect; |
15 class GrGLDistanceFieldLCDTextureEffect; | 15 class GrGLDistanceFieldLCDTextureEffect; |
16 | 16 |
17 enum GrDistanceFieldEffectFlags { | 17 enum GrDistanceFieldEffectFlags { |
18 kSimilarity_DistanceFieldEffectFlag = 0x01, // ctm is similarity matrix | 18 kSimilarity_DistanceFieldEffectFlag = 0x01, // ctm is similarity matrix |
19 kRectToRect_DistanceFieldEffectFlag = 0x02, // ctm maps rects to rects | 19 kRectToRect_DistanceFieldEffectFlag = 0x02, // ctm maps rects to rects |
20 kUseLCD_DistanceFieldEffectFlag = 0x04, // use lcd text | 20 kUseLCD_DistanceFieldEffectFlag = 0x04, // use lcd text |
21 kBGR_DistanceFieldEffectFlag = 0x08, // lcd display has bgr order | 21 kBGR_DistanceFieldEffectFlag = 0x08, // lcd display has bgr order |
22 kPortrait_DistanceFieldEffectFlag = 0x10, // lcd display is in portrait
mode (not used yet) | 22 kPortrait_DistanceFieldEffectFlag = 0x10, // lcd display is in portrait
mode (not used yet) |
23 | 23 |
24 kUniformScale_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag
| | 24 kUniformScale_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag
| |
25 kRectToRect_DistanceFieldEffectFlag, | 25 kRectToRect_DistanceFieldEffectFlag, |
26 // The subset of the flags relevant to GrDistanceFieldTextureEffect | 26 // The subset of the flags relevant to GrDistanceFieldTextureEffect |
27 kNonLCD_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag, | 27 kNonLCD_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag, |
28 // The subset of the flags relevant to GrDistanceFieldLCDTextureEffect | 28 // The subset of the flags relevant to GrDistanceFieldLCDTextureEffect |
29 kLCD_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag
| | 29 kLCD_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag
| |
30 kRectToRect_DistanceFieldEffectFlag
| | 30 kRectToRect_DistanceFieldEffectFlag
| |
31 kUseLCD_DistanceFieldEffectFlag | | 31 kUseLCD_DistanceFieldEffectFlag | |
32 kBGR_DistanceFieldEffectFlag, | 32 kBGR_DistanceFieldEffectFlag, |
33 }; | 33 }; |
34 | 34 |
35 /** | 35 /** |
36 * The output color of this effect is a modulation of the input color and a samp
le from a | 36 * The output color of this effect is a modulation of the input color and a samp
le from a |
37 * distance field texture (using a smoothed step function near 0.5). | 37 * distance field texture (using a smoothed step function near 0.5). |
38 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input | 38 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
39 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 39 * coords are a custom attribute. Gamma correction is handled via a texture LUT. |
40 */ | 40 */ |
41 class GrDistanceFieldTextureEffect : public GrVertexEffect { | 41 class GrDistanceFieldTextureEffect : public GrGeometryProcessor { |
42 public: | 42 public: |
43 #ifdef SK_GAMMA_APPLY_TO_A8 | 43 #ifdef SK_GAMMA_APPLY_TO_A8 |
44 static GrEffect* Create(GrTexture* tex, const GrTextureParams& params, | 44 static GrEffect* Create(GrTexture* tex, const GrTextureParams& params, |
45 GrTexture* gamma, const GrTextureParams& gammaParams
, float lum, | 45 GrTexture* gamma, const GrTextureParams& gammaParams
, float lum, |
46 uint32_t flags) { | 46 uint32_t flags) { |
47 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, gamma, gamm
aParams, lum, | 47 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, gamma, gamm
aParams, lum, |
48 flags)); | 48 flags)); |
49 } | 49 } |
50 #else | 50 #else |
51 static GrEffect* Create(GrTexture* tex, const GrTextureParams& params, | 51 static GrEffect* Create(GrTexture* tex, const GrTextureParams& params, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 typedef GrEffect INHERITED; | 89 typedef GrEffect INHERITED; |
90 }; | 90 }; |
91 | 91 |
92 /** | 92 /** |
93 * The output color of this effect is a modulation of the input color and sample
s from a | 93 * The output color of this effect is a modulation of the input color and sample
s from a |
94 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. | 94 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. |
95 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input | 95 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
96 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 96 * coords are a custom attribute. Gamma correction is handled via a texture LUT. |
97 */ | 97 */ |
98 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { | 98 class GrDistanceFieldLCDTextureEffect : public GrGeometryProcessor { |
99 public: | 99 public: |
100 static GrEffect* Create(GrTexture* tex, const GrTextureParams& params, | 100 static GrEffect* Create(GrTexture* tex, const GrTextureParams& params, |
101 GrTexture* gamma, const GrTextureParams& gammaParams
, | 101 GrTexture* gamma, const GrTextureParams& gammaParams
, |
102 SkColor textColor, uint32_t flags) { | 102 SkColor textColor, uint32_t flags) { |
103 return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, | 103 return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, |
104 (tex, params, gamma, gammaParams, textColor, flags)); | 104 (tex, params, gamma, gammaParams, textColor, flags)); |
105 } | 105 } |
106 | 106 |
107 virtual ~GrDistanceFieldLCDTextureEffect() {} | 107 virtual ~GrDistanceFieldLCDTextureEffect() {} |
108 | 108 |
(...skipping 19 matching lines...) Expand all Loading... |
128 GrTextureAccess fGammaTextureAccess; | 128 GrTextureAccess fGammaTextureAccess; |
129 GrColor fTextColor; | 129 GrColor fTextColor; |
130 uint32_t fFlags; | 130 uint32_t fFlags; |
131 | 131 |
132 GR_DECLARE_EFFECT_TEST; | 132 GR_DECLARE_EFFECT_TEST; |
133 | 133 |
134 typedef GrEffect INHERITED; | 134 typedef GrEffect INHERITED; |
135 }; | 135 }; |
136 | 136 |
137 #endif | 137 #endif |
OLD | NEW |