Kaydet (Commit) ca77ec42 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

vcl: Improve management of mnRef0Count.

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

Change-Id: Ic0c3228efb59a182e1562b73117418cd8b5e6017
üst 751c5f5b
...@@ -153,7 +153,12 @@ public: ...@@ -153,7 +153,12 @@ public:
ImplFontEntry* GetFontEntry( PhysicalFontCollection*, FontSelectPattern& ); ImplFontEntry* GetFontEntry( PhysicalFontCollection*, FontSelectPattern& );
ImplFontEntry* GetGlyphFallbackFont( PhysicalFontCollection*, FontSelectPattern&, ImplFontEntry* GetGlyphFallbackFont( PhysicalFontCollection*, FontSelectPattern&,
int nFallbackLevel, OUString& rMissingCodes ); 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(); void Invalidate();
}; };
......
...@@ -1326,8 +1326,7 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList, ...@@ -1326,8 +1326,7 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
if( pEntry ) // cache hit => use existing font instance if( pEntry ) // cache hit => use existing font instance
{ {
// increase the font instance's reference count // increase the font instance's reference count
if( !pEntry->mnRefCount++ ) Acquire(pEntry);
--mnRef0Count;
} }
if (!pEntry && pFontData)// still no cache hit => create a new font instance if (!pEntry && pFontData)// still no cache hit => create a new font instance
...@@ -1400,7 +1399,15 @@ ImplFontEntry* ImplFontCache::GetGlyphFallbackFont( PhysicalFontCollection* pFon ...@@ -1400,7 +1399,15 @@ ImplFontEntry* ImplFontCache::GetGlyphFallbackFont( PhysicalFontCollection* pFon
return pFallbackFont; 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; static const int FONTCACHE_MAX = 50;
...@@ -1411,6 +1418,8 @@ void ImplFontCache::Release( ImplFontEntry* pEntry ) ...@@ -1411,6 +1418,8 @@ void ImplFontCache::Release( ImplFontEntry* pEntry )
if (++mnRef0Count < FONTCACHE_MAX) if (++mnRef0Count < FONTCACHE_MAX)
return; return;
assert(CountUnreferencedEntries() == mnRef0Count);
// remove unused entries from font instance cache // remove unused entries from font instance cache
FontInstanceList::iterator it_next = maFontInstanceList.begin(); FontInstanceList::iterator it_next = maFontInstanceList.begin();
while( it_next != maFontInstanceList.end() ) while( it_next != maFontInstanceList.end() )
......
...@@ -455,7 +455,8 @@ WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWF ...@@ -455,7 +455,8 @@ WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWF
mrWinFontEntry(rWFE), mrWinFontEntry(rWFE),
mbUseOpenGL(bUseOpenGL) mbUseOpenGL(bUseOpenGL)
{ {
++mrWinFontEntry.mnRefCount; // keep it alive // keep mrWinFontEntry alive
mrWinFontEntry.m_pFontCache->Acquire(&mrWinFontEntry);
} }
WinLayout::~WinLayout() 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