diff options
author | bungeman <bungeman@google.com> | 2016-07-13 05:16:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-13 05:16:58 -0700 |
commit | e3aea10428d1597838fd563c92340beaf969a9b4 (patch) | |
tree | c9afef7b181fbfdb9897c72b4fe61cd44f34d692 /src | |
parent | ba3880fa6d47d467bfcf4db80c553f051336e406 (diff) |
Remove user specified typeface id.
Now that there may be multiple font managers in a process the typeface
ids must be unique across all typefaces, not just unique within a font
manager. If two typefaces have the same id there will be issues in the
glyph cache. All existing font managers were already doing this by
calling SkFontCache::NewFontID, so centralize this in SkTypeface.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2147733002
Review-Url: https://codereview.chromium.org/2147733002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkTypeface.cpp | 7 | ||||
-rw-r--r-- | src/fonts/SkGScalerContext.cpp | 2 | ||||
-rw-r--r-- | src/fonts/SkRandomScalerContext.cpp | 2 | ||||
-rw-r--r-- | src/fonts/SkTestScalerContext.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontConfigTypeface.h | 4 | ||||
-rw-r--r-- | src/ports/SkFontHost_FreeType_common.h | 4 | ||||
-rw-r--r-- | src/ports/SkFontHost_mac.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontHost_win.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontMgr_android.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontMgr_custom.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontMgr_fontconfig.cpp | 3 | ||||
-rw-r--r-- | src/ports/SkTypeface_win_dw.h | 7 |
12 files changed, 19 insertions, 20 deletions
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index 90a1eaabec..4b0dd0831b 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -14,9 +14,10 @@ #include "SkOnce.h" #include "SkStream.h" #include "SkTypeface.h" +#include "SkTypefaceCache.h" -SkTypeface::SkTypeface(const SkFontStyle& style, SkFontID fontID, bool isFixedPitch) - : fUniqueID(fontID), fStyle(style), fIsFixedPitch(isFixedPitch) { } +SkTypeface::SkTypeface(const SkFontStyle& style, bool isFixedPitch) + : fUniqueID(SkTypefaceCache::NewFontID()), fStyle(style), fIsFixedPitch(isFixedPitch) { } SkTypeface::~SkTypeface() { } @@ -40,7 +41,7 @@ class SkEmptyTypeface : public SkTypeface { public: static SkEmptyTypeface* Create() { return new SkEmptyTypeface; } protected: - SkEmptyTypeface() : SkTypeface(SkFontStyle(), 0, true) { } + SkEmptyTypeface() : SkTypeface(SkFontStyle(), true) { } SkStreamAsset* onOpenStream(int* ttcIndex) const override { return nullptr; } SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, diff --git a/src/fonts/SkGScalerContext.cpp b/src/fonts/SkGScalerContext.cpp index 1d34536cbe..5a439b7eb5 100644 --- a/src/fonts/SkGScalerContext.cpp +++ b/src/fonts/SkGScalerContext.cpp @@ -152,7 +152,7 @@ void SkGScalerContext::generateFontMetrics(SkPaint::FontMetrics* metrics) { #include "SkTypefaceCache.h" SkGTypeface::SkGTypeface(sk_sp<SkTypeface> proxy, const SkPaint& paint) - : SkTypeface(proxy->fontStyle(), SkTypefaceCache::NewFontID(), false) + : SkTypeface(proxy->fontStyle(), false) , fProxy(std::move(proxy)) , fPaint(paint) {} diff --git a/src/fonts/SkRandomScalerContext.cpp b/src/fonts/SkRandomScalerContext.cpp index 6d3718cbef..c9cb87c03c 100644 --- a/src/fonts/SkRandomScalerContext.cpp +++ b/src/fonts/SkRandomScalerContext.cpp @@ -191,7 +191,7 @@ void SkRandomScalerContext::generateFontMetrics(SkPaint::FontMetrics* metrics) { #include "SkTypefaceCache.h" SkRandomTypeface::SkRandomTypeface(sk_sp<SkTypeface> proxy, const SkPaint& paint, bool fakeIt) - : SkTypeface(proxy->fontStyle(), SkTypefaceCache::NewFontID(), false) + : SkTypeface(proxy->fontStyle(), false) , fProxy(std::move(proxy)) , fPaint(paint) , fFakeIt(fakeIt) {} diff --git a/src/fonts/SkTestScalerContext.cpp b/src/fonts/SkTestScalerContext.cpp index ebe2ee1c52..bab6b893e2 100644 --- a/src/fonts/SkTestScalerContext.cpp +++ b/src/fonts/SkTestScalerContext.cpp @@ -115,7 +115,7 @@ void SkTestFont::init(const SkScalar* pts, const unsigned char* verbs) { } SkTestTypeface::SkTestTypeface(SkTestFont* testFont, const SkFontStyle& style) - : SkTypeface(style, SkTypefaceCache::NewFontID(), false) + : SkTypeface(style, false) , fTestFont(testFont) { } diff --git a/src/ports/SkFontConfigTypeface.h b/src/ports/SkFontConfigTypeface.h index eb5db94fdf..590c6fac89 100644 --- a/src/ports/SkFontConfigTypeface.h +++ b/src/ports/SkFontConfigTypeface.h @@ -50,14 +50,14 @@ protected: const SkFontConfigInterface::FontIdentity& fi, const SkString& familyName, const SkFontStyle& style) - : INHERITED(style, SkTypefaceCache::NewFontID(), false) + : INHERITED(style, false) , fFCI(SkRef(fci)) , fIdentity(fi) , fFamilyName(familyName) , fLocalStream(nullptr) {} SkTypeface_FCI(const SkFontStyle& style, bool fixedWidth, SkStreamAsset* localStream, int index) - : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) + : INHERITED(style, fixedWidth) , fLocalStream(localStream) { fIdentity.fTTCIndex = index; diff --git a/src/ports/SkFontHost_FreeType_common.h b/src/ports/SkFontHost_FreeType_common.h index 6d050cdd99..3801453e22 100644 --- a/src/ports/SkFontHost_FreeType_common.h +++ b/src/ports/SkFontHost_FreeType_common.h @@ -71,8 +71,8 @@ public: }; protected: - SkTypeface_FreeType(const SkFontStyle& style, SkFontID uniqueID, bool isFixedPitch) - : INHERITED(style, uniqueID, isFixedPitch) + SkTypeface_FreeType(const SkFontStyle& style, bool isFixedPitch) + : INHERITED(style, isFixedPitch) {} virtual SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp index c129a6b24b..55eec33502 100644 --- a/src/ports/SkFontHost_mac.cpp +++ b/src/ports/SkFontHost_mac.cpp @@ -436,7 +436,7 @@ public: SkTypeface_Mac(CTFontRef fontRef, CFTypeRef resourceRef, const SkFontStyle& fs, bool isFixedPitch, bool isLocalStream) - : SkTypeface(fs, SkTypefaceCache::NewFontID(), isFixedPitch) + : SkTypeface(fs, isFixedPitch) , fFontRef(fontRef) // caller has already called CFRetain for us , fOriginatingCFTypeRef(resourceRef) // caller has already called CFRetain for us , fHasColorGlyphs(SkToBool(CTFontGetSymbolicTraits(fFontRef) & SkCTFontColorGlyphsTrait)) diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 25038dcf38..34d05068f5 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -206,7 +206,7 @@ static unsigned calculateUPEM(HDC hdc, const LOGFONT& lf) { class LogFontTypeface : public SkTypeface { public: LogFontTypeface(const SkFontStyle& style, const LOGFONT& lf, bool serializeAsStream) - : SkTypeface(style, SkTypefaceCache::NewFontID(), false) + : SkTypeface(style, false) , fLogFont(lf) , fSerializeAsStream(serializeAsStream) { diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp index 2e619af0fb..a8d5b12a43 100644 --- a/src/ports/SkFontMgr_android.cpp +++ b/src/ports/SkFontMgr_android.cpp @@ -35,7 +35,7 @@ public: SkTypeface_Android(const SkFontStyle& style, bool isFixedPitch, const SkString& familyName) - : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) + : INHERITED(style, isFixedPitch) , fFamilyName(familyName) { } diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp index 0fc5180dd4..a05cc9b650 100644 --- a/src/ports/SkFontMgr_custom.cpp +++ b/src/ports/SkFontMgr_custom.cpp @@ -30,7 +30,7 @@ class SkTypeface_Custom : public SkTypeface_FreeType { public: SkTypeface_Custom(const SkFontStyle& style, bool isFixedPitch, bool sysFont, const SkString familyName, int index) - : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) + : INHERITED(style, isFixedPitch) , fIsSysFont(sysFont), fFamilyName(familyName), fIndex(index) { } diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp index 610a3001fb..0876fb6325 100644 --- a/src/ports/SkFontMgr_fontconfig.cpp +++ b/src/ports/SkFontMgr_fontconfig.cpp @@ -405,7 +405,7 @@ class SkTypeface_stream : public SkTypeface_FreeType { public: /** @param data takes ownership of the font data.*/ SkTypeface_stream(SkFontData* data, const SkFontStyle& style, bool fixedWidth) - : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) + : INHERITED(style, fixedWidth) , fData(data) { }; @@ -493,7 +493,6 @@ private: /** @param pattern takes ownership of the reference. */ SkTypeface_fontconfig(FcPattern* pattern) : INHERITED(skfontstyle_from_fcpattern(pattern), - SkTypefaceCache::NewFontID(), FC_PROPORTIONAL != get_int(pattern, FC_SPACING, FC_PROPORTIONAL)) , fPattern(pattern) { }; diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h index 11b3fb5ffc..1119841e00 100644 --- a/src/ports/SkTypeface_win_dw.h +++ b/src/ports/SkTypeface_win_dw.h @@ -39,14 +39,14 @@ static SkFontStyle get_style(IDWriteFont* font) { class DWriteFontTypeface : public SkTypeface { private: - DWriteFontTypeface(const SkFontStyle& style, SkFontID fontID, + DWriteFontTypeface(const SkFontStyle& style, IDWriteFactory* factory, IDWriteFontFace* fontFace, IDWriteFont* font, IDWriteFontFamily* fontFamily, IDWriteFontFileLoader* fontFileLoader = nullptr, IDWriteFontCollectionLoader* fontCollectionLoader = nullptr) - : SkTypeface(style, fontID, false) + : SkTypeface(style, false) , fFactory(SkRefComPtr(factory)) , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader)) , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader)) @@ -80,8 +80,7 @@ public: IDWriteFontFamily* fontFamily, IDWriteFontFileLoader* fontFileLoader = nullptr, IDWriteFontCollectionLoader* fontCollectionLoader = nullptr) { - SkFontID fontID = SkTypefaceCache::NewFontID(); - return new DWriteFontTypeface(get_style(font), fontID, factory, fontFace, font, fontFamily, + return new DWriteFontTypeface(get_style(font), factory, fontFace, font, fontFamily, fontFileLoader, fontCollectionLoader); } |