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 fEffectTextureUniqueID = SK_InvalidUniqueID; |
60 | 60 |
61 fVertices = NULL; | 61 fVertices = NULL; |
62 fMaxVertices = 0; | 62 fMaxVertices = 0; |
63 | 63 |
64 fVertexBounds.setLargestInverted(); | 64 fVertexBounds.setLargestInverted(); |
65 } | 65 } |
66 | 66 |
67 GrBitmapTextContext::~GrBitmapTextContext() { | 67 GrBitmapTextContext::~GrBitmapTextContext() { |
68 this->flushGlyphs(); | 68 this->flushGlyphs(); |
69 } | 69 } |
(...skipping 17 matching lines...) Expand all Loading... |
87 GrDrawState* drawState = fDrawTarget->drawState(); | 87 GrDrawState* drawState = fDrawTarget->drawState(); |
88 GrDrawState::AutoRestoreEffects are(drawState); | 88 GrDrawState::AutoRestoreEffects are(drawState); |
89 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); | 89 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
90 | 90 |
91 if (fCurrVertex > 0) { | 91 if (fCurrVertex > 0) { |
92 // setup our sampler state for our text texture/atlas | 92 // setup our sampler state for our text texture/atlas |
93 SkASSERT(SkIsAlign4(fCurrVertex)); | 93 SkASSERT(SkIsAlign4(fCurrVertex)); |
94 SkASSERT(fCurrTexture); | 94 SkASSERT(fCurrTexture); |
95 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 95 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
96 | 96 |
97 uint32_t textureGenID = fCurrTexture->getGenerationID(); | 97 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
98 | 98 |
99 if (textureGenID != fEffectTextureGenID) { | 99 if (textureUniqueID != fEffectTextureUniqueID) { |
100 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture
, params)); | 100 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture
, params)); |
101 fEffectTextureGenID = textureGenID; | 101 fEffectTextureUniqueID = textureUniqueID; |
102 } | 102 } |
103 | 103 |
104 // This effect could be stored with one of the cache objects (atlas?) | 104 // This effect could be stored with one of the cache objects (atlas?) |
105 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC
olorAttributeIndex : | 105 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC
olorAttributeIndex : |
106 kGlyphCoordsNoCol
orAttributeIndex; | 106 kGlyphCoordsNoCol
orAttributeIndex; |
107 drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx); | 107 drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx); |
108 SkASSERT(NULL != fStrike); | 108 SkASSERT(NULL != fStrike); |
109 switch (fStrike->getMaskFormat()) { | 109 switch (fStrike->getMaskFormat()) { |
110 // Color bitmap text | 110 // Color bitmap text |
111 case kARGB_GrMaskFormat: | 111 case kARGB_GrMaskFormat: |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 if (useColorVerts) { | 596 if (useColorVerts) { |
597 // color comes after position. | 597 // color comes after position. |
598 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); | 598 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); |
599 for (int i = 0; i < 4; ++i) { | 599 for (int i = 0; i < 4; ++i) { |
600 *colors = fPaint.getColor(); | 600 *colors = fPaint.getColor(); |
601 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors
) + vertSize); | 601 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors
) + vertSize); |
602 } | 602 } |
603 } | 603 } |
604 fCurrVertex += 4; | 604 fCurrVertex += 4; |
605 } | 605 } |
OLD | NEW |