From c4c56de1b0e62ec866b519b2b24c5e805f0a86d3 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 5 Jun 2018 14:16:23 +0200 Subject: hold LogicalFontInstance with rtl::Reference instead of manual reference counting. Also the releasing of not-currently-in-use LogicalFontInstance objects from the cache is made less aggressive - we now only flush entries until we have less than CACHE_SIZE instances, instead of flushing the whole cache. Change-Id: Ib235b132776b5f09ae8ae93a933c2eebe5fa9610 Reviewed-on: https://gerrit.libreoffice.org/55384 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/inc/impfontcache.hxx | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'vcl/inc/impfontcache.hxx') diff --git a/vcl/inc/impfontcache.hxx b/vcl/inc/impfontcache.hxx index a99283fb300e..6cb05b39d9b3 100644 --- a/vcl/inc/impfontcache.hxx +++ b/vcl/inc/impfontcache.hxx @@ -33,36 +33,24 @@ class PhysicalFontCollection; class ImplFontCache { - // For access to Acquire and Release - friend class LogicalFontInstance; - private: LogicalFontInstance* mpLastHitCacheEntry; ///< keeps the last hit cache entry - int mnRef0Count; ///< number of unreferenced LogicalFontInstances // 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 FontInstanceList; + typedef std::unordered_map, IFSD_Hash, IFSD_Equal> FontInstanceList; FontInstanceList maFontInstanceList; - int CountUnreferencedEntries() const; - bool IsFontInList(const LogicalFontInstance* pFont) const; - - /// Increase the refcount of the given LogicalFontInstance. - void Acquire(LogicalFontInstance*); - /// Decrease the refcount and potentially cleanup the entries with zero refcount from the cache. - void Release(LogicalFontInstance*); - - LogicalFontInstance* GetFontInstance(PhysicalFontCollection const*, FontSelectPattern&); + rtl::Reference GetFontInstance(PhysicalFontCollection const*, FontSelectPattern&); public: ImplFontCache(); ~ImplFontCache(); - LogicalFontInstance* GetFontInstance( PhysicalFontCollection const *, + rtl::Reference GetFontInstance( PhysicalFontCollection const *, const vcl::Font&, const Size& rPixelSize, float fExactHeight); - LogicalFontInstance* GetGlyphFallbackFont( PhysicalFontCollection const *, FontSelectPattern&, + rtl::Reference GetGlyphFallbackFont( PhysicalFontCollection const *, FontSelectPattern&, int nFallbackLevel, OUString& rMissingCodes ); void Invalidate(); -- cgit