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 GrDistanceFieldGeoProc_DEFINED | 8 #ifndef GrDistanceFieldGeoProc_DEFINED |
9 #define GrDistanceFieldGeoProc_DEFINED | 9 #define GrDistanceFieldGeoProc_DEFINED |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 /** | 43 /** |
44 * The output color of this effect is a modulation of the input color and a samp
le from a | 44 * The output color of this effect is a modulation of the input color and a samp
le from a |
45 * distance field texture (using a smoothed step function near 0.5). | 45 * distance field texture (using a smoothed step function near 0.5). |
46 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input | 46 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
47 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 47 * coords are a custom attribute. Gamma correction is handled via a texture LUT. |
48 */ | 48 */ |
49 class GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor { | 49 class GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor { |
50 public: | 50 public: |
51 #ifdef SK_GAMMA_APPLY_TO_A8 | 51 #ifdef SK_GAMMA_APPLY_TO_A8 |
52 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 52 static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMa
trix, |
53 GrTexture* tex, const GrTextureParams& pa
rams, | 53 GrTexture* tex, const GrTextureParams
& params, |
54 float lum, uint32_t flags, bool usesLocal
Coords) { | 54 float lum, uint32_t flags, bool usesL
ocalCoords) { |
55 return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params,
lum, flags, | 55 return sk_sp<GrGeometryProcessor>( |
56 usesLocalCoords); | 56 new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, lum
, flags, |
| 57 usesLocalCoords)); |
57 } | 58 } |
58 #else | 59 #else |
59 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 60 static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMa
trix, |
60 GrTexture* tex, const GrTextureParams& pa
rams, | 61 GrTexture* tex, const GrTextureParams
& params, |
61 uint32_t flags, bool usesLocalCoords) { | 62 uint32_t flags, bool usesLocalCoords)
{ |
62 return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params,
flags, | 63 return sk_sp<GrGeometryProcessor>( |
63 usesLocalCoords); | 64 new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, fla
gs, |
| 65 usesLocalCoords)); |
64 } | 66 } |
65 #endif | 67 #endif |
66 | 68 |
67 virtual ~GrDistanceFieldA8TextGeoProc() {} | 69 virtual ~GrDistanceFieldA8TextGeoProc() {} |
68 | 70 |
69 const char* name() const override { return "DistanceFieldTexture"; } | 71 const char* name() const override { return "DistanceFieldTexture"; } |
70 | 72 |
71 const Attribute* inPosition() const { return fInPosition; } | 73 const Attribute* inPosition() const { return fInPosition; } |
72 const Attribute* inColor() const { return fInColor; } | 74 const Attribute* inColor() const { return fInColor; } |
73 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 75 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 113 |
112 | 114 |
113 /** | 115 /** |
114 * The output color of this effect is a modulation of the input color and a sampl
e from a | 116 * The output color of this effect is a modulation of the input color and a sampl
e from a |
115 * distance field texture (using a smoothed step function near 0.5). | 117 * distance field texture (using a smoothed step function near 0.5). |
116 * It allows explicit specification of the filtering and wrap modes (GrTexturePar
ams). The input | 118 * It allows explicit specification of the filtering and wrap modes (GrTexturePar
ams). The input |
117 * coords are a custom attribute. No gamma correct blending is applied. Used for
paths only. | 119 * coords are a custom attribute. No gamma correct blending is applied. Used for
paths only. |
118 */ | 120 */ |
119 class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { | 121 class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { |
120 public: | 122 public: |
121 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, GrTexture* tex, | 123 static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMa
trix, |
122 const GrTextureParams& params, | 124 GrTexture* tex, const GrTextureParams
& params, |
123 uint32_t flags, bool usesLocalCoords) { | 125 uint32_t flags, bool usesLocalCoords)
{ |
124 return new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, fl
ags, | 126 return sk_sp<GrGeometryProcessor>( |
125 usesLocalCoords); | 127 new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, flags
, usesLocalCoords)); |
126 } | 128 } |
127 | 129 |
128 virtual ~GrDistanceFieldPathGeoProc() {} | 130 virtual ~GrDistanceFieldPathGeoProc() {} |
129 | 131 |
130 const char* name() const override { return "DistanceFieldTexture"; } | 132 const char* name() const override { return "DistanceFieldTexture"; } |
131 | 133 |
132 const Attribute* inPosition() const { return fInPosition; } | 134 const Attribute* inPosition() const { return fInPosition; } |
133 const Attribute* inColor() const { return fInColor; } | 135 const Attribute* inColor() const { return fInColor; } |
134 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 136 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
135 GrColor color() const { return fColor; } | 137 GrColor color() const { return fColor; } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return result; | 179 return result; |
178 } | 180 } |
179 bool operator==(const DistanceAdjust& wa) const { | 181 bool operator==(const DistanceAdjust& wa) const { |
180 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); | 182 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); |
181 } | 183 } |
182 bool operator!=(const DistanceAdjust& wa) const { | 184 bool operator!=(const DistanceAdjust& wa) const { |
183 return !(*this == wa); | 185 return !(*this == wa); |
184 } | 186 } |
185 }; | 187 }; |
186 | 188 |
187 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 189 static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMa
trix, |
188 GrTexture* tex, const GrTextureParams& pa
rams, | 190 GrTexture* tex, const GrTextureParams
& params, |
189 DistanceAdjust distanceAdjust, uint32_t f
lags, | 191 DistanceAdjust distanceAdjust, uint32
_t flags, |
190 bool usesLocalCoords) { | 192 bool usesLocalCoords) { |
191 return new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params,
distanceAdjust, | 193 return sk_sp<GrGeometryProcessor>( |
192 flags, usesLocalCoords); | 194 new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params, di
stanceAdjust, |
| 195 flags, usesLocalCoords)); |
193 } | 196 } |
194 | 197 |
195 virtual ~GrDistanceFieldLCDTextGeoProc() {} | 198 virtual ~GrDistanceFieldLCDTextGeoProc() {} |
196 | 199 |
197 const char* name() const override { return "DistanceFieldLCDTexture"; } | 200 const char* name() const override { return "DistanceFieldLCDTexture"; } |
198 | 201 |
199 const Attribute* inPosition() const { return fInPosition; } | 202 const Attribute* inPosition() const { return fInPosition; } |
200 const Attribute* inColor() const { return fInColor; } | 203 const Attribute* inColor() const { return fInColor; } |
201 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 204 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
202 DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } | 205 DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } |
(...skipping 22 matching lines...) Expand all Loading... |
225 const Attribute* fInColor; | 228 const Attribute* fInColor; |
226 const Attribute* fInTextureCoords; | 229 const Attribute* fInTextureCoords; |
227 bool fUsesLocalCoords; | 230 bool fUsesLocalCoords; |
228 | 231 |
229 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 232 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
230 | 233 |
231 typedef GrGeometryProcessor INHERITED; | 234 typedef GrGeometryProcessor INHERITED; |
232 }; | 235 }; |
233 | 236 |
234 #endif | 237 #endif |
OLD | NEW |