LibreOffice Module vcl (master)  1
impfontcache.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_INC_IMPFONTCACHE_HXX
21 #define INCLUDED_VCL_INC_IMPFONTCACHE_HXX
22 
23 #include <boost/functional/hash.hpp>
24 
25 #include <rtl/ref.hxx>
26 #include <o3tl/lru_map.hxx>
27 #include <tools/gen.hxx>
28 #include <vcl/glyphitem.hxx>
29 
30 #include "fontselect.hxx"
31 
32 class Size;
33 namespace vcl { class Font; }
35 
36 // TODO: closely couple with PhysicalFontCollection
37 
39 {
42 
44  : m_pFont(pFont), m_nId(nID)
45  {}
46 
47  bool operator==(GlpyhBoundRectCacheKey const& aOther) const
48  { return m_pFont == aOther.m_pFont && m_nId == aOther.m_nId; }
49 };
50 
52 {
53  std::size_t operator()(GlpyhBoundRectCacheKey const& aCache) const
54  {
55  std::size_t seed = 0;
56  boost::hash_combine(seed, aCache.m_pFont);
57  boost::hash_combine(seed, aCache.m_nId);
58  return seed;
59  }
60 };
61 
65 
67 {
68 private:
69  // cache of recently used font instances
70  struct IFSD_Equal { bool operator()( const FontSelectPattern&, const FontSelectPattern& ) const; };
71  struct IFSD_Hash { size_t operator()( const FontSelectPattern& ) const; };
74 
76  FontInstanceList maFontInstanceList;
77  GlpyhBoundRectCache m_aBoundRectCache;
78 
80 
81 public:
82  ImplFontCache();
84 
86  const vcl::Font&, const Size& rPixelSize, float fExactHeight, bool bNonAntialias = false);
88  LogicalFontInstance* pLogicalFont,
89  int nFallbackLevel, OUString& rMissingCodes );
90 
93 
94  void Invalidate();
95 };
96 
97 #endif // INCLUDED_VCL_INC_IMPFONTCACHE_HXX
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t operator()(const FontSelectPattern &) const
Definition: fontcache.cxx:27
o3tl::lru_map< GlpyhBoundRectCacheKey, tools::Rectangle, GlpyhBoundRectCacheHash > GlpyhBoundRectCache
LogicalFontInstance * mpLastHitCacheEntry
keeps the last hit cache entry
sal_uInt16 sal_GlyphId
Definition: glyphitem.hxx:26
std::size_t operator()(GlpyhBoundRectCacheKey const &aCache) const
const sal_GlyphId m_nId
GlpyhBoundRectCacheKey(const LogicalFontInstance *pFont, sal_GlyphId nID)
void Invalidate()
Definition: fontcache.cxx:234
bool operator()(const FontSelectPattern &, const FontSelectPattern &) const
Definition: fontcache.cxx:32
o3tl::lru_map< FontSelectPattern, rtl::Reference< LogicalFontInstance >, IFSD_Hash, IFSD_Equal > FontInstanceList
bool operator==(GlpyhBoundRectCacheKey const &aOther) const
FontInstanceList::key_value_pair_t FontInstanceListPair
void CacheGlyphBoundRect(const LogicalFontInstance *, sal_GlyphId, tools::Rectangle &)
Definition: fontcache.cxx:261
const LogicalFontInstance * m_pFont
rtl::Reference< LogicalFontInstance > GetGlyphFallbackFont(PhysicalFontCollection const *, FontSelectPattern &, LogicalFontInstance *pLogicalFont, int nFallbackLevel, OUString &rMissingCodes)
Definition: fontcache.cxx:199
bool GetCachedGlyphBoundRect(const LogicalFontInstance *, sal_GlyphId, tools::Rectangle &)
Definition: fontcache.cxx:244
rtl::Reference< LogicalFontInstance > GetFontInstance(PhysicalFontCollection const *, FontSelectPattern &)
Definition: fontcache.cxx:105
GlpyhBoundRectCache m_aBoundRectCache
GlpyhBoundRectCache::key_value_pair_t GlpyhBoundRectCachePair
FontInstanceList maFontInstanceList