Kaydet (Commit) 44377b91 authored tarafından Jan Holesovsky's avatar Jan Holesovsky Kaydeden (comit) Michael Stahl

vcl: Improve management of mnRef0Count.

Follow-up to 34700400; this fixes sw_ww8export
unit test on Windows.

Change-Id: Ic0c3228efb59a182e1562b73117418cd8b5e6017
Reviewed-on: https://gerrit.libreoffice.org/18175Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 64895577
......@@ -157,7 +157,12 @@ public:
ImplFontEntry* GetFontEntry( PhysicalFontCollection*, FontSelectPattern& );
ImplFontEntry* GetGlyphFallbackFont( PhysicalFontCollection*, FontSelectPattern&,
int nFallbackLevel, OUString& rMissingCodes );
void Release( ImplFontEntry* );
/// Increase the refcount of the given ImplFontEntry.
void Acquire(ImplFontEntry*);
/// Decrease the refcount and potentially cleanup the entries with zero refcount from the cache.
void Release(ImplFontEntry*);
void Invalidate();
};
......
......@@ -1316,8 +1316,7 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
if( pEntry ) // cache hit => use existing font instance
{
// increase the font instance's reference count
if( !pEntry->mnRefCount++ )
--mnRef0Count;
Acquire(pEntry);
}
if (!pEntry && pFontData)// still no cache hit => create a new font instance
......@@ -1390,7 +1389,15 @@ ImplFontEntry* ImplFontCache::GetGlyphFallbackFont( PhysicalFontCollection* pFon
return pFallbackFont;
}
void ImplFontCache::Release( ImplFontEntry* pEntry )
void ImplFontCache::Acquire(ImplFontEntry* pEntry)
{
assert(pEntry->m_pFontCache == this);
if (0 == pEntry->mnRefCount++)
--mnRef0Count;
}
void ImplFontCache::Release(ImplFontEntry* pEntry)
{
static const int FONTCACHE_MAX = 50;
......@@ -1401,6 +1408,8 @@ void ImplFontCache::Release( ImplFontEntry* pEntry )
if (++mnRef0Count < FONTCACHE_MAX)
return;
assert(CountUnreferencedEntries() == mnRef0Count);
// remove unused entries from font instance cache
FontInstanceList::iterator it_next = maFontInstanceList.begin();
while( it_next != maFontInstanceList.end() )
......
......@@ -455,7 +455,8 @@ WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWF
mrWinFontEntry(rWFE),
mbUseOpenGL(bUseOpenGL)
{
++mrWinFontEntry.mnRefCount; // keep it alive
// keep mrWinFontEntry alive
mrWinFontEntry.m_pFontCache->Acquire(&mrWinFontEntry);
}
WinLayout::~WinLayout()
......
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