[Libreoffice-commits] core.git: vcl/inc vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Oct 6 10:05:01 UTC 2018


 vcl/inc/unx/freetype_glyphcache.hxx            |   20 --------------
 vcl/inc/unx/glyphcache.hxx                     |    9 ++++--
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   35 +++++++------------------
 vcl/unx/generic/glyphs/glyphcache.cxx          |   33 +++++------------------
 4 files changed, 24 insertions(+), 73 deletions(-)

New commits:
commit ede39d78282484650796456327a35a879a475cef
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Oct 5 08:25:40 2018 +0000
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Sat Oct 6 12:04:40 2018 +0200

    UNX merge FreetypeManager into GlyphCache
    
    Change-Id: I736cc60af6d0c91623a25843bd9ff8fcdd9e8e90
    Reviewed-on: https://gerrit.libreoffice.org/61453
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index 3e27aa6592ad..3a6a64fb929e 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -86,26 +86,6 @@ private:
     FontCharMapRef  mxFontCharMap;
 };
 
-class FreetypeManager
-{
-public:
-                        FreetypeManager();
-                        ~FreetypeManager();
-
-    void                AddFontFile( const OString& rNormalizedName,
-                            int nFaceNum, sal_IntPtr nFontId, const FontAttributes&);
-    void                AnnounceFonts( PhysicalFontCollection* ) const;
-    void                ClearFontList();
-
-    FreetypeFont* CreateFont(LogicalFontInstance* pLogicalFont);
-
-private:
-    typedef std::unordered_map<sal_IntPtr, std::unique_ptr<FreetypeFontInfo>> FontList;
-    FontList            maFontList;
-
-    sal_IntPtr          mnMaxFontId;
-};
-
 class FreetypeFontFace : public PhysicalFontFace
 {
 private:
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index 9d0be13e3a6d..561029b67bbd 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -38,7 +38,7 @@
 
 #include <unordered_map>
 
-class FreetypeManager;
+class FreetypeFont;
 class FreetypeFontInstance;
 class FreetypeFontInfo;
 class GlyphData;
@@ -68,7 +68,6 @@ public:
     FreetypeFont*           CacheFont(LogicalFontInstance* pFontInstance);
     void                    UncacheFont( FreetypeFont& );
     void                    ClearFontCache();
-    void                    InvalidateAllGlyphs();
     void                    ClearFontOptions();
 
 private:
@@ -79,13 +78,16 @@ private:
     void                    UsingGlyph( GlyphData const & );
 
 private:
+    void                    InitFreetype();
     void                    GarbageCollect();
+    FreetypeFont*           CreateFont(LogicalFontInstance* pLogicalFont);
 
     // the GlyphCache's FontList matches a font request to a serverfont instance
     // the FontList key's mpFontData member is reinterpreted as integer font id
     struct IFSD_Equal{  bool operator()( const rtl::Reference<LogicalFontInstance>&, const rtl::Reference<LogicalFontInstance>& ) const; };
     struct IFSD_Hash{ size_t operator()( const rtl::Reference<LogicalFontInstance>& ) const; };
     typedef std::unordered_map<rtl::Reference<LogicalFontInstance>,std::unique_ptr<FreetypeFont>,IFSD_Hash,IFSD_Equal > FontList;
+    typedef std::unordered_map<sal_IntPtr, std::unique_ptr<FreetypeFontInfo>> FontInfoList;
 
     FontList                maFontList;
     static constexpr sal_uLong gnMaxSize = 1500000;  // max overall cache size in bytes
@@ -94,7 +96,8 @@ private:
     mutable int             mnGlyphCount;
     FreetypeFont*           mpCurrentGCFont;
 
-    std::unique_ptr<FreetypeManager>  mpFtManager;
+    FontInfoList            m_aFontInfoList;
+    sal_IntPtr              m_nMaxFontId;
 };
 
 class GlyphData
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 4a65c2b4b6b4..cfc91deb07e0 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -86,8 +86,6 @@ static int nDefaultPrioEmbedded    = 2;
 static int nDefaultPrioAutoHint    = 1;
 static int nDefaultPrioAntiAlias   = 1;
 
-// FreetypeManager
-
 FreetypeFontFile::FreetypeFontFile( const OString& rNativeFileName )
 :   maNativeFileName( rNativeFileName ),
     mpFileMap( nullptr ),
@@ -260,8 +258,7 @@ void FreetypeFontInfo::AnnounceFont( PhysicalFontCollection* pFontCollection )
     pFontCollection->Add( pFD );
 }
 
-FreetypeManager::FreetypeManager()
-:   mnMaxFontId( 0 )
+void GlyphCache::InitFreetype()
 {
     /*FT_Error rcFT =*/ FT_Init_FreeType( &aLibFT );
 
@@ -291,42 +288,32 @@ FT_Face FreetypeFont::GetFtFace() const
     return maFaceFT;
 }
 
-FreetypeManager::~FreetypeManager()
-{
-    ClearFontList();
-}
-
-void FreetypeManager::AddFontFile( const OString& rNormalizedName,
+void GlyphCache::AddFontFile( const OString& rNormalizedName,
     int nFaceNum, sal_IntPtr nFontId, const FontAttributes& rDevFontAttr)
 {
     if( rNormalizedName.isEmpty() )
         return;
 
-    if( maFontList.find( nFontId ) != maFontList.end() )
+    if( m_aFontInfoList.find( nFontId ) != m_aFontInfoList.end() )
         return;
 
     FreetypeFontInfo* pFontInfo = new FreetypeFontInfo( rDevFontAttr,
         rNormalizedName, nFaceNum, nFontId);
-    maFontList[ nFontId ].reset(pFontInfo);
-    if( mnMaxFontId < nFontId )
-        mnMaxFontId = nFontId;
+    m_aFontInfoList[ nFontId ].reset(pFontInfo);
+    if( m_nMaxFontId < nFontId )
+        m_nMaxFontId = nFontId;
 }
 
-void FreetypeManager::AnnounceFonts( PhysicalFontCollection* pToAdd ) const
+void GlyphCache::AnnounceFonts( PhysicalFontCollection* pToAdd ) const
 {
-    for (auto const& font : maFontList)
+    for (auto const& font : m_aFontInfoList)
     {
         FreetypeFontInfo* pFreetypeFontInfo = font.second.get();
         pFreetypeFontInfo->AnnounceFont( pToAdd );
     }
 }
 
-void FreetypeManager::ClearFontList( )
-{
-    maFontList.clear();
-}
-
-FreetypeFont* FreetypeManager::CreateFont(LogicalFontInstance* pFontInstance)
+FreetypeFont* GlyphCache::CreateFont(LogicalFontInstance* pFontInstance)
 {
     // find a FontInfo matching to the font id
     if (!pFontInstance)
@@ -337,8 +324,8 @@ FreetypeFont* FreetypeManager::CreateFont(LogicalFontInstance* pFontInstance)
         return nullptr;
 
     sal_IntPtr nFontId = pFontFace->GetFontId();
-    FontList::iterator it = maFontList.find(nFontId);
-    FreetypeFontInfo* pFontInfo = it != maFontList.end() ? it->second.get() : nullptr;
+    FontInfoList::iterator it = m_aFontInfoList.find(nFontId);
+    FreetypeFontInfo* pFontInfo = it != m_aFontInfoList.end() ? it->second.get() : nullptr;
 
     if (!pFontInfo)
         return nullptr;
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx
index 3ce24ece848c..e2a1358b3567 100644
--- a/vcl/unx/generic/glyphs/glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/glyphcache.cxx
@@ -37,17 +37,19 @@ GlyphCache::GlyphCache()
     mnLruIndex(0),
     mnGlyphCount(0),
     mpCurrentGCFont(nullptr)
+    , m_nMaxFontId(0)
 {
     pInstance = this;
-    mpFtManager.reset( new FreetypeManager );
+
+    InitFreetype();
 }
 
 GlyphCache::~GlyphCache()
 {
-    InvalidateAllGlyphs();
+    ClearFontCache();
 }
 
-void GlyphCache::InvalidateAllGlyphs()
+void GlyphCache::ClearFontCache()
 {
     for (auto& font : maFontList)
     {
@@ -59,6 +61,7 @@ void GlyphCache::InvalidateAllGlyphs()
 
     maFontList.clear();
     mpCurrentGCFont = nullptr;
+    m_aFontInfoList.clear();
 }
 
 void GlyphCache::ClearFontOptions()
@@ -159,26 +162,6 @@ GlyphCache& GlyphCache::GetInstance()
     return *pInstance;
 }
 
-void GlyphCache::AddFontFile( const OString& rNormalizedName, int nFaceNum,
-    sal_IntPtr nFontId, const FontAttributes& rDFA)
-{
-    if( mpFtManager )
-        mpFtManager->AddFontFile( rNormalizedName, nFaceNum, nFontId, rDFA);
-}
-
-void GlyphCache::AnnounceFonts( PhysicalFontCollection* pFontCollection ) const
-{
-    if( mpFtManager )
-        mpFtManager->AnnounceFonts( pFontCollection );
-}
-
-void GlyphCache::ClearFontCache()
-{
-    InvalidateAllGlyphs();
-    if (mpFtManager)
-        mpFtManager->ClearFontList();
-}
-
 FreetypeFont* GlyphCache::CacheFont(LogicalFontInstance* pFontInstance)
 {
     // a serverfont request has a fontid > 0
@@ -195,9 +178,7 @@ FreetypeFont* GlyphCache::CacheFont(LogicalFontInstance* pFontInstance)
     }
 
     // font not cached yet => create new font item
-    FreetypeFont* pNew = nullptr;
-    if (mpFtManager)
-        pNew = mpFtManager->CreateFont(pFontInstance);
+    FreetypeFont* pNew = CreateFont(pFontInstance);
 
     if( pNew )
     {


More information about the Libreoffice-commits mailing list