vcl/inc/outdev.h | 7 ++++++- vcl/source/outdev/font.cxx | 15 ++++++++++++--- vcl/win/source/gdi/winlayout.cxx | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-)
New commits: commit ca77ec422ea617c84400370b082e71437e4590cc Author: Jan Holesovsky <ke...@collabora.com> Date: Mon Aug 31 15:37:22 2015 +0200 vcl: Improve management of mnRef0Count. Follow-up to 34700400247e378e074ce4164ab2809edb092201; this fixes sw_ww8export unit test on Windows. Change-Id: Ic0c3228efb59a182e1562b73117418cd8b5e6017 diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h index a4cc54f..628329e 100644 --- a/vcl/inc/outdev.h +++ b/vcl/inc/outdev.h @@ -153,7 +153,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 b673f91..6960525 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1326,8 +1326,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 @@ -1400,7 +1399,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; @@ -1411,6 +1418,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 a7f44e2..cd4b369 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -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() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits