[Libreoffice-commits] core.git: vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Oct 6 13:19:58 UTC 2018


 vcl/win/gdi/salfont.cxx |   19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

New commits:
commit 01a782d2ceb741d20721b44d26d862d80b47d226
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Oct 4 14:05:30 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Sat Oct 6 15:19:38 2018 +0200

    tdf#119829 use font cache based glyph rect cache
    
    The current glyph cache on Windows didn't work for multiple fonts
    and had to be manually invalidated on font change. The new glyph
    rect cache is coupled to the font cache and will invalidate all
    cached glyph rects, if a cached font is released.
    
    So switch to the new cache on Windows.
    
    Change-Id: Ic641f78e2e664dc0ad52e595d5fdfb6ef611eb3f
    Reviewed-on: https://gerrit.libreoffice.org/61278
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index ba205d1c8d74..a93141ff83e5 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -60,11 +60,6 @@
 
 using namespace vcl;
 
-// GetGlyphOutlineW() seems to be a little slow, and doesn't seem to do its own caching (tested on Windows10).
-// TODO include the font as part of the cache key, then we won't need to clear it on font change
-// The cache limit is set by the rough number of characters needed to read your average Asian newspaper.
-static o3tl::lru_map<sal_GlyphId, tools::Rectangle> g_BoundRectCache(3000);
-
 static const int MAXFONTHEIGHT = 2048;
 
 static inline FIXED FixedFromDouble( double d )
@@ -846,8 +841,6 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
                                     float& o_rFontScale,
                                     HFONT& o_rOldFont)
 {
-    // clear the cache on font change
-    g_BoundRectCache.clear();
     HFONT hNewFont = nullptr;
 
     LOGFONTW aLogFont;
@@ -1335,16 +1328,12 @@ void WinSalGraphics::ClearDevFontCache()
 
 bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
 {
-    auto it = g_BoundRectCache.find(rGlyph.maGlyphId);
-    if (it != g_BoundRectCache.end())
-    {
-        rRect = it->second;
-        return true;
-    }
-
     rtl::Reference<WinFontInstance> pFont = mpWinFontEntry[rGlyph.mnFallbackLevel];
     assert(pFont.is());
 
+    if (pFont.is() && pFont->GetCachedGlyphBoundRect(rGlyph.maGlyphId, rRect))
+        return true;
+
     HDC hDC = getHDC();
     HFONT hFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT));
     float fFontScale = 1.0;
@@ -1379,7 +1368,7 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle
     rRect.SetTop(static_cast<int>( fFontScale * rRect.Top() ));
     rRect.SetBottom(static_cast<int>( fFontScale * rRect.Bottom() ) + 1);
 
-    g_BoundRectCache.insert({rGlyph.maGlyphId, rRect});
+    pFont->CacheGlyphBoundRect(rGlyph.maGlyphId, rRect);
 
     return true;
 }


More information about the Libreoffice-commits mailing list