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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // TODO: move supportsRGBCoverage check to setupCoverageEffect a
nd only add LCD | 542 // TODO: move supportsRGBCoverage check to setupCoverageEffect a
nd only add LCD |
543 // processor if the xp can support it. For now we will simply as
sume that if | 543 // processor if the xp can support it. For now we will simply as
sume that if |
544 // fUseLCDText is true, then we have a known color output. | 544 // fUseLCDText is true, then we have a known color output. |
545 if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrCo
lorComponentFlags)) { | 545 if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrCo
lorComponentFlags)) { |
546 SkDebugf("LCD Text will not draw correctly.\n"); | 546 SkDebugf("LCD Text will not draw correctly.\n"); |
547 } | 547 } |
548 break; | 548 break; |
549 } | 549 } |
550 // Grayscale/BW text | 550 // Grayscale/BW text |
551 case kA8_GrMaskFormat: | 551 case kA8_GrMaskFormat: |
552 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, | |
553 0xFF == GrColorUnpackA(fPaint.getColor())); | |
554 break; | 552 break; |
555 default: | 553 default: |
556 SkFAIL("Unexpected mask format."); | 554 SkFAIL("Unexpected mask format."); |
557 } | 555 } |
558 | 556 |
559 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 557 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
560 // TODO cache these GPs | 558 // TODO cache these GPs |
561 if (kARGB_GrMaskFormat == fCurrMaskFormat) { | 559 if (kARGB_GrMaskFormat == fCurrMaskFormat) { |
562 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 560 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
563 if (textureUniqueID != fEffectTextureUniqueID || | 561 if (textureUniqueID != fEffectTextureUniqueID || |
564 fCachedGeometryProcessor->getColor() != color) { | 562 fCachedGeometryProcessor->color() != color) { |
565 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; | 563 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; |
566 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c
olor, flags)); | 564 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c
olor, flags)); |
567 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, | 565 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, |
568 SkMa
trix::I(), | 566 SkMa
trix::I(), |
569 para
ms)); | 567 para
ms)); |
570 } | 568 } |
571 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); | |
572 drawState.addColorProcessor(fCachedTextureProcessor.get()); | 569 drawState.addColorProcessor(fCachedTextureProcessor.get()); |
573 } else { | 570 } else { |
574 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 571 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
575 if (textureUniqueID != fEffectTextureUniqueID || | 572 if (textureUniqueID != fEffectTextureUniqueID || |
576 fCachedGeometryProcessor->getColor() != color) { | 573 fCachedGeometryProcessor->color() != color) { |
577 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; | 574 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; |
| 575 bool opaqueVertexColors = GrColorIsOpaque(fPaint.getColor()); |
578 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, | 576 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, |
579
fCurrTexture, | 577 fCurr
Texture, |
580
params, | 578 param
s, |
581
hasColor)); | 579 hasCo
lor, |
| 580 opaqu
eVertexColors)); |
582 fEffectTextureUniqueID = textureUniqueID; | 581 fEffectTextureUniqueID = textureUniqueID; |
583 } | 582 } |
584 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); | |
585 } | 583 } |
586 | 584 |
587 int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 585 int nGlyphs = fCurrVertex / kVerticesPerGlyph; |
588 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 586 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
589 fDrawTarget->drawIndexedInstances(&drawState, | 587 fDrawTarget->drawIndexedInstances(&drawState, |
| 588 fCachedGeometryProcessor.get(), |
590 kTriangles_GrPrimitiveType, | 589 kTriangles_GrPrimitiveType, |
591 nGlyphs, | 590 nGlyphs, |
592 kVerticesPerGlyph, | 591 kVerticesPerGlyph, |
593 kIndicesPerGlyph, | 592 kIndicesPerGlyph, |
594 &fVertexBounds); | 593 &fVertexBounds); |
595 | 594 |
596 fDrawTarget->resetVertexSource(); | 595 fDrawTarget->resetVertexSource(); |
597 fVertices = NULL; | 596 fVertices = NULL; |
598 fAllocVertexCount = 0; | 597 fAllocVertexCount = 0; |
599 // reset to be those that are left | 598 // reset to be those that are left |
600 fTotalVertexCount -= fCurrVertex; | 599 fTotalVertexCount -= fCurrVertex; |
601 fCurrVertex = 0; | 600 fCurrVertex = 0; |
602 fVertexBounds.setLargestInverted(); | 601 fVertexBounds.setLargestInverted(); |
603 SkSafeSetNull(fCurrTexture); | 602 SkSafeSetNull(fCurrTexture); |
604 } | 603 } |
605 } | 604 } |
606 | 605 |
607 inline void GrBitmapTextContext::finish() { | 606 inline void GrBitmapTextContext::finish() { |
608 this->flush(); | 607 this->flush(); |
609 fTotalVertexCount = 0; | 608 fTotalVertexCount = 0; |
610 | 609 |
611 GrTextContext::finish(); | 610 GrTextContext::finish(); |
612 } | 611 } |
613 | 612 |
OLD | NEW |