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 "GrDistanceFieldTextContext.h" | 8 #include "GrDistanceFieldTextContext.h" |
9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
10 #include "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 kRectToRect_DistanceFieldEffectFlag : 0; | 398 kRectToRect_DistanceFieldEffectFlag : 0; |
399 bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.pixelGeometry()); | 399 bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.pixelGeometry()); |
400 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; | 400 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; |
401 | 401 |
402 // see if we need to create a new effect | 402 // see if we need to create a new effect |
403 if (textureUniqueID != fEffectTextureUniqueID || | 403 if (textureUniqueID != fEffectTextureUniqueID || |
404 filteredColor != fEffectColor || | 404 filteredColor != fEffectColor || |
405 flags != fEffectFlags) { | 405 flags != fEffectFlags) { |
406 if (fUseLCDText) { | 406 if (fUseLCDText) { |
407 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); | 407 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); |
408 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Crea
te(fCurrTexture, | 408 |
| 409 // We don't use the GrPaint's color in this case because it's been p
remultiplied by |
| 410 // alpha. Instead we feed in a non-premultiplied color, and multiply
its alpha by |
| 411 // the mask texture color. The end result is that we get |
| 412 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstCo
lor |
| 413 int a = GrColorUnpackA(fSkPaint.getColor()); |
| 414 GrColor color = GrColorPackRGBA(a, a, a, a); |
| 415 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Crea
te(color, |
| 416
fCurrTexture, |
409
params, | 417
params, |
410
fGammaTexture, | 418
fGammaTexture, |
411
gammaParams, | 419
gammaParams, |
412
colorNoPreMul, | 420
colorNoPreMul, |
413
flags)); | 421
flags)); |
414 } else { | 422 } else { |
415 flags |= kColorAttr_DistanceFieldEffectFlag; | 423 flags |= kColorAttr_DistanceFieldEffectFlag; |
| 424 GrColor color = fSkPaint.getColor(); |
416 #ifdef SK_GAMMA_APPLY_TO_A8 | 425 #ifdef SK_GAMMA_APPLY_TO_A8 |
417 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie
s.gamma(), | 426 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie
s.gamma(), |
418 filteredColor); | 427 filteredColor); |
419 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create(
fCurrTexture, | 428 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create(
color, |
| 429
fCurrTexture, |
420
params, | 430
params, |
421
fGammaTexture, | 431
fGammaTexture, |
422
gammaParams, | 432
gammaParams, |
423
lum/255.f, | 433
lum/255.f, |
424
flags)); | 434
flags)); |
425 #else | 435 #else |
426 fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::
Create(fCurrTexture, | 436 fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::
Create(color, |
427
params, flags)); | 437
fCurrTexture, |
| 438
params, |
| 439
flags)); |
428 #endif | 440 #endif |
429 } | 441 } |
430 fEffectTextureUniqueID = textureUniqueID; | 442 fEffectTextureUniqueID = textureUniqueID; |
431 fEffectColor = filteredColor; | 443 fEffectColor = filteredColor; |
432 fEffectFlags = flags; | 444 fEffectFlags = flags; |
433 } | 445 } |
434 | 446 |
435 } | 447 } |
436 | 448 |
437 inline bool GrDistanceFieldTextContext::uploadGlyph(GrGlyph* glyph, GrFontScaler
* scaler) { | 449 inline bool GrDistanceFieldTextContext::uploadGlyph(GrGlyph* glyph, GrFontScaler
* scaler) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 } | 680 } |
669 } | 681 } |
670 | 682 |
671 inline void GrDistanceFieldTextContext::finish() { | 683 inline void GrDistanceFieldTextContext::finish() { |
672 this->flush(); | 684 this->flush(); |
673 fTotalVertexCount = 0; | 685 fTotalVertexCount = 0; |
674 | 686 |
675 GrTextContext::finish(); | 687 GrTextContext::finish(); |
676 } | 688 } |
677 | 689 |
OLD | NEW |