| 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->color() != color) { | 564 fCachedGeometryProcessor->getColor() != 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()); |
| 571 drawState.addColorProcessor(fCachedTextureProcessor.get()); | 572 drawState.addColorProcessor(fCachedTextureProcessor.get()); |
| 572 } else { | 573 } else { |
| 573 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 574 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
| 574 if (textureUniqueID != fEffectTextureUniqueID || | 575 if (textureUniqueID != fEffectTextureUniqueID || |
| 575 fCachedGeometryProcessor->color() != color) { | 576 fCachedGeometryProcessor->getColor() != color) { |
| 576 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; | 577 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; |
| 577 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, | 578 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color
, |
| 578
fCurrTexture, | 579
fCurrTexture, |
| 579
params, | 580
params, |
| 580
hasColor)); | 581
hasColor)); |
| 581 fEffectTextureUniqueID = textureUniqueID; | 582 fEffectTextureUniqueID = textureUniqueID; |
| 582 } | 583 } |
| 584 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); |
| 583 } | 585 } |
| 584 | 586 |
| 585 int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 587 int nGlyphs = fCurrVertex / kVerticesPerGlyph; |
| 586 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 588 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
| 587 fDrawTarget->drawIndexedInstances(&drawState, | 589 fDrawTarget->drawIndexedInstances(&drawState, |
| 588 fCachedGeometryProcessor.get(), | |
| 589 kTriangles_GrPrimitiveType, | 590 kTriangles_GrPrimitiveType, |
| 590 nGlyphs, | 591 nGlyphs, |
| 591 kVerticesPerGlyph, | 592 kVerticesPerGlyph, |
| 592 kIndicesPerGlyph, | 593 kIndicesPerGlyph, |
| 593 &fVertexBounds); | 594 &fVertexBounds); |
| 594 | 595 |
| 595 fDrawTarget->resetVertexSource(); | 596 fDrawTarget->resetVertexSource(); |
| 596 fVertices = NULL; | 597 fVertices = NULL; |
| 597 fAllocVertexCount = 0; | 598 fAllocVertexCount = 0; |
| 598 // reset to be those that are left | 599 // reset to be those that are left |
| 599 fTotalVertexCount -= fCurrVertex; | 600 fTotalVertexCount -= fCurrVertex; |
| 600 fCurrVertex = 0; | 601 fCurrVertex = 0; |
| 601 fVertexBounds.setLargestInverted(); | 602 fVertexBounds.setLargestInverted(); |
| 602 SkSafeSetNull(fCurrTexture); | 603 SkSafeSetNull(fCurrTexture); |
| 603 } | 604 } |
| 604 } | 605 } |
| 605 | 606 |
| 606 inline void GrBitmapTextContext::finish() { | 607 inline void GrBitmapTextContext::finish() { |
| 607 this->flush(); | 608 this->flush(); |
| 608 fTotalVertexCount = 0; | 609 fTotalVertexCount = 0; |
| 609 | 610 |
| 610 GrTextContext::finish(); | 611 GrTextContext::finish(); |
| 611 } | 612 } |
| 612 | 613 |
| OLD | NEW |