| 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 "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, | 52 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, |
| 53 const SkDeviceProperties& properties) | 53 const SkDeviceProperties& properties) |
| 54 : GrTextContext(context, properties) { | 54 : GrTextContext(context, properties) { |
| 55 fStrike = NULL; | 55 fStrike = NULL; |
| 56 | 56 |
| 57 fCurrTexture = NULL; | 57 fCurrTexture = NULL; |
| 58 fCurrVertex = 0; | 58 fCurrVertex = 0; |
| 59 fEFfectTextureGenID = 0; |
| 59 | 60 |
| 60 fVertices = NULL; | 61 fVertices = NULL; |
| 61 fMaxVertices = 0; | 62 fMaxVertices = 0; |
| 62 | 63 |
| 63 fVertexBounds.setLargestInverted(); | 64 fVertexBounds.setLargestInverted(); |
| 64 } | 65 } |
| 65 | 66 |
| 66 GrBitmapTextContext::~GrBitmapTextContext() { | 67 GrBitmapTextContext::~GrBitmapTextContext() { |
| 67 this->flushGlyphs(); | 68 this->flushGlyphs(); |
| 68 } | 69 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 88 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); | 89 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
| 89 | 90 |
| 90 if (fCurrVertex > 0) { | 91 if (fCurrVertex > 0) { |
| 91 fContext->getFontCache()->updateTextures(); | 92 fContext->getFontCache()->updateTextures(); |
| 92 | 93 |
| 93 // setup our sampler state for our text texture/atlas | 94 // setup our sampler state for our text texture/atlas |
| 94 SkASSERT(SkIsAlign4(fCurrVertex)); | 95 SkASSERT(SkIsAlign4(fCurrVertex)); |
| 95 SkASSERT(fCurrTexture); | 96 SkASSERT(fCurrTexture); |
| 96 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 97 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
| 97 | 98 |
| 99 uint32_t textureGenID = fCurrTexture->getGenerationID(); |
| 100 |
| 101 if (textureGenID != fEFfectTextureGenID) { |
| 102 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture
, params)); |
| 103 fEFfectTextureGenID = textureGenID; |
| 104 } |
| 105 |
| 98 // This effect could be stored with one of the cache objects (atlas?) | 106 // This effect could be stored with one of the cache objects (atlas?) |
| 99 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC
olorAttributeIndex : | 107 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC
olorAttributeIndex : |
| 100 kGlyphCoordsNoCol
orAttributeIndex; | 108 kGlyphCoordsNoCol
orAttributeIndex; |
| 101 drawState->addCoverageEffect( | 109 drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx); |
| 102 GrCustomCoordsTextureEffect::Create(fCurrTexture
, params), | |
| 103 coordsIdx)->unref(); | |
| 104 SkASSERT(NULL != fStrike); | 110 SkASSERT(NULL != fStrike); |
| 105 switch (fStrike->getMaskFormat()) { | 111 switch (fStrike->getMaskFormat()) { |
| 106 // Color bitmap text | 112 // Color bitmap text |
| 107 case kARGB_GrMaskFormat: | 113 case kARGB_GrMaskFormat: |
| 108 SkASSERT(!drawState->hasColorVertexAttribute()); | 114 SkASSERT(!drawState->hasColorVertexAttribute()); |
| 109 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst
BlendCoeff()); | 115 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst
BlendCoeff()); |
| 110 drawState->setColor(0xffffffff); | 116 drawState->setColor(0xffffffff); |
| 111 break; | 117 break; |
| 112 // LCD text | 118 // LCD text |
| 113 case kA888_GrMaskFormat: | 119 case kA888_GrMaskFormat: |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 if (useColorVerts) { | 598 if (useColorVerts) { |
| 593 // color comes after position. | 599 // color comes after position. |
| 594 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); | 600 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); |
| 595 for (int i = 0; i < 4; ++i) { | 601 for (int i = 0; i < 4; ++i) { |
| 596 *colors = fPaint.getColor(); | 602 *colors = fPaint.getColor(); |
| 597 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors
) + vertSize); | 603 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors
) + vertSize); |
| 598 } | 604 } |
| 599 } | 605 } |
| 600 fCurrVertex += 4; | 606 fCurrVertex += 4; |
| 601 } | 607 } |
| OLD | NEW |