bump product version to 7.2.5.1
[LibreOffice.git] / vcl / inc / impfontcache.hxx
blob09aa33ca906ba9b2668693d621ef0503ff888d0c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_IMPFONTCACHE_HXX
21 #define INCLUDED_VCL_INC_IMPFONTCACHE_HXX
24 #include <rtl/ref.hxx>
25 #include <o3tl/lru_map.hxx>
26 #include <o3tl/hash_combine.hxx>
27 #include <tools/gen.hxx>
28 #include <vcl/glyphitem.hxx>
30 #include "fontselect.hxx"
32 class Size;
33 namespace vcl { class Font; }
34 class PhysicalFontCollection;
36 // TODO: closely couple with PhysicalFontCollection
38 struct GlyphBoundRectCacheKey
40 const LogicalFontInstance* m_pFont;
41 const sal_GlyphId m_nId;
43 GlyphBoundRectCacheKey(const LogicalFontInstance* pFont, sal_GlyphId nID)
44 : m_pFont(pFont), m_nId(nID)
47 bool operator==(GlyphBoundRectCacheKey const& aOther) const
48 { return m_pFont == aOther.m_pFont && m_nId == aOther.m_nId; }
51 struct GlyphBoundRectCacheHash
53 std::size_t operator()(GlyphBoundRectCacheKey const& aCache) const
55 std::size_t seed = 0;
56 o3tl::hash_combine(seed, aCache.m_pFont);
57 o3tl::hash_combine(seed, aCache.m_nId);
58 return seed;
62 typedef o3tl::lru_map<GlyphBoundRectCacheKey, tools::Rectangle,
63 GlyphBoundRectCacheHash> GlyphBoundRectCache;
65 class ImplFontCache
67 private:
68 // cache of recently used font instances
69 struct IFSD_Equal { bool operator()( const FontSelectPattern&, const FontSelectPattern& ) const; };
70 struct IFSD_Hash { size_t operator()( const FontSelectPattern& ) const; };
71 typedef o3tl::lru_map<FontSelectPattern, rtl::Reference<LogicalFontInstance>, IFSD_Hash, IFSD_Equal> FontInstanceList;
73 LogicalFontInstance* mpLastHitCacheEntry; ///< keeps the last hit cache entry
74 FontInstanceList maFontInstanceList;
75 GlyphBoundRectCache m_aBoundRectCache;
77 rtl::Reference<LogicalFontInstance> GetFontInstance(PhysicalFontCollection const*, FontSelectPattern&);
79 public:
80 ImplFontCache();
81 ~ImplFontCache();
83 rtl::Reference<LogicalFontInstance> GetFontInstance(PhysicalFontCollection const *,
84 const vcl::Font&, const Size& rPixelSize, float fExactHeight, bool bNonAntialias = false);
85 rtl::Reference<LogicalFontInstance> GetGlyphFallbackFont( PhysicalFontCollection const *, FontSelectPattern&,
86 LogicalFontInstance* pLogicalFont,
87 int nFallbackLevel, OUString& rMissingCodes );
89 bool GetCachedGlyphBoundRect(const LogicalFontInstance *, sal_GlyphId, tools::Rectangle &);
90 void CacheGlyphBoundRect(const LogicalFontInstance *, sal_GlyphId, tools::Rectangle &);
92 void Invalidate();
95 #endif // INCLUDED_VCL_INC_IMPFONTCACHE_HXX
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */