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 | 16 |
16 /** | 17 /** |
17 * 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 |
18 * distance field texture (using a smoothed step function near 0.5). | 19 * distance field texture (using a smoothed step function near 0.5). |
19 * 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 |
20 * coords are a custom attribute. | 21 * coords are a custom attribute. |
21 */ | 22 */ |
22 class GrDistanceFieldTextureEffect : public GrVertexEffect { | 23 class GrDistanceFieldTextureEffect : public GrVertexEffect { |
23 public: | 24 public: |
24 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& para, bool
uniformScale) { | 25 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, bo
ol similarity) { |
25 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, pa
ra, uniformScale))); | 26 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, pa
rams, similarity))); |
26 return CreateEffectRef(effect); | 27 return CreateEffectRef(effect); |
27 } | 28 } |
28 | 29 |
29 virtual ~GrDistanceFieldTextureEffect() {} | 30 virtual ~GrDistanceFieldTextureEffect() {} |
30 | 31 |
31 static const char* Name() { return "DistanceFieldTexture"; } | 32 static const char* Name() { return "DistanceFieldTexture"; } |
32 | 33 |
33 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 34 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
34 bool isUniformScale() const { return fUniformScale; } | 35 bool isSimilarity() const { return fIsSimilarity; } |
35 | 36 |
36 typedef GrGLDistanceFieldTextureEffect GLEffect; | 37 typedef GrGLDistanceFieldTextureEffect GLEffect; |
37 | 38 |
38 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 39 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
39 | 40 |
40 private: | 41 private: |
41 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& para
ms, | 42 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& para
ms, |
42 bool uniformScale); | 43 bool uniformScale); |
43 | 44 |
44 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; | 45 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
45 | 46 |
46 GrTextureAccess fTextureAccess; | 47 GrTextureAccess fTextureAccess; |
47 bool fUniformScale; | 48 bool fIsSimilarity; |
48 | 49 |
49 GR_DECLARE_EFFECT_TEST; | 50 GR_DECLARE_EFFECT_TEST; |
50 | 51 |
51 typedef GrVertexEffect INHERITED; | 52 typedef GrVertexEffect INHERITED; |
52 }; | 53 }; |
53 | 54 |
| 55 /** |
| 56 * The output color of this effect is a modulation of the input color and sample
s from a |
| 57 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. |
| 58 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
| 59 * coords are a custom attribute. |
| 60 */ |
| 61 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { |
| 62 public: |
| 63 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, |
| 64 bool uniformScale, bool useBGR) { |
| 65 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, |
| 66 (tex, params, uniformScale, useBGR))); |
| 67 return CreateEffectRef(effect); |
| 68 } |
| 69 |
| 70 virtual ~GrDistanceFieldLCDTextureEffect() {} |
| 71 |
| 72 static const char* Name() { return "DistanceFieldLCDTexture"; } |
| 73 |
| 74 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
| 75 bool isUniformScale() const { return fUniformScale; } |
| 76 bool useBGR() const { return fUseBGR; } |
| 77 |
| 78 typedef GrGLDistanceFieldLCDTextureEffect GLEffect; |
| 79 |
| 80 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
| 81 |
| 82 private: |
| 83 GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& p
arams, |
| 84 bool uniformScale, bool useBGR); |
| 85 |
| 86 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
| 87 |
| 88 GrTextureAccess fTextureAccess; |
| 89 bool fUniformScale; |
| 90 bool fUseBGR; |
| 91 |
| 92 GR_DECLARE_EFFECT_TEST; |
| 93 |
| 94 typedef GrVertexEffect INHERITED; |
| 95 }; |
| 96 |
| 97 |
54 #endif | 98 #endif |
OLD | NEW |