Kaydet (Commit) 01a782d2 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

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: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst 612339e5
...@@ -60,11 +60,6 @@ ...@@ -60,11 +60,6 @@
using namespace vcl; 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 const int MAXFONTHEIGHT = 2048;
static inline FIXED FixedFromDouble( double d ) static inline FIXED FixedFromDouble( double d )
...@@ -846,8 +841,6 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont, ...@@ -846,8 +841,6 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
float& o_rFontScale, float& o_rFontScale,
HFONT& o_rOldFont) HFONT& o_rOldFont)
{ {
// clear the cache on font change
g_BoundRectCache.clear();
HFONT hNewFont = nullptr; HFONT hNewFont = nullptr;
LOGFONTW aLogFont; LOGFONTW aLogFont;
...@@ -1335,16 +1328,12 @@ void WinSalGraphics::ClearDevFontCache() ...@@ -1335,16 +1328,12 @@ void WinSalGraphics::ClearDevFontCache()
bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect) 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]; rtl::Reference<WinFontInstance> pFont = mpWinFontEntry[rGlyph.mnFallbackLevel];
assert(pFont.is()); assert(pFont.is());
if (pFont.is() && pFont->GetCachedGlyphBoundRect(rGlyph.maGlyphId, rRect))
return true;
HDC hDC = getHDC(); HDC hDC = getHDC();
HFONT hFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT)); HFONT hFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT));
float fFontScale = 1.0; float fFontScale = 1.0;
...@@ -1379,7 +1368,7 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle ...@@ -1379,7 +1368,7 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle
rRect.SetTop(static_cast<int>( fFontScale * rRect.Top() )); rRect.SetTop(static_cast<int>( fFontScale * rRect.Top() ));
rRect.SetBottom(static_cast<int>( fFontScale * rRect.Bottom() ) + 1); rRect.SetBottom(static_cast<int>( fFontScale * rRect.Bottom() ) + 1);
g_BoundRectCache.insert({rGlyph.maGlyphId, rRect}); pFont->CacheGlyphBoundRect(rGlyph.maGlyphId, rRect);
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment