diff options
author | Herb Derby <herb@google.com> | 2018-03-05 14:36:45 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-06 15:50:26 +0000 |
commit | eb3f674d6ddd88e4a31570b26f61238b4b82f490 (patch) | |
tree | e092900bb1f4f025f03e2b5a36097dea334d027d /src/core/SkPaint.cpp | |
parent | 7487ec86b9d8dcd632378d9d6a4178877e144a16 (diff) |
Add GetTypefaceOrDefault to SkPaintPriv
Remove most uses of GetDefaultTypeface. SkTypeface has
fewer friends.
BUG=skia:7515
Change-Id: Iedec5b39b9ef8c638772be4971075491b59b740b
Reviewed-on: https://skia-review.googlesource.com/112300
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkPaint.cpp')
-rw-r--r-- | src/core/SkPaint.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 76f50ce1a1..e3680713b5 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -928,7 +928,7 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { paint, nullptr, SkScalerContextFlags::kNone, zoomPtr, &ad, &effects); { - auto typeface = SkTypeface::NormalizeTypeface(paint.getTypeface()); + auto typeface = SkPaintPriv::GetTypefaceOrDefault(paint); auto cache = SkGlyphCache::FindOrCreateStrikeExclusive(*desc, effects, *typeface); *metrics = cache->getFontMetrics(); } @@ -1201,10 +1201,7 @@ SkRect SkPaint::getFontBounds() const { m.setScale(fTextSize * fTextScaleX, fTextSize); m.postSkew(fTextSkewX, 0); - SkTypeface* typeface = this->getTypeface(); - if (nullptr == typeface) { - typeface = SkTypeface::GetDefaultTypeface(); - } + SkTypeface* typeface = SkPaintPriv::GetTypefaceOrDefault(*this); SkRect bounds; m.mapRect(&bounds, typeface->getBounds()); @@ -1386,13 +1383,10 @@ static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed) { it if there are not tricky elements like shaders, etc. */ void SkPaint::flatten(SkWriteBuffer& buffer) const { - SkTypeface* tf = this->getTypeface(); - if (!tf) { - // We force recording our typeface, even if its "default" since the receiver process - // may have a different notion of default. - tf = SkTypeface::GetDefaultTypeface(); - SkASSERT(tf); - } + // We force recording our typeface, even if its "default" since the receiver process + // may have a different notion of default. + SkTypeface* tf = SkPaintPriv::GetTypefaceOrDefault(*this); + SkASSERT(tf); uint8_t flatFlags = kHasTypeface_FlatFlag; |