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 #include "GrDistanceFieldGeoProc.h" | 8 #include "GrDistanceFieldGeoProc.h" |
9 #include "GrFontAtlasSizes.h" | 9 #include "GrFontAtlasSizes.h" |
10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
11 #include "GrTexture.h" | 11 #include "GrTexture.h" |
12 | 12 |
13 #include "SkDistanceFieldGen.h" | 13 #include "SkDistanceFieldGen.h" |
14 | 14 |
15 #include "gl/GrGLProcessor.h" | 15 #include "gl/GrGLProcessor.h" |
16 #include "gl/GrGLSL.h" | 16 #include "gl/GrGLSL.h" |
17 #include "gl/GrGLTexture.h" | 17 #include "gl/GrGLTexture.h" |
18 #include "gl/GrGLGeometryProcessor.h" | 18 #include "gl/GrGLGeometryProcessor.h" |
19 #include "gl/builders/GrGLProgramBuilder.h" | 19 #include "gl/builders/GrGLProgramBuilder.h" |
20 | 20 |
21 // Assuming a radius of a little less than the diagonal of the fragment | 21 // Assuming a radius of a little less than the diagonal of the fragment |
22 #define SK_DistanceFieldAAFactor "0.65" | 22 #define SK_DistanceFieldAAFactor "0.65" |
23 | 23 |
24 struct DistanceFieldBatchTracker { | |
25 GrGPInput fInputColorType; | |
26 GrColor fColor; | |
27 bool fUsesLocalCoords; | |
28 }; | |
29 | |
30 class GrGLDistanceFieldA8TextGeoProc : public GrGLGeometryProcessor { | 24 class GrGLDistanceFieldA8TextGeoProc : public GrGLGeometryProcessor { |
31 public: | 25 public: |
32 GrGLDistanceFieldA8TextGeoProc(const GrGeometryProcessor&, | 26 GrGLDistanceFieldA8TextGeoProc(const GrGeometryProcessor&, |
33 const GrBatchTracker&) | 27 const GrBatchTracker&) |
34 : fColor(GrColor_ILLEGAL) | 28 : fColor(GrColor_ILLEGAL) |
35 #ifdef SK_GAMMA_APPLY_TO_A8 | 29 #ifdef SK_GAMMA_APPLY_TO_A8 |
36 , fDistanceAdjust(-1.0f) | 30 , fDistanceAdjust(-1.0f) |
37 #endif | 31 #endif |
38 {} | 32 {} |
39 | 33 |
40 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 34 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
41 const GrDistanceFieldA8TextGeoProc& dfTexEffect = | 35 const GrDistanceFieldA8TextGeoProc& dfTexEffect = |
42 args.fGP.cast<GrDistanceFieldA8TextGeoProc>(); | 36 args.fGP.cast<GrDistanceFieldA8TextGeoProc>(); |
43 const DistanceFieldBatchTracker& local = args.fBT.cast<DistanceFieldBatc
hTracker>(); | |
44 GrGLGPBuilder* pb = args.fPB; | 37 GrGLGPBuilder* pb = args.fPB; |
45 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 38 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
46 SkAssertResult(fsBuilder->enableFeature( | 39 SkAssertResult(fsBuilder->enableFeature( |
47 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); | 40 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); |
48 | 41 |
49 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 42 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
50 | 43 |
51 // emit attributes | 44 // emit attributes |
52 vsBuilder->emitAttributes(dfTexEffect); | 45 vsBuilder->emitAttributes(dfTexEffect); |
53 | 46 |
54 #ifdef SK_GAMMA_APPLY_TO_A8 | 47 #ifdef SK_GAMMA_APPLY_TO_A8 |
55 // adjust based on gamma | 48 // adjust based on gamma |
56 const char* distanceAdjustUniName = NULL; | 49 const char* distanceAdjustUniName = NULL; |
57 // width, height, 1/(3*width) | 50 // width, height, 1/(3*width) |
58 fDistanceAdjustUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_
Visibility, | 51 fDistanceAdjustUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_
Visibility, |
59 kFloat_GrSLType, kDefault_GrSLPrecision, | 52 kFloat_GrSLType, kDefault_GrSLPrecision, |
60 "DistanceAdjust", &distanceAdjustUniName); | 53 "DistanceAdjust", &distanceAdjustUniName); |
61 #endif | 54 #endif |
62 | 55 |
63 // Setup pass through color | 56 // Setup pass through color |
64 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, | 57 if (!dfTexEffect.colorIgnored()) { |
65 dfTexEffect.inColor(), &fColorUniform); | 58 if (dfTexEffect.hasVertexColor()) { |
| 59 pb->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputC
olor); |
| 60 } else { |
| 61 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); |
| 62 } |
| 63 } |
66 | 64 |
67 // Setup position | 65 // Setup position |
68 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); | 66 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); |
69 | 67 |
70 // emit transforms | 68 // emit transforms |
71 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, | 69 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
72 args.fTransformsIn, args.fTransformsOut); | 70 args.fTransformsIn, args.fTransformsOut); |
73 | 71 |
74 // add varyings | 72 // add varyings |
75 GrGLVertToFrag recipScale(kFloat_GrSLType); | 73 GrGLVertToFrag recipScale(kFloat_GrSLType); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 float distanceAdjust = dfTexEffect.getDistanceAdjust(); | 145 float distanceAdjust = dfTexEffect.getDistanceAdjust(); |
148 if (distanceAdjust != fDistanceAdjust) { | 146 if (distanceAdjust != fDistanceAdjust) { |
149 pdman.set1f(fDistanceAdjustUni, distanceAdjust); | 147 pdman.set1f(fDistanceAdjustUni, distanceAdjust); |
150 fDistanceAdjust = distanceAdjust; | 148 fDistanceAdjust = distanceAdjust; |
151 } | 149 } |
152 #endif | 150 #endif |
153 | 151 |
154 const GrDistanceFieldA8TextGeoProc& dfa8gp = proc.cast<GrDistanceFieldA8
TextGeoProc>(); | 152 const GrDistanceFieldA8TextGeoProc& dfa8gp = proc.cast<GrDistanceFieldA8
TextGeoProc>(); |
155 this->setUniformViewMatrix(pdman, dfa8gp.viewMatrix()); | 153 this->setUniformViewMatrix(pdman, dfa8gp.viewMatrix()); |
156 | 154 |
157 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack
er>(); | 155 if (dfa8gp.color() != fColor && !dfa8gp.hasVertexColor()) { |
158 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | |
159 GrGLfloat c[4]; | 156 GrGLfloat c[4]; |
160 GrColorToRGBAFloat(local.fColor, c); | 157 GrColorToRGBAFloat(dfa8gp.color(), c); |
161 pdman.set4fv(fColorUniform, 1, c); | 158 pdman.set4fv(fColorUniform, 1, c); |
162 fColor = local.fColor; | 159 fColor = dfa8gp.color(); |
163 } | 160 } |
164 } | 161 } |
165 | 162 |
166 static inline void GenKey(const GrGeometryProcessor& gp, | 163 static inline void GenKey(const GrGeometryProcessor& gp, |
167 const GrBatchTracker& bt, | 164 const GrBatchTracker& bt, |
168 const GrGLSLCaps&, | 165 const GrGLSLCaps&, |
169 GrProcessorKeyBuilder* b) { | 166 GrProcessorKeyBuilder* b) { |
170 const GrDistanceFieldA8TextGeoProc& dfTexEffect = gp.cast<GrDistanceFiel
dA8TextGeoProc>(); | 167 const GrDistanceFieldA8TextGeoProc& dfTexEffect = gp.cast<GrDistanceFiel
dA8TextGeoProc>(); |
171 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack
er>(); | |
172 uint32_t key = dfTexEffect.getFlags(); | 168 uint32_t key = dfTexEffect.getFlags(); |
173 key |= local.fInputColorType << 16; | 169 key |= dfTexEffect.hasVertexColor() << 16; |
| 170 key |= dfTexEffect.colorIgnored() << 17; |
174 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; | 171 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; |
175 b->add32(key); | 172 b->add32(key); |
176 } | 173 } |
177 | 174 |
178 private: | 175 private: |
179 GrColor fColor; | 176 GrColor fColor; |
180 UniformHandle fColorUniform; | 177 UniformHandle fColorUniform; |
181 #ifdef SK_GAMMA_APPLY_TO_A8 | 178 #ifdef SK_GAMMA_APPLY_TO_A8 |
182 float fDistanceAdjust; | 179 float fDistanceAdjust; |
183 UniformHandle fDistanceAdjustUni; | 180 UniformHandle fDistanceAdjustUni; |
184 #endif | 181 #endif |
185 | 182 |
186 typedef GrGLGeometryProcessor INHERITED; | 183 typedef GrGLGeometryProcessor INHERITED; |
187 }; | 184 }; |
188 | 185 |
189 /////////////////////////////////////////////////////////////////////////////// | 186 /////////////////////////////////////////////////////////////////////////////// |
190 | 187 |
191 GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color, | 188 GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color, |
192 const SkMatrix& viewM
atrix, | 189 const SkMatrix& viewM
atrix, |
193 GrTexture* texture, | 190 GrTexture* texture, |
194 const GrTextureParams
& params, | 191 const GrTextureParams
& params, |
195 #ifdef SK_GAMMA_APPLY_TO_A8 | 192 #ifdef SK_GAMMA_APPLY_TO_A8 |
196 float distanceAdjust, | 193 float distanceAdjust, |
197 #endif | 194 #endif |
198 uint32_t flags) | 195 uint32_t flags, |
| 196 bool usesLocalCoords) |
199 : fColor(color) | 197 : fColor(color) |
200 , fViewMatrix(viewMatrix) | 198 , fViewMatrix(viewMatrix) |
201 , fTextureAccess(texture, params) | 199 , fTextureAccess(texture, params) |
202 #ifdef SK_GAMMA_APPLY_TO_A8 | 200 #ifdef SK_GAMMA_APPLY_TO_A8 |
203 , fDistanceAdjust(distanceAdjust) | 201 , fDistanceAdjust(distanceAdjust) |
204 #endif | 202 #endif |
205 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) | 203 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) |
206 , fInColor(NULL) { | 204 , fInColor(NULL) |
| 205 , fUsesLocalCoords(usesLocalCoords) { |
207 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); | 206 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); |
208 this->initClassID<GrDistanceFieldA8TextGeoProc>(); | 207 this->initClassID<GrDistanceFieldA8TextGeoProc>(); |
209 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 208 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
210 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 209 if (flags & kColorAttr_DistanceFieldEffectFlag) { |
211 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 210 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); |
212 } | 211 } |
213 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 212 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
214 kVec2s_GrVertexAttribT
ype)); | 213 kVec2s_GrVertexAttribT
ype)); |
215 this->addTextureAccess(&fTextureAccess); | 214 this->addTextureAccess(&fTextureAccess); |
216 } | 215 } |
217 | 216 |
218 void GrDistanceFieldA8TextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, | 217 void GrDistanceFieldA8TextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, |
219 const GrGLSLCaps& caps, | 218 const GrGLSLCaps& caps, |
220 GrProcessorKeyBuilder* b) c
onst { | 219 GrProcessorKeyBuilder* b) c
onst { |
221 GrGLDistanceFieldA8TextGeoProc::GenKey(*this, bt, caps, b); | 220 GrGLDistanceFieldA8TextGeoProc::GenKey(*this, bt, caps, b); |
222 } | 221 } |
223 | 222 |
224 GrGLPrimitiveProcessor* | 223 GrGLPrimitiveProcessor* |
225 GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt, | 224 GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt, |
226 const GrGLSLCaps&) const { | 225 const GrGLSLCaps&) const { |
227 return SkNEW_ARGS(GrGLDistanceFieldA8TextGeoProc, (*this, bt)); | 226 return SkNEW_ARGS(GrGLDistanceFieldA8TextGeoProc, (*this, bt)); |
228 } | 227 } |
229 | 228 |
230 void GrDistanceFieldA8TextGeoProc::initBatchTracker(GrBatchTracker* bt, | |
231 const GrPipelineInfo& init)
const { | |
232 DistanceFieldBatchTracker* local = bt->cast<DistanceFieldBatchTracker>(); | |
233 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, | |
234 SkToBool(fInColor)); | |
235 local->fUsesLocalCoords = init.fUsesLocalCoords; | |
236 } | |
237 | |
238 /////////////////////////////////////////////////////////////////////////////// | 229 /////////////////////////////////////////////////////////////////////////////// |
239 | 230 |
240 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); | 231 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); |
241 | 232 |
242 GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(SkRandom* random, | 233 GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(SkRandom* random, |
243 GrContext*, | 234 GrContext*, |
244 const GrDrawTarget
Caps&, | 235 const GrDrawTarget
Caps&, |
245 GrTexture* texture
s[]) { | 236 GrTexture* texture
s[]) { |
246 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : | 237 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : |
247 GrProcessorUnitTest::kAlphaTextureIdx; | 238 GrProcessorUnitTest::kAlphaTextureIdx; |
248 static const SkShader::TileMode kTileModes[] = { | 239 static const SkShader::TileMode kTileModes[] = { |
249 SkShader::kClamp_TileMode, | 240 SkShader::kClamp_TileMode, |
250 SkShader::kRepeat_TileMode, | 241 SkShader::kRepeat_TileMode, |
251 SkShader::kMirror_TileMode, | 242 SkShader::kMirror_TileMode, |
252 }; | 243 }; |
253 SkShader::TileMode tileModes[] = { | 244 SkShader::TileMode tileModes[] = { |
254 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 245 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
255 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 246 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
256 }; | 247 }; |
257 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 248 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
258 GrTextureParams::kNon
e_FilterMode); | 249 GrTextureParams::kNon
e_FilterMode); |
259 | 250 |
260 return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(random), | 251 return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(random), |
261 GrTest::TestMatrix(random), | 252 GrTest::TestMatrix(random), |
262 textures[texIdx], params, | 253 textures[texIdx], params, |
263 #ifdef SK_GAMMA_APPLY_TO_A8 | 254 #ifdef SK_GAMMA_APPLY_TO_A8 |
264 random->nextF(), | 255 random->nextF(), |
265 #endif | 256 #endif |
266 random->nextBool() ? | 257 random->nextBool() ? |
267 kSimilarity_DistanceFieldEff
ectFlag : 0); | 258 kSimilarity_DistanceFieldEff
ectFlag : 0, |
| 259 random->nextBool()); |
268 } | 260 } |
269 | 261 |
270 /////////////////////////////////////////////////////////////////////////////// | 262 /////////////////////////////////////////////////////////////////////////////// |
271 | 263 |
272 struct DistanceFieldPathBatchTracker { | |
273 GrGPInput fInputColorType; | |
274 GrColor fColor; | |
275 bool fUsesLocalCoords; | |
276 }; | |
277 | |
278 class GrGLDistanceFieldPathGeoProc : public GrGLGeometryProcessor { | 264 class GrGLDistanceFieldPathGeoProc : public GrGLGeometryProcessor { |
279 public: | 265 public: |
280 GrGLDistanceFieldPathGeoProc(const GrGeometryProcessor&, | 266 GrGLDistanceFieldPathGeoProc(const GrGeometryProcessor&, |
281 const GrBatchTracker&) | 267 const GrBatchTracker&) |
282 : fColor(GrColor_ILLEGAL), fTextureSize(SkISize::Make(-1, -1)) {} | 268 : fColor(GrColor_ILLEGAL), fTextureSize(SkISize::Make(-1, -1)) {} |
283 | 269 |
284 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 270 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
285 const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistance
FieldPathGeoProc>(); | 271 const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistance
FieldPathGeoProc>(); |
286 | 272 |
287 const DistanceFieldPathBatchTracker& local = args.fBT.cast<DistanceField
PathBatchTracker>(); | |
288 GrGLGPBuilder* pb = args.fPB; | 273 GrGLGPBuilder* pb = args.fPB; |
289 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 274 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
290 SkAssertResult(fsBuilder->enableFeature( | 275 SkAssertResult(fsBuilder->enableFeature( |
291 GrGLFragmentShaderBuilder::kStandardDerivat
ives_GLSLFeature)); | 276 GrGLFragmentShaderBuilder::kStandardDerivat
ives_GLSLFeature)); |
292 | 277 |
293 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 278 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
294 | 279 |
295 // emit attributes | 280 // emit attributes |
296 vsBuilder->emitAttributes(dfTexEffect); | 281 vsBuilder->emitAttributes(dfTexEffect); |
297 | 282 |
298 GrGLVertToFrag v(kVec2f_GrSLType); | 283 GrGLVertToFrag v(kVec2f_GrSLType); |
299 args.fPB->addVarying("TextureCoords", &v, kHigh_GrSLPrecision); | 284 args.fPB->addVarying("TextureCoords", &v, kHigh_GrSLPrecision); |
300 | 285 |
301 // setup pass through color | 286 // setup pass through color |
302 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, | 287 if (!dfTexEffect.colorIgnored()) { |
303 dfTexEffect.inColor(), &fColorUniform); | 288 if (dfTexEffect.hasVertexColor()) { |
304 | 289 pb->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputC
olor); |
| 290 } else { |
| 291 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); |
| 292 } |
| 293 } |
305 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 294 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
306 | 295 |
307 // Setup position | 296 // Setup position |
308 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); | 297 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); |
309 | 298 |
310 // emit transforms | 299 // emit transforms |
311 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, | 300 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
312 args.fTransformsIn, args.fTransformsOut); | 301 args.fTransformsIn, args.fTransformsOut); |
313 | 302 |
314 const char* textureSizeUniName = NULL; | 303 const char* textureSizeUniName = NULL; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 texture->height() != fTextureSize.height()) { | 366 texture->height() != fTextureSize.height()) { |
378 fTextureSize = SkISize::Make(texture->width(), texture->height()); | 367 fTextureSize = SkISize::Make(texture->width(), texture->height()); |
379 pdman.set2f(fTextureSizeUni, | 368 pdman.set2f(fTextureSizeUni, |
380 SkIntToScalar(fTextureSize.width()), | 369 SkIntToScalar(fTextureSize.width()), |
381 SkIntToScalar(fTextureSize.height())); | 370 SkIntToScalar(fTextureSize.height())); |
382 } | 371 } |
383 | 372 |
384 const GrDistanceFieldPathGeoProc& dfpgp = proc.cast<GrDistanceFieldPathG
eoProc>(); | 373 const GrDistanceFieldPathGeoProc& dfpgp = proc.cast<GrDistanceFieldPathG
eoProc>(); |
385 this->setUniformViewMatrix(pdman, dfpgp.viewMatrix()); | 374 this->setUniformViewMatrix(pdman, dfpgp.viewMatrix()); |
386 | 375 |
387 const DistanceFieldPathBatchTracker& local = bt.cast<DistanceFieldPathBa
tchTracker>(); | 376 if (dfpgp.color() != fColor) { |
388 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | |
389 GrGLfloat c[4]; | 377 GrGLfloat c[4]; |
390 GrColorToRGBAFloat(local.fColor, c); | 378 GrColorToRGBAFloat(dfpgp.color(), c); |
391 pdman.set4fv(fColorUniform, 1, c); | 379 pdman.set4fv(fColorUniform, 1, c); |
392 fColor = local.fColor; | 380 fColor = dfpgp.color(); |
393 } | 381 } |
394 } | 382 } |
395 | 383 |
396 static inline void GenKey(const GrGeometryProcessor& gp, | 384 static inline void GenKey(const GrGeometryProcessor& gp, |
397 const GrBatchTracker& bt, | 385 const GrBatchTracker& bt, |
398 const GrGLSLCaps&, | 386 const GrGLSLCaps&, |
399 GrProcessorKeyBuilder* b) { | 387 GrProcessorKeyBuilder* b) { |
400 const GrDistanceFieldPathGeoProc& dfTexEffect = gp.cast<GrDistanceFieldP
athGeoProc>(); | 388 const GrDistanceFieldPathGeoProc& dfTexEffect = gp.cast<GrDistanceFieldP
athGeoProc>(); |
401 | 389 |
402 const DistanceFieldPathBatchTracker& local = bt.cast<DistanceFieldPathBa
tchTracker>(); | |
403 uint32_t key = dfTexEffect.getFlags(); | 390 uint32_t key = dfTexEffect.getFlags(); |
404 key |= local.fInputColorType << 16; | 391 key |= dfTexEffect.colorIgnored() << 16; |
| 392 key |= dfTexEffect.hasVertexColor() << 17; |
405 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; | 393 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; |
406 b->add32(key); | 394 b->add32(key); |
407 } | 395 } |
408 | 396 |
409 private: | 397 private: |
410 UniformHandle fColorUniform; | 398 UniformHandle fColorUniform; |
411 UniformHandle fTextureSizeUni; | 399 UniformHandle fTextureSizeUni; |
412 GrColor fColor; | 400 GrColor fColor; |
413 SkISize fTextureSize; | 401 SkISize fTextureSize; |
414 | 402 |
415 typedef GrGLGeometryProcessor INHERITED; | 403 typedef GrGLGeometryProcessor INHERITED; |
416 }; | 404 }; |
417 | 405 |
418 /////////////////////////////////////////////////////////////////////////////// | 406 /////////////////////////////////////////////////////////////////////////////// |
419 | 407 |
420 GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( | 408 GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( |
421 GrColor color, | 409 GrColor color, |
422 const SkMatrix& viewMatrix, | 410 const SkMatrix& viewMatrix, |
423 GrTexture* texture, | 411 GrTexture* texture, |
424 const GrTextureParams& params, | 412 const GrTextureParams& params, |
425 uint32_t flags) | 413 uint32_t flags, |
| 414 bool usesLocalCoords) |
426 : fColor(color) | 415 : fColor(color) |
427 , fViewMatrix(viewMatrix) | 416 , fViewMatrix(viewMatrix) |
428 , fTextureAccess(texture, params) | 417 , fTextureAccess(texture, params) |
429 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) | 418 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) |
430 , fInColor(NULL) { | 419 , fInColor(NULL) |
| 420 , fUsesLocalCoords(usesLocalCoords) { |
431 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); | 421 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); |
432 this->initClassID<GrDistanceFieldPathGeoProc>(); | 422 this->initClassID<GrDistanceFieldPathGeoProc>(); |
433 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 423 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
434 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 424 if (flags & kColorAttr_DistanceFieldEffectFlag) { |
435 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 425 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); |
436 } | 426 } |
437 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 427 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
438 kVec2f_GrVertexAttribT
ype)); | 428 kVec2f_GrVertexAttribTyp
e)); |
439 this->addTextureAccess(&fTextureAccess); | 429 this->addTextureAccess(&fTextureAccess); |
440 } | 430 } |
441 | 431 |
442 void GrDistanceFieldPathGeoProc::getGLProcessorKey(const GrBatchTracker& bt, | 432 void GrDistanceFieldPathGeoProc::getGLProcessorKey(const GrBatchTracker& bt, |
443 const GrGLSLCaps& caps, | 433 const GrGLSLCaps& caps, |
444 GrProcessorKeyBuilder* b) con
st { | 434 GrProcessorKeyBuilder* b) con
st { |
445 GrGLDistanceFieldPathGeoProc::GenKey(*this, bt, caps, b); | 435 GrGLDistanceFieldPathGeoProc::GenKey(*this, bt, caps, b); |
446 } | 436 } |
447 | 437 |
448 GrGLPrimitiveProcessor* | 438 GrGLPrimitiveProcessor* |
449 GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG
LSLCaps&) const { | 439 GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG
LSLCaps&) const { |
450 return SkNEW_ARGS(GrGLDistanceFieldPathGeoProc, (*this, bt)); | 440 return SkNEW_ARGS(GrGLDistanceFieldPathGeoProc, (*this, bt)); |
451 } | 441 } |
452 | 442 |
453 void GrDistanceFieldPathGeoProc::initBatchTracker(GrBatchTracker* bt, | |
454 const GrPipelineInfo& init) co
nst { | |
455 DistanceFieldPathBatchTracker* local = bt->cast<DistanceFieldPathBatchTracke
r>(); | |
456 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, | |
457 SkToBool(fInColor)); | |
458 local->fUsesLocalCoords = init.fUsesLocalCoords; | |
459 } | |
460 | |
461 /////////////////////////////////////////////////////////////////////////////// | 443 /////////////////////////////////////////////////////////////////////////////// |
462 | 444 |
463 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); | 445 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); |
464 | 446 |
465 GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(SkRandom* random, | 447 GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(SkRandom* random, |
466 GrContext*, | 448 GrContext*, |
467 const GrDrawTargetCa
ps&, | 449 const GrDrawTargetCa
ps&, |
468 GrTexture* textures[
]) { | 450 GrTexture* textures[
]) { |
469 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx | 451 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx |
470 : GrProcessorUnitTest::kAlphaTextureIdx; | 452 : GrProcessorUnitTest::kAlphaTextureIdx; |
471 static const SkShader::TileMode kTileModes[] = { | 453 static const SkShader::TileMode kTileModes[] = { |
472 SkShader::kClamp_TileMode, | 454 SkShader::kClamp_TileMode, |
473 SkShader::kRepeat_TileMode, | 455 SkShader::kRepeat_TileMode, |
474 SkShader::kMirror_TileMode, | 456 SkShader::kMirror_TileMode, |
475 }; | 457 }; |
476 SkShader::TileMode tileModes[] = { | 458 SkShader::TileMode tileModes[] = { |
477 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 459 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
478 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 460 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
479 }; | 461 }; |
480 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode | 462 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode |
481 : GrTextureParams::kNon
e_FilterMode); | 463 : GrTextureParams::kNon
e_FilterMode); |
482 | 464 |
483 return GrDistanceFieldPathGeoProc::Create(GrRandomColor(random), | 465 return GrDistanceFieldPathGeoProc::Create(GrRandomColor(random), |
484 GrTest::TestMatrix(random), | 466 GrTest::TestMatrix(random), |
485 textures[texIdx], | 467 textures[texIdx], |
486 params, | 468 params, |
487 random->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0); | 469 random->nextBool() ? |
| 470 kSimilarity_DistanceFieldE
ffectFlag : 0, |
| 471 random->nextBool()); |
488 } | 472 } |
489 | 473 |
490 /////////////////////////////////////////////////////////////////////////////// | 474 /////////////////////////////////////////////////////////////////////////////// |
491 | 475 |
492 struct DistanceFieldLCDBatchTracker { | |
493 GrGPInput fInputColorType; | |
494 GrColor fColor; | |
495 bool fUsesLocalCoords; | |
496 }; | |
497 | |
498 class GrGLDistanceFieldLCDTextGeoProc : public GrGLGeometryProcessor { | 476 class GrGLDistanceFieldLCDTextGeoProc : public GrGLGeometryProcessor { |
499 public: | 477 public: |
500 GrGLDistanceFieldLCDTextGeoProc(const GrGeometryProcessor&, const GrBatchTra
cker&) | 478 GrGLDistanceFieldLCDTextGeoProc(const GrGeometryProcessor&, const GrBatchTra
cker&) |
501 : fColor(GrColor_ILLEGAL) { | 479 : fColor(GrColor_ILLEGAL) { |
502 fDistanceAdjust = GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(1.
0f, 1.0f, 1.0f); | 480 fDistanceAdjust = GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(1.
0f, 1.0f, 1.0f); |
503 } | 481 } |
504 | 482 |
505 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 483 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
506 const GrDistanceFieldLCDTextGeoProc& dfTexEffect = | 484 const GrDistanceFieldLCDTextGeoProc& dfTexEffect = |
507 args.fGP.cast<GrDistanceFieldLCDTextGeoProc>(); | 485 args.fGP.cast<GrDistanceFieldLCDTextGeoProc>(); |
508 const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldL
CDBatchTracker>(); | |
509 GrGLGPBuilder* pb = args.fPB; | 486 GrGLGPBuilder* pb = args.fPB; |
510 | 487 |
511 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 488 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
512 | 489 |
513 // emit attributes | 490 // emit attributes |
514 vsBuilder->emitAttributes(dfTexEffect); | 491 vsBuilder->emitAttributes(dfTexEffect); |
515 | 492 |
516 // setup pass through color | 493 // setup pass through color |
517 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, NULL, | 494 if (!dfTexEffect.colorIgnored()) { |
518 &fColorUniform); | 495 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); |
| 496 } |
519 | 497 |
520 // Setup position | 498 // Setup position |
521 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); | 499 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); |
522 | 500 |
523 // emit transforms | 501 // emit transforms |
524 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, | 502 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
525 args.fTransformsIn, args.fTransformsOut); | 503 args.fTransformsIn, args.fTransformsOut); |
526 | 504 |
527 // set up varyings | 505 // set up varyings |
528 bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_Di
stanceFieldEffectMask); | 506 bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_Di
stanceFieldEffectMask); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 if (wa != fDistanceAdjust) { | 623 if (wa != fDistanceAdjust) { |
646 pdman.set3f(fDistanceAdjustUni, | 624 pdman.set3f(fDistanceAdjustUni, |
647 wa.fR, | 625 wa.fR, |
648 wa.fG, | 626 wa.fG, |
649 wa.fB); | 627 wa.fB); |
650 fDistanceAdjust = wa; | 628 fDistanceAdjust = wa; |
651 } | 629 } |
652 | 630 |
653 this->setUniformViewMatrix(pdman, dfTexEffect.viewMatrix()); | 631 this->setUniformViewMatrix(pdman, dfTexEffect.viewMatrix()); |
654 | 632 |
655 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc
hTracker>(); | 633 if (dfTexEffect.color() != fColor) { |
656 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | |
657 GrGLfloat c[4]; | 634 GrGLfloat c[4]; |
658 GrColorToRGBAFloat(local.fColor, c); | 635 GrColorToRGBAFloat(dfTexEffect.color(), c); |
659 pdman.set4fv(fColorUniform, 1, c); | 636 pdman.set4fv(fColorUniform, 1, c); |
660 fColor = local.fColor; | 637 fColor = dfTexEffect.color(); |
661 } | 638 } |
662 } | 639 } |
663 | 640 |
664 static inline void GenKey(const GrGeometryProcessor& gp, | 641 static inline void GenKey(const GrGeometryProcessor& gp, |
665 const GrBatchTracker& bt, | 642 const GrBatchTracker& bt, |
666 const GrGLSLCaps&, | 643 const GrGLSLCaps&, |
667 GrProcessorKeyBuilder* b) { | 644 GrProcessorKeyBuilder* b) { |
668 const GrDistanceFieldLCDTextGeoProc& dfTexEffect = gp.cast<GrDistanceFie
ldLCDTextGeoProc>(); | 645 const GrDistanceFieldLCDTextGeoProc& dfTexEffect = gp.cast<GrDistanceFie
ldLCDTextGeoProc>(); |
669 | 646 |
670 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc
hTracker>(); | |
671 uint32_t key = dfTexEffect.getFlags(); | 647 uint32_t key = dfTexEffect.getFlags(); |
672 key |= local.fInputColorType << 16; | 648 key |= dfTexEffect.colorIgnored() << 16; |
673 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; | 649 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; |
674 b->add32(key); | 650 b->add32(key); |
675 } | 651 } |
676 | 652 |
677 private: | 653 private: |
678 GrColor fColor; | 654 GrColor fColor; |
679 UniformHandle fColorUniform; | 655 UniformHandle fColorUniform; |
680 GrDistanceFieldLCDTextGeoProc::DistanceAdjust fDistanceAdjust; | 656 GrDistanceFieldLCDTextGeoProc::DistanceAdjust fDistanceAdjust; |
681 UniformHandle fDistanceAdjustUni; | 657 UniformHandle fDistanceAdjustUni; |
682 | 658 |
683 typedef GrGLGeometryProcessor INHERITED; | 659 typedef GrGLGeometryProcessor INHERITED; |
684 }; | 660 }; |
685 | 661 |
686 /////////////////////////////////////////////////////////////////////////////// | 662 /////////////////////////////////////////////////////////////////////////////// |
687 | 663 |
688 GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc( | 664 GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc( |
689 GrColor color, const SkMatrix&
viewMatrix, | 665 GrColor color, const SkMatrix&
viewMatrix, |
690 GrTexture* texture, const GrTe
xtureParams& params, | 666 GrTexture* texture, const GrTe
xtureParams& params, |
691 DistanceAdjust distanceAdjust, | 667 DistanceAdjust distanceAdjust, |
692 uint32_t flags) | 668 uint32_t flags, bool usesLocal
Coords) |
693 : fColor(color) | 669 : fColor(color) |
694 , fViewMatrix(viewMatrix) | 670 , fViewMatrix(viewMatrix) |
695 , fTextureAccess(texture, params) | 671 , fTextureAccess(texture, params) |
696 , fDistanceAdjust(distanceAdjust) | 672 , fDistanceAdjust(distanceAdjust) |
697 , fFlags(flags & kLCD_DistanceFieldEffectMask){ | 673 , fFlags(flags & kLCD_DistanceFieldEffectMask) |
| 674 , fUsesLocalCoords(usesLocalCoords) { |
698 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); | 675 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); |
699 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); | 676 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); |
700 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 677 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
701 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 678 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
702 kVec2s_GrVertexAttribT
ype)); | 679 kVec2s_GrVertexAttribTyp
e)); |
703 this->addTextureAccess(&fTextureAccess); | 680 this->addTextureAccess(&fTextureAccess); |
704 } | 681 } |
705 | 682 |
706 void GrDistanceFieldLCDTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, | 683 void GrDistanceFieldLCDTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, |
707 const GrGLSLCaps& caps, | 684 const GrGLSLCaps& caps, |
708 GrProcessorKeyBuilder* b)
const { | 685 GrProcessorKeyBuilder* b)
const { |
709 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, bt, caps, b); | 686 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, bt, caps, b); |
710 } | 687 } |
711 | 688 |
712 GrGLPrimitiveProcessor* | 689 GrGLPrimitiveProcessor* |
713 GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt, | 690 GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt, |
714 const GrGLSLCaps&) const { | 691 const GrGLSLCaps&) const { |
715 return SkNEW_ARGS(GrGLDistanceFieldLCDTextGeoProc, (*this, bt)); | 692 return SkNEW_ARGS(GrGLDistanceFieldLCDTextGeoProc, (*this, bt)); |
716 } | 693 } |
717 | 694 |
718 void GrDistanceFieldLCDTextGeoProc::initBatchTracker(GrBatchTracker* bt, | |
719 const GrPipelineInfo& init)
const { | |
720 DistanceFieldLCDBatchTracker* local = bt->cast<DistanceFieldLCDBatchTracker>
(); | |
721 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); | |
722 local->fUsesLocalCoords = init.fUsesLocalCoords; | |
723 } | |
724 | |
725 /////////////////////////////////////////////////////////////////////////////// | 695 /////////////////////////////////////////////////////////////////////////////// |
726 | 696 |
727 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); | 697 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); |
728 | 698 |
729 GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(SkRandom* random, | 699 GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(SkRandom* random, |
730 GrContext*, | 700 GrContext*, |
731 const GrDrawTar
getCaps&, | 701 const GrDrawTar
getCaps&, |
732 GrTexture* text
ures[]) { | 702 GrTexture* text
ures[]) { |
733 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : | 703 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : |
734 GrProcessorUnitTest::kAlphaTextureIdx; | 704 GrProcessorUnitTest::kAlphaTextureIdx; |
735 static const SkShader::TileMode kTileModes[] = { | 705 static const SkShader::TileMode kTileModes[] = { |
736 SkShader::kClamp_TileMode, | 706 SkShader::kClamp_TileMode, |
737 SkShader::kRepeat_TileMode, | 707 SkShader::kRepeat_TileMode, |
738 SkShader::kMirror_TileMode, | 708 SkShader::kMirror_TileMode, |
739 }; | 709 }; |
740 SkShader::TileMode tileModes[] = { | 710 SkShader::TileMode tileModes[] = { |
741 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 711 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
742 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 712 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
743 }; | 713 }; |
744 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 714 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
745 GrTextureParams::kNone_FilterMode); | 715 GrTextureParams::kNone_FilterMode); |
746 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; | 716 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; |
747 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 717 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
748 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 718 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
749 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 719 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
750 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(random), | 720 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(random), |
751 GrTest::TestMatrix(random), | 721 GrTest::TestMatrix(random), |
752 textures[texIdx], params, | 722 textures[texIdx], params, |
753 wa, | 723 wa, |
754 flags); | 724 flags, |
| 725 random->nextBool()); |
755 } | 726 } |
OLD | NEW |