| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrAtlasTextBatch.h" | 8 #include "GrAtlasTextBatch.h" |
| 9 | 9 |
| 10 #include "GrBatchFontCache.h" | 10 #include "GrBatchFontCache.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_F
ilterMode); | 508 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_F
ilterMode); |
| 509 bool isLCD = this->isLCD(); | 509 bool isLCD = this->isLCD(); |
| 510 // set up any flags | 510 // set up any flags |
| 511 uint32_t flags = viewMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffect
Flag : 0; | 511 uint32_t flags = viewMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffect
Flag : 0; |
| 512 | 512 |
| 513 // see if we need to create a new effect | 513 // see if we need to create a new effect |
| 514 if (isLCD) { | 514 if (isLCD) { |
| 515 flags |= kUseLCD_DistanceFieldEffectFlag; | 515 flags |= kUseLCD_DistanceFieldEffectFlag; |
| 516 flags |= viewMatrix.rectStaysRect() ? kRectToRect_DistanceFieldEffectFla
g : 0; | 516 flags |= viewMatrix.rectStaysRect() ? kRectToRect_DistanceFieldEffectFla
g : 0; |
| 517 flags |= fUseBGR ? kBGR_DistanceFieldEffectFlag : 0; | 517 flags |= fUseBGR ? kBGR_DistanceFieldEffectFlag : 0; |
| 518 flags |= kColorAttr_DistanceFieldEffectFlag; | |
| 519 | 518 |
| 520 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor); | 519 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor); |
| 521 | 520 |
| 522 float redCorrection = | 521 float redCorrection = |
| 523 (*fDistanceAdjustTable)[GrColorUnpackR(colorNoPreMul) >> kDistanceAd
justLumShift]; | 522 (*fDistanceAdjustTable)[GrColorUnpackR(colorNoPreMul) >> kDistanceAd
justLumShift]; |
| 524 float greenCorrection = | 523 float greenCorrection = |
| 525 (*fDistanceAdjustTable)[GrColorUnpackG(colorNoPreMul) >> kDistanceAd
justLumShift]; | 524 (*fDistanceAdjustTable)[GrColorUnpackG(colorNoPreMul) >> kDistanceAd
justLumShift]; |
| 526 float blueCorrection = | 525 float blueCorrection = |
| 527 (*fDistanceAdjustTable)[GrColorUnpackB(colorNoPreMul) >> kDistanceAd
justLumShift]; | 526 (*fDistanceAdjustTable)[GrColorUnpackB(colorNoPreMul) >> kDistanceAd
justLumShift]; |
| 528 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust = | 527 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust = |
| 529 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrection, | 528 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrection, |
| 530 greenCorrection, | 529 greenCorrection, |
| 531 blueCorrection); | 530 blueCorrection); |
| 532 | 531 |
| 533 return GrDistanceFieldLCDTextGeoProc::Create(color, | 532 return GrDistanceFieldLCDTextGeoProc::Create(color, |
| 534 viewMatrix, | 533 viewMatrix, |
| 535 texture, | 534 texture, |
| 536 params, | 535 params, |
| 537 widthAdjust, | 536 widthAdjust, |
| 538 flags, | 537 flags, |
| 539 this->usesLocalCoords()); | 538 this->usesLocalCoords()); |
| 540 } else { | 539 } else { |
| 541 flags |= kColorAttr_DistanceFieldEffectFlag; | |
| 542 #ifdef SK_GAMMA_APPLY_TO_A8 | 540 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 543 U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, f
ilteredColor); | 541 U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, f
ilteredColor); |
| 544 float correction = (*fDistanceAdjustTable)[lum >> kDistanceAdjustLumShif
t]; | 542 float correction = (*fDistanceAdjustTable)[lum >> kDistanceAdjustLumShif
t]; |
| 545 return GrDistanceFieldA8TextGeoProc::Create(color, | 543 return GrDistanceFieldA8TextGeoProc::Create(color, |
| 546 viewMatrix, | 544 viewMatrix, |
| 547 texture, | 545 texture, |
| 548 params, | 546 params, |
| 549 correction, | 547 correction, |
| 550 flags, | 548 flags, |
| 551 this->usesLocalCoords()); | 549 this->usesLocalCoords()); |
| 552 #else | 550 #else |
| 553 return GrDistanceFieldA8TextGeoProc::Create(color, | 551 return GrDistanceFieldA8TextGeoProc::Create(color, |
| 554 viewMatrix, | 552 viewMatrix, |
| 555 texture, | 553 texture, |
| 556 params, | 554 params, |
| 557 flags, | 555 flags, |
| 558 this->usesLocalCoords()); | 556 this->usesLocalCoords()); |
| 559 #endif | 557 #endif |
| 560 } | 558 } |
| 561 | 559 |
| 562 } | 560 } |
| OLD | NEW |