summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-08-21 08:38:57 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-08-22 00:24:15 +0200
commitb10c8f3fce37d72019f4767fdb9612b46845aecd (patch)
treeb6a74975522b301cb9892021a32135ee75bf7a2d /vcl/unx
parent4790dd4d957827f9b2eeffe23ce1a8d63635df0d (diff)
turn the cache around to work on LogicalFontInstance
instead of a FontSelectPattern with an associated LogicalFontInstance use a LogicalFontInstance with owned FontSelectPatternAttributes Change-Id: I939f84731fcb8db5ff6484dcfbd2f9199bb50d23 Reviewed-on: https://gerrit.libreoffice.org/59388 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx6
-rw-r--r--vcl/unx/generic/glyphs/freetype_glyphcache.cxx2
-rw-r--r--vcl/unx/generic/glyphs/glyphcache.cxx39
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx23
4 files changed, 35 insertions, 35 deletions
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 600a1eaafa81..3b250838e785 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -84,7 +84,7 @@ CairoTextRender::CairoTextRender()
rp = nullptr;
}
-void CairoTextRender::setFont( LogicalFontInstance *pEntry, int nFallbackLevel )
+void CairoTextRender::setFont(LogicalFontInstance *pEntry, int nFallbackLevel)
{
// release all no longer needed font resources
for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
@@ -102,7 +102,7 @@ void CairoTextRender::setFont( LogicalFontInstance *pEntry, int nFallbackLevel )
return;
// handle the request for a non-native X11-font => use the GlyphCache
- FreetypeFont* pFreetypeFont = GlyphCache::GetInstance().CacheFont(pEntry->GetFontSelectPattern());
+ FreetypeFont* pFreetypeFont = GlyphCache::GetInstance().CacheFont(pEntry);
if( pFreetypeFont != nullptr )
{
// ignore fonts with e.g. corrupted font files
@@ -364,7 +364,7 @@ bool CairoTextRender::GetFontCapabilities(vcl::FontCapabilities &rGetImplFontCap
// SalGraphics
-void CairoTextRender::SetFont( LogicalFontInstance *pEntry, int nFallbackLevel )
+void CairoTextRender::SetFont(LogicalFontInstance *pEntry, int nFallbackLevel)
{
setFont(pEntry, nFallbackLevel);
}
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index da5d6e650ed6..0dd01d679ad0 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -353,7 +353,7 @@ FreetypeFontFace::FreetypeFontFace( FreetypeFontInfo* pFI, const FontAttributes&
{
}
-rtl::Reference<LogicalFontInstance> FreetypeFontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
+rtl::Reference<LogicalFontInstance> FreetypeFontFace::CreateFontInstance(const FontSelectPatternAttributes& rFSD) const
{
return new FreetypeFontInstance(*this, rFSD);
}
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx
index 321707a97535..b48e3178c35b 100644
--- a/vcl/unx/generic/glyphs/glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/glyphcache.cxx
@@ -72,18 +72,20 @@ void GlyphCache::ClearFontOptions()
}
}
-static inline sal_IntPtr GetFontId(const FontSelectPattern& rFSP)
+static inline sal_IntPtr GetFontId(const LogicalFontInstance& rFontInstance)
{
- if (rFSP.mpFontInstance && rFSP.mpFontInstance->GetFontFace())
- return rFSP.mpFontInstance->GetFontFace()->GetFontId();
+ if (rFontInstance.GetFontFace())
+ return rFontInstance.GetFontFace()->GetFontId();
return 0;
}
inline
-size_t GlyphCache::IFSD_Hash::operator()( const FontSelectPattern& rFontSelData ) const
+size_t GlyphCache::IFSD_Hash::operator()(const rtl::Reference<LogicalFontInstance>& rFontInstance) const
{
// TODO: is it worth to improve this hash function?
- sal_uIntPtr nFontId = GetFontId(rFontSelData);
+ sal_uIntPtr nFontId = GetFontId(*rFontInstance);
+
+ const FontSelectPatternAttributes& rFontSelData = rFontInstance->GetFontSelectPattern();
if (rFontSelData.maTargetName.indexOf(FontSelectPatternAttributes::FEAT_PREFIX)
!= -1)
@@ -103,15 +105,19 @@ size_t GlyphCache::IFSD_Hash::operator()( const FontSelectPattern& rFontSelData
return nHash;
}
-bool GlyphCache::IFSD_Equal::operator()( const FontSelectPattern& rA, const FontSelectPattern& rB) const
+bool GlyphCache::IFSD_Equal::operator()(const rtl::Reference<LogicalFontInstance>& rAFontInstance,
+ const rtl::Reference<LogicalFontInstance>& rBFontInstance) const
{
- if (!rA.mpFontInstance->GetFontCache() || !rB.mpFontInstance->GetFontCache())
+ if (!rAFontInstance->GetFontCache() || !rBFontInstance->GetFontCache())
return false;
// check font ids
- if (GetFontId(rA) != GetFontId(rB))
+ if (GetFontId(*rAFontInstance) != GetFontId(*rBFontInstance))
return false;
+ const FontSelectPatternAttributes& rA = rAFontInstance->GetFontSelectPattern();
+ const FontSelectPatternAttributes& rB = rBFontInstance->GetFontSelectPattern();
+
// compare with the requested metrics
if( (rA.mnHeight != rB.mnHeight)
|| (rA.mnOrientation != rB.mnOrientation)
@@ -174,13 +180,13 @@ void GlyphCache::ClearFontCache()
mpFtManager->ClearFontList();
}
-FreetypeFont* GlyphCache::CacheFont( const FontSelectPattern& rFontSelData )
+FreetypeFont* GlyphCache::CacheFont(LogicalFontInstance* pFontInstance)
{
// a serverfont request has a fontid > 0
- if (GetFontId(rFontSelData) <= 0)
+ if (GetFontId(*pFontInstance) <= 0)
return nullptr;
- FontList::iterator it = maFontList.find(rFontSelData);
+ FontList::iterator it = maFontList.find(pFontInstance);
if( it != maFontList.end() )
{
FreetypeFont* pFound = it->second.get();
@@ -191,12 +197,12 @@ FreetypeFont* GlyphCache::CacheFont( const FontSelectPattern& rFontSelData )
// font not cached yet => create new font item
FreetypeFont* pNew = nullptr;
- if( mpFtManager )
- pNew = mpFtManager->CreateFont(rFontSelData.mpFontInstance.get());
+ if (mpFtManager)
+ pNew = mpFtManager->CreateFont(pFontInstance);
if( pNew )
{
- maFontList[ rFontSelData ].reset(pNew);
+ maFontList[pFontInstance].reset(pNew);
mnBytesUsed += pNew->GetByteCount();
// enable garbage collection for new font
@@ -260,8 +266,7 @@ void GlyphCache::GarbageCollect()
pFreetypeFont->GarbageCollect( mnLruIndex+0x10000000 );
if( pFreetypeFont == mpCurrentGCFont )
mpCurrentGCFont = nullptr;
- const FontSelectPattern& rIFSD = pFreetypeFont->GetFontInstance()->GetFontSelectPattern();
- maFontList.erase( rIFSD );
+ maFontList.erase(pFreetypeFont->GetFontInstance());
mnBytesUsed -= pFreetypeFont->GetByteCount();
// remove font from list of garbage collected fonts
@@ -349,7 +354,7 @@ void FreetypeFont::GarbageCollect( long nMinLruIndex )
}
}
-FreetypeFontInstance::FreetypeFontInstance(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP)
+FreetypeFontInstance::FreetypeFontInstance(const PhysicalFontFace& rPFF, const FontSelectPatternAttributes& rFSP)
: LogicalFontInstance(rPFF, rFSP)
, mpFreetypeFont(nullptr)
{}
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 7bd9490899ad..aa376c7629fe 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -592,7 +592,7 @@ bool GenPspGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilitie
return m_pFreetypeFont[0]->GetFontCapabilities(rFontCapabilities);
}
-void GenPspGraphics::SetFont( LogicalFontInstance *pFontInstance, int nFallbackLevel )
+void GenPspGraphics::SetFont(LogicalFontInstance *pFontInstance, int nFallbackLevel)
{
// release all fonts that are to be overridden
for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
@@ -611,7 +611,7 @@ void GenPspGraphics::SetFont( LogicalFontInstance *pFontInstance, int nFallbackL
sal_IntPtr nID = pFontInstance->GetFontFace()->GetFontId();
- const FontSelectPattern& rEntry = pFontInstance->GetFontSelectPattern();
+ const FontSelectPatternAttributes& rEntry = pFontInstance->GetFontSelectPattern();
// determine which font attributes need to be emulated
bool bArtItalic = false;
@@ -629,20 +629,15 @@ void GenPspGraphics::SetFont( LogicalFontInstance *pFontInstance, int nFallbackL
bArtBold = true;
}
- assert(rEntry.mpFontInstance == pFontInstance);
-
// also set the serverside font for layouting
- if( rEntry.mpFontInstance )
+ // requesting a font provided by builtin rasterizer
+ FreetypeFont* pFreetypeFont = GlyphCache::GetInstance().CacheFont(pFontInstance);
+ if( pFreetypeFont != nullptr )
{
- // requesting a font provided by builtin rasterizer
- FreetypeFont* pFreetypeFont = GlyphCache::GetInstance().CacheFont( rEntry );
- if( pFreetypeFont != nullptr )
- {
- if( pFreetypeFont->TestFont() )
- m_pFreetypeFont[ nFallbackLevel ] = pFreetypeFont;
- else
- GlyphCache::GetInstance().UncacheFont( *pFreetypeFont );
- }
+ if( pFreetypeFont->TestFont() )
+ m_pFreetypeFont[ nFallbackLevel ] = pFreetypeFont;
+ else
+ GlyphCache::GetInstance().UncacheFont( *pFreetypeFont );
}
// set the printer font