| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 | 8 |
| 9 | 9 |
| 10 #include "GrTextContext.h" | 10 #include "GrTextContext.h" |
| 11 #include "GrAtlas.h" | 11 #include "GrAtlas.h" |
| 12 #include "GrContext.h" | 12 #include "GrContext.h" |
| 13 #include "GrDrawTarget.h" | 13 #include "GrDrawTarget.h" |
| 14 #include "GrFontScaler.h" | 14 #include "GrFontScaler.h" |
| 15 #include "GrIndexBuffer.h" | 15 #include "GrIndexBuffer.h" |
| 16 #include "GrTextStrike.h" | 16 #include "GrTextStrike.h" |
| 17 #include "GrTextStrike_impl.h" | 17 #include "GrTextStrike_impl.h" |
| 18 #include "SkPath.h" | 18 #include "SkPath.h" |
| 19 #include "SkStrokeRec.h" | 19 #include "SkStrokeRec.h" |
| 20 #include "effects/GrCustomCoordsTextureEffect.h" |
| 20 | 21 |
| 21 static const int kGlyphCoordsAttributeIndex = 1; | 22 static const int kGlyphCoordsAttributeIndex = 1; |
| 22 | 23 |
| 23 void GrTextContext::flushGlyphs() { | 24 void GrTextContext::flushGlyphs() { |
| 24 if (NULL == fDrawTarget) { | 25 if (NULL == fDrawTarget) { |
| 25 return; | 26 return; |
| 26 } | 27 } |
| 27 | 28 |
| 28 GrDrawState* drawState = fDrawTarget->drawState(); | 29 GrDrawState* drawState = fDrawTarget->drawState(); |
| 29 GrDrawState::AutoRestoreEffects are(drawState); | 30 GrDrawState::AutoRestoreEffects are(drawState); |
| 30 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); | 31 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
| 31 | 32 |
| 32 if (fCurrVertex > 0) { | 33 if (fCurrVertex > 0) { |
| 33 // setup our sampler state for our text texture/atlas | 34 // setup our sampler state for our text texture/atlas |
| 34 SkASSERT(GrIsALIGN4(fCurrVertex)); | 35 SkASSERT(GrIsALIGN4(fCurrVertex)); |
| 35 SkASSERT(fCurrTexture); | 36 SkASSERT(fCurrTexture); |
| 36 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 37 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
| 37 | 38 |
| 38 // This effect could be stored with one of the cache objects (atlas?) | 39 // This effect could be stored with one of the cache objects (atlas?) |
| 39 drawState->addCoverageEffect( | 40 drawState->addCoverageEffect( |
| 40 GrSimpleTextureEffect::CreateWithCustomCoords(fC
urrTexture, params), | 41 GrCustomCoordsTextureEffect::Create(fCurrTexture
, params), |
| 41 kGlyphCoordsAttributeIndex)->unref(); | 42 kGlyphCoordsAttributeIndex)->unref(); |
| 42 | 43 |
| 43 if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { | 44 if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { |
| 44 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || | 45 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || |
| 45 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || | 46 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || |
| 46 fPaint.numColorStages()) { | 47 fPaint.numColorStages()) { |
| 47 GrPrintf("LCD Text will not draw correctly.\n"); | 48 GrPrintf("LCD Text will not draw correctly.\n"); |
| 48 } | 49 } |
| 49 // setup blend so that we get mask * paintColor + (1-mask)*dstColor | 50 // setup blend so that we get mask * paintColor + (1-mask)*dstColor |
| 50 drawState->setBlendConstant(fPaint.getColor()); | 51 drawState->setBlendConstant(fPaint.getColor()); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 SkFixedToFloat(vx + width), | 249 SkFixedToFloat(vx + width), |
| 249 SkFixedToFloat(vy + height), | 250 SkFixedToFloat(vy + height), |
| 250 2 * sizeof(SkPoint)); | 251 2 * sizeof(SkPoint)); |
| 251 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed
X(tx)), | 252 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed
X(tx)), |
| 252 SkFixedToFloat(texture->normalizeFixed
Y(ty)), | 253 SkFixedToFloat(texture->normalizeFixed
Y(ty)), |
| 253 SkFixedToFloat(texture->normalizeFixed
X(tx + width)), | 254 SkFixedToFloat(texture->normalizeFixed
X(tx + width)), |
| 254 SkFixedToFloat(texture->normalizeFixed
Y(ty + height)), | 255 SkFixedToFloat(texture->normalizeFixed
Y(ty + height)), |
| 255 2 * sizeof(SkPoint)); | 256 2 * sizeof(SkPoint)); |
| 256 fCurrVertex += 4; | 257 fCurrVertex += 4; |
| 257 } | 258 } |
| OLD | NEW |