diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-10-04 14:03:07 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-10-06 15:17:52 +0200 |
commit | 612339e574293b248c44cc04a4fae0c77a64ad53 (patch) | |
tree | ebc9a280800f40e26ef32fa9189845ba74bc9c40 /include/o3tl | |
parent | 4435135e68f7d1024875defc3df18de183607048 (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 'include/o3tl')
-rw-r--r-- | include/o3tl/lru_map.hxx | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/include/o3tl/lru_map.hxx b/include/o3tl/lru_map.hxx index 015120e31cb3..79e81293a858 100644 --- a/include/o3tl/lru_map.hxx +++ b/include/o3tl/lru_map.hxx @@ -34,8 +34,10 @@ namespace o3tl template<typename Key, typename Value, class KeyHash = std::hash<Key>> class lru_map final { -private: +public: typedef typename std::pair<Key, Value> key_value_pair_t; + +private: typedef std::list<key_value_pair_t> list_t; typedef typename list_t::iterator list_iterator_t; typedef typename list_t::const_iterator list_const_iterator_t; @@ -58,6 +60,7 @@ private: mLruList.pop_back(); } } + public: typedef list_iterator_t iterator; typedef list_const_iterator_t const_iterator; @@ -126,6 +129,28 @@ public: } } + // reverse-iterates the list removing all items matching the predicate + template<class UnaryPredicate> + void remove_if(UnaryPredicate pred) + { + auto it = mLruList.rbegin(); + while (it != mLruList.rend()) + { + if (pred(*it)) + { + mLruMap.erase(it->first); + it = decltype(it){ mLruList.erase(std::next(it).base()) }; + } + else + ++it; + } + } + + const list_const_iterator_t begin() const + { + return mLruList.cbegin(); + } + const list_const_iterator_t end() const { return mLruList.cend(); |