summaryrefslogtreecommitdiff
path: root/vcl/inc/impfontcache.hxx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-10-04 14:03:07 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2018-10-06 15:17:52 +0200
commit612339e574293b248c44cc04a4fae0c77a64ad53 (patch)
treeebc9a280800f40e26ef32fa9189845ba74bc9c40 /vcl/inc/impfontcache.hxx
parent4435135e68f7d1024875defc3df18de183607048 (diff)
Add a glyph-bound-rect cache to the font cache
This way the font cache can correctly invalidate the cached glyph rects when a font is dropped from the cache. Change-Id: I050866099742334f01cac1b872228a017ddb5e9b Reviewed-on: https://gerrit.libreoffice.org/61371 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/inc/impfontcache.hxx')
-rw-r--r--vcl/inc/impfontcache.hxx48
1 files changed, 42 insertions, 6 deletions
diff --git a/vcl/inc/impfontcache.hxx b/vcl/inc/impfontcache.hxx
index 10a38540e67b..c96994300176 100644
--- a/vcl/inc/impfontcache.hxx
+++ b/vcl/inc/impfontcache.hxx
@@ -21,6 +21,11 @@
#define INCLUDED_VCL_INC_IMPFONTCACHE_HXX
#include <unordered_map>
+#include <boost/functional/hash.hpp>
+
+#include <o3tl/lru_map.hxx>
+#include <tools/gen.hxx>
+#include <vcl/vcllayout.hxx>
#include "fontselect.hxx"
@@ -28,25 +33,53 @@ class Size;
namespace vcl { class Font; }
class PhysicalFontCollection;
-
// TODO: closely couple with PhysicalFontCollection
+struct GlpyhBoundRectCacheKey
+{
+ const LogicalFontInstance* m_pFont;
+ const sal_GlyphId m_nId;
+
+ GlpyhBoundRectCacheKey(const LogicalFontInstance* pFont, sal_GlyphId nID)
+ : m_pFont(pFont), m_nId(nID)
+ {}
+
+ bool operator==(GlpyhBoundRectCacheKey const& aOther) const
+ { return m_pFont == aOther.m_pFont && m_nId == aOther.m_nId; }
+};
+
+struct GlpyhBoundRectCacheHash
+{
+ std::size_t operator()(GlpyhBoundRectCacheKey const& aCache) const
+ {
+ std::size_t seed = 0;
+ boost::hash_combine(seed, aCache.m_pFont);
+ boost::hash_combine(seed, aCache.m_nId);
+ return seed;
+ }
+};
+
+typedef o3tl::lru_map<GlpyhBoundRectCacheKey, tools::Rectangle,
+ GlpyhBoundRectCacheHash> GlpyhBoundRectCache;
+typedef GlpyhBoundRectCache::key_value_pair_t GlpyhBoundRectCachePair;
+
class ImplFontCache
{
private:
- LogicalFontInstance* mpLastHitCacheEntry; ///< keeps the last hit cache entry
-
// cache of recently used font instances
struct IFSD_Equal { bool operator()( const FontSelectPattern&, const FontSelectPattern& ) const; };
struct IFSD_Hash { size_t operator()( const FontSelectPattern& ) const; };
typedef std::unordered_map<FontSelectPattern, rtl::Reference<LogicalFontInstance>, IFSD_Hash, IFSD_Equal> FontInstanceList;
- FontInstanceList maFontInstanceList;
+
+ LogicalFontInstance* mpLastHitCacheEntry; ///< keeps the last hit cache entry
+ FontInstanceList maFontInstanceList;
+ GlpyhBoundRectCache m_aBoundRectCache;
rtl::Reference<LogicalFontInstance> GetFontInstance(PhysicalFontCollection const*, FontSelectPattern&);
public:
- ImplFontCache();
- ~ImplFontCache();
+ ImplFontCache();
+ ~ImplFontCache();
rtl::Reference<LogicalFontInstance> GetFontInstance( PhysicalFontCollection const *,
const vcl::Font&, const Size& rPixelSize, float fExactHeight);
@@ -54,6 +87,9 @@ public:
LogicalFontInstance* pLogicalFont,
int nFallbackLevel, OUString& rMissingCodes );
+ bool GetCachedGlyphBoundRect(LogicalFontInstance *, sal_GlyphId, tools::Rectangle &);
+ void CacheGlyphBoundRect(LogicalFontInstance *, sal_GlyphId, tools::Rectangle &);
+
void Invalidate();
};