aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDraw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkDraw.cpp')
-rw-r--r--src/core/SkDraw.cpp104
1 files changed, 15 insertions, 89 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index d9bdd8e7b1..1d75ca36a8 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,21 @@ static void measure_text(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc,
SkASSERT(text == stop);
}
+bool SkDraw::ShouldDrawTextAsPaths(const SkPaint& paint, const SkMatrix& ctm) {
+ // hairline glyphs are fast enough so we don't need to cache them
+ 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 {
@@ -1716,30 +1715,10 @@ void SkDraw::drawText(const char text[], size_t byteLength,
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 +1777,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
}
}
@@ -2013,23 +1968,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
}
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;
@@ -2048,11 +1987,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()) {
@@ -2075,16 +2010,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;