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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 * The output color of this effect is a modulation of the input color and a samp le from a | 42 * The output color of this effect is a modulation of the input color and a samp le from a |
43 * distance field texture (using a smoothed step function near 0.5). | 43 * distance field texture (using a smoothed step function near 0.5). |
44 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). The input | 44 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). The input |
45 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 45 * coords are a custom attribute. Gamma correction is handled via a texture LUT. |
46 */ | 46 */ |
47 class GrDistanceFieldTextureEffect : public GrGeometryProcessor { | 47 class GrDistanceFieldTextureEffect : public GrGeometryProcessor { |
48 public: | 48 public: |
49 #ifdef SK_GAMMA_APPLY_TO_A8 | 49 #ifdef SK_GAMMA_APPLY_TO_A8 |
50 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix , GrTexture* tex, | 50 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix , GrTexture* tex, |
51 const GrTextureParams& params, | 51 const GrTextureParams& params, |
52 GrTexture* gamma, const GrTextureParams& gammaParams, | |
53 float lum, uint32_t flags, bool opaqueVer texColors) { | 52 float lum, uint32_t flags, bool opaqueVer texColors) { |
54 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (color, viewMatrix, tex, params, gamma, | 53 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (color, viewMatrix, tex, params, lum, |
55 gammaParams, lum, | |
56 flags, opaqueVertexColor s)); | 54 flags, opaqueVertexColor s)); |
57 } | 55 } |
58 #else | 56 #else |
59 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix , GrTexture* tex, | 57 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix , GrTexture* tex, |
60 const GrTextureParams& params, | 58 const GrTextureParams& params, |
61 uint32_t flags, bool opaqueVertexColors) { | 59 uint32_t flags, bool opaqueVertexColors) { |
62 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (color, viewMatrix, tex , params, flags, | 60 return SkNEW_ARGS(GrDistanceFieldTextureEffect, (color, viewMatrix, tex , params, flags, |
63 opaqueVertexColors)); | 61 opaqueVertexColors)); |
64 } | 62 } |
65 #endif | 63 #endif |
66 | 64 |
67 virtual ~GrDistanceFieldTextureEffect() {} | 65 virtual ~GrDistanceFieldTextureEffect() {} |
68 | 66 |
69 const char* name() const override { return "DistanceFieldTexture"; } | 67 const char* name() const override { return "DistanceFieldTexture"; } |
70 | 68 |
71 const Attribute* inPosition() const { return fInPosition; } | 69 const Attribute* inPosition() const { return fInPosition; } |
72 const Attribute* inColor() const { return fInColor; } | 70 const Attribute* inColor() const { return fInColor; } |
73 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 71 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
74 #ifdef SK_GAMMA_APPLY_TO_A8 | 72 #ifdef SK_GAMMA_APPLY_TO_A8 |
75 float getLuminance() const { return fLuminance; } | 73 float getWidthAdjust() const { return fWidthAdjust; } |
76 #endif | 74 #endif |
77 uint32_t getFlags() const { return fFlags; } | 75 uint32_t getFlags() const { return fFlags; } |
78 | 76 |
79 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 77 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
80 const GrGLCaps& caps, | 78 const GrGLCaps& caps, |
81 GrProcessorKeyBuilder* b) const override; | 79 GrProcessorKeyBuilder* b) const override; |
82 | 80 |
83 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 81 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
84 const GrGLCaps&) const over ride; | 82 const GrGLCaps&) const over ride; |
85 | 83 |
86 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; | 84 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; |
87 | 85 |
88 bool onCanMakeEqual(const GrBatchTracker&, | 86 bool onCanMakeEqual(const GrBatchTracker&, |
89 const GrGeometryProcessor&, | 87 const GrGeometryProcessor&, |
90 const GrBatchTracker&) const override; | 88 const GrBatchTracker&) const override; |
91 | 89 |
92 private: | 90 private: |
93 GrDistanceFieldTextureEffect(GrColor, const SkMatrix& viewMatrix, GrTexture* texture, | 91 GrDistanceFieldTextureEffect(GrColor, const SkMatrix& viewMatrix, GrTexture* texture, |
94 const GrTextureParams& params, | 92 const GrTextureParams& params, |
95 #ifdef SK_GAMMA_APPLY_TO_A8 | 93 #ifdef SK_GAMMA_APPLY_TO_A8 |
96 GrTexture* gamma, const GrTextureParams& gammaP arams, float lum, | 94 float widthAdjust, |
97 #endif | 95 #endif |
98 uint32_t flags, bool opaqueVertexColors); | 96 uint32_t flags, bool opaqueVertexColors); |
99 | 97 |
100 bool onIsEqual(const GrGeometryProcessor& other) const override; | 98 bool onIsEqual(const GrGeometryProcessor& other) const override; |
101 | 99 |
102 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override; | 100 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override; |
103 | 101 |
104 GrTextureAccess fTextureAccess; | 102 GrTextureAccess fTextureAccess; |
105 #ifdef SK_GAMMA_APPLY_TO_A8 | 103 #ifdef SK_GAMMA_APPLY_TO_A8 |
106 GrTextureAccess fGammaTextureAccess; | 104 float fWidthAdjust; |
107 float fLuminance; | |
108 #endif | 105 #endif |
109 uint32_t fFlags; | 106 uint32_t fFlags; |
110 const Attribute* fInPosition; | 107 const Attribute* fInPosition; |
111 const Attribute* fInColor; | 108 const Attribute* fInColor; |
112 const Attribute* fInTextureCoords; | 109 const Attribute* fInTextureCoords; |
113 | 110 |
114 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 111 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
115 | 112 |
116 typedef GrGeometryProcessor INHERITED; | 113 typedef GrGeometryProcessor INHERITED; |
117 }; | 114 }; |
118 | 115 |
119 | 116 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 }; | 172 }; |
176 | 173 |
177 /** | 174 /** |
178 * The output color of this effect is a modulation of the input color and sample s from a | 175 * The output color of this effect is a modulation of the input color and sample s from a |
179 * distance field texture (using a smoothed step function near 0.5), adjusted fo r LCD displays. | 176 * distance field texture (using a smoothed step function near 0.5), adjusted fo r LCD displays. |
180 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). The input | 177 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). The input |
181 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 178 * coords are a custom attribute. Gamma correction is handled via a texture LUT. |
182 */ | 179 */ |
183 class GrDistanceFieldLCDTextureEffect : public GrGeometryProcessor { | 180 class GrDistanceFieldLCDTextureEffect : public GrGeometryProcessor { |
184 public: | 181 public: |
182 struct WidthAdjust { | |
183 SkScalar fR, fG, fB; | |
184 static WidthAdjust Make(SkScalar r, SkScalar g, SkScalar b) { | |
185 WidthAdjust result; | |
186 result.fR = r; result.fG = g; result.fB = b; | |
187 return result; | |
188 } | |
189 bool operator==(const WidthAdjust& wa) const { | |
190 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); | |
191 } | |
192 bool operator!=(const WidthAdjust& wa) const { | |
egdaniel
2015/04/01 15:55:13
cleaner to do not of equals? or vice versa
jvanverth1
2015/04/01 16:21:01
Done.
| |
193 return (fR != wa.fR || fG != wa.fG || fB != wa.fB); | |
194 } | |
195 }; | |
196 | |
185 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix , GrTexture* tex, | 197 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix , GrTexture* tex, |
186 const GrTextureParams& params, GrTexture* gamma, | 198 const GrTextureParams& params, |
187 const GrTextureParams& gammaParams, | 199 WidthAdjust widthAdjust, uint32_t flags) { |
188 SkColor textColor, uint32_t flags) { | |
189 return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, | 200 return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, |
190 (color, viewMatrix, tex, params, gamma, gammaParams, t extColor, flags)); | 201 (color, viewMatrix, tex, params, widthAdjust, flags)); |
191 } | 202 } |
192 | 203 |
193 virtual ~GrDistanceFieldLCDTextureEffect() {} | 204 virtual ~GrDistanceFieldLCDTextureEffect() {} |
194 | 205 |
195 const char* name() const override { return "DistanceFieldLCDTexture"; } | 206 const char* name() const override { return "DistanceFieldLCDTexture"; } |
196 | 207 |
197 const Attribute* inPosition() const { return fInPosition; } | 208 const Attribute* inPosition() const { return fInPosition; } |
198 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 209 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
199 GrColor getTextColor() const { return fTextColor; } | 210 WidthAdjust getWidthAdjust() const { return fWidthAdjust; } |
200 uint32_t getFlags() const { return fFlags; } | 211 uint32_t getFlags() const { return fFlags; } |
201 | 212 |
202 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 213 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
203 const GrGLCaps& caps, | 214 const GrGLCaps& caps, |
204 GrProcessorKeyBuilder* b) const override; | 215 GrProcessorKeyBuilder* b) const override; |
205 | 216 |
206 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 217 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
207 const GrGLCaps&) const over ride; | 218 const GrGLCaps&) const over ride; |
208 | 219 |
209 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; | 220 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; |
210 | 221 |
211 bool onCanMakeEqual(const GrBatchTracker&, | 222 bool onCanMakeEqual(const GrBatchTracker&, |
212 const GrGeometryProcessor&, | 223 const GrGeometryProcessor&, |
213 const GrBatchTracker&) const override; | 224 const GrBatchTracker&) const override; |
214 | 225 |
215 private: | 226 private: |
216 GrDistanceFieldLCDTextureEffect(GrColor, const SkMatrix& viewMatrix, GrTextu re* texture, | 227 GrDistanceFieldLCDTextureEffect(GrColor, const SkMatrix& viewMatrix, GrTextu re* texture, |
217 const GrTextureParams& params, | 228 const GrTextureParams& params, |
218 GrTexture* gamma, const GrTextureParams& gam maParams, | 229 WidthAdjust wa, uint32_t flags); |
219 SkColor textColor, uint32_t flags); | |
220 | 230 |
221 bool onIsEqual(const GrGeometryProcessor& other) const override; | 231 bool onIsEqual(const GrGeometryProcessor& other) const override; |
222 | 232 |
223 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override; | 233 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override; |
224 | 234 |
225 GrTextureAccess fTextureAccess; | 235 GrTextureAccess fTextureAccess; |
226 GrTextureAccess fGammaTextureAccess; | 236 WidthAdjust fWidthAdjust; |
227 GrColor fTextColor; | 237 uint32_t fFlags; |
228 uint32_t fFlags; | |
229 const Attribute* fInPosition; | 238 const Attribute* fInPosition; |
230 const Attribute* fInTextureCoords; | 239 const Attribute* fInTextureCoords; |
231 | 240 |
232 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 241 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
233 | 242 |
234 typedef GrGeometryProcessor INHERITED; | 243 typedef GrGeometryProcessor INHERITED; |
235 }; | 244 }; |
236 | 245 |
237 #endif | 246 #endif |
OLD | NEW |