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