diff options
author | Jan-Marek Glogowski <jan-marek.glogowski@extern.cib.de> | 2019-11-18 13:56:55 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-11-19 03:14:45 +0100 |
commit | 852a0f9cd88ef1f646af67e59a0fdd779b0e7627 (patch) | |
tree | 48dc90a99620311e826b25a625f2b9ce15be571b /vcl/unx | |
parent | f8e1f8652255cadd80a991aa3e059ee631b333b8 (diff) |
Rename GlyphCache to FreetypeManager
And while at it remove the unneeded getPlatformGlyphCache
abstraction.
Change-Id: Id5cad751eda9e6bf177dfb4816280d7c5af7066a
Reviewed-on: https://gerrit.libreoffice.org/83125
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/generic/app/gendata.cxx | 4 | ||||
-rw-r--r-- | vcl/unx/generic/app/saldisp.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/cairotextrender.cxx | 31 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/x11cairotextrender.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/x11cairotextrender.hxx | 1 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 8 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/glyphcache.cxx | 30 | ||||
-rw-r--r-- | vcl/unx/generic/print/genpspgraphics.cxx | 22 |
8 files changed, 48 insertions, 55 deletions
diff --git a/vcl/unx/generic/app/gendata.cxx b/vcl/unx/generic/app/gendata.cxx index ea091105529a..500d3b13331e 100644 --- a/vcl/unx/generic/app/gendata.cxx +++ b/vcl/unx/generic/app/gendata.cxx @@ -32,11 +32,11 @@ GenericUnixSalData::GenericUnixSalData(GenericUnixSalDataType const t, SalInstan GenericUnixSalData::~GenericUnixSalData() {} -void GenericUnixSalData::InitGlyphCache() { m_pGlyphCache.reset(new GlyphCache); } +void GenericUnixSalData::InitFreetypeManager() { m_pFreetypeManager.reset(new FreetypeManager); } void GenericUnixSalData::InitPrintFontManager() { - GetGlyphCache(); + GetFreetypeManager(); m_pPrintFontManager.reset(new psp::PrintFontManager); m_pPrintFontManager->initialize(); } diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index 21ddd3eab4ee..8756fc2299e3 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -336,7 +336,7 @@ void SalDisplay::doDestruct() rMap.clear(); } } - GlyphCache::GetInstance().ClearFontCache(); + FreetypeManager::get().ClearFontCache(); if( IsDisplay() ) { diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index 9610a73bc1d6..0a290c1d1958 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -94,7 +94,7 @@ void CairoTextRender::SetFont(LogicalFontInstance *pEntry, int nFallbackLevel) if( mpFreetypeFont[i] != nullptr ) { // old server side font is no longer referenced - GlyphCache::GetInstance().UncacheFont( *mpFreetypeFont[i] ); + FreetypeManager::get().UncacheFont( *mpFreetypeFont[i] ); mpFreetypeFont[i] = nullptr; } } @@ -103,14 +103,14 @@ void CairoTextRender::SetFont(LogicalFontInstance *pEntry, int nFallbackLevel) if( !pEntry ) return; - // handle the request for a non-native X11-font => use the GlyphCache - FreetypeFont* pFreetypeFont = GlyphCache::GetInstance().CacheFont(pEntry); + // handle the request for a non-native X11-font => use the FreetypeManager + FreetypeFont* pFreetypeFont = FreetypeManager::get().CacheFont(pEntry); if( pFreetypeFont != nullptr ) { // ignore fonts with e.g. corrupted font files if( !pFreetypeFont->TestFont() ) { - GlyphCache::GetInstance().UncacheFont( *pFreetypeFont ); + FreetypeManager::get().UncacheFont( *pFreetypeFont ); return; } @@ -398,19 +398,18 @@ bool CairoTextRender::AddTempDevFont( PhysicalFontCollection* pFontCollection, const OUString& rFileURL, const OUString& rFontName ) { - return GenPspGraphics::AddTempDevFontHelper( pFontCollection, rFileURL, rFontName, getPlatformGlyphCache() ); + return GenPspGraphics::AddTempDevFontHelper(pFontCollection, rFileURL, rFontName); } void CairoTextRender::ClearDevFontCache() { - GlyphCache& rGC = getPlatformGlyphCache(); - rGC.ClearFontCache(); + FreetypeManager::get().ClearFontCache(); } void CairoTextRender::GetDevFontList( PhysicalFontCollection* pFontCollection ) { - // prepare the GlyphCache using psprint's font infos - GlyphCache& rGC = getPlatformGlyphCache(); + // prepare the FreetypeManager using psprint's font infos + FreetypeManager& rFreetypeManager = FreetypeManager::get(); psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); ::std::vector< psp::fontID > aList; @@ -421,19 +420,19 @@ void CairoTextRender::GetDevFontList( PhysicalFontCollection* pFontCollection ) if( !rMgr.getFontFastInfo( elem, aInfo ) ) continue; - // normalize face number to the GlyphCache + // normalize face number to the FreetypeManager int nFaceNum = rMgr.getFontFaceNumber( aInfo.m_nID ); int nVariantNum = rMgr.getFontFaceVariation( aInfo.m_nID ); - // inform GlyphCache about this font provided by the PsPrint subsystem + // inform FreetypeManager about this font provided by the PsPrint subsystem FontAttributes aDFA = GenPspGraphics::Info2FontAttributes( aInfo ); aDFA.IncreaseQualityBy( 4096 ); const OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); - rGC.AddFontFile( rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA ); + rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA); } // announce glyphcache fonts - rGC.AnnounceFonts( pFontCollection ); + rFreetypeManager.AnnounceFonts(pFontCollection); // register platform specific font substitutions if available if (!utl::ConfigManager::IsFuzzing()) @@ -503,7 +502,7 @@ bool CairoTextRender::CreateFontSubset( // font since they are the only ones left after the PDF // export has filtered its list of subsettable fonts (for // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont + // be to have the FreetypeManager search for the PhysicalFontFace pFont psp::fontID aFont = pFont->GetFontId(); psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); @@ -523,7 +522,7 @@ const void* CairoTextRender::GetEmbedFontData(const PhysicalFontFace* pFont, lon // font since they are the only ones left after the PDF // export has filtered its list of subsettable fonts (for // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont + // be to have the FreetypeManager search for the PhysicalFontFace pFont psp::fontID aFont = pFont->GetFontId(); return GenPspGraphics::DoGetEmbedFontData(aFont, pDataLen); } @@ -542,7 +541,7 @@ void CairoTextRender::GetGlyphWidths( const PhysicalFontFace* pFont, // font since they are the only ones left after the PDF // export has filtered its list of subsettable fonts (for // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont + // be to have the FreetypeManager search for the PhysicalFontFace pFont psp::fontID aFont = pFont->GetFontId(); GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); } diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx index 81af057a06ac..426a5222e143 100644 --- a/vcl/unx/generic/gdi/x11cairotextrender.cxx +++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx @@ -29,11 +29,6 @@ X11CairoTextRender::X11CairoTextRender(X11SalGraphics& rParent) { } -GlyphCache& X11CairoTextRender::getPlatformGlyphCache() -{ - return GlyphCache::GetInstance(); -} - cairo_t* X11CairoTextRender::getCairoContext() { return mrParent.getCairoContext(); diff --git a/vcl/unx/generic/gdi/x11cairotextrender.hxx b/vcl/unx/generic/gdi/x11cairotextrender.hxx index 3eaf220f3eb6..666f09f8c0c9 100644 --- a/vcl/unx/generic/gdi/x11cairotextrender.hxx +++ b/vcl/unx/generic/gdi/x11cairotextrender.hxx @@ -35,7 +35,6 @@ protected: public: explicit X11CairoTextRender(X11SalGraphics& rParent); - virtual GlyphCache& getPlatformGlyphCache() override; virtual cairo_t* getCairoContext() override; virtual void getSurfaceOffset(double& nDX, double& nDY) override; virtual void clipRegion(cairo_t* cr) override; diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 6535c7c4b976..5d64fc08c4a1 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -278,7 +278,7 @@ void FreetypeFontInfo::AnnounceFont( PhysicalFontCollection* pFontCollection ) pFontCollection->Add( pFD.get() ); } -void GlyphCache::InitFreetype() +void FreetypeManager::InitFreetype() { /*FT_Error rcFT =*/ FT_Init_FreeType( &aLibFT ); @@ -319,7 +319,7 @@ FT_Face FreetypeFont::GetFtFace() const return maFaceFT; } -void GlyphCache::AddFontFile(const OString& rNormalizedName, +void FreetypeManager::AddFontFile(const OString& rNormalizedName, int nFaceNum, int nVariantNum, sal_IntPtr nFontId, const FontAttributes& rDevFontAttr) { if( rNormalizedName.isEmpty() ) @@ -335,7 +335,7 @@ void GlyphCache::AddFontFile(const OString& rNormalizedName, m_nMaxFontId = nFontId; } -void GlyphCache::AnnounceFonts( PhysicalFontCollection* pToAdd ) const +void FreetypeManager::AnnounceFonts( PhysicalFontCollection* pToAdd ) const { for (auto const& font : m_aFontInfoList) { @@ -344,7 +344,7 @@ void GlyphCache::AnnounceFonts( PhysicalFontCollection* pToAdd ) const } } -FreetypeFont* GlyphCache::CreateFont(LogicalFontInstance* pFontInstance) +FreetypeFont* FreetypeManager::CreateFont(LogicalFontInstance* pFontInstance) { // find a FontInfo matching to the font id if (!pFontInstance) diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index 9640ea70adcf..40e96b9789df 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -26,20 +26,20 @@ #include <rtl/ustring.hxx> #include <sal/log.hxx> -GlyphCache::GlyphCache() -: mnBytesUsed(sizeof(GlyphCache)), +FreetypeManager::FreetypeManager() +: mnBytesUsed(sizeof(FreetypeManager)), mpCurrentGCFont(nullptr) , m_nMaxFontId(0) { InitFreetype(); } -GlyphCache::~GlyphCache() +FreetypeManager::~FreetypeManager() { ClearFontCache(); } -void GlyphCache::ClearFontCache() +void FreetypeManager::ClearFontCache() { for (auto &aFontPair : maFontList) static_cast<FreetypeFontInstance*>(aFontPair.first.get())->SetFreetypeFont(nullptr); @@ -48,7 +48,7 @@ void GlyphCache::ClearFontCache() m_aFontInfoList.clear(); } -void GlyphCache::ClearFontOptions() +void FreetypeManager::ClearFontOptions() { for (auto const& font : maFontList) { @@ -66,7 +66,7 @@ static sal_IntPtr GetFontId(const LogicalFontInstance& rFontInstance) } inline -size_t GlyphCache::IFSD_Hash::operator()(const rtl::Reference<LogicalFontInstance>& rFontInstance) const +size_t FreetypeManager::IFSD_Hash::operator()(const rtl::Reference<LogicalFontInstance>& rFontInstance) const { // TODO: is it worth to improve this hash function? sal_uIntPtr nFontId = GetFontId(*rFontInstance); @@ -91,7 +91,7 @@ size_t GlyphCache::IFSD_Hash::operator()(const rtl::Reference<LogicalFontInstanc return seed; } -bool GlyphCache::IFSD_Equal::operator()(const rtl::Reference<LogicalFontInstance>& rAFontInstance, +bool FreetypeManager::IFSD_Equal::operator()(const rtl::Reference<LogicalFontInstance>& rAFontInstance, const rtl::Reference<LogicalFontInstance>& rBFontInstance) const { if (!rAFontInstance->GetFontCache() || !rBFontInstance->GetFontCache()) @@ -141,14 +141,14 @@ bool GlyphCache::IFSD_Equal::operator()(const rtl::Reference<LogicalFontInstance return true; } -GlyphCache& GlyphCache::GetInstance() +FreetypeManager& FreetypeManager::get() { GenericUnixSalData* const pSalData(GetGenericUnixSalData()); assert(pSalData); - return *pSalData->GetGlyphCache(); + return *pSalData->GetFreetypeManager(); } -FreetypeFont* GlyphCache::CacheFont(LogicalFontInstance* pFontInstance) +FreetypeFont* FreetypeManager::CacheFont(LogicalFontInstance* pFontInstance) { // a serverfont request has a fontid > 0 if (GetFontId(*pFontInstance) <= 0) @@ -190,7 +190,7 @@ FreetypeFont* GlyphCache::CacheFont(LogicalFontInstance* pFontInstance) return pNew; } -void GlyphCache::UncacheFont( FreetypeFont& rFreetypeFont ) +void FreetypeManager::UncacheFont( FreetypeFont& rFreetypeFont ) { if( (rFreetypeFont.Release() <= 0) && (gnMaxSize <= mnBytesUsed) ) { @@ -199,7 +199,7 @@ void GlyphCache::UncacheFont( FreetypeFont& rFreetypeFont ) } } -void GlyphCache::TryGarbageCollectFont(LogicalFontInstance *pFontInstance) +void FreetypeManager::TryGarbageCollectFont(LogicalFontInstance *pFontInstance) { if (maFontList.empty() || !pFontInstance) return; @@ -214,7 +214,7 @@ void GlyphCache::TryGarbageCollectFont(LogicalFontInstance *pFontInstance) } } -void GlyphCache::GarbageCollect() +void FreetypeManager::GarbageCollect() { // when current GC font has been destroyed get another one if( !mpCurrentGCFont ) @@ -236,7 +236,7 @@ void GlyphCache::GarbageCollect() && (pFreetypeFont->GetRefCount() <= 0) ) // font still used { SAL_WARN_IF( (pFreetypeFont->GetRefCount() != 0), "vcl", - "GlyphCache::GC detected RefCount underflow" ); + "FreetypeManager::GC detected RefCount underflow" ); // free all pFreetypeFont related data if( pFreetypeFont == mpCurrentGCFont ) @@ -259,7 +259,7 @@ void GlyphCache::GarbageCollect() } } -FreetypeFontFile* GlyphCache::FindFontFile(const OString& rNativeFileName) +FreetypeFontFile* FreetypeManager::FindFontFile(const OString& rNativeFileName) { // font file already known? (e.g. for ttc, synthetic, aliased fonts) const char* pFileName = rNativeFileName.getStr(); diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index 61d924caf999..ab5c2ab77d7a 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -616,7 +616,7 @@ void GenPspGraphics::SetFont(LogicalFontInstance *pFontInstance, int nFallbackLe if( m_pFreetypeFont[i] != nullptr ) { // old server side font is no longer referenced - GlyphCache::GetInstance().UncacheFont( *m_pFreetypeFont[i] ); + FreetypeManager::get().UncacheFont(*m_pFreetypeFont[i]); m_pFreetypeFont[i] = nullptr; } } @@ -647,13 +647,13 @@ void GenPspGraphics::SetFont(LogicalFontInstance *pFontInstance, int nFallbackLe // also set the serverside font for layouting // requesting a font provided by builtin rasterizer - FreetypeFont* pFreetypeFont = GlyphCache::GetInstance().CacheFont(pFontInstance); + FreetypeFont* pFreetypeFont = FreetypeManager::get().CacheFont(pFontInstance); if( pFreetypeFont != nullptr ) { if( pFreetypeFont->TestFont() ) m_pFreetypeFont[ nFallbackLevel ] = pFreetypeFont; else - GlyphCache::GetInstance().UncacheFont( *pFreetypeFont ); + FreetypeManager::get().UncacheFont( *pFreetypeFont ); } // set the printer font @@ -682,8 +682,7 @@ bool GenPspGraphics::AddTempDevFont( PhysicalFontCollection*, const OUString&,co bool GenPspGraphics::AddTempDevFontHelper( PhysicalFontCollection* pFontCollection, const OUString& rFileURL, - const OUString& rFontName, - GlyphCache &rGC ) + const OUString& rFontName) { // inform PSP font manager psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); @@ -691,6 +690,7 @@ bool GenPspGraphics::AddTempDevFontHelper( PhysicalFontCollection* pFontCollecti if( aFontIds.empty() ) return false; + FreetypeManager& rFreetypeManager = FreetypeManager::get(); for (auto const& elem : aFontIds) { // prepare font data @@ -706,11 +706,11 @@ bool GenPspGraphics::AddTempDevFontHelper( PhysicalFontCollection* pFontCollecti int nVariantNum = rMgr.getFontFaceVariation( aInfo.m_nID ); const OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); - rGC.AddFontFile( rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA ); + rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA); } // announce new font to device's font list - rGC.AnnounceFonts( pFontCollection ); + rFreetypeManager.AnnounceFonts(pFontCollection); return true; } @@ -731,7 +731,7 @@ void GenPspGraphics::GetDevFontList( PhysicalFontCollection *pFontCollection ) void GenPspGraphics::ClearDevFontCache() { - GlyphCache::GetInstance().ClearFontCache(); + FreetypeManager::get().ClearFontCache(); } void GenPspGraphics::GetFontMetric(ImplFontMetricDataRef& rxFontMetric, int nFallbackLevel) @@ -765,7 +765,7 @@ bool GenPspGraphics::CreateFontSubset( // font since they are the only ones left after the PDF // export has filtered its list of subsettable fonts (for // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont + // be to have the FreetypeManager search for the PhysicalFontFace pFont psp::fontID aFont = pFont->GetFontId(); psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); @@ -788,7 +788,7 @@ void GenPspGraphics::GetGlyphWidths( const PhysicalFontFace* pFont, // font since they are the only ones left after the PDF // export has filtered its list of subsettable fonts (for // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont + // be to have the FreetypeManager search for the PhysicalFontFace pFont psp::fontID aFont = pFont->GetFontId(); GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); } @@ -997,7 +997,7 @@ const void* GenPspGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long // font since they are the only ones left after the PDF // export has filtered its list of subsettable fonts (for // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont + // be to have the FreetypeManager search for the PhysicalFontFace pFont psp::fontID aFont = pFont->GetFontId(); return DoGetEmbedFontData(aFont, pDataLen); } |