Kaydet (Commit) 1a23a85d authored tarafından Matúš Kukan's avatar Matúš Kukan Kaydeden (comit) Fridrich Štrba

Related bnc#822625: Cache FontEntry with the original FontSelectPattern.

Otherwise we never hit cache directly, only after expensive call to
ImplFindByFont.

Change-Id: If15b368feeba94c8fff8ee7cbe049fc4a2069768
üst 792bc97a
...@@ -149,7 +149,7 @@ public: ...@@ -149,7 +149,7 @@ public:
ImplFontEntry* GetFontEntry( PhysicalFontCollection*, ImplFontEntry* GetFontEntry( PhysicalFontCollection*,
const Font&, const Size& rPixelSize, float fExactHeight); const Font&, const Size& rPixelSize, float fExactHeight);
ImplFontEntry* GetFontEntry( PhysicalFontCollection*, FontSelectPattern& ); ImplFontEntry* GetFontEntry( PhysicalFontCollection*, const FontSelectPattern& );
ImplFontEntry* GetGlyphFallbackFont( PhysicalFontCollection*, FontSelectPattern&, ImplFontEntry* GetGlyphFallbackFont( PhysicalFontCollection*, FontSelectPattern&,
int nFallbackLevel, OUString& rMissingCodes ); int nFallbackLevel, OUString& rMissingCodes );
void Release( ImplFontEntry* ); void Release( ImplFontEntry* );
......
...@@ -1227,22 +1227,23 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList, ...@@ -1227,22 +1227,23 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
} }
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, // check if a directly matching logical font instance is already cached,
// the most recently used font usually has a hit rate of >50% // the most recently used font usually has a hit rate of >50%
ImplFontEntry *pEntry = NULL; ImplFontEntry *pEntry = NULL;
PhysicalFontFamily* pFontFamily = NULL; PhysicalFontFamily* pFontFamily = NULL;
IFSD_Equal aIFSD_Equal; IFSD_Equal aIFSD_Equal;
if( mpFirstEntry && aIFSD_Equal( aFontSelData, mpFirstEntry->maFontSelData ) ) if( mpFirstEntry && aIFSD_Equal( rFontSelData, mpFirstEntry->maFontSelData ) )
pEntry = mpFirstEntry; pEntry = mpFirstEntry;
else else
{ {
FontInstanceList::iterator it = maFontInstanceList.find( aFontSelData ); FontInstanceList::iterator it = maFontInstanceList.find( rFontSelData );
if( it != maFontInstanceList.end() ) if( it != maFontInstanceList.end() )
pEntry = (*it).second; pEntry = (*it).second;
} }
FontSelectPattern aFontSelData(rFontSelData);
if( !pEntry ) // no direct cache hit if( !pEntry ) // no direct cache hit
{ {
// find the best matching logical font family and update font selector accordingly // find the best matching logical font family and update font selector accordingly
...@@ -1315,8 +1316,9 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList, ...@@ -1315,8 +1316,9 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
} }
#endif #endif
// add the new entry to the cache // Add the new entry to the cache with the original FontSelectPattern,
maFontInstanceList[ aFontSelData ] = pEntry; // so that we can find it next time as a direct cache hit.
maFontInstanceList[ rFontSelData ] = pEntry;
} }
mpFirstEntry = pEntry; mpFirstEntry = pEntry;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment