summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-05-27 16:37:30 +0200
committerMatúš Kukan <matus.kukan@collabora.com>2014-05-28 08:47:12 +0200
commitda5ab383bd4695956b338e176de55f3a163aecbd (patch)
treee6b92f7184984c24d25018f602bea356d0c7a85b
parent1d0447c2d1b2ce41edf2972b72ba1d59349ef62e (diff)
Related bnc#822625: Cache FontEntry with the original FontSelectPattern.
Otherwise we never hit cache directly, only after expensive call to ImplFindByFont. Change-Id: If15b368feeba94c8fff8ee7cbe049fc4a2069768 (cherry picked from commit a6b00d16eb27a5e7e31c721671001a909ecef960)
-rw-r--r--vcl/inc/outdev.h2
-rw-r--r--vcl/source/outdev/font.cxx12
2 files changed, 8 insertions, 6 deletions
diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h
index dcde57c09ee9..e468ae22534a 100644
--- a/vcl/inc/outdev.h
+++ b/vcl/inc/outdev.h
@@ -149,7 +149,7 @@ public:
ImplFontEntry* GetFontEntry( PhysicalFontCollection*,
const Font&, const Size& rPixelSize, float fExactHeight);
- ImplFontEntry* GetFontEntry( PhysicalFontCollection*, FontSelectPattern& );
+ ImplFontEntry* GetFontEntry( PhysicalFontCollection*, const FontSelectPattern& );
ImplFontEntry* GetGlyphFallbackFont( PhysicalFontCollection*, FontSelectPattern&,
int nFallbackLevel, OUString& rMissingCodes );
void Release( ImplFontEntry* );
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 9e40712e3051..d8b77db84134 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1227,22 +1227,23 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
}
ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
- FontSelectPattern& aFontSelData )
+ const FontSelectPattern& rFontSelData )
{
// check if a directly matching logical font instance is already cached,
// the most recently used font usually has a hit rate of >50%
ImplFontEntry *pEntry = NULL;
PhysicalFontFamily* pFontFamily = NULL;
IFSD_Equal aIFSD_Equal;
- if( mpFirstEntry && aIFSD_Equal( aFontSelData, mpFirstEntry->maFontSelData ) )
+ if( mpFirstEntry && aIFSD_Equal( rFontSelData, mpFirstEntry->maFontSelData ) )
pEntry = mpFirstEntry;
else
{
- FontInstanceList::iterator it = maFontInstanceList.find( aFontSelData );
+ FontInstanceList::iterator it = maFontInstanceList.find( rFontSelData );
if( it != maFontInstanceList.end() )
pEntry = (*it).second;
}
+ FontSelectPattern aFontSelData(rFontSelData);
if( !pEntry ) // no direct cache hit
{
// find the best matching logical font family and update font selector accordingly
@@ -1315,8 +1316,9 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
}
#endif
- // add the new entry to the cache
- maFontInstanceList[ aFontSelData ] = pEntry;
+ // Add the new entry to the cache with the original FontSelectPattern,
+ // so that we can find it next time as a direct cache hit.
+ maFontInstanceList[ rFontSelData ] = pEntry;
}
mpFirstEntry = pEntry;