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

Noel Grandin noel.grandin at collabora.co.uk
Fri May 4 10:32:52 UTC 2018


 vcl/inc/win/salgdi.h    |    1 -
 vcl/win/gdi/salfont.cxx |   24 +++++++-----------------
 vcl/win/gdi/salgdi.cxx  |    3 +--
 3 files changed, 8 insertions(+), 20 deletions(-)

New commits:
commit e74fd983e3195ea2867acd4b925e9899571a1651
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu May 3 13:38:44 2018 +0200

    tdf#117364 Special Character dialog grid font issues
    
    Revert "tdf#113643 Editing tables in Impress lags terribly"
    This reverts commit 13a1bc409d9b2f0d14f4d316b7977b1fc2eb3c8a.
    
    Will probably need more sophisticated caching, so just revert this
    for now.
    
    Change-Id: I05cc26b911d3d138b57098656ea0c9c3c4e82592
    Reviewed-on: https://gerrit.libreoffice.org/53784
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index f45d85c4c89c..23531842dde3 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -177,7 +177,6 @@ private:
     RGNDATA*                mpClipRgnData;      // ClipRegion-Data
     RGNDATA*                mpStdClipRgnData;   // Cache Standard-ClipRegion-Data
     int                     mnPenWidth;         // line width
-    const PhysicalFontFace* mpCurrentPhysicalFontFace; // the font face currently selected into the DC
 
     LogicalFontInstance* GetWinFontEntry(int nFallbackLevel);
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 0acdbd666bef..6fe84173c710 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -57,22 +57,10 @@
 
 using namespace vcl;
 
-using BoundRectCacheKey = std::pair<PhysicalFontFace const *,sal_GlyphId>;
-namespace std
-{
-    template<> struct hash<BoundRectCacheKey>
-    {
-        std::size_t operator()(const BoundRectCacheKey & key ) const
-        {
-            return std::hash<PhysicalFontFace const *>()(key.first)
-                ^  std::hash<sal_GlyphId>()(key.second);
-        }
-    };
-};
 // GetGlyphOutlineW() seems to be a little slow, and doesn't seem to do it's 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<BoundRectCacheKey, tools::Rectangle> g_BoundRectCache(3000);
+static o3tl::lru_map<sal_GlyphId, tools::Rectangle> g_BoundRectCache(3000);
 
 static const int MAXFONTHEIGHT = 2048;
 
@@ -852,9 +840,10 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 
 HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const * i_pFont, float& o_rFontScale, HFONT& o_rOldFont)
 {
-    mpCurrentPhysicalFontFace = i_pFont->mpFontData;
-
+    // clear the cache on font change
+    g_BoundRectCache.clear();
     HFONT hNewFont = nullptr;
+
     HDC hdcScreen = nullptr;
     if( mbVirDev )
         // only required for virtual devices, see below for details
@@ -1366,7 +1355,7 @@ void WinSalGraphics::ClearDevFontCache()
 
 bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
 {
-    auto it = g_BoundRectCache.find({mpCurrentPhysicalFontFace,rGlyph.maGlyphId});
+    auto it = g_BoundRectCache.find(rGlyph.maGlyphId);
     if (it != g_BoundRectCache.end())
     {
         rRect = it->second;
@@ -1397,7 +1386,8 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle
     rRect.SetTop(static_cast<int>( mfCurrentFontScale * rRect.Top() ));
     rRect.SetBottom(static_cast<int>( mfCurrentFontScale * rRect.Bottom() ) + 1);
 
-    g_BoundRectCache.insert({{mpCurrentPhysicalFontFace,rGlyph.maGlyphId}, rRect});
+    g_BoundRectCache.insert({rGlyph.maGlyphId, rRect});
+
     return true;
 }
 
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 890b28cc0c57..8aa601a461b2 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -614,8 +614,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
     mhDefFont(nullptr),
     mhDefPal(nullptr),
     mpStdClipRgnData(nullptr),
-    mnPenWidth(GSL_PEN_WIDTH),
-    mpCurrentPhysicalFontFace(nullptr)
+    mnPenWidth(GSL_PEN_WIDTH)
 {
     if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter)
         mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this, pProvider));


More information about the Libreoffice-commits mailing list