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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; | 396 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; |
397 flags |= fUseLCDText && ctm.rectStaysRect() ? | 397 flags |= fUseLCDText && ctm.rectStaysRect() ? |
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 GrColor color = fPaint.getColor(); |
406 if (fUseLCDText) { | 407 if (fUseLCDText) { |
407 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); | 408 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); |
408 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Crea
te(fCurrTexture, | 409 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Crea
te(color, |
| 410
fCurrTexture, |
409
params, | 411
params, |
410
fGammaTexture, | 412
fGammaTexture, |
411
gammaParams, | 413
gammaParams, |
412
colorNoPreMul, | 414
colorNoPreMul, |
413
flags)); | 415
flags)); |
414 } else { | 416 } else { |
415 flags |= kColorAttr_DistanceFieldEffectFlag; | 417 flags |= kColorAttr_DistanceFieldEffectFlag; |
416 #ifdef SK_GAMMA_APPLY_TO_A8 | 418 #ifdef SK_GAMMA_APPLY_TO_A8 |
417 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie
s.gamma(), | 419 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie
s.gamma(), |
418 filteredColor); | 420 filteredColor); |
419 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create(
fCurrTexture, | 421 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create(
color, |
| 422
fCurrTexture, |
420
params, | 423
params, |
421
fGammaTexture, | 424
fGammaTexture, |
422
gammaParams, | 425
gammaParams, |
423
lum/255.f, | 426
lum/255.f, |
424
flags)); | 427
flags)); |
425 #else | 428 #else |
426 fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::
Create(fCurrTexture, | 429 fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::
Create(color, |
427
params, flags)); | 430
fCurrTexture, |
| 431
params, |
| 432
flags)); |
428 #endif | 433 #endif |
429 } | 434 } |
430 fEffectTextureUniqueID = textureUniqueID; | 435 fEffectTextureUniqueID = textureUniqueID; |
431 fEffectColor = filteredColor; | 436 fEffectColor = filteredColor; |
432 fEffectFlags = flags; | 437 fEffectFlags = flags; |
433 } | 438 } |
434 | 439 |
435 } | 440 } |
436 | 441 |
437 inline bool GrDistanceFieldTextContext::uploadGlyph(GrGlyph* glyph, GrFontScaler
* scaler) { | 442 inline bool GrDistanceFieldTextContext::uploadGlyph(GrGlyph* glyph, GrFontScaler
* scaler) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 } | 673 } |
669 } | 674 } |
670 | 675 |
671 inline void GrDistanceFieldTextContext::finish() { | 676 inline void GrDistanceFieldTextContext::finish() { |
672 this->flush(); | 677 this->flush(); |
673 fTotalVertexCount = 0; | 678 fTotalVertexCount = 0; |
674 | 679 |
675 GrTextContext::finish(); | 680 GrTextContext::finish(); |
676 } | 681 } |
677 | 682 |
OLD | NEW |