[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - vcl/inc vcl/source vcl/win

Jan Holesovsky kendy at collabora.com
Mon Aug 31 07:53:00 PDT 2015


 vcl/inc/outdev.h                 |    7 ++++++-
 vcl/source/outdev/font.cxx       |   15 ++++++++++++---
 vcl/win/source/gdi/winlayout.cxx |    2 +-
 3 files changed, 19 insertions(+), 5 deletions(-)

New commits:
commit df6f0031020da56bc38dcd240e9cc0a0446ae06a
Author: Jan Holesovsky <kendy at 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.
    
    Reviewed-on: https://gerrit.libreoffice.org/18175
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 44377b911f9e19e43f14e390b69db4055f423b6a)
    Signed-off-by: Michael Stahl <mstahl at redhat.com>
    
    Change-Id: Ic0c3228efb59a182e1562b73117418cd8b5e6017

diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h
index 5581fe1..d8a27b3 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 6e46b80..c7faaef 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 d010985..11f6248a 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()


More information about the Libreoffice-commits mailing list