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 break; | 554 break; |
555 } | 555 } |
556 // Grayscale/BW text | 556 // Grayscale/BW text |
557 case kA8_GrMaskFormat: | 557 case kA8_GrMaskFormat: |
558 break; | 558 break; |
559 default: | 559 default: |
560 SkFAIL("Unexpected mask format."); | 560 SkFAIL("Unexpected mask format."); |
561 } | 561 } |
562 | 562 |
563 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 563 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
564 if (kARGB_GrMaskFormat == fCurrMaskFormat) { | 564 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
565 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 565 if (textureUniqueID != fEffectTextureUniqueID || |
566 if (textureUniqueID != fEffectTextureUniqueID || | 566 fCachedGeometryProcessor->color() != color || |
567 fCachedGeometryProcessor->color() != color) { | 567 !fCachedGeometryProcessor->localMatrix().cheapEqualTo(fLocalMatrix))
{ |
568 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; | 568 // This will be ignored in the non A8 case |
569 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(f
lags, color)); | 569 bool opaqueVertexColors = GrColorIsOpaque(fPaint.getColor()); |
570 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, | 570 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color, |
571 SkMa
trix::I(), | 571 fCurrText
ure, |
572 para
ms)); | 572 params, |
573 fEffectTextureUniqueID = textureUniqueID; | 573 fCurrMask
Format, |
574 } | 574 opaqueVer
texColors, |
575 pipelineBuilder.addColorProcessor(fCachedTextureProcessor.get()); | 575 fLocalMat
rix)); |
576 } else { | 576 fEffectTextureUniqueID = textureUniqueID; |
577 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | |
578 if (textureUniqueID != fEffectTextureUniqueID || | |
579 fCachedGeometryProcessor->color() != color || | |
580 !fCachedGeometryProcessor->localMatrix().cheapEqualTo(fLocalMatr
ix)) { | |
581 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; | |
582 bool opaqueVertexColors = GrColorIsOpaque(fPaint.getColor()); | |
583 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, | |
584 fCurr
Texture, | |
585 param
s, | |
586 hasCo
lor, | |
587 opaqu
eVertexColors, | |
588 fLoca
lMatrix)); | |
589 fEffectTextureUniqueID = textureUniqueID; | |
590 } | |
591 } | 577 } |
592 | 578 |
593 int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 579 int nGlyphs = fCurrVertex / kVerticesPerGlyph; |
594 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 580 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
595 fDrawTarget->drawIndexedInstances(&pipelineBuilder, | 581 fDrawTarget->drawIndexedInstances(&pipelineBuilder, |
596 fCachedGeometryProcessor.get(), | 582 fCachedGeometryProcessor.get(), |
597 kTriangles_GrPrimitiveType, | 583 kTriangles_GrPrimitiveType, |
598 nGlyphs, | 584 nGlyphs, |
599 kVerticesPerGlyph, | 585 kVerticesPerGlyph, |
600 kIndicesPerGlyph, | 586 kIndicesPerGlyph, |
(...skipping 10 matching lines...) Expand all Loading... |
611 } | 597 } |
612 } | 598 } |
613 | 599 |
614 inline void GrBitmapTextContext::finish() { | 600 inline void GrBitmapTextContext::finish() { |
615 this->flush(); | 601 this->flush(); |
616 fTotalVertexCount = 0; | 602 fTotalVertexCount = 0; |
617 | 603 |
618 GrTextContext::finish(); | 604 GrTextContext::finish(); |
619 } | 605 } |
620 | 606 |
OLD | NEW |