Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 85653004: Move distance field font code into SkGpuDevice (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Clean up formatting and address nits Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698