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