Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index a0692d09b248ada7608d70774b61c5241c48d301..0a220ffebc765cbf6b4bdccf5c269329cd517d6a 100644 |
--- a/src/gpu/SkGpuDevice.cpp |
+++ b/src/gpu/SkGpuDevice.cpp |
@@ -1749,9 +1749,6 @@ SkDrawProcs* SkGpuDevice::initDrawForText(GrTextContext* context) { |
fDrawProcs = SkNEW(GrSkDrawProcs); |
fDrawProcs->fD1GProc = SkGPU_Draw1Glyph; |
fDrawProcs->fContext = fContext; |
-#if SK_DISTANCEFIELD_FONTS |
- fDrawProcs->fFlags = 0; |
-#endif |
} |
// init our (and GL's) state |
@@ -1765,9 +1762,25 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
const SkPaint& paint) { |
CHECK_SHOULD_DRAW(draw, false); |
- if (fContext->getMatrix().hasPerspective()) { |
- // this guy will just call our drawPath() |
- draw.drawText((const char*)text, byteLength, x, y, paint); |
+ if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) { |
+ draw.drawText_asPaths((const char*)text, byteLength, x, y, paint); |
+#if SK_DISTANCEFIELD_FONTS |
+ } else if (!paint.getRasterizer()) { |
+ GrPaint grPaint; |
+ if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
+ return; |
+ } |
+ |
+ SkDEBUGCODE(this->validate();) |
+ |
+ GrDistanceFieldTextContext context(fContext, grPaint, paint); |
+ |
+ SkAutoGlyphCache autoCache(context.getSkPaint(), &this->fLeakyProperties, NULL); |
+ SkGlyphCache* cache = autoCache.getCache(); |
+ GrFontScaler* fontScaler = get_gr_font_scaler(cache); |
+ |
+ context.drawText((const char *)text, byteLength, x, y, cache, fontScaler); |
+#endif |
} else { |
SkDraw myDraw(draw); |
@@ -1775,23 +1788,10 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
return; |
} |
-#if SK_DISTANCEFIELD_FONTS |
- 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 |
+ |
+ GrBitmapTextContext context(fContext, grPaint, paint.getColor()); |
+ myDraw.fProcs = this->initDrawForText(&context); |
+ this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint); |
} |
} |
@@ -1801,10 +1801,28 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, |
const SkPaint& paint) { |
CHECK_SHOULD_DRAW(draw, false); |
- if (fContext->getMatrix().hasPerspective()) { |
+ if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) { |
// this guy will just call our drawPath() |
- draw.drawPosText((const char*)text, byteLength, pos, constY, |
+ draw.drawPosText_asPaths((const char*)text, byteLength, pos, constY, |
scalarsPerPos, paint); |
+#if SK_DISTANCEFIELD_FONTS |
+ } else if (!paint.getRasterizer()) { |
+ GrPaint grPaint; |
+ if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
+ return; |
+ } |
+ |
+ SkDEBUGCODE(this->validate();) |
+ |
+ GrDistanceFieldTextContext context(fContext, grPaint, paint); |
+ |
+ SkAutoGlyphCache autoCache(context.getSkPaint(), &this->fLeakyProperties, NULL); |
+ SkGlyphCache* cache = autoCache.getCache(); |
+ GrFontScaler* fontScaler = get_gr_font_scaler(cache); |
+ |
+ context.drawPosText((const char *)text, byteLength, pos, constY, scalarsPerPos, |
+ cache, fontScaler); |
+#endif |
} else { |
SkDraw myDraw(draw); |
@@ -1812,25 +1830,10 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, |
if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
return; |
} |
-#if SK_DISTANCEFIELD_FONTS |
- 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 |
+ GrBitmapTextContext context(fContext, grPaint, paint.getColor()); |
+ myDraw.fProcs = this->initDrawForText(&context); |
+ this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY, |
+ scalarsPerPos, paint); |
} |
} |