| Index: src/gpu/GrBitmapTextContext.cpp
|
| diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
|
| index 48054f4eac1ed949e12655435a33e4d22980e487..b1b944a2f57f308cbe3bd5cc4735eb69f1cf5ca8 100755
|
| --- a/src/gpu/GrBitmapTextContext.cpp
|
| +++ b/src/gpu/GrBitmapTextContext.cpp
|
| @@ -535,35 +535,16 @@ void GrBitmapTextContext::flush() {
|
| SkASSERT(SkIsAlign4(fCurrVertex));
|
| SkASSERT(fCurrTexture);
|
|
|
| - // This effect could be stored with one of the cache objects (atlas?)
|
| - GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode);
|
| - if (kARGB_GrMaskFormat == fCurrMaskFormat) {
|
| - uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType;
|
| - drawState.setGeometryProcessor(GrDefaultGeoProcFactory::Create(flags))->unref();
|
| - GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(fCurrTexture,
|
| - SkMatrix::I(),
|
| - params);
|
| - drawState.addColorProcessor(fragProcessor)->unref();
|
| - } else {
|
| - uint32_t textureUniqueID = fCurrTexture->getUniqueID();
|
| - if (textureUniqueID != fEffectTextureUniqueID) {
|
| - bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat;
|
| - fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture,
|
| - params,
|
| - hasColor));
|
| - fEffectTextureUniqueID = textureUniqueID;
|
| - }
|
| - drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
|
| - }
|
| -
|
| SkASSERT(fStrike);
|
| + GrColor color;
|
| switch (fCurrMaskFormat) {
|
| // Color bitmap text
|
| - case kARGB_GrMaskFormat:
|
| - SkASSERT(!drawState.hasColorVertexAttribute());
|
| + case kARGB_GrMaskFormat: {
|
| drawState.setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlendCoeff());
|
| - drawState.setAlpha(fSkPaint.getAlpha());
|
| + int a = fSkPaint.getAlpha();
|
| + color = SkColorSetARGB(a, a, a, a);
|
| break;
|
| + }
|
| // LCD text
|
| case kA565_GrMaskFormat: {
|
| // TODO: move supportsRGBCoverage check to setupCoverageEffect and only add LCD
|
| @@ -572,14 +553,13 @@ void GrBitmapTextContext::flush() {
|
| if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorComponentFlags)) {
|
| SkDebugf("LCD Text will not draw correctly.\n");
|
| }
|
| - SkASSERT(!drawState.hasColorVertexAttribute());
|
| // We don't use the GrPaint's color in this case because it's been premultiplied by
|
| // alpha. Instead we feed in a non-premultiplied color, and multiply its alpha by
|
| // the mask texture color. The end result is that we get
|
| // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstColor
|
| int a = SkColorGetA(fSkPaint.getColor());
|
| // paintAlpha
|
| - drawState.setColor(SkColorSetARGB(a, a, a, a));
|
| + color = SkColorSetARGB(a, a, a, a);
|
| // paintColor
|
| drawState.setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkPaint.getColor()));
|
| drawState.setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff);
|
| @@ -589,14 +569,42 @@ void GrBitmapTextContext::flush() {
|
| case kA8_GrMaskFormat:
|
| drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint,
|
| 0xFF == GrColorUnpackA(fPaint.getColor()));
|
| + color = fPaint.getColor();
|
| // set back to normal in case we took LCD path previously.
|
| drawState.setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlendCoeff());
|
| - // We're using per-vertex color.
|
| - SkASSERT(drawState.hasColorVertexAttribute());
|
| break;
|
| default:
|
| SkFAIL("Unexpected mask format.");
|
| }
|
| +
|
| + GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode);
|
| + // TODO cache these GPs
|
| + if (kARGB_GrMaskFormat == fCurrMaskFormat) {
|
| + uint32_t textureUniqueID = fCurrTexture->getUniqueID();
|
| + if (textureUniqueID != fEffectTextureUniqueID ||
|
| + fCachedGeometryProcessor->getColor() != color) {
|
| + uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType;
|
| + fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(color, flags));
|
| + fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCurrTexture,
|
| + SkMatrix::I(),
|
| + params));
|
| + }
|
| + drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
|
| + drawState.addColorProcessor(fCachedTextureProcessor.get());
|
| + } else {
|
| + uint32_t textureUniqueID = fCurrTexture->getUniqueID();
|
| + if (textureUniqueID != fEffectTextureUniqueID ||
|
| + fCachedGeometryProcessor->getColor() != color) {
|
| + bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat;
|
| + fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(color,
|
| + fCurrTexture,
|
| + params,
|
| + hasColor));
|
| + fEffectTextureUniqueID = textureUniqueID;
|
| + }
|
| + drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
|
| + }
|
| +
|
| int nGlyphs = fCurrVertex / kVerticesPerGlyph;
|
| fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
|
| fDrawTarget->drawIndexedInstances(&drawState,
|
|
|