diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-10-04 14:05:30 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-10-06 15:19:38 +0200 |
commit | 01a782d2ceb741d20721b44d26d862d80b47d226 (patch) | |
tree | 559d3537864df61e1682e78b884103c2d5535a3c | |
parent | 612339e574293b248c44cc04a4fae0c77a64ad53 (diff) |
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@fbihome.de>
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 19 |
1 files changed, 4 insertions, 15 deletions
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; } |