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 default: | 555 default: |
556 SkFAIL("Unexpected mask format."); | 556 SkFAIL("Unexpected mask format."); |
557 } | 557 } |
558 | 558 |
559 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 559 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
560 // TODO cache these GPs | 560 // TODO cache these GPs |
561 if (kARGB_GrMaskFormat == fCurrMaskFormat) { | 561 if (kARGB_GrMaskFormat == fCurrMaskFormat) { |
562 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 562 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
563 if (textureUniqueID != fEffectTextureUniqueID || | 563 if (textureUniqueID != fEffectTextureUniqueID || |
564 fCachedGeometryProcessor->getColor() != color) { | 564 fCachedGeometryProcessor->color() != color) { |
565 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; | 565 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; |
566 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c
olor, flags)); | 566 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c
olor, flags)); |
567 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, | 567 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, |
568 SkMa
trix::I(), | 568 SkMa
trix::I(), |
569 para
ms)); | 569 para
ms)); |
570 } | 570 } |
571 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); | |
572 drawState.addColorProcessor(fCachedTextureProcessor.get()); | 571 drawState.addColorProcessor(fCachedTextureProcessor.get()); |
573 } else { | 572 } else { |
574 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 573 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
575 if (textureUniqueID != fEffectTextureUniqueID || | 574 if (textureUniqueID != fEffectTextureUniqueID || |
576 fCachedGeometryProcessor->getColor() != color) { | 575 fCachedGeometryProcessor->color() != color) { |
577 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; | 576 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; |
578 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, | 577 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, |
579
fCurrTexture, | 578
fCurrTexture, |
580
params, | 579
params, |
581
hasColor)); | 580
hasColor)); |
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 |