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

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: Don't use SkPaint distance field flag for filtering the ScalarContext::Rec; add getGammaLUT* commen… 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 #ifdef SK_GAMMA_APPLY_TO_A8
27 GrTexture* gamma, const GrTextureParams& gammaPar ams, float lum,
28 #endif
29 bool similarity) {
30 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect,
31 (tex, params,
32 #ifdef SK_GAMMA_APPLY_TO_A8
33 gamma, gammaParams, lum,
34 #endif
35 similarity)));
27 return CreateEffectRef(effect); 36 return CreateEffectRef(effect);
28 } 37 }
29 38
30 virtual ~GrDistanceFieldTextureEffect() {} 39 virtual ~GrDistanceFieldTextureEffect() {}
31 40
32 static const char* Name() { return "DistanceFieldTexture"; } 41 static const char* Name() { return "DistanceFieldTexture"; }
33 42
34 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
45 float getLuminance() const { return fLuminance; }
46 #endif
35 bool isSimilarity() const { return fIsSimilarity; } 47 bool isSimilarity() const { return fIsSimilarity; }
36 48
37 typedef GrGLDistanceFieldTextureEffect GLEffect; 49 typedef GrGLDistanceFieldTextureEffect GLEffect;
38 50
39 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 51 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
40 52
41 private: 53 private:
42 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& para ms, 54 GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& para ms,
55 #ifdef SK_GAMMA_APPLY_TO_A8
56 GrTexture* gamma, const GrTextureParams& gammaP arams, float lum,
57 #endif
43 bool uniformScale); 58 bool uniformScale);
44 59
45 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; 60 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
46 61
47 GrTextureAccess fTextureAccess; 62 GrTextureAccess fTextureAccess;
63 #ifdef SK_GAMMA_APPLY_TO_A8
64 GrTextureAccess fGammaTextureAccess;
65 float fLuminance;
66 #endif
48 bool fIsSimilarity; 67 bool fIsSimilarity;
49 68
50 GR_DECLARE_EFFECT_TEST; 69 GR_DECLARE_EFFECT_TEST;
51 70
52 typedef GrVertexEffect INHERITED; 71 typedef GrVertexEffect INHERITED;
53 }; 72 };
54 73
55 /** 74 /**
56 * 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
57 * 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.
58 * 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
59 * coords are a custom attribute. 78 * coords are a custom attribute. Gamma correction is handled via a texture LUT.
60 */ 79 */
61 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect { 80 class GrDistanceFieldLCDTextureEffect : public GrVertexEffect {
62 public: 81 public:
63 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, 82 static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params,
83 GrTexture* gamma, const GrTextureParams& gammaPar ams,
84 SkColor textColor,
64 bool uniformScale, bool useBGR) { 85 bool uniformScale, bool useBGR) {
65 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, 86 AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect,
66 (tex, params, uniformScale, useBGR))); 87 (tex, params, gamma, gammaParams, text Color, uniformScale,
88 useBGR)));
67 return CreateEffectRef(effect); 89 return CreateEffectRef(effect);
68 } 90 }
69 91
70 virtual ~GrDistanceFieldLCDTextureEffect() {} 92 virtual ~GrDistanceFieldLCDTextureEffect() {}
71 93
72 static const char* Name() { return "DistanceFieldLCDTexture"; } 94 static const char* Name() { return "DistanceFieldLCDTexture"; }
73 95
74 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 96 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
97 GrColor getTextColor() const { return fTextColor; }
75 bool isUniformScale() const { return fUniformScale; } 98 bool isUniformScale() const { return fUniformScale; }
76 bool useBGR() const { return fUseBGR; } 99 bool useBGR() const { return fUseBGR; }
77 100
78 typedef GrGLDistanceFieldLCDTextureEffect GLEffect; 101 typedef GrGLDistanceFieldLCDTextureEffect GLEffect;
79 102
80 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 103 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
81 104
82 private: 105 private:
83 GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& p arams, 106 GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& p arams,
107 GrTexture* gamma, const GrTextureParams& gam maParams,
108 SkColor textColor,
84 bool uniformScale, bool useBGR); 109 bool uniformScale, bool useBGR);
85 110
86 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; 111 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
87 112
88 GrTextureAccess fTextureAccess; 113 GrTextureAccess fTextureAccess;
114 GrTextureAccess fGammaTextureAccess;
115 GrColor fTextColor;
89 bool fUniformScale; 116 bool fUniformScale;
90 bool fUseBGR; 117 bool fUseBGR;
91 118
92 GR_DECLARE_EFFECT_TEST; 119 GR_DECLARE_EFFECT_TEST;
93 120
94 typedef GrVertexEffect INHERITED; 121 typedef GrVertexEffect INHERITED;
95 }; 122 };
96 123
97
98 #endif 124 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698