diff options
author | jvanverth <jvanverth@google.com> | 2015-01-28 13:08:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-28 13:08:41 -0800 |
commit | 5a3d92fca17b9d4d7763c6d24c72c74f7682881f (patch) | |
tree | 5ecd3e9a35d9a52e28b186d5ee6c58e7dcaed2ff /src | |
parent | 4d8da81562852e0ff7e18b66ee1cebd50ad81ee8 (diff) |
Use distance fields for glyphs > 256 pt, before switching to paths.
BUG=452313
Review URL: https://codereview.chromium.org/862403004
Diffstat (limited to 'src')
-rwxr-xr-x | src/gpu/GrDistanceFieldTextContext.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp index 820223ddc4..41c2844037 100755 --- a/src/gpu/GrDistanceFieldTextContext.cpp +++ b/src/gpu/GrDistanceFieldTextContext.cpp @@ -33,9 +33,9 @@ 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; @@ -80,7 +80,20 @@ 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(); + // Scaling up beyond 2x yields undesireable artifacts + if (scaledTextSize > 2*kLargeDFFontSize) { + return false; + } + + if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP() && + scaledTextSize < kLargeDFFontSize) { return false; } @@ -96,12 +109,6 @@ bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& v return false; } - // TODO: choose an appropriate maximum scale for distance fields and - // enable perspective - if (SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix)) { - return false; - } - return true; } |