| 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 GrEffect* Create(GrTexture* tex, const GrTextureParams& params, |
| 27 GrTexture* gamma, const GrTextureParams& gammaPar
ams, float lum, | 27 GrTexture* gamma, const GrTextureParams& gammaParams
, float lum, |
| 28 bool similarity) { | 28 bool similarity) { |
| 29 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, gamma, gamm
aParams, lum, | 29 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, gamma, gamm
aParams, lum, |
| 30 similarity)); | 30 similarity)); |
| 31 } | 31 } |
| 32 #else | 32 #else |
| 33 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, | 33 static GrEffect* Create(GrTexture* tex, const GrTextureParams& params, |
| 34 bool similarity) { | 34 bool similarity) { |
| 35 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, similarit
y)); | 35 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, similarit
y)); |
| 36 } | 36 } |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 virtual ~GrDistanceFieldTextureEffect() {} | 39 virtual ~GrDistanceFieldTextureEffect() {} |
| 40 | 40 |
| 41 static const char* Name() { return "DistanceFieldTexture"; } | 41 static const char* Name() { return "DistanceFieldTexture"; } |
| 42 | 42 |
| 43 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 43 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
| 44 #ifdef SK_GAMMA_APPLY_TO_A8 | 44 #ifdef SK_GAMMA_APPLY_TO_A8 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * The output color of this effect is a modulation of the input color and sample
s from a | 75 * The output color of this effect is a modulation of the input color and sample
s from a |
| 76 * 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. |
| 77 * 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 |
| 78 * 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. |
| 79 */ | 79 */ |
| 80 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { | 80 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { |
| 81 public: | 81 public: |
| 82 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, | 82 static GrEffect* Create(GrTexture* tex, const GrTextureParams& params, |
| 83 GrTexture* gamma, const GrTextureParams& gammaPar
ams, | 83 GrTexture* gamma, const GrTextureParams& gammaParams
, |
| 84 SkColor textColor, | 84 SkColor textColor, bool uniformScale, bool useBGR) { |
| 85 bool uniformScale, bool useBGR) { | |
| 86 return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, | 85 return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, |
| 87 (tex, params, gamma, gammaParams, textColor, uniformSc
ale, useBGR)); | 86 (tex, params, gamma, gammaParams, textColor, uniformSc
ale, useBGR)); |
| 88 } | 87 } |
| 89 | 88 |
| 90 virtual ~GrDistanceFieldLCDTextureEffect() {} | 89 virtual ~GrDistanceFieldLCDTextureEffect() {} |
| 91 | 90 |
| 92 static const char* Name() { return "DistanceFieldLCDTexture"; } | 91 static const char* Name() { return "DistanceFieldLCDTexture"; } |
| 93 | 92 |
| 94 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 93 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
| 95 GrColor getTextColor() const { return fTextColor; } | 94 GrColor getTextColor() const { return fTextColor; } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 113 GrColor fTextColor; | 112 GrColor fTextColor; |
| 114 bool fUniformScale; | 113 bool fUniformScale; |
| 115 bool fUseBGR; | 114 bool fUseBGR; |
| 116 | 115 |
| 117 GR_DECLARE_EFFECT_TEST; | 116 GR_DECLARE_EFFECT_TEST; |
| 118 | 117 |
| 119 typedef GrVertexEffect INHERITED; | 118 typedef GrVertexEffect INHERITED; |
| 120 }; | 119 }; |
| 121 | 120 |
| 122 #endif | 121 #endif |
| OLD | NEW |