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 * 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 GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor { | 47 class GrDistanceFieldA8TextGeoProc : 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
, | 50 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, |
51 GrTexture* tex, const GrTextureParams& pa
rams, | 51 GrTexture* tex, const GrTextureParams& pa
rams, |
52 float lum, uint32_t flags, bool usesLocal
Coords) { | 52 float lum, uint32_t flags) { |
53 return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex,
params, lum, | 53 return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex,
params, lum, |
54 flags, usesLocalCoords)
); | 54 flags)); |
55 } | 55 } |
56 #else | 56 #else |
57 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 57 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, |
58 GrTexture* tex, const GrTextureParams& pa
rams, | 58 GrTexture* tex, const GrTextureParams& pa
rams, |
59 uint32_t flags, bool usesLocalCoords) { | 59 uint32_t flags) { |
60 return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex,
params, flags, | 60 return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex,
params, flags)); |
61 usesLocalCoords)); | |
62 } | 61 } |
63 #endif | 62 #endif |
64 | 63 |
65 virtual ~GrDistanceFieldA8TextGeoProc() {} | 64 virtual ~GrDistanceFieldA8TextGeoProc() {} |
66 | 65 |
67 const char* name() const override { return "DistanceFieldTexture"; } | 66 const char* name() const override { return "DistanceFieldTexture"; } |
68 | 67 |
69 const Attribute* inPosition() const { return fInPosition; } | 68 const Attribute* inPosition() const { return fInPosition; } |
70 const Attribute* inColor() const { return fInColor; } | 69 const Attribute* inColor() const { return fInColor; } |
71 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 70 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
72 GrColor color() const { return fColor; } | 71 GrColor color() const { return fColor; } |
73 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | |
74 bool hasVertexColor() const { return SkToBool(fInColor); } | |
75 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 72 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
76 bool usesLocalCoords() const { return fUsesLocalCoords; } | |
77 #ifdef SK_GAMMA_APPLY_TO_A8 | 73 #ifdef SK_GAMMA_APPLY_TO_A8 |
78 float getDistanceAdjust() const { return fDistanceAdjust; } | 74 float getDistanceAdjust() const { return fDistanceAdjust; } |
79 #endif | 75 #endif |
80 uint32_t getFlags() const { return fFlags; } | 76 uint32_t getFlags() const { return fFlags; } |
81 | 77 |
82 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 78 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
83 const GrGLSLCaps& caps, | 79 const GrGLSLCaps& caps, |
84 GrProcessorKeyBuilder* b) const override; | 80 GrProcessorKeyBuilder* b) const override; |
85 | 81 |
86 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 82 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
87 const GrGLSLCaps&) const ov
erride; | 83 const GrGLSLCaps&) const ov
erride; |
88 | 84 |
| 85 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; |
| 86 |
89 private: | 87 private: |
90 GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix, | 88 GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix, |
91 GrTexture* texture, const GrTextureParams& para
ms, | 89 GrTexture* texture, const GrTextureParams& para
ms, |
92 #ifdef SK_GAMMA_APPLY_TO_A8 | 90 #ifdef SK_GAMMA_APPLY_TO_A8 |
93 float distanceAdjust, | 91 float distanceAdjust, |
94 #endif | 92 #endif |
95 uint32_t flags, bool usesLocalCoords); | 93 uint32_t flags); |
96 | 94 |
97 GrColor fColor; | 95 GrColor fColor; |
98 SkMatrix fViewMatrix; | 96 SkMatrix fViewMatrix; |
99 GrTextureAccess fTextureAccess; | 97 GrTextureAccess fTextureAccess; |
100 #ifdef SK_GAMMA_APPLY_TO_A8 | 98 #ifdef SK_GAMMA_APPLY_TO_A8 |
101 float fDistanceAdjust; | 99 float fDistanceAdjust; |
102 #endif | 100 #endif |
103 uint32_t fFlags; | 101 uint32_t fFlags; |
104 const Attribute* fInPosition; | 102 const Attribute* fInPosition; |
105 const Attribute* fInColor; | 103 const Attribute* fInColor; |
106 const Attribute* fInTextureCoords; | 104 const Attribute* fInTextureCoords; |
107 bool fUsesLocalCoords; | |
108 | 105 |
109 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 106 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
110 | 107 |
111 typedef GrGeometryProcessor INHERITED; | 108 typedef GrGeometryProcessor INHERITED; |
112 }; | 109 }; |
113 | 110 |
114 | 111 |
115 /** | 112 /** |
116 * The output color of this effect is a modulation of the input color and a sampl
e from a | 113 * The output color of this effect is a modulation of the input color and a sampl
e from a |
117 * distance field texture (using a smoothed step function near 0.5). | 114 * distance field texture (using a smoothed step function near 0.5). |
118 * It allows explicit specification of the filtering and wrap modes (GrTexturePar
ams). The input | 115 * It allows explicit specification of the filtering and wrap modes (GrTexturePar
ams). The input |
119 * coords are a custom attribute. No gamma correct blending is applied. Used for
paths only. | 116 * coords are a custom attribute. No gamma correct blending is applied. Used for
paths only. |
120 */ | 117 */ |
121 class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { | 118 class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { |
122 public: | 119 public: |
123 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, GrTexture* tex, | 120 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, GrTexture* tex, |
124 const GrTextureParams& params, | 121 const GrTextureParams& params, |
125 uint32_t flags, bool usesLocalCoords) { | 122 uint32_t flags) { |
126 return SkNEW_ARGS(GrDistanceFieldPathGeoProc, (color, viewMatrix, tex, p
arams, flags, | 123 return SkNEW_ARGS(GrDistanceFieldPathGeoProc, (color, viewMatrix, tex, p
arams, flags)); |
127 usesLocalCoords)); | |
128 } | 124 } |
129 | 125 |
130 virtual ~GrDistanceFieldPathGeoProc() {} | 126 virtual ~GrDistanceFieldPathGeoProc() {} |
131 | 127 |
132 const char* name() const override { return "DistanceFieldTexture"; } | 128 const char* name() const override { return "DistanceFieldTexture"; } |
133 | 129 |
134 const Attribute* inPosition() const { return fInPosition; } | 130 const Attribute* inPosition() const { return fInPosition; } |
135 const Attribute* inColor() const { return fInColor; } | 131 const Attribute* inColor() const { return fInColor; } |
136 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 132 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
137 GrColor color() const { return fColor; } | 133 GrColor color() const { return fColor; } |
138 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | |
139 bool hasVertexColor() const { return SkToBool(fInColor); } | |
140 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 134 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
141 uint32_t getFlags() const { return fFlags; } | 135 uint32_t getFlags() const { return fFlags; } |
142 bool usesLocalCoords() const { return fUsesLocalCoords; } | |
143 | 136 |
144 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 137 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
145 const GrGLSLCaps& caps, | 138 const GrGLSLCaps& caps, |
146 GrProcessorKeyBuilder* b) const override; | 139 GrProcessorKeyBuilder* b) const override; |
147 | 140 |
148 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 141 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
149 const GrGLSLCaps&) const ov
erride; | 142 const GrGLSLCaps&) const ov
erride; |
150 | 143 |
| 144 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; |
| 145 |
151 private: | 146 private: |
152 GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* t
exture, | 147 GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* t
exture, |
153 const GrTextureParams& params, uint32_t flags, | 148 const GrTextureParams& params, uint32_t flags); |
154 bool usesLocalCoords); | |
155 | 149 |
156 GrColor fColor; | 150 GrColor fColor; |
157 SkMatrix fViewMatrix; | 151 SkMatrix fViewMatrix; |
158 GrTextureAccess fTextureAccess; | 152 GrTextureAccess fTextureAccess; |
159 uint32_t fFlags; | 153 uint32_t fFlags; |
160 const Attribute* fInPosition; | 154 const Attribute* fInPosition; |
161 const Attribute* fInColor; | 155 const Attribute* fInColor; |
162 const Attribute* fInTextureCoords; | 156 const Attribute* fInTextureCoords; |
163 bool fUsesLocalCoords; | |
164 | 157 |
165 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 158 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
166 | 159 |
167 typedef GrGeometryProcessor INHERITED; | 160 typedef GrGeometryProcessor INHERITED; |
168 }; | 161 }; |
169 | 162 |
170 /** | 163 /** |
171 * The output color of this effect is a modulation of the input color and sample
s from a | 164 * The output color of this effect is a modulation of the input color and sample
s from a |
172 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. | 165 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. |
173 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input | 166 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
(...skipping 11 matching lines...) Expand all Loading... |
185 bool operator==(const DistanceAdjust& wa) const { | 178 bool operator==(const DistanceAdjust& wa) const { |
186 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); | 179 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); |
187 } | 180 } |
188 bool operator!=(const DistanceAdjust& wa) const { | 181 bool operator!=(const DistanceAdjust& wa) const { |
189 return !(*this == wa); | 182 return !(*this == wa); |
190 } | 183 } |
191 }; | 184 }; |
192 | 185 |
193 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 186 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, |
194 GrTexture* tex, const GrTextureParams& pa
rams, | 187 GrTexture* tex, const GrTextureParams& pa
rams, |
195 DistanceAdjust distanceAdjust, uint32_t f
lags, | 188 DistanceAdjust distanceAdjust, uint32_t f
lags) { |
196 bool usesLocalCoords) { | |
197 return SkNEW_ARGS(GrDistanceFieldLCDTextGeoProc, | 189 return SkNEW_ARGS(GrDistanceFieldLCDTextGeoProc, |
198 (color, viewMatrix, tex, params, distanceAdjust, flags
, usesLocalCoords)); | 190 (color, viewMatrix, tex, params, distanceAdjust, flags
)); |
199 } | 191 } |
200 | 192 |
201 virtual ~GrDistanceFieldLCDTextGeoProc() {} | 193 virtual ~GrDistanceFieldLCDTextGeoProc() {} |
202 | 194 |
203 const char* name() const override { return "DistanceFieldLCDTexture"; } | 195 const char* name() const override { return "DistanceFieldLCDTexture"; } |
204 | 196 |
205 const Attribute* inPosition() const { return fInPosition; } | 197 const Attribute* inPosition() const { return fInPosition; } |
206 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 198 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
207 DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } | 199 DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } |
208 GrColor color() const { return fColor; } | 200 GrColor color() const { return fColor; } |
209 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | |
210 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 201 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
211 uint32_t getFlags() const { return fFlags; } | 202 uint32_t getFlags() const { return fFlags; } |
212 bool usesLocalCoords() const { return fUsesLocalCoords; } | |
213 | 203 |
214 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 204 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
215 const GrGLSLCaps& caps, | 205 const GrGLSLCaps& caps, |
216 GrProcessorKeyBuilder* b) const override; | 206 GrProcessorKeyBuilder* b) const override; |
217 | 207 |
218 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 208 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
219 const GrGLSLCaps&) const ov
erride; | 209 const GrGLSLCaps&) const ov
erride; |
220 | 210 |
| 211 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; |
| 212 |
221 private: | 213 private: |
222 GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix, | 214 GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix, |
223 GrTexture* texture, const GrTextureParams& par
ams, | 215 GrTexture* texture, const GrTextureParams& par
ams, |
224 DistanceAdjust wa, uint32_t flags, | 216 DistanceAdjust wa, uint32_t flags); |
225 bool usesLocalCoords); | |
226 | 217 |
227 GrColor fColor; | 218 GrColor fColor; |
228 SkMatrix fViewMatrix; | 219 SkMatrix fViewMatrix; |
229 GrTextureAccess fTextureAccess; | 220 GrTextureAccess fTextureAccess; |
230 DistanceAdjust fDistanceAdjust; | 221 DistanceAdjust fDistanceAdjust; |
231 uint32_t fFlags; | 222 uint32_t fFlags; |
232 const Attribute* fInPosition; | 223 const Attribute* fInPosition; |
233 const Attribute* fInTextureCoords; | 224 const Attribute* fInTextureCoords; |
234 bool fUsesLocalCoords; | |
235 | 225 |
236 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 226 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
237 | 227 |
238 typedef GrGeometryProcessor INHERITED; | 228 typedef GrGeometryProcessor INHERITED; |
239 }; | 229 }; |
240 | 230 |
241 #endif | 231 #endif |
OLD | NEW |