diff options
author | Herb Derby <herb@google.com> | 2018-02-28 18:47:27 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-05 19:35:45 +0000 |
commit | dfeb2aa13baab291ea794502a16daa270b11e153 (patch) | |
tree | af4711e0b71bd9e93dd3bd4cf01282fbf0b481ab /src/core/SkPaint.cpp | |
parent | 2a4f983c94e4f749fe24b08bc8b5ae7cc8550d1d (diff) |
SkGlyphCache - update core routines.
- Allows different methods for creating SkGlyphCaches
- Enables passing FontMetrics for cache creation.
- Removes VisitCache
- Removes VisitAll
- Introduces SkExclusiveStrikePtr which should
replaces SkAutoGlyphCache with simpler mechanism.
BUG=skia:7515
Change-Id: Ibada35e3985335179d2cc8284a837fc525224c92
Reviewed-on: https://skia-review.googlesource.com/111063
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkPaint.cpp')
-rw-r--r-- | src/core/SkPaint.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index f754c021eb..76f50ce1a1 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -905,11 +905,6 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth, /////////////////////////////////////////////////////////////////////////////// -static bool FontMetricsCacheProc(const SkGlyphCache* cache, void* context) { - *(SkPaint::FontMetrics*)context = cache->getFontMetrics(); - return false; // don't detach the cache -} - SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { SkCanonicalizePaint canon(*this); const SkPaint& paint = canon.getPaint(); @@ -932,7 +927,11 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { auto desc = SkScalerContext::CreateDescriptorAndEffectsUsingPaint( paint, nullptr, SkScalerContextFlags::kNone, zoomPtr, &ad, &effects); - SkGlyphCache::VisitCache(paint.getTypeface(), effects, desc, FontMetricsCacheProc, metrics); + { + auto typeface = SkTypeface::NormalizeTypeface(paint.getTypeface()); + auto cache = SkGlyphCache::FindOrCreateStrikeExclusive(*desc, effects, *typeface); + *metrics = cache->getFontMetrics(); + } if (scale) { SkPaintPriv::ScaleFontMetrics(metrics, scale); |