Index: src/core/SkDraw.cpp |
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp |
index df73f7ae3795829c09e40349a8671d805dd19d6c..c48b088951762f6339ef149e034797a194ef0ab5 100644 |
--- a/src/core/SkDraw.cpp |
+++ b/src/core/SkDraw.cpp |
@@ -1680,11 +1680,24 @@ void SkDraw::drawText(const char text[], size_t byteLength, |
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); |
- SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix); |
+ const SkMatrix* ctm = fMatrix; |
+ const SkPaint* paintRef = &paint; |
+ SkPaint paintCopy; |
+ uint32_t procFlags = fProcs ? fProcs->fFlags : 0; |
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
+ paintCopy = paint; |
robertphillips
2013/11/05 15:30:26
Would it make sense to make 32 a constant and docu
jvanverth1
2013/11/05 17:09:22
It would -- still trying to figure out the right p
|
+ paintCopy.setTextSize(32); |
+ paintCopy.setLCDRenderText(false); |
+ paintRef = &paintCopy; |
+ } |
+ if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
+ ctm = NULL; |
+ } |
+ SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm); |
SkGlyphCache* cache = autoCache.getCache(); |
// transform our starting point |
- { |
+ if (!(procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag)) { |
SkPoint loc; |
fMatrix->mapXY(x, y, &loc); |
x = loc.fX; |
@@ -1742,16 +1755,31 @@ void SkDraw::drawText(const char text[], size_t byteLength, |
SkFixed fx = SkScalarToFixed(x) + d1g.fHalfSampleX; |
SkFixed fy = SkScalarToFixed(y) + d1g.fHalfSampleY; |
robertphillips
2013/11/05 15:30:26
fscale is a bit confusing since it seems like a ty
jvanverth1
2013/11/05 17:09:22
Done.
|
+ SkFixed fscale; |
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
robertphillips
2013/11/05 15:30:26
Merge these two into 1 line?
jvanverth1
2013/11/05 17:09:22
Done.
|
+ SkScalar sscale = paint.getTextSize()/32.f; |
+ fscale = SkScalarToFixed(sscale); |
+ } |
while (text < stop) { |
const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fyMask); |
- fx += autokern.adjust(glyph); |
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
+ fx += SkFixedMul_portable(autokern.adjust(glyph), fscale); |
+ } else { |
+ fx += autokern.adjust(glyph); |
+ } |
if (glyph.fWidth) { |
proc(d1g, fx, fy, glyph); |
} |
- fx += glyph.fAdvanceX; |
- fy += glyph.fAdvanceY; |
+ |
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
+ fx += SkFixedMul_portable(glyph.fAdvanceX, fscale); |
+ fy += SkFixedMul_portable(glyph.fAdvanceY, fscale); |
+ } else { |
+ fx += glyph.fAdvanceX; |
+ fy += glyph.fAdvanceY; |
+ } |
} |
} |
@@ -1909,7 +1937,19 @@ void SkDraw::drawPosText(const char text[], size_t byteLength, |
} |
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); |
- SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix); |
+ const SkMatrix* ctm = fMatrix; |
+ const SkPaint* paintRef = &paint; |
+ SkPaint paintCopy; |
+ uint32_t procFlags = fProcs ? fProcs->fFlags : 0; |
+ if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
+ paintCopy = paint; |
+ paintCopy.setTextSize(32); |
+ paintRef = &paintCopy; |
+ } |
+ if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
+ ctm = NULL; |
+ } |
+ SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm); |
SkGlyphCache* cache = autoCache.getCache(); |
SkAAClipBlitterWrapper wrapper; |
@@ -1951,7 +1991,12 @@ void SkDraw::drawPosText(const char text[], size_t byteLength, |
if (SkPaint::kLeft_Align == paint.getTextAlign()) { |
while (text < stop) { |
- tmsProc(tms, pos); |
+ if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
+ tms.fLoc.fX = *pos; |
+ tms.fLoc.fY = *(pos+1); |
+ } else { |
+ tmsProc(tms, pos); |
+ } |
SkFixed fx = SkScalarToFixed(tms.fLoc.fX) + d1g.fHalfSampleX; |
SkFixed fy = SkScalarToFixed(tms.fLoc.fY) + d1g.fHalfSampleY; |