[Libreoffice-commits] core.git: include/o3tl vcl/win
Noel Grandin
noel at peralex.com
Wed Apr 11 17:01:50 UTC 2018
include/o3tl/lru_map.hxx | 3 ++-
vcl/win/gdi/salfont.cxx | 8 +++-----
2 files changed, 5 insertions(+), 6 deletions(-)
New commits:
commit 8094fa17207729c119f7a1fa399286919dd1a8a3
Author: Noel Grandin <noel at peralex.com>
Date: Wed Apr 11 15:53:35 2018 +0200
improve commit 95eb921ec06ee7
"tdf#108608 more Draw text editing responsiveness fixes"
lru_map is fine on Windows, was a bug in the new clear method I
added.
Change-Id: I27565675dfe0f57e2ba3c3e0c50297770761dc6a
Reviewed-on: https://gerrit.libreoffice.org/52728
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/o3tl/lru_map.hxx b/include/o3tl/lru_map.hxx
index 4eb05bd97a43..f2369e45030a 100644
--- a/include/o3tl/lru_map.hxx
+++ b/include/o3tl/lru_map.hxx
@@ -125,7 +125,7 @@ public:
const list_const_iterator_t end() const
{
- return mLruList.end();
+ return mLruList.cend();
}
size_t size() const
@@ -135,6 +135,7 @@ public:
void clear()
{
+ mLruMap.clear();
mLruList.clear();
}
};
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index e415ec8fa1b3..7c6bb027f245 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -28,6 +28,7 @@
#include <svsys.h>
#include <vector>
+#include <o3tl/lru_map.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <i18nlangtag/mslangid.hxx>
@@ -57,10 +58,9 @@
using namespace vcl;
// GetGlyphOutlineW() seems to be a little slow, and doesn't seem to do it's own caching (tested on Windows10).
-// TODO use something a little smarter here like an LRU cache, and include the font as part of the cache key
+// 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.
-constexpr size_t BOUND_RECT_CACHE_SIZE = 3000;
-static std::unordered_map<sal_GlyphId, tools::Rectangle> g_BoundRectCache;
+static o3tl::lru_map<sal_GlyphId, tools::Rectangle> g_BoundRectCache(3000);
inline FIXED FixedFromDouble( double d )
{
@@ -1340,8 +1340,6 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle
rRect = it->second;
return true;
}
- if (g_BoundRectCache.size() > BOUND_RECT_CACHE_SIZE)
- g_BoundRectCache.clear();
HDC hDC = getHDC();
More information about the Libreoffice-commits
mailing list