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 "GrBitmapTextContext.h" | 8 #include "GrBitmapTextContext.h" |
9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
10 #include "GrDefaultGeoProcFactory.h" | 10 #include "GrDefaultGeoProcFactory.h" |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 fEffectTextureUniqueID = textureUniqueID; | 554 fEffectTextureUniqueID = textureUniqueID; |
555 } | 555 } |
556 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); | 556 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); |
557 } | 557 } |
558 | 558 |
559 SkASSERT(fStrike); | 559 SkASSERT(fStrike); |
560 switch (fCurrMaskFormat) { | 560 switch (fCurrMaskFormat) { |
561 // Color bitmap text | 561 // Color bitmap text |
562 case kARGB_GrMaskFormat: | 562 case kARGB_GrMaskFormat: |
563 SkASSERT(!drawState.hasColorVertexAttribute()); | 563 SkASSERT(!drawState.hasColorVertexAttribute()); |
| 564 drawState.setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstB
lendCoeff()); |
564 drawState.setAlpha(fSkPaint.getAlpha()); | 565 drawState.setAlpha(fSkPaint.getAlpha()); |
565 break; | 566 break; |
566 // LCD text | 567 // LCD text |
567 case kA565_GrMaskFormat: { | 568 case kA565_GrMaskFormat: { |
568 // TODO: move supportsRGBCoverage check to setupCoverageEffect a
nd only add LCD | 569 // TODO: move supportsRGBCoverage check to setupCoverageEffect a
nd only add LCD |
569 // processor if the xp can support it. For now we will simply as
sume that if | 570 // processor if the xp can support it. For now we will simply as
sume that if |
570 // fUseLCDText is true, then we have a known color output. | 571 // fUseLCDText is true, then we have a known color output. |
571 if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrCo
lorComponentFlags)) { | 572 if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrCo
lorComponentFlags)) { |
572 SkDebugf("LCD Text will not draw correctly.\n"); | 573 SkDebugf("LCD Text will not draw correctly.\n"); |
573 } | 574 } |
574 SkASSERT(!drawState.hasColorVertexAttribute()); | 575 SkASSERT(!drawState.hasColorVertexAttribute()); |
| 576 // We don't use the GrPaint's color in this case because it's be
en premultiplied by |
| 577 // alpha. Instead we feed in a non-premultiplied color, and mult
iply its alpha by |
| 578 // the mask texture color. The end result is that we get |
| 579 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*d
stColor |
| 580 int a = SkColorGetA(fSkPaint.getColor()); |
| 581 // paintAlpha |
| 582 drawState.setColor(SkColorSetARGB(a, a, a, a)); |
| 583 // paintColor |
| 584 drawState.setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkP
aint.getColor())); |
| 585 drawState.setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); |
575 break; | 586 break; |
576 } | 587 } |
577 // Grayscale/BW text | 588 // Grayscale/BW text |
578 case kA8_GrMaskFormat: | 589 case kA8_GrMaskFormat: |
579 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, | 590 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, |
580 0xFF == GrColorUnpackA(fPaint.getColor())); | 591 0xFF == GrColorUnpackA(fPaint.getColor())); |
| 592 // set back to normal in case we took LCD path previously. |
| 593 drawState.setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstB
lendCoeff()); |
581 // We're using per-vertex color. | 594 // We're using per-vertex color. |
582 SkASSERT(drawState.hasColorVertexAttribute()); | 595 SkASSERT(drawState.hasColorVertexAttribute()); |
583 break; | 596 break; |
584 default: | 597 default: |
585 SkFAIL("Unexpected mask format."); | 598 SkFAIL("Unexpected mask format."); |
586 } | 599 } |
587 int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 600 int nGlyphs = fCurrVertex / kVerticesPerGlyph; |
588 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 601 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
589 fDrawTarget->drawIndexedInstances(&drawState, | 602 fDrawTarget->drawIndexedInstances(&drawState, |
590 kTriangles_GrPrimitiveType, | 603 kTriangles_GrPrimitiveType, |
(...skipping 13 matching lines...) Expand all Loading... |
604 } | 617 } |
605 } | 618 } |
606 | 619 |
607 inline void GrBitmapTextContext::finish() { | 620 inline void GrBitmapTextContext::finish() { |
608 this->flush(); | 621 this->flush(); |
609 fTotalVertexCount = 0; | 622 fTotalVertexCount = 0; |
610 | 623 |
611 GrTextContext::finish(); | 624 GrTextContext::finish(); |
612 } | 625 } |
613 | 626 |
OLD | NEW |