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#pragma once
21
22#include <sal/config.h>
23
24#include <rtl/ref.hxx>
25#include <o3tl/lru_map.hxx>
26#include <o3tl/hash_combine.hxx>
27#include <tools/gen.hxx>
28
30#include "glyphid.hxx"
31
32class Size;
33namespace vcl { class Font; }
34namespace vcl::font { class PhysicalFontCollection; }
35
36// TODO: closely couple with PhysicalFontCollection
37
39{
42
44 : m_pFont(pFont), m_nId(nID)
45 {}
46
47 bool operator==(GlyphBoundRectCacheKey const& aOther) const
48 { return m_pFont == aOther.m_pFont && m_nId == aOther.m_nId; }
49};
50
52{
53 std::size_t operator()(GlyphBoundRectCacheKey const& aCache) const
54 {
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;
59 }
60};
61
64
66{
67private:
68 // cache of recently used font instances
70 struct IFSD_Hash { size_t operator()( const vcl::font::FontSelectPattern& ) const; };
72
76
78
79public:
82
84 const vcl::Font&, const Size& rPixelSize, float fExactHeight, bool bNonAntialias = false);
86 LogicalFontInstance* pLogicalFont,
87 int nFallbackLevel, OUString& rMissingCodes );
88
91
92 void Invalidate();
93};
94
95/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
LogicalFontInstance * mpLastHitCacheEntry
keeps the last hit cache entry
rtl::Reference< LogicalFontInstance > GetFontInstance(vcl::font::PhysicalFontCollection const *, vcl::font::FontSelectPattern &)
Definition: fontcache.cxx:114
bool GetCachedGlyphBoundRect(const LogicalFontInstance *, sal_GlyphId, tools::Rectangle &)
Definition: fontcache.cxx:255
FontInstanceList maFontInstanceList
GlyphBoundRectCache m_aBoundRectCache
o3tl::lru_map< vcl::font::FontSelectPattern, rtl::Reference< LogicalFontInstance >, IFSD_Hash, IFSD_Equal > FontInstanceList
void CacheGlyphBoundRect(const LogicalFontInstance *, sal_GlyphId, tools::Rectangle &)
Definition: fontcache.cxx:272
rtl::Reference< LogicalFontInstance > GetGlyphFallbackFont(vcl::font::PhysicalFontCollection const *, vcl::font::FontSelectPattern &, LogicalFontInstance *pLogicalFont, int nFallbackLevel, OUString &rMissingCodes)
Definition: fontcache.cxx:209
void Invalidate()
Definition: fontcache.cxx:244
uint32_t sal_GlyphId
Definition: glyphid.hxx:24
o3tl::lru_map< GlyphBoundRectCacheKey, tools::Rectangle, GlyphBoundRectCacheHash > GlyphBoundRectCache
std::enable_if_t<(sizeof(N)==4)> hash_combine(N &nSeed, T const *pValue, size_t nCount)
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
std::size_t operator()(GlyphBoundRectCacheKey const &aCache) const
GlyphBoundRectCacheKey(const LogicalFontInstance *pFont, sal_GlyphId nID)
bool operator==(GlyphBoundRectCacheKey const &aOther) const
const sal_GlyphId m_nId
const LogicalFontInstance * m_pFont
bool operator()(const vcl::font::FontSelectPattern &, const vcl::font::FontSelectPattern &) const
Definition: fontcache.cxx:38
size_t operator()(const vcl::font::FontSelectPattern &) const
Definition: fontcache.cxx:33