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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 fCurrVertex += 4; | 521 fCurrVertex += 4; |
522 } | 522 } |
523 | 523 |
524 void GrBitmapTextContext::flush() { | 524 void GrBitmapTextContext::flush() { |
525 if (NULL == fDrawTarget) { | 525 if (NULL == fDrawTarget) { |
526 return; | 526 return; |
527 } | 527 } |
528 | 528 |
529 if (fCurrVertex > 0) { | 529 if (fCurrVertex > 0) { |
530 GrDrawState drawState; | 530 GrDrawState drawState; |
531 drawState.setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget(
)); | 531 drawState.setFromPaint(fPaint, fContext->getRenderTarget()); |
532 | 532 |
533 // setup our sampler state for our text texture/atlas | 533 // setup our sampler state for our text texture/atlas |
534 SkASSERT(SkIsAlign4(fCurrVertex)); | 534 SkASSERT(SkIsAlign4(fCurrVertex)); |
535 SkASSERT(fCurrTexture); | 535 SkASSERT(fCurrTexture); |
536 | 536 |
537 SkASSERT(fStrike); | 537 SkASSERT(fStrike); |
538 GrColor color = fPaint.getColor(); | 538 GrColor color = fPaint.getColor(); |
539 switch (fCurrMaskFormat) { | 539 switch (fCurrMaskFormat) { |
540 // Color bitmap text | 540 // Color bitmap text |
541 case kARGB_GrMaskFormat: { | 541 case kARGB_GrMaskFormat: { |
(...skipping 17 matching lines...) Expand all Loading... |
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 if (kARGB_GrMaskFormat == fCurrMaskFormat) { |
565 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 565 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
566 if (textureUniqueID != fEffectTextureUniqueID || | 566 if (textureUniqueID != fEffectTextureUniqueID || |
567 fCachedGeometryProcessor->color() != color) { | 567 fCachedGeometryProcessor->color() != color) { |
568 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; | 568 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; |
569 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c
olor, flags)); | 569 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(f
lags, color)); |
570 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, | 570 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur
rTexture, |
571 SkMa
trix::I(), | 571 SkMa
trix::I(), |
572 para
ms)); | 572 para
ms)); |
573 fEffectTextureUniqueID = textureUniqueID; | 573 fEffectTextureUniqueID = textureUniqueID; |
574 } | 574 } |
575 drawState.addColorProcessor(fCachedTextureProcessor.get()); | 575 drawState.addColorProcessor(fCachedTextureProcessor.get()); |
576 } else { | 576 } else { |
577 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 577 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
578 if (textureUniqueID != fEffectTextureUniqueID || | 578 if (textureUniqueID != fEffectTextureUniqueID || |
579 fCachedGeometryProcessor->color() != color || | 579 fCachedGeometryProcessor->color() != color || |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 611 } |
612 } | 612 } |
613 | 613 |
614 inline void GrBitmapTextContext::finish() { | 614 inline void GrBitmapTextContext::finish() { |
615 this->flush(); | 615 this->flush(); |
616 fTotalVertexCount = 0; | 616 fTotalVertexCount = 0; |
617 | 617 |
618 GrTextContext::finish(); | 618 GrTextContext::finish(); |
619 } | 619 } |
620 | 620 |
OLD | NEW |