diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-21 15:09:33 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-21 15:09:33 +0000 |
commit | 75a22954453f4c0e3c0cb2ec0a46f32a473622f9 (patch) | |
tree | 2cbe2af4c120e945af10335ca7c39e776c19825f /src | |
parent | a4662865e37a2ca95b5e3379072f6a274acc8ac8 (diff) |
Minor fixes for distance field fonts:
- Remove additional transform in drawpostext()
- Use bitmap fonts if rasterizer set in paint
- Correctly set scale ratio for drawtext()
R=bsalomon@google.com
Author: jvanverth@google.com
Review URL: https://codereview.chromium.org/79283004
git-svn-id: http://skia.googlecode.com/svn/trunk@12338 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkDraw.cpp | 6 | ||||
-rwxr-xr-x | src/gpu/GrBitmapTextContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 47 |
3 files changed, 38 insertions, 17 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index aa91df3df5..0288dee409 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -2012,7 +2012,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength, paintRef = &paintCopy; } if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { - ctm = NULL; + ctm = &SkMatrix::I(); } SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm); #else @@ -2036,7 +2036,11 @@ void SkDraw::drawPosText(const char text[], size_t byteLength, AlignProc alignProc = pick_align_proc(paint.getTextAlign()); SkDraw1Glyph d1g; SkDraw1Glyph::Proc proc = d1g.init(this, blitter, cache, paint); +#if SK_DISTANCEFIELD_FONTS + TextMapState tms(*ctm, constY); +#else TextMapState tms(*fMatrix, constY); +#endif TextMapState::Proc tmsProc = tms.pickProc(scalarsPerPosition); if (cache->isSubpixel()) { diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp index 433eda148a..8d955bbb4c 100755 --- a/src/gpu/GrBitmapTextContext.cpp +++ b/src/gpu/GrBitmapTextContext.cpp @@ -124,7 +124,7 @@ void GrBitmapTextContext::drawPackedGlyph(GrGlyph::PackedID packed, } if (NULL == fStrike) { #if SK_DISTANCEFIELD_FONTS - fStrike = fContext->getFontCache()->getStrike(scaler, true); + fStrike = fContext->getFontCache()->getStrike(scaler, false); #else fStrike = fContext->getFontCache()->getStrike(scaler); #endif diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index afdc7e92df..063509a5a4 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1699,8 +1699,6 @@ SkDrawProcs* SkGpuDevice::initDrawForText(GrTextContext* context) { fDrawProcs->fContext = fContext; #if SK_DISTANCEFIELD_FONTS fDrawProcs->fFlags = 0; - fDrawProcs->fFlags |= SkDrawProcs::kSkipBakedGlyphTransform_Flag; - fDrawProcs->fFlags |= SkDrawProcs::kUseScaledGlyphs_Flag; #endif } @@ -1726,13 +1724,22 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, return; } #if SK_DISTANCEFIELD_FONTS - GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(), - paint.getTextSize()); -#else - GrBitmapTextContext context(fContext, grPaint, paint.getColor()); + if (paint.getRasterizer()) { +#endif + GrBitmapTextContext context(fContext, grPaint, paint.getColor()); + myDraw.fProcs = this->initDrawForText(&context); + this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint); +#if SK_DISTANCEFIELD_FONTS + } else { + GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(), + paint.getTextSize()/SkDrawProcs::kBaseDFFontSize); + myDraw.fProcs = this->initDrawForText(&context); + fDrawProcs->fFlags |= SkDrawProcs::kSkipBakedGlyphTransform_Flag; + fDrawProcs->fFlags |= SkDrawProcs::kUseScaledGlyphs_Flag; + this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint); + fDrawProcs->fFlags = 0; + } #endif - myDraw.fProcs = this->initDrawForText(&context); - this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint); } } @@ -1754,14 +1761,24 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, return; } #if SK_DISTANCEFIELD_FONTS - GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(), - paint.getTextSize()/SkDrawProcs::kBaseDFFontSize); -#else - GrBitmapTextContext context(fContext, grPaint, paint.getColor()); + if (paint.getRasterizer()) { +#endif + GrBitmapTextContext context(fContext, grPaint, paint.getColor()); + myDraw.fProcs = this->initDrawForText(&context); + this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY, + scalarsPerPos, paint); +#if SK_DISTANCEFIELD_FONTS + } else { + GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(), + paint.getTextSize()/SkDrawProcs::kBaseDFFontSize); + myDraw.fProcs = this->initDrawForText(&context); + fDrawProcs->fFlags |= SkDrawProcs::kSkipBakedGlyphTransform_Flag; + fDrawProcs->fFlags |= SkDrawProcs::kUseScaledGlyphs_Flag; + this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY, + scalarsPerPos, paint); + fDrawProcs->fFlags = 0; + } #endif - myDraw.fProcs = this->initDrawForText(&context); - this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY, - scalarsPerPos, paint); } } |