diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-08-31 15:37:22 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-09-04 17:11:15 +0200 |
commit | 17066c347559de545bbdc0e16d1627b729c86a30 (patch) | |
tree | c82970a0ff207a84f5cf7f98bcb18d6683922f6f /vcl | |
parent | 499a67c2e2934851425d771f811a9c6a10d44bb2 (diff) |
vcl: Improve management of mnRef0Count.
Follow-up to 34700400247e378e074ce4164ab2809edb092201; this fixes sw_ww8export
unit test on Windows.
Reviewed-on: https://gerrit.libreoffice.org/18175
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
(cherry picked from commit 44377b911f9e19e43f14e390b69db4055f423b6a)
Signed-off-by: Michael Stahl <mstahl@redhat.com>
Change-Id: Ic0c3228efb59a182e1562b73117418cd8b5e6017
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/outdev.h | 7 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 15 | ||||
-rw-r--r-- | vcl/win/source/gdi/winlayout.cxx | 2 |
3 files changed, 19 insertions, 5 deletions
diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h index 5581fe1abd64..d8a27b352a14 100644 --- a/vcl/inc/outdev.h +++ b/vcl/inc/outdev.h @@ -154,7 +154,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(); }; diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 6e46b80833fc..c7faaeffef53 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1297,8 +1297,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 @@ -1371,7 +1370,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; @@ -1382,6 +1389,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() ) diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index d010985d779f..11f6248a334a 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -115,7 +115,7 @@ WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWF mrWinFontEntry(rWFE), mbUseOpenGL(bUseOpenGL) { - ++mrWinFontEntry.mnRefCount; // keep it alive + mrWinFontEntry.m_pFontCache->Acquire(&mrWinFontEntry); } WinLayout::~WinLayout() |