Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: src/gpu/effects/GrDistanceFieldTextureEffect.h

Issue 258883002: Gamma correction for distance field text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comments for the magic bold factor Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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. 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 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, bo ol similarity) { 25 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params,
26 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, pa rams, similarity))); 26 GrTexture* gamma, const GrTextureParams& gammaPar ams,
27 float lum, bool similarity) {
28 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect,
29 (tex, params, gamma, gammaParams, lum, similarity)));
27 return CreateEffectRef(effect); 30 return CreateEffectRef(effect);
28 } 31 }
29 32
30 virtual ~GrDistanceFieldTextureEffect() {} 33 virtual ~GrDistanceFieldTextureEffect() {}
31 34
32 static const char* Name() { return "DistanceFieldTexture"; } 35 static const char* Name() { return "DistanceFieldTexture"; }
33 36
34 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 37 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
38 float getLuminance() const { return fLuminance; }
35 bool isSimilarity() const { return fIsSimilarity; } 39 bool isSimilarity() const { return fIsSimilarity; }
36 40
37 typedef GrGLDistanceFieldTextureEffect GLEffect; 41 typedef GrGLDistanceFieldTextureEffect GLEffect;
38 42
39 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 43 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
40 44
41 private: 45 private:
42 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& para ms, 46 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& para ms,
43 bool uniformScale); 47 GrTexture* gamma, const GrTextureParams& gammaP arams,
48 float lum, bool uniformScale);
44 49
45 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; 50 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
46 51
47 GrTextureAccess fTextureAccess; 52 GrTextureAccess fTextureAccess;
53 GrTextureAccess fGammaTextureAccess;
54 float fLuminance;
48 bool fIsSimilarity; 55 bool fIsSimilarity;
49 56
50 GR_DECLARE_EFFECT_TEST; 57 GR_DECLARE_EFFECT_TEST;
51 58
52 typedef GrVertexEffect INHERITED; 59 typedef GrVertexEffect INHERITED;
53 }; 60 };
54 61
55 /** 62 /**
56 * The output color of this effect is a modulation of the input color and sample s from a 63 * 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. 64 * 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 65 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). The input
59 * coords are a custom attribute. 66 * coords are a custom attribute. Gamma correction is handled via a texture LUT.
60 */ 67 */
61 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { 68 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect {
62 public: 69 public:
63 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, 70 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params,
71 GrTexture* gamma, const GrTextureParams& gammaPar ams,
72 SkColor textColor,
64 bool uniformScale, bool useBGR) { 73 bool uniformScale, bool useBGR) {
65 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, 74 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect,
66 (tex, params, uniformScale, useBGR))); 75 (tex, params, gamma, gammaParams, text Color, uniformScale,
76 useBGR)));
67 return CreateEffectRef(effect); 77 return CreateEffectRef(effect);
68 } 78 }
69 79
70 virtual ~GrDistanceFieldLCDTextureEffect() {} 80 virtual ~GrDistanceFieldLCDTextureEffect() {}
71 81
72 static const char* Name() { return "DistanceFieldLCDTexture"; } 82 static const char* Name() { return "DistanceFieldLCDTexture"; }
73 83
74 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 84 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
85 GrColor getTextColor() const { return fTextColor; }
75 bool isUniformScale() const { return fUniformScale; } 86 bool isUniformScale() const { return fUniformScale; }
76 bool useBGR() const { return fUseBGR; } 87 bool useBGR() const { return fUseBGR; }
77 88
78 typedef GrGLDistanceFieldLCDTextureEffect GLEffect; 89 typedef GrGLDistanceFieldLCDTextureEffect GLEffect;
79 90
80 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 91 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
81 92
82 private: 93 private:
83 GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& p arams, 94 GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& p arams,
95 GrTexture* gamma, const GrTextureParams& gam maParams,
96 SkColor textColor,
84 bool uniformScale, bool useBGR); 97 bool uniformScale, bool useBGR);
85 98
86 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; 99 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
87 100
88 GrTextureAccess fTextureAccess; 101 GrTextureAccess fTextureAccess;
102 GrTextureAccess fGammaTextureAccess;
103 GrColor fTextColor;
89 bool fUniformScale; 104 bool fUniformScale;
90 bool fUseBGR; 105 bool fUseBGR;
91 106
92 GR_DECLARE_EFFECT_TEST; 107 GR_DECLARE_EFFECT_TEST;
93 108
94 typedef GrVertexEffect INHERITED; 109 typedef GrVertexEffect INHERITED;
95 }; 110 };
96 111
97
98 #endif 112 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698