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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 if (kARGB_GrMaskFormat == fCurrMaskFormat) { | 568 if (kARGB_GrMaskFormat == fCurrMaskFormat) { |
569 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 569 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
570 if (textureUniqueID != fEffectTextureUniqueID || | 570 if (textureUniqueID != fEffectTextureUniqueID || |
571 fCachedGeometryProcessor->getColor() != color) { | 571 fCachedGeometryProcessor->getColor() != color) { |
572 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; | 572 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; |
573 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c
olor, flags)); | 573 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c
olor, flags)); |
574 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, | 574 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, |
575 SkMa
trix::I(), | 575 SkMa
trix::I(), |
576 para
ms)); | 576 para
ms)); |
577 } | 577 } |
578 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); | |
579 drawState.addColorProcessor(fCachedTextureProcessor.get()); | 578 drawState.addColorProcessor(fCachedTextureProcessor.get()); |
580 } else { | 579 } else { |
581 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 580 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
582 if (textureUniqueID != fEffectTextureUniqueID || | 581 if (textureUniqueID != fEffectTextureUniqueID || |
583 fCachedGeometryProcessor->getColor() != color) { | 582 fCachedGeometryProcessor->getColor() != color) { |
584 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; | 583 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; |
585 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, | 584 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, |
586
fCurrTexture, | 585
fCurrTexture, |
587
params, | 586
params, |
588
hasColor)); | 587
hasColor)); |
589 fEffectTextureUniqueID = textureUniqueID; | 588 fEffectTextureUniqueID = textureUniqueID; |
590 } | 589 } |
591 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); | |
592 } | 590 } |
593 | 591 |
594 int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 592 int nGlyphs = fCurrVertex / kVerticesPerGlyph; |
595 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 593 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
596 fDrawTarget->drawIndexedInstances(&drawState, | 594 fDrawTarget->drawIndexedInstances(&drawState, |
| 595 fCachedGeometryProcessor.get(), |
597 kTriangles_GrPrimitiveType, | 596 kTriangles_GrPrimitiveType, |
598 nGlyphs, | 597 nGlyphs, |
599 kVerticesPerGlyph, | 598 kVerticesPerGlyph, |
600 kIndicesPerGlyph, | 599 kIndicesPerGlyph, |
601 &fVertexBounds); | 600 &fVertexBounds); |
602 | 601 |
603 fDrawTarget->resetVertexSource(); | 602 fDrawTarget->resetVertexSource(); |
604 fVertices = NULL; | 603 fVertices = NULL; |
605 fAllocVertexCount = 0; | 604 fAllocVertexCount = 0; |
606 // reset to be those that are left | 605 // reset to be those that are left |
607 fTotalVertexCount -= fCurrVertex; | 606 fTotalVertexCount -= fCurrVertex; |
608 fCurrVertex = 0; | 607 fCurrVertex = 0; |
609 fVertexBounds.setLargestInverted(); | 608 fVertexBounds.setLargestInverted(); |
610 SkSafeSetNull(fCurrTexture); | 609 SkSafeSetNull(fCurrTexture); |
611 } | 610 } |
612 } | 611 } |
613 | 612 |
614 inline void GrBitmapTextContext::finish() { | 613 inline void GrBitmapTextContext::finish() { |
615 this->flush(); | 614 this->flush(); |
616 fTotalVertexCount = 0; | 615 fTotalVertexCount = 0; |
617 | 616 |
618 GrTextContext::finish(); | 617 GrTextContext::finish(); |
619 } | 618 } |
620 | 619 |
OLD | NEW |