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" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 /////////////////////////////////////////////////////////////////////////////// | 190 /////////////////////////////////////////////////////////////////////////////// |
191 | 191 |
192 GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color, | 192 GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color, |
193 const SkMatrix& viewM
atrix, | 193 const SkMatrix& viewM
atrix, |
194 GrTexture* texture, | 194 GrTexture* texture, |
195 const GrTextureParams
& params, | 195 const GrTextureParams
& params, |
196 #ifdef SK_GAMMA_APPLY_TO_A8 | 196 #ifdef SK_GAMMA_APPLY_TO_A8 |
197 float distanceAdjust, | 197 float distanceAdjust, |
198 #endif | 198 #endif |
199 uint32_t flags) | 199 uint32_t flags, bool
opaqueVertexColors) |
200 : INHERITED(color, viewMatrix, SkMatrix::I()) | 200 : INHERITED(color, viewMatrix, SkMatrix::I(), opaqueVertexColors) |
201 , fTextureAccess(texture, params) | 201 , fTextureAccess(texture, params) |
202 #ifdef SK_GAMMA_APPLY_TO_A8 | 202 #ifdef SK_GAMMA_APPLY_TO_A8 |
203 , fDistanceAdjust(distanceAdjust) | 203 , fDistanceAdjust(distanceAdjust) |
204 #endif | 204 #endif |
205 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) | 205 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) |
206 , fInColor(NULL) { | 206 , fInColor(NULL) { |
207 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); | 207 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); |
208 this->initClassID<GrDistanceFieldA8TextGeoProc>(); | 208 this->initClassID<GrDistanceFieldA8TextGeoProc>(); |
209 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 209 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
210 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 210 if (flags & kColorAttr_DistanceFieldEffectFlag) { |
211 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 211 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); |
| 212 this->setHasVertexColor(); |
212 } | 213 } |
213 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 214 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
214 kVec2s_GrVertexAttribT
ype)); | 215 kVec2s_GrVertexAttribT
ype)); |
215 this->addTextureAccess(&fTextureAccess); | 216 this->addTextureAccess(&fTextureAccess); |
216 } | 217 } |
217 | 218 |
| 219 bool GrDistanceFieldA8TextGeoProc::onIsEqual(const GrGeometryProcessor& other) c
onst { |
| 220 const GrDistanceFieldA8TextGeoProc& cte = other.cast<GrDistanceFieldA8TextGe
oProc>(); |
| 221 return |
| 222 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 223 fDistanceAdjust == cte.fDistanceAdjust && |
| 224 #endif |
| 225 fFlags == cte.fFlags; |
| 226 } |
| 227 |
| 228 void GrDistanceFieldA8TextGeoProc::onGetInvariantOutputCoverage(GrInitInvariantO
utput* out) const { |
| 229 out->setUnknownSingleComponent(); |
| 230 } |
| 231 |
218 void GrDistanceFieldA8TextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, | 232 void GrDistanceFieldA8TextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, |
219 const GrGLCaps& caps, | 233 const GrGLCaps& caps, |
220 GrProcessorKeyBuilder* b) c
onst { | 234 GrProcessorKeyBuilder* b) c
onst { |
221 GrGLDistanceFieldA8TextGeoProc::GenKey(*this, bt, caps, b); | 235 GrGLDistanceFieldA8TextGeoProc::GenKey(*this, bt, caps, b); |
222 } | 236 } |
223 | 237 |
224 GrGLPrimitiveProcessor* | 238 GrGLPrimitiveProcessor* |
225 GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt, | 239 GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt, |
226 const GrGLCaps&) const { | 240 const GrGLCaps&) const { |
227 return SkNEW_ARGS(GrGLDistanceFieldA8TextGeoProc, (*this, bt)); | 241 return SkNEW_ARGS(GrGLDistanceFieldA8TextGeoProc, (*this, bt)); |
228 } | 242 } |
229 | 243 |
230 void GrDistanceFieldA8TextGeoProc::initBatchTracker(GrBatchTracker* bt, | 244 void GrDistanceFieldA8TextGeoProc::initBatchTracker(GrBatchTracker* bt, |
231 const GrPipelineInfo& init)
const { | 245 const GrPipelineInfo& init)
const { |
232 DistanceFieldBatchTracker* local = bt->cast<DistanceFieldBatchTracker>(); | 246 DistanceFieldBatchTracker* local = bt->cast<DistanceFieldBatchTracker>(); |
233 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, | 247 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, |
234 SkToBool(fInColor)); | 248 SkToBool(fInColor)); |
235 local->fUsesLocalCoords = init.fUsesLocalCoords; | 249 local->fUsesLocalCoords = init.fUsesLocalCoords; |
236 } | 250 } |
237 | 251 |
| 252 bool GrDistanceFieldA8TextGeoProc::onCanMakeEqual(const GrBatchTracker& m, |
| 253 const GrGeometryProcessor& tha
t, |
| 254 const GrBatchTracker& t) const
{ |
| 255 const DistanceFieldBatchTracker& mine = m.cast<DistanceFieldBatchTracker>(); |
| 256 const DistanceFieldBatchTracker& theirs = t.cast<DistanceFieldBatchTracker>(
); |
| 257 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 258 that, theirs.fUsesLocalCoords) && |
| 259 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 260 theirs.fInputColorType, theirs.fColor); |
| 261 } |
| 262 |
238 /////////////////////////////////////////////////////////////////////////////// | 263 /////////////////////////////////////////////////////////////////////////////// |
239 | 264 |
240 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); | 265 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); |
241 | 266 |
242 GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(SkRandom* random, | 267 GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(SkRandom* random, |
243 GrContext*, | 268 GrContext*, |
244 const GrDrawTarget
Caps&, | 269 const GrDrawTarget
Caps&, |
245 GrTexture* texture
s[]) { | 270 GrTexture* texture
s[]) { |
246 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : | 271 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : |
247 GrProcessorUnitTest::kAlphaTextureIdx; | 272 GrProcessorUnitTest::kAlphaTextureIdx; |
248 static const SkShader::TileMode kTileModes[] = { | 273 static const SkShader::TileMode kTileModes[] = { |
249 SkShader::kClamp_TileMode, | 274 SkShader::kClamp_TileMode, |
250 SkShader::kRepeat_TileMode, | 275 SkShader::kRepeat_TileMode, |
251 SkShader::kMirror_TileMode, | 276 SkShader::kMirror_TileMode, |
252 }; | 277 }; |
253 SkShader::TileMode tileModes[] = { | 278 SkShader::TileMode tileModes[] = { |
254 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 279 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
255 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 280 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
256 }; | 281 }; |
257 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 282 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
258 GrTextureParams::kNon
e_FilterMode); | 283 GrTextureParams::kNon
e_FilterMode); |
259 | 284 |
260 return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(random), | 285 return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(random), |
261 GrProcessorUnitTest::TestMatrix(
random), | 286 GrProcessorUnitTest::TestMatrix(
random), |
262 textures[texIdx], params, | 287 textures[texIdx], params, |
263 #ifdef SK_GAMMA_APPLY_TO_A8 | 288 #ifdef SK_GAMMA_APPLY_TO_A8 |
264 random->nextF(), | 289 random->nextF(), |
265 #endif | 290 #endif |
266 random->nextBool() ? | 291 random->nextBool() ? |
267 kSimilarity_DistanceFieldEff
ectFlag : 0); | 292 kSimilarity_DistanceFieldEff
ectFlag : 0, |
| 293 random->nextBool()); |
268 } | 294 } |
269 | 295 |
270 /////////////////////////////////////////////////////////////////////////////// | 296 /////////////////////////////////////////////////////////////////////////////// |
271 | 297 |
272 struct DistanceFieldPathBatchTracker { | 298 struct DistanceFieldPathBatchTracker { |
273 GrGPInput fInputColorType; | 299 GrGPInput fInputColorType; |
274 GrColor fColor; | 300 GrColor fColor; |
275 bool fUsesLocalCoords; | 301 bool fUsesLocalCoords; |
276 }; | 302 }; |
277 | 303 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 typedef GrGLGeometryProcessor INHERITED; | 441 typedef GrGLGeometryProcessor INHERITED; |
416 }; | 442 }; |
417 | 443 |
418 /////////////////////////////////////////////////////////////////////////////// | 444 /////////////////////////////////////////////////////////////////////////////// |
419 | 445 |
420 GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( | 446 GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( |
421 GrColor color, | 447 GrColor color, |
422 const SkMatrix& viewMatrix, | 448 const SkMatrix& viewMatrix, |
423 GrTexture* texture, | 449 GrTexture* texture, |
424 const GrTextureParams& params, | 450 const GrTextureParams& params, |
425 uint32_t flags) | 451 uint32_t flags, |
426 : INHERITED(color, viewMatrix, SkMatrix::I()) | 452 bool opaqueVertexColors) |
| 453 : INHERITED(color, viewMatrix, SkMatrix::I(), opaqueVertexColors) |
427 , fTextureAccess(texture, params) | 454 , fTextureAccess(texture, params) |
428 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) | 455 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) |
429 , fInColor(NULL) { | 456 , fInColor(NULL) { |
430 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); | 457 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); |
431 this->initClassID<GrDistanceFieldPathGeoProc>(); | 458 this->initClassID<GrDistanceFieldPathGeoProc>(); |
432 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 459 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
433 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 460 if (flags & kColorAttr_DistanceFieldEffectFlag) { |
434 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 461 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); |
| 462 this->setHasVertexColor(); |
435 } | 463 } |
436 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 464 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
437 kVec2f_GrVertexAttribT
ype)); | 465 kVec2f_GrVertexAttribT
ype)); |
438 this->addTextureAccess(&fTextureAccess); | 466 this->addTextureAccess(&fTextureAccess); |
439 } | 467 } |
440 | 468 |
| 469 bool GrDistanceFieldPathGeoProc::onIsEqual(const GrGeometryProcessor& other) con
st { |
| 470 const GrDistanceFieldPathGeoProc& cte = other.cast<GrDistanceFieldPathGeoPro
c>(); |
| 471 return fFlags == cte.fFlags; |
| 472 } |
| 473 |
| 474 void GrDistanceFieldPathGeoProc::onGetInvariantOutputCoverage(GrInitInvariantOut
put* out) const { |
| 475 out->setUnknownSingleComponent(); |
| 476 } |
| 477 |
441 void GrDistanceFieldPathGeoProc::getGLProcessorKey(const GrBatchTracker& bt, | 478 void GrDistanceFieldPathGeoProc::getGLProcessorKey(const GrBatchTracker& bt, |
442 const GrGLCaps& caps, | 479 const GrGLCaps& caps, |
443 GrProcessorKeyBuilder* b) con
st { | 480 GrProcessorKeyBuilder* b) con
st { |
444 GrGLDistanceFieldPathGeoProc::GenKey(*this, bt, caps, b); | 481 GrGLDistanceFieldPathGeoProc::GenKey(*this, bt, caps, b); |
445 } | 482 } |
446 | 483 |
447 GrGLPrimitiveProcessor* | 484 GrGLPrimitiveProcessor* |
448 GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG
LCaps&) const { | 485 GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG
LCaps&) const { |
449 return SkNEW_ARGS(GrGLDistanceFieldPathGeoProc, (*this, bt)); | 486 return SkNEW_ARGS(GrGLDistanceFieldPathGeoProc, (*this, bt)); |
450 } | 487 } |
451 | 488 |
452 void GrDistanceFieldPathGeoProc::initBatchTracker(GrBatchTracker* bt, | 489 void GrDistanceFieldPathGeoProc::initBatchTracker(GrBatchTracker* bt, |
453 const GrPipelineInfo& init) co
nst { | 490 const GrPipelineInfo& init) co
nst { |
454 DistanceFieldPathBatchTracker* local = bt->cast<DistanceFieldPathBatchTracke
r>(); | 491 DistanceFieldPathBatchTracker* local = bt->cast<DistanceFieldPathBatchTracke
r>(); |
455 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, | 492 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, |
456 SkToBool(fInColor)); | 493 SkToBool(fInColor)); |
457 local->fUsesLocalCoords = init.fUsesLocalCoords; | 494 local->fUsesLocalCoords = init.fUsesLocalCoords; |
458 } | 495 } |
459 | 496 |
| 497 bool GrDistanceFieldPathGeoProc::onCanMakeEqual(const GrBatchTracker& m, |
| 498 const GrGeometryProcessor& that, |
| 499 const GrBatchTracker& t) const { |
| 500 const DistanceFieldPathBatchTracker& mine = m.cast<DistanceFieldPathBatchTra
cker>(); |
| 501 const DistanceFieldPathBatchTracker& theirs = t.cast<DistanceFieldPathBatchT
racker>(); |
| 502 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 503 that, theirs.fUsesLocalCoords) && |
| 504 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 505 theirs.fInputColorType, theirs.fColor); |
| 506 } |
| 507 |
460 /////////////////////////////////////////////////////////////////////////////// | 508 /////////////////////////////////////////////////////////////////////////////// |
461 | 509 |
462 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); | 510 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); |
463 | 511 |
464 GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(SkRandom* random, | 512 GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(SkRandom* random, |
465 GrContext*, | 513 GrContext*, |
466 const GrDrawTargetCa
ps&, | 514 const GrDrawTargetCa
ps&, |
467 GrTexture* textures[
]) { | 515 GrTexture* textures[
]) { |
468 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx | 516 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx |
469 : GrProcessorUnitTest::kAlphaTextureIdx; | 517 : GrProcessorUnitTest::kAlphaTextureIdx; |
470 static const SkShader::TileMode kTileModes[] = { | 518 static const SkShader::TileMode kTileModes[] = { |
471 SkShader::kClamp_TileMode, | 519 SkShader::kClamp_TileMode, |
472 SkShader::kRepeat_TileMode, | 520 SkShader::kRepeat_TileMode, |
473 SkShader::kMirror_TileMode, | 521 SkShader::kMirror_TileMode, |
474 }; | 522 }; |
475 SkShader::TileMode tileModes[] = { | 523 SkShader::TileMode tileModes[] = { |
476 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 524 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
477 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 525 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
478 }; | 526 }; |
479 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode | 527 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode |
480 : GrTextureParams::kNon
e_FilterMode); | 528 : GrTextureParams::kNon
e_FilterMode); |
481 | 529 |
482 return GrDistanceFieldPathGeoProc::Create(GrRandomColor(random), | 530 return GrDistanceFieldPathGeoProc::Create(GrRandomColor(random), |
483 GrProcessorUnitTest::TestMatrix(ra
ndom), | 531 GrProcessorUnitTest::TestMatrix(ra
ndom), |
484 textures[texIdx], | 532 textures[texIdx], |
485 params, | 533 params, |
486 random->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0); | 534 random->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0, random->ne
xtBool()); |
487 } | 535 } |
488 | 536 |
489 /////////////////////////////////////////////////////////////////////////////// | 537 /////////////////////////////////////////////////////////////////////////////// |
490 | 538 |
491 struct DistanceFieldLCDBatchTracker { | 539 struct DistanceFieldLCDBatchTracker { |
492 GrGPInput fInputColorType; | 540 GrGPInput fInputColorType; |
493 GrColor fColor; | 541 GrColor fColor; |
494 bool fUsesLocalCoords; | 542 bool fUsesLocalCoords; |
495 }; | 543 }; |
496 | 544 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 , fDistanceAdjust(distanceAdjust) | 744 , fDistanceAdjust(distanceAdjust) |
697 , fFlags(flags & kLCD_DistanceFieldEffectMask){ | 745 , fFlags(flags & kLCD_DistanceFieldEffectMask){ |
698 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); | 746 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); |
699 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); | 747 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); |
700 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 748 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
701 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 749 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
702 kVec2s_GrVertexAttribT
ype)); | 750 kVec2s_GrVertexAttribT
ype)); |
703 this->addTextureAccess(&fTextureAccess); | 751 this->addTextureAccess(&fTextureAccess); |
704 } | 752 } |
705 | 753 |
| 754 bool GrDistanceFieldLCDTextGeoProc::onIsEqual(const GrGeometryProcessor& other)
const { |
| 755 const GrDistanceFieldLCDTextGeoProc& cte = other.cast<GrDistanceFieldLCDText
GeoProc>(); |
| 756 return (fDistanceAdjust == cte.fDistanceAdjust && |
| 757 fFlags == cte.fFlags); |
| 758 } |
| 759 |
| 760 void GrDistanceFieldLCDTextGeoProc::onGetInvariantOutputCoverage(GrInitInvariant
Output* out) const { |
| 761 out->setUnknownFourComponents(); |
| 762 out->setUsingLCDCoverage(); |
| 763 } |
| 764 |
706 void GrDistanceFieldLCDTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, | 765 void GrDistanceFieldLCDTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, |
707 const GrGLCaps& caps, | 766 const GrGLCaps& caps, |
708 GrProcessorKeyBuilder* b)
const { | 767 GrProcessorKeyBuilder* b)
const { |
709 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, bt, caps, b); | 768 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, bt, caps, b); |
710 } | 769 } |
711 | 770 |
712 GrGLPrimitiveProcessor* | 771 GrGLPrimitiveProcessor* |
713 GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt, | 772 GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt, |
714 const GrGLCaps&) const { | 773 const GrGLCaps&) const { |
715 return SkNEW_ARGS(GrGLDistanceFieldLCDTextGeoProc, (*this, bt)); | 774 return SkNEW_ARGS(GrGLDistanceFieldLCDTextGeoProc, (*this, bt)); |
716 } | 775 } |
717 | 776 |
718 void GrDistanceFieldLCDTextGeoProc::initBatchTracker(GrBatchTracker* bt, | 777 void GrDistanceFieldLCDTextGeoProc::initBatchTracker(GrBatchTracker* bt, |
719 const GrPipelineInfo& init)
const { | 778 const GrPipelineInfo& init)
const { |
720 DistanceFieldLCDBatchTracker* local = bt->cast<DistanceFieldLCDBatchTracker>
(); | 779 DistanceFieldLCDBatchTracker* local = bt->cast<DistanceFieldLCDBatchTracker>
(); |
721 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); | 780 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, false); |
722 local->fUsesLocalCoords = init.fUsesLocalCoords; | 781 local->fUsesLocalCoords = init.fUsesLocalCoords; |
723 } | 782 } |
724 | 783 |
| 784 bool GrDistanceFieldLCDTextGeoProc::onCanMakeEqual(const GrBatchTracker& m, |
| 785 const GrGeometryProcessor& th
at, |
| 786 const GrBatchTracker& t) cons
t { |
| 787 const DistanceFieldLCDBatchTracker& mine = m.cast<DistanceFieldLCDBatchTrack
er>(); |
| 788 const DistanceFieldLCDBatchTracker& theirs = t.cast<DistanceFieldLCDBatchTra
cker>(); |
| 789 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 790 that, theirs.fUsesLocalCoords) && |
| 791 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 792 theirs.fInputColorType, theirs.fColor); |
| 793 } |
| 794 |
725 /////////////////////////////////////////////////////////////////////////////// | 795 /////////////////////////////////////////////////////////////////////////////// |
726 | 796 |
727 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); | 797 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); |
728 | 798 |
729 GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(SkRandom* random, | 799 GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(SkRandom* random, |
730 GrContext*, | 800 GrContext*, |
731 const GrDrawTar
getCaps&, | 801 const GrDrawTar
getCaps&, |
732 GrTexture* text
ures[]) { | 802 GrTexture* text
ures[]) { |
733 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : | 803 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : |
734 GrProcessorUnitTest::kAlphaTextureIdx; | 804 GrProcessorUnitTest::kAlphaTextureIdx; |
(...skipping 11 matching lines...) Expand all Loading... |
746 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; | 816 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; |
747 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 817 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
748 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 818 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
749 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 819 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
750 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(random), | 820 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(random), |
751 GrProcessorUnitTest::TestMatrix
(random), | 821 GrProcessorUnitTest::TestMatrix
(random), |
752 textures[texIdx], params, | 822 textures[texIdx], params, |
753 wa, | 823 wa, |
754 flags); | 824 flags); |
755 } | 825 } |
OLD | NEW |