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 "GrProcessor.h" | 11 #include "GrProcessor.h" |
12 #include "GrGeometryProcessor.h" | 12 #include "GrGeometryProcessor.h" |
13 | 13 |
14 class GrGLDistanceFieldTextureEffect; | 14 class GrGLDistanceFieldTextureEffect; |
15 class GrGLDistanceFieldNoGammaTextureEffect; | |
15 class GrGLDistanceFieldLCDTextureEffect; | 16 class GrGLDistanceFieldLCDTextureEffect; |
16 | 17 |
17 enum GrDistanceFieldEffectFlags { | 18 enum GrDistanceFieldEffectFlags { |
18 kSimilarity_DistanceFieldEffectFlag = 0x01, // ctm is similarity matrix | 19 kSimilarity_DistanceFieldEffectFlag = 0x01, // ctm is similarity matrix |
19 kRectToRect_DistanceFieldEffectFlag = 0x02, // ctm maps rects to rects | 20 kRectToRect_DistanceFieldEffectFlag = 0x02, // ctm maps rects to rects |
20 kUseLCD_DistanceFieldEffectFlag = 0x04, // use lcd text | 21 kUseLCD_DistanceFieldEffectFlag = 0x04, // use lcd text |
21 kBGR_DistanceFieldEffectFlag = 0x08, // lcd display has bgr order | 22 kBGR_DistanceFieldEffectFlag = 0x08, // lcd display has bgr order |
22 kPortrait_DistanceFieldEffectFlag = 0x10, // lcd display is in portrait mode (not used yet) | 23 kPortrait_DistanceFieldEffectFlag = 0x10, // lcd display is in portrait mode (not used yet) |
23 | 24 |
24 kUniformScale_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag | | 25 kUniformScale_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag | |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 GrTextureAccess fTextureAccess; | 83 GrTextureAccess fTextureAccess; |
83 #ifdef SK_GAMMA_APPLY_TO_A8 | 84 #ifdef SK_GAMMA_APPLY_TO_A8 |
84 GrTextureAccess fGammaTextureAccess; | 85 GrTextureAccess fGammaTextureAccess; |
85 float fLuminance; | 86 float fLuminance; |
86 #endif | 87 #endif |
87 uint32_t fFlags; | 88 uint32_t fFlags; |
88 const GrShaderVar& fInTextureCoords; | 89 const GrShaderVar& fInTextureCoords; |
89 | 90 |
90 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 91 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
91 | 92 |
92 typedef GrFragmentProcessor INHERITED; | 93 typedef GrGeometryProcessor INHERITED; |
94 }; | |
95 | |
96 | |
97 /** | |
98 * The output color of this effect is a modulation of the input color and a sampl e from a | |
99 * distance field texture (using a smoothed step function near 0.5). | |
100 * It allows explicit specification of the filtering and wrap modes (GrTexturePar ams). The input | |
101 * coords are a custom attribute. No gamma correct blending is applied. | |
102 */ | |
103 class GrDistanceFieldNoGammaTextureEffect : public GrGeometryProcessor { | |
104 public: | |
105 static GrGeometryProcessor* Create(GrTexture* tex, const GrTextureParams& pa rams, | |
106 uint32_t flags) { | |
robertphillips
2014/10/03 19:23:40
extra ' ' here ?
| |
107 return SkNEW_ARGS(GrDistanceFieldNoGammaTextureEffect, (tex, params, fl ags)); | |
108 } | |
109 | |
110 virtual ~GrDistanceFieldNoGammaTextureEffect() {} | |
111 | |
112 static const char* Name() { return "DistanceFieldTexture"; } | |
113 | |
114 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; | |
115 | |
116 const GrShaderVar& inTextureCoords() const { return fInTextureCoords; } | |
117 uint32_t getFlags() const { return fFlags; } | |
118 | |
119 typedef GrGLDistanceFieldNoGammaTextureEffect GLProcessor; | |
120 | |
121 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR IDE; | |
122 | |
123 private: | |
124 GrDistanceFieldNoGammaTextureEffect(GrTexture* texture, const GrTextureParam s& params, | |
125 uint32_t flags); | |
126 | |
127 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE; | |
128 | |
129 GrTextureAccess fTextureAccess; | |
130 uint32_t fFlags; | |
131 const GrShaderVar& fInTextureCoords; | |
132 | |
133 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | |
134 | |
135 typedef GrGeometryProcessor INHERITED; | |
93 }; | 136 }; |
94 | 137 |
95 /** | 138 /** |
96 * The output color of this effect is a modulation of the input color and sample s from a | 139 * The output color of this effect is a modulation of the input color and sample s from a |
97 * distance field texture (using a smoothed step function near 0.5), adjusted fo r LCD displays. | 140 * distance field texture (using a smoothed step function near 0.5), adjusted fo r LCD displays. |
98 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). The input | 141 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). The input |
99 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 142 * coords are a custom attribute. Gamma correction is handled via a texture LUT. |
100 */ | 143 */ |
101 class GrDistanceFieldLCDTextureEffect : public GrGeometryProcessor { | 144 class GrDistanceFieldLCDTextureEffect : public GrGeometryProcessor { |
102 public: | 145 public: |
(...skipping 26 matching lines...) Expand all Loading... | |
129 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE; | 172 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE; |
130 | 173 |
131 GrTextureAccess fTextureAccess; | 174 GrTextureAccess fTextureAccess; |
132 GrTextureAccess fGammaTextureAccess; | 175 GrTextureAccess fGammaTextureAccess; |
133 GrColor fTextColor; | 176 GrColor fTextColor; |
134 uint32_t fFlags; | 177 uint32_t fFlags; |
135 const GrShaderVar& fInTextureCoords; | 178 const GrShaderVar& fInTextureCoords; |
136 | 179 |
137 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 180 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
138 | 181 |
139 typedef GrFragmentProcessor INHERITED; | 182 typedef GrGeometryProcessor INHERITED; |
140 }; | 183 }; |
141 | 184 |
142 #endif | 185 #endif |
OLD | NEW |