Chromium Code Reviews| Index: src/core/SkDraw.cpp |
| diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp |
| index 52891ea5219d8ac72011be88dc316923fe4da7aa..abaab8bfdacf10742a38aff2ddd529235da631b6 100644 |
| --- a/src/core/SkDraw.cpp |
| +++ b/src/core/SkDraw.cpp |
| @@ -32,22 +32,6 @@ |
| #include "SkDrawProcs.h" |
| #include "SkMatrixUtils.h" |
| -bool SkDraw::ShouldDrawTextAsPaths(const SkPaint& paint, const SkMatrix& ctm) { |
| - // we don't cache hairlines in the cache |
| - if (SkPaint::kStroke_Style == paint.getStyle() && |
| - 0 == paint.getStrokeWidth()) { |
| - return true; |
| - } |
| - |
| - // we don't cache perspective |
| - if (ctm.hasPerspective()) { |
| - return true; |
| - } |
| - |
| - SkMatrix textM; |
| - return SkPaint::TooBigToUseCache(ctm, *paint.setTextMatrix(&textM)); |
| -} |
| - |
| //#define TRACE_BITMAP_DRAWS |
| #define kBlitterStorageLongCount (sizeof(SkBitmapProcShader) >> 2) |
| @@ -1458,6 +1442,22 @@ static void measure_text(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
| SkASSERT(text == stop); |
| } |
| +bool SkDraw::shouldDrawTextAsPaths(const SkPaint& paint, const SkMatrix& ctm) const { |
| + // we don't cache hairlines in the cache |
|
robertphillips
2013/11/25 20:39:44
line up? or 1 line?
Shouldn't this comment be "//
|
| + if (SkPaint::kStroke_Style == paint.getStyle() && |
| + 0 == paint.getStrokeWidth()) { |
| + return true; |
| + } |
| + |
| + // we don't cache perspective |
| + if (ctm.hasPerspective()) { |
| + return true; |
| + } |
| + |
| + SkMatrix textM; |
| + return SkPaint::TooBigToUseCache(ctm, *paint.setTextMatrix(&textM)); |
| +} |
| + |
| void SkDraw::drawText_asPaths(const char text[], size_t byteLength, |
| SkScalar x, SkScalar y, |
| const SkPaint& paint) const { |
| @@ -1709,37 +1709,17 @@ void SkDraw::drawText(const char text[], size_t byteLength, |
| // SkScalarRec doesn't currently have a way of representing hairline stroke and |
| // will fill if its frame-width is 0. |
|
robertphillips
2013/11/25 20:39:44
this->
|
| - if (ShouldDrawTextAsPaths(paint, *fMatrix)) { |
| + if (shouldDrawTextAsPaths(paint, *fMatrix)) { |
| this->drawText_asPaths(text, byteLength, x, y, paint); |
| return; |
| } |
| SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); |
| -#if SK_DISTANCEFIELD_FONTS |
| - 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(SkDrawProcs::kBaseDFFontSize); |
| - paintCopy.setLCDRenderText(false); |
| - paintRef = &paintCopy; |
| - } |
| - if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
| - ctm = NULL; |
| - } |
| - SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm); |
| -#else |
| SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix); |
| -#endif |
| SkGlyphCache* cache = autoCache.getCache(); |
| // transform our starting point |
| -#if SK_DISTANCEFIELD_FONTS |
| - if (!(procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag)) |
| -#endif |
| { |
| SkPoint loc; |
| fMatrix->mapXY(x, y, &loc); |
| @@ -1798,41 +1778,17 @@ void SkDraw::drawText(const char text[], size_t byteLength, |
| SkFixed fx = SkScalarToFixed(x) + d1g.fHalfSampleX; |
| SkFixed fy = SkScalarToFixed(y) + d1g.fHalfSampleY; |
| -#if SK_DISTANCEFIELD_FONTS |
| - SkFixed fixedScale; |
| - if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
| - fixedScale = SkScalarToFixed(paint.getTextSize()/(float)SkDrawProcs::kBaseDFFontSize); |
| - } |
| -#endif |
| while (text < stop) { |
| const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fyMask); |
| -#if SK_DISTANCEFIELD_FONTS |
| - if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
| - fx += SkFixedMul_portable(autokern.adjust(glyph), fixedScale); |
| - } else { |
| - fx += autokern.adjust(glyph); |
| - } |
| -#else |
| fx += autokern.adjust(glyph); |
| -#endif |
| if (glyph.fWidth) { |
| proc(d1g, fx, fy, glyph); |
| } |
| -#if SK_DISTANCEFIELD_FONTS |
| - if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
| - fx += SkFixedMul_portable(glyph.fAdvanceX, fixedScale); |
| - fy += SkFixedMul_portable(glyph.fAdvanceY, fixedScale); |
| - } else { |
| - fx += glyph.fAdvanceX; |
| - fy += glyph.fAdvanceY; |
| - } |
| -#else |
| fx += glyph.fAdvanceX; |
| fy += glyph.fAdvanceY; |
| -#endif |
| } |
| } |
| @@ -1983,30 +1939,14 @@ void SkDraw::drawPosText(const char text[], size_t byteLength, |
| return; |
| } |
|
robertphillips
2013/11/25 20:39:44
this->
|
| - if (ShouldDrawTextAsPaths(paint, *fMatrix)) { |
| + if (shouldDrawTextAsPaths(paint, *fMatrix)) { |
| this->drawPosText_asPaths(text, byteLength, pos, constY, |
| scalarsPerPosition, paint); |
| return; |
| } |
| SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); |
| -#if SK_DISTANCEFIELD_FONTS |
| - 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(SkDrawProcs::kBaseDFFontSize); |
| - paintRef = &paintCopy; |
| - } |
| - if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
| - ctm = &SkMatrix::I(); |
| - } |
| - SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm); |
| -#else |
| SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix); |
| -#endif |
| SkGlyphCache* cache = autoCache.getCache(); |
| SkAAClipBlitterWrapper wrapper; |
| @@ -2025,11 +1965,7 @@ 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()) { |
| @@ -2052,16 +1988,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength, |
| if (SkPaint::kLeft_Align == paint.getTextAlign()) { |
| while (text < stop) { |
| -#if SK_DISTANCEFIELD_FONTS |
| - if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
| - tms.fLoc.fX = *pos; |
| - tms.fLoc.fY = *(pos+1); |
| - } else { |
| - tmsProc(tms, pos); |
| - } |
| -#else |
| tmsProc(tms, pos); |
| -#endif |
| SkFixed fx = SkScalarToFixed(tms.fLoc.fX) + d1g.fHalfSampleX; |
| SkFixed fy = SkScalarToFixed(tms.fLoc.fY) + d1g.fHalfSampleY; |