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 "GrDistanceFieldTextureEffect.h" | 8 #include "GrDistanceFieldTextureEffect.h" |
9 #include "gl/GrGLEffect.h" | 9 #include "gl/GrGLEffect.h" |
10 #include "gl/GrGLShaderBuilder.h" | 10 #include "gl/GrGLShaderBuilder.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 builder->fsCodeAppend("\tfloat distance = " | 72 builder->fsCodeAppend("\tfloat distance = " |
73 SK_DistanceFieldMultiplier "*(texColor.r - " SK_Distan
ceFieldThreshold ")" | 73 SK_DistanceFieldMultiplier "*(texColor.r - " SK_Distan
ceFieldThreshold ")" |
74 "+ " SK_DistanceFieldNonLCDFactor ";\n"); | 74 "+ " SK_DistanceFieldNonLCDFactor ";\n"); |
75 | 75 |
76 // we adjust for the effect of the transformation on the distance by usi
ng | 76 // we adjust for the effect of the transformation on the distance by usi
ng |
77 // the length of the gradient of the texture coordinates. We use st coor
dinates | 77 // the length of the gradient of the texture coordinates. We use st coor
dinates |
78 // to ensure we're mapping 1:1 from texel space to pixel space. | 78 // to ensure we're mapping 1:1 from texel space to pixel space. |
79 builder->fsCodeAppendf("\tvec2 uv = %s;\n", fsCoordName.c_str()); | 79 builder->fsCodeAppendf("\tvec2 uv = %s;\n", fsCoordName.c_str()); |
80 builder->fsCodeAppendf("\tvec2 st = uv*%s;\n", textureSizeUniName); | 80 builder->fsCodeAppendf("\tvec2 st = uv*%s;\n", textureSizeUniName); |
81 builder->fsCodeAppend("\tfloat afwidth;\n"); | 81 builder->fsCodeAppend("\tfloat afwidth;\n"); |
82 if (dfTexEffect.isSimilarity()) { | 82 if (dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag) { |
83 // this gives us a smooth step across approximately one fragment | 83 // this gives us a smooth step across approximately one fragment |
84 builder->fsCodeAppend("\tafwidth = " SK_DistanceFieldAAFactor "*dFdx
(st.x);\n"); | 84 builder->fsCodeAppend("\tafwidth = " SK_DistanceFieldAAFactor "*dFdx
(st.x);\n"); |
85 } else { | 85 } else { |
86 builder->fsCodeAppend("\tvec2 Jdx = dFdx(st);\n"); | 86 builder->fsCodeAppend("\tvec2 Jdx = dFdx(st);\n"); |
87 builder->fsCodeAppend("\tvec2 Jdy = dFdy(st);\n"); | 87 builder->fsCodeAppend("\tvec2 Jdy = dFdy(st);\n"); |
88 | 88 |
89 builder->fsCodeAppend("\tvec2 uv_grad;\n"); | 89 builder->fsCodeAppend("\tvec2 uv_grad;\n"); |
90 if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) { | 90 if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) { |
91 // this is to compensate for the Adreno, which likes to drop til
es on division by 0 | 91 // this is to compensate for the Adreno, which likes to drop til
es on division by 0 |
92 builder->fsCodeAppend("\tfloat uv_len2 = dot(uv, uv);\n"); | 92 builder->fsCodeAppend("\tfloat uv_len2 = dot(uv, uv);\n"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 fLuminance = luminance; | 146 fLuminance = luminance; |
147 } | 147 } |
148 #endif | 148 #endif |
149 } | 149 } |
150 | 150 |
151 static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, | 151 static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, |
152 GrEffectKeyBuilder* b) { | 152 GrEffectKeyBuilder* b) { |
153 const GrDistanceFieldTextureEffect& dfTexEffect = | 153 const GrDistanceFieldTextureEffect& dfTexEffect = |
154 drawEffect.castEffect<GrDistanceFi
eldTextureEffect>(); | 154 drawEffect.castEffect<GrDistanceFi
eldTextureEffect>(); |
155 | 155 |
156 b->add32(dfTexEffect.isSimilarity()); | 156 b->add32(dfTexEffect.getFlags()); |
157 } | 157 } |
158 | 158 |
159 private: | 159 private: |
160 GrGLProgramDataManager::UniformHandle fTextureSizeUni; | 160 GrGLProgramDataManager::UniformHandle fTextureSizeUni; |
161 SkISize fTextureSize; | 161 SkISize fTextureSize; |
162 GrGLProgramDataManager::UniformHandle fLuminanceUni; | 162 GrGLProgramDataManager::UniformHandle fLuminanceUni; |
163 float fLuminance; | 163 float fLuminance; |
164 | 164 |
165 typedef GrGLVertexEffect INHERITED; | 165 typedef GrGLVertexEffect INHERITED; |
166 }; | 166 }; |
167 | 167 |
168 /////////////////////////////////////////////////////////////////////////////// | 168 /////////////////////////////////////////////////////////////////////////////// |
169 | 169 |
170 GrDistanceFieldTextureEffect::GrDistanceFieldTextureEffect(GrTexture* texture, | 170 GrDistanceFieldTextureEffect::GrDistanceFieldTextureEffect(GrTexture* texture, |
171 const GrTextureParams
& params, | 171 const GrTextureParams
& params, |
172 #ifdef SK_GAMMA_APPLY_TO_A8 | 172 #ifdef SK_GAMMA_APPLY_TO_A8 |
173 GrTexture* gamma, | 173 GrTexture* gamma, |
174 const GrTextureParams
& gammaParams, | 174 const GrTextureParams
& gammaParams, |
175 float luminance, | 175 float luminance, |
176 #endif | 176 #endif |
177 bool similarity) | 177 uint32_t flags) |
178 : fTextureAccess(texture, params) | 178 : fTextureAccess(texture, params) |
179 #ifdef SK_GAMMA_APPLY_TO_A8 | 179 #ifdef SK_GAMMA_APPLY_TO_A8 |
180 , fGammaTextureAccess(gamma, gammaParams) | 180 , fGammaTextureAccess(gamma, gammaParams) |
181 , fLuminance(luminance) | 181 , fLuminance(luminance) |
182 #endif | 182 #endif |
183 , fIsSimilarity(similarity) { | 183 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) { |
| 184 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); |
184 this->addTextureAccess(&fTextureAccess); | 185 this->addTextureAccess(&fTextureAccess); |
185 #ifdef SK_GAMMA_APPLY_TO_A8 | 186 #ifdef SK_GAMMA_APPLY_TO_A8 |
186 this->addTextureAccess(&fGammaTextureAccess); | 187 this->addTextureAccess(&fGammaTextureAccess); |
187 #endif | 188 #endif |
188 this->addVertexAttrib(kVec2f_GrSLType); | 189 this->addVertexAttrib(kVec2f_GrSLType); |
189 } | 190 } |
190 | 191 |
191 bool GrDistanceFieldTextureEffect::onIsEqual(const GrEffect& other) const { | 192 bool GrDistanceFieldTextureEffect::onIsEqual(const GrEffect& other) const { |
192 const GrDistanceFieldTextureEffect& cte = CastEffect<GrDistanceFieldTextureE
ffect>(other); | 193 const GrDistanceFieldTextureEffect& cte = CastEffect<GrDistanceFieldTextureE
ffect>(other); |
193 return fTextureAccess == cte.fTextureAccess; | 194 return fTextureAccess == cte.fTextureAccess && |
| 195 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 196 fGammaTextureAccess == cte.fGammaTextureAccess && |
| 197 fLuminance == cte.fLuminance && |
| 198 #endif |
| 199 fFlags == cte.fFlags; |
194 } | 200 } |
195 | 201 |
196 void GrDistanceFieldTextureEffect::getConstantColorComponents(GrColor* color, | 202 void GrDistanceFieldTextureEffect::getConstantColorComponents(GrColor* color, |
197 uint32_t* validFlag
s) const { | 203 uint32_t* validFlag
s) const { |
198 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && | 204 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && |
199 GrPixelConfigIsOpaque(this->texture(0)->config())) { | 205 GrPixelConfigIsOpaque(this->texture(0)->config())) { |
200 *validFlags = kA_GrColorComponentFlag; | 206 *validFlags = kA_GrColorComponentFlag; |
201 } else { | 207 } else { |
202 *validFlags = 0; | 208 *validFlags = 0; |
203 } | 209 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 #ifdef SK_GAMMA_APPLY_TO_A8 | 241 #ifdef SK_GAMMA_APPLY_TO_A8 |
236 GrTextureParams params2(tileModes, random->nextBool() ? GrTextureParams::kBi
lerp_FilterMode : | 242 GrTextureParams params2(tileModes, random->nextBool() ? GrTextureParams::kBi
lerp_FilterMode : |
237 GrTextureParams::kNo
ne_FilterMode); | 243 GrTextureParams::kNo
ne_FilterMode); |
238 #endif | 244 #endif |
239 | 245 |
240 return GrDistanceFieldTextureEffect::Create(textures[texIdx], params, | 246 return GrDistanceFieldTextureEffect::Create(textures[texIdx], params, |
241 #ifdef SK_GAMMA_APPLY_TO_A8 | 247 #ifdef SK_GAMMA_APPLY_TO_A8 |
242 textures[texIdx2], params2, | 248 textures[texIdx2], params2, |
243 random->nextF(), | 249 random->nextF(), |
244 #endif | 250 #endif |
245 random->nextBool()); | 251 random->nextBool() ? |
| 252 kSimilarity_DistanceFieldEff
ectFlag : 0); |
246 } | 253 } |
247 | 254 |
248 /////////////////////////////////////////////////////////////////////////////// | 255 /////////////////////////////////////////////////////////////////////////////// |
249 | 256 |
250 class GrGLDistanceFieldLCDTextureEffect : public GrGLVertexEffect { | 257 class GrGLDistanceFieldLCDTextureEffect : public GrGLVertexEffect { |
251 public: | 258 public: |
252 GrGLDistanceFieldLCDTextureEffect(const GrBackendEffectFactory& factory, | 259 GrGLDistanceFieldLCDTextureEffect(const GrBackendEffectFactory& factory, |
253 const GrDrawEffect& drawEffect) | 260 const GrDrawEffect& drawEffect) |
254 : INHERITED (factory) | 261 : INHERITED (factory) |
255 , fTextureSize(SkISize::Make(-1,-1)) {} | 262 , fTextureSize(SkISize::Make(-1,-1)) {} |
(...skipping 23 matching lines...) Expand all Loading... |
279 | 286 |
280 const char* textureSizeUniName = NULL; | 287 const char* textureSizeUniName = NULL; |
281 // width, height, 1/(3*width) | 288 // width, height, 1/(3*width) |
282 fTextureSizeUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visib
ility, | 289 fTextureSizeUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visib
ility, |
283 kVec3f_GrSLType, "TextureSize", | 290 kVec3f_GrSLType, "TextureSize", |
284 &textureSizeUniName); | 291 &textureSizeUniName); |
285 | 292 |
286 // create LCD offset adjusted by inverse of transform | 293 // create LCD offset adjusted by inverse of transform |
287 builder->fsCodeAppendf("\tvec2 uv = %s;\n", fsCoordName.c_str()); | 294 builder->fsCodeAppendf("\tvec2 uv = %s;\n", fsCoordName.c_str()); |
288 builder->fsCodeAppendf("\tvec2 st = uv*%s.xy;\n", textureSizeUniName); | 295 builder->fsCodeAppendf("\tvec2 st = uv*%s.xy;\n", textureSizeUniName); |
289 if (dfTexEffect.isUniformScale()) { | 296 bool isUniformScale = !!(dfTexEffect.getFlags() & kUniformScale_Distance
FieldEffectMask); |
| 297 if (isUniformScale) { |
290 builder->fsCodeAppend("\tfloat dx = dFdx(st.x);\n"); | 298 builder->fsCodeAppend("\tfloat dx = dFdx(st.x);\n"); |
291 builder->fsCodeAppendf("\tvec2 offset = vec2(dx*%s.z, 0.0);\n", text
ureSizeUniName); | 299 builder->fsCodeAppendf("\tvec2 offset = vec2(dx*%s.z, 0.0);\n", text
ureSizeUniName); |
292 } else { | 300 } else { |
293 builder->fsCodeAppend("\tvec2 Jdx = dFdx(st);\n"); | 301 builder->fsCodeAppend("\tvec2 Jdx = dFdx(st);\n"); |
294 builder->fsCodeAppend("\tvec2 Jdy = dFdy(st);\n"); | 302 builder->fsCodeAppend("\tvec2 Jdy = dFdy(st);\n"); |
295 builder->fsCodeAppendf("\tvec2 offset = %s.z*Jdx;\n", textureSizeUni
Name); | 303 builder->fsCodeAppendf("\tvec2 offset = %s.z*Jdx;\n", textureSizeUni
Name); |
296 } | 304 } |
297 | 305 |
298 // green is distance to uv center | 306 // green is distance to uv center |
299 builder->fsCodeAppend("\tvec4 texColor = "); | 307 builder->fsCodeAppend("\tvec4 texColor = "); |
(...skipping 20 matching lines...) Expand all Loading... |
320 | 328 |
321 // we adjust for the effect of the transformation on the distance by usi
ng | 329 // we adjust for the effect of the transformation on the distance by usi
ng |
322 // the length of the gradient of the texture coordinates. We use st coor
dinates | 330 // the length of the gradient of the texture coordinates. We use st coor
dinates |
323 // to ensure we're mapping 1:1 from texel space to pixel space. | 331 // to ensure we're mapping 1:1 from texel space to pixel space. |
324 | 332 |
325 // To be strictly correct, we should compute the anti-aliasing factor se
parately | 333 // To be strictly correct, we should compute the anti-aliasing factor se
parately |
326 // for each color component. However, this is only important when using
perspective | 334 // for each color component. However, this is only important when using
perspective |
327 // transformations, and even then using a single factor seems like a rea
sonable | 335 // transformations, and even then using a single factor seems like a rea
sonable |
328 // trade-off between quality and speed. | 336 // trade-off between quality and speed. |
329 builder->fsCodeAppend("\tfloat afwidth;\n"); | 337 builder->fsCodeAppend("\tfloat afwidth;\n"); |
330 if (dfTexEffect.isUniformScale()) { | 338 if (isUniformScale) { |
331 // this gives us a smooth step across approximately one fragment | 339 // this gives us a smooth step across approximately one fragment |
332 builder->fsCodeAppend("\tafwidth = " SK_DistanceFieldAAFactor "*dx;\
n"); | 340 builder->fsCodeAppend("\tafwidth = " SK_DistanceFieldAAFactor "*dx;\
n"); |
333 } else { | 341 } else { |
334 builder->fsCodeAppend("\tvec2 uv_grad;\n"); | 342 builder->fsCodeAppend("\tvec2 uv_grad;\n"); |
335 if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) { | 343 if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) { |
336 // this is to compensate for the Adreno, which likes to drop til
es on division by 0 | 344 // this is to compensate for the Adreno, which likes to drop til
es on division by 0 |
337 builder->fsCodeAppend("\tfloat uv_len2 = dot(uv, uv);\n"); | 345 builder->fsCodeAppend("\tfloat uv_len2 = dot(uv, uv);\n"); |
338 builder->fsCodeAppend("\tif (uv_len2 < 0.0001) {\n"); | 346 builder->fsCodeAppend("\tif (uv_len2 < 0.0001) {\n"); |
339 builder->fsCodeAppend("\t\tuv_grad = vec2(0.7071, 0.7071);\n"); | 347 builder->fsCodeAppend("\t\tuv_grad = vec2(0.7071, 0.7071);\n"); |
340 builder->fsCodeAppend("\t} else {\n"); | 348 builder->fsCodeAppend("\t} else {\n"); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 SkASSERT(fTextureSizeUni.isValid()); | 394 SkASSERT(fTextureSizeUni.isValid()); |
387 SkASSERT(fTextColorUni.isValid()); | 395 SkASSERT(fTextColorUni.isValid()); |
388 | 396 |
389 const GrDistanceFieldLCDTextureEffect& dfTexEffect = | 397 const GrDistanceFieldLCDTextureEffect& dfTexEffect = |
390 drawEffect.castEffect<GrDistanceFieldLCDText
ureEffect>(); | 398 drawEffect.castEffect<GrDistanceFieldLCDText
ureEffect>(); |
391 GrTexture* texture = drawEffect.effect()->texture(0); | 399 GrTexture* texture = drawEffect.effect()->texture(0); |
392 if (texture->width() != fTextureSize.width() || | 400 if (texture->width() != fTextureSize.width() || |
393 texture->height() != fTextureSize.height()) { | 401 texture->height() != fTextureSize.height()) { |
394 fTextureSize = SkISize::Make(texture->width(), texture->height()); | 402 fTextureSize = SkISize::Make(texture->width(), texture->height()); |
395 float delta = 1.0f/(3.0f*texture->width()); | 403 float delta = 1.0f/(3.0f*texture->width()); |
396 if (dfTexEffect.useBGR()) { | 404 if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) { |
397 delta = -delta; | 405 delta = -delta; |
398 } | 406 } |
399 pdman.set3f(fTextureSizeUni, | 407 pdman.set3f(fTextureSizeUni, |
400 SkIntToScalar(fTextureSize.width()), | 408 SkIntToScalar(fTextureSize.width()), |
401 SkIntToScalar(fTextureSize.height()), | 409 SkIntToScalar(fTextureSize.height()), |
402 delta); | 410 delta); |
403 } | 411 } |
404 | 412 |
405 GrColor textColor = dfTexEffect.getTextColor(); | 413 GrColor textColor = dfTexEffect.getTextColor(); |
406 if (textColor != fTextColor) { | 414 if (textColor != fTextColor) { |
407 static const float ONE_OVER_255 = 1.f / 255.f; | 415 static const float ONE_OVER_255 = 1.f / 255.f; |
408 pdman.set3f(fTextColorUni, | 416 pdman.set3f(fTextColorUni, |
409 GrColorUnpackR(textColor) * ONE_OVER_255, | 417 GrColorUnpackR(textColor) * ONE_OVER_255, |
410 GrColorUnpackG(textColor) * ONE_OVER_255, | 418 GrColorUnpackG(textColor) * ONE_OVER_255, |
411 GrColorUnpackB(textColor) * ONE_OVER_255); | 419 GrColorUnpackB(textColor) * ONE_OVER_255); |
412 fTextColor = textColor; | 420 fTextColor = textColor; |
413 } | 421 } |
414 } | 422 } |
415 | 423 |
416 static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, | 424 static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, |
417 GrEffectKeyBuilder* b) { | 425 GrEffectKeyBuilder* b) { |
418 const GrDistanceFieldLCDTextureEffect& dfTexEffect = | 426 const GrDistanceFieldLCDTextureEffect& dfTexEffect = |
419 drawEffect.castEffect<GrDistanceField
LCDTextureEffect>(); | 427 drawEffect.castEffect<GrDistanceField
LCDTextureEffect>(); |
420 | 428 |
421 b->add32(dfTexEffect.isUniformScale()); | 429 b->add32(dfTexEffect.getFlags()); |
422 } | 430 } |
423 | 431 |
424 private: | 432 private: |
425 GrGLProgramDataManager::UniformHandle fTextureSizeUni; | 433 GrGLProgramDataManager::UniformHandle fTextureSizeUni; |
426 SkISize fTextureSize; | 434 SkISize fTextureSize; |
427 GrGLProgramDataManager::UniformHandle fTextColorUni; | 435 GrGLProgramDataManager::UniformHandle fTextColorUni; |
428 SkColor fTextColor; | 436 SkColor fTextColor; |
429 | 437 |
430 typedef GrGLVertexEffect INHERITED; | 438 typedef GrGLVertexEffect INHERITED; |
431 }; | 439 }; |
432 | 440 |
433 /////////////////////////////////////////////////////////////////////////////// | 441 /////////////////////////////////////////////////////////////////////////////// |
434 | 442 |
435 GrDistanceFieldLCDTextureEffect::GrDistanceFieldLCDTextureEffect( | 443 GrDistanceFieldLCDTextureEffect::GrDistanceFieldLCDTextureEffect( |
436 GrTexture* texture, const GrTe
xtureParams& params, | 444 GrTexture* texture, const GrTe
xtureParams& params, |
437 GrTexture* gamma, const GrText
ureParams& gParams, | 445 GrTexture* gamma, const GrText
ureParams& gParams, |
438 SkColor textColor, | 446 SkColor textColor, |
439 bool uniformScale, bool useBGR
) | 447 uint32_t flags) |
440 : fTextureAccess(texture, params) | 448 : fTextureAccess(texture, params) |
441 , fGammaTextureAccess(gamma, gParams) | 449 , fGammaTextureAccess(gamma, gParams) |
442 , fTextColor(textColor) | 450 , fTextColor(textColor) |
443 , fUniformScale(uniformScale) | 451 , fFlags(flags & kLCD_DistanceFieldEffectMask) { |
444 , fUseBGR(useBGR) { | 452 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); |
| 453 |
445 this->addTextureAccess(&fTextureAccess); | 454 this->addTextureAccess(&fTextureAccess); |
446 this->addTextureAccess(&fGammaTextureAccess); | 455 this->addTextureAccess(&fGammaTextureAccess); |
447 this->addVertexAttrib(kVec2f_GrSLType); | 456 this->addVertexAttrib(kVec2f_GrSLType); |
448 } | 457 } |
449 | 458 |
450 bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrEffect& other) const { | 459 bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrEffect& other) const { |
451 const GrDistanceFieldLCDTextureEffect& cte = | 460 const GrDistanceFieldLCDTextureEffect& cte = |
452 CastEffect<GrDistanceFieldLCDTexture
Effect>(other); | 461 CastEffect<GrDistanceFieldLCDTexture
Effect>(other); |
453 return (fTextureAccess == cte.fTextureAccess && fGammaTextureAccess == cte.f
GammaTextureAccess); | 462 return (fTextureAccess == cte.fTextureAccess && |
| 463 fGammaTextureAccess == cte.fGammaTextureAccess && |
| 464 fTextColor == cte.fTextColor && |
| 465 fFlags == cte.fFlags); |
454 } | 466 } |
455 | 467 |
456 void GrDistanceFieldLCDTextureEffect::getConstantColorComponents(GrColor* color, | 468 void GrDistanceFieldLCDTextureEffect::getConstantColorComponents(GrColor* color, |
457 uint32_t* valid
Flags) const { | 469 uint32_t* valid
Flags) const { |
458 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && | 470 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && |
459 GrPixelConfigIsOpaque(this->texture(0)->config())) { | 471 GrPixelConfigIsOpaque(this->texture(0)->config())) { |
460 *validFlags = kA_GrColorComponentFlag; | 472 *validFlags = kA_GrColorComponentFlag; |
461 } else { | 473 } else { |
462 *validFlags = 0; | 474 *validFlags = 0; |
463 } | 475 } |
(...skipping 25 matching lines...) Expand all Loading... |
489 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 501 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
490 }; | 502 }; |
491 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 503 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
492 GrTextureParams::kNone_FilterMode); | 504 GrTextureParams::kNone_FilterMode); |
493 GrTextureParams params2(tileModes, random->nextBool() ? GrTextureParams::kBi
lerp_FilterMode : | 505 GrTextureParams params2(tileModes, random->nextBool() ? GrTextureParams::kBi
lerp_FilterMode : |
494 GrTextureParams::kNone_FilterMode); | 506 GrTextureParams::kNone_FilterMode); |
495 GrColor textColor = GrColorPackRGBA(random->nextULessThan(256), | 507 GrColor textColor = GrColorPackRGBA(random->nextULessThan(256), |
496 random->nextULessThan(256), | 508 random->nextULessThan(256), |
497 random->nextULessThan(256), | 509 random->nextULessThan(256), |
498 random->nextULessThan(256)); | 510 random->nextULessThan(256)); |
| 511 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 512 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 513 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
499 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, | 514 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, |
500 textures[texIdx2], params2, | 515 textures[texIdx2], params2, |
501 textColor, | 516 textColor, |
502 random->nextBool(), random->n
extBool()); | 517 flags); |
503 } | 518 } |
OLD | NEW |