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

Unified Diff: src/gpu/GrDistanceFieldTextContext.cpp

Issue 862403004: Use distance fields for glyphs > 256 pt, before switching to paths. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDistanceFieldTextContext.cpp
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 820223ddc49d1d9084db580b56c201a508d880be..f48d412a79d058b2e8f6c3f35830a05d159ae249 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -33,13 +33,15 @@ SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
static const int kSmallDFFontSize = 32;
static const int kSmallDFFontLimit = 32;
-static const int kMediumDFFontSize = 64;
-static const int kMediumDFFontLimit = 64;
-static const int kLargeDFFontSize = 128;
+static const int kMediumDFFontSize = 78;
+static const int kMediumDFFontLimit = 78;
+static const int kLargeDFFontSize = 192;
static const int kVerticesPerGlyph = 4;
static const int kIndicesPerGlyph = 6;
+static const int kMaxFontCacheSize = 256;
+
GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
const SkDeviceProperties& properties,
bool enable)
@@ -80,7 +82,19 @@ GrDistanceFieldTextContext::~GrDistanceFieldTextContext() {
}
bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) {
- if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP()) {
+ // TODO: support perspective (need getMaxScale replacement)
+ if (viewMatrix.hasPerspective()) {
+ return false;
+ }
+
+ SkScalar maxScale = viewMatrix.getMaxScale();
+ SkScalar scaledTextSize = maxScale*paint.getTextSize();
robertphillips 2015/01/28 00:03:16 // Scaling up beyond 2x yields undesireable artifa
jvanverth1 2015/01/28 17:47:38 Done.
+ if (scaledTextSize > 2*kLargeDFFontSize) {
+ return false;
+ }
+
+ if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP() &&
+ scaledTextSize < kMaxFontCacheSize) {
return false;
}
@@ -96,12 +110,6 @@ bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& v
return false;
}
- // TODO: choose an appropriate maximum scale for distance fields and
- // enable perspective
robertphillips 2015/01/28 00:03:16 Is ShouldDrawTextAsPaths still used anywhere?
jvanverth1 2015/01/28 17:47:38 It's still used in BitmapTextContext, and in raste
- if (SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix)) {
- return false;
- }
-
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698