Bug 1457103 - patch 1 - Make gfxFontEntry::HasVariations a pure-virtual method, and fill in missing subclass implementations, particularly in FT2FontEntry. r=jwatt
authorJonathan Kew <jkew@mozilla.com>
Thu, 26 Apr 2018 17:08:18 +0100
changeset 415838 46864f33859eecba12b01b4011d392ee20520648
parent 415837 422aebe40856002e8e53916433703840dc6fafa9
child 415839 c4e1dc66dae2bec5444fd92ba27dde33ccd95917
push id33910
push usershindli@mozilla.com
push dateThu, 26 Apr 2018 21:39:52 +0000
treeherdermozilla-central@63a0e2f626fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1457103
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1457103 - patch 1 - Make gfxFontEntry::HasVariations a pure-virtual method, and fill in missing subclass implementations, particularly in FT2FontEntry. r=jwatt
gfx/thebes/gfxFT2FontList.cpp
gfx/thebes/gfxFT2FontList.h
gfx/thebes/gfxFontEntry.h
gfx/thebes/gfxGDIFontList.h
gfx/thebes/gfxUserFontSet.h
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -613,16 +613,33 @@ FT2FontEntry::GetFontTable(uint32_t aTab
         }
     }
 
     // otherwise, use the default method (which in turn will call our
     // implementation of CopyFontTable)
     return gfxFontEntry::GetFontTable(aTableTag);
 }
 
+bool
+FT2FontEntry::HasVariations()
+{
+    if (mHasVariationsInitialized) {
+        return mHasVariations;
+    }
+    mHasVariationsInitialized = true;
+
+    AutoFTFace face(this);
+    if (face) {
+        mHasVariations =
+            FT_Face(face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS;
+    }
+
+    return mHasVariations;
+}
+
 void
 FT2FontEntry::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
                                      FontListSizes* aSizes) const
 {
     gfxFontEntry::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
     aSizes->mFontListSize +=
         mFilename.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
 }
--- a/gfx/thebes/gfxFT2FontList.h
+++ b/gfx/thebes/gfxFT2FontList.h
@@ -82,32 +82,37 @@ public:
 
     nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr) override;
 
     virtual hb_blob_t* GetFontTable(uint32_t aTableTag) override;
 
     virtual nsresult CopyFontTable(uint32_t aTableTag,
                                    nsTArray<uint8_t>& aBuffer) override;
 
+    bool HasVariations() override;
+
     // Check for various kinds of brokenness, and set flags on the entry
     // accordingly so that we avoid using bad font tables
     void CheckForBrokenFont(gfxFontFamily *aFamily);
 
     virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                         FontListSizes* aSizes) const override;
     virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                         FontListSizes* aSizes) const override;
 
     FT_Face mFTFace;
     cairo_font_face_t *mFontFace;
 
     nsCString mFilename;
     uint8_t   mFTFontIndex;
 
     mozilla::ThreadSafeWeakPtr<mozilla::gfx::UnscaledFontFreeType> mUnscaledFont;
+
+    bool mHasVariations = false;
+    bool mHasVariationsInitialized = false;
 };
 
 class FT2FontFamily : public gfxFontFamily
 {
 public:
     explicit FT2FontFamily(const nsAString& aName) :
         gfxFontFamily(aName) { }
 
--- a/gfx/thebes/gfxFontEntry.h
+++ b/gfx/thebes/gfxFontEntry.h
@@ -360,22 +360,18 @@ public:
         uint32_t         rangeStart;
         uint32_t         rangeEnd;
         hb_tag_t         tags[3]; // one or two OpenType script tags to check,
                                   // plus a NULL terminator
     };
 
     bool SupportsScriptInGSUB(const hb_tag_t* aScriptTags);
 
-    // For variation font support, which is not yet implemented on all
-    // platforms; default implementations assume it is not present.
-    virtual bool HasVariations()
-    {
-        return false;
-    }
+    // For variation font support; default implementations assume it is not present.
+    virtual bool HasVariations() = 0;
     virtual void GetVariationAxes(nsTArray<gfxFontVariationAxis>& aVariationAxes)
     {
     }
     virtual void GetVariationInstances(nsTArray<gfxFontVariationInstance>& aInstances)
     {
     }
 
     // Set up the entry's weight/stretch/style ranges according to axes found
--- a/gfx/thebes/gfxGDIFontList.h
+++ b/gfx/thebes/gfxGDIFontList.h
@@ -158,16 +158,18 @@ public:
 
     virtual bool TestCharacterMap(uint32_t aCh);
 
     virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                         FontListSizes* aSizes) const;
 
     gfxFontEntry* Clone() const override;
 
+    bool HasVariations() override { return false; }
+
     // create a font entry for a font with a given name
     static GDIFontEntry* CreateFontEntry(const nsAString& aName,
                                          gfxWindowsFontType aFontType,
                                          SlantStyleRange aStyle,
                                          WeightRange aWeight,
                                          StretchRange aStretch,
                                          gfxUserFontData* aUserFontData);
 
--- a/gfx/thebes/gfxUserFontSet.h
+++ b/gfx/thebes/gfxUserFontSet.h
@@ -634,16 +634,18 @@ public:
     gfxUserFontSet* GetUserFontSet() const { return mFontSet; }
 #endif
 
     const nsTArray<gfxFontFaceSrc>& SourceList() const
     {
       return mSrcList;
     }
 
+    bool HasVariations() override { return false; }
+
 protected:
     const uint8_t* SanitizeOpenTypeData(const uint8_t* aData,
                                         uint32_t aLength,
                                         uint32_t& aSaneLength,
                                         gfxUserFontType aFontType);
 
     // attempt to load the next resource in the src list.
     void LoadNextSrc();