LibreOffice Module vcl (master) 1
glyphitemcache.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_GLYPHITEMCACHE_HXX
21#define INCLUDED_VCL_GLYPHITEMCACHE_HXX
22
23#include <sal/types.h>
24#include <vcl/dllapi.h>
25
26#include <o3tl/lru_map.hxx>
27#include <o3tl/hash_combine.hxx>
28#include <vcl/glyphitem.hxx>
29#include <vcl/metric.hxx>
30#include <vcl/outdev.hxx>
31#include <vcl/vclptr.hxx>
32#include <tools/gen.hxx>
33
34#include <optional>
35
44{
45public:
46 // NOTE: The lifetime of the returned value is guaranteed only until the next call
47 // to any function in this class.
49 const OUString& text,
50 const vcl::text::TextLayoutCache* layoutCache = nullptr)
51 {
52 return GetLayoutGlyphs(outputDevice, text, 0, text.getLength(), 0, layoutCache);
53 }
54 const SalLayoutGlyphs* GetLayoutGlyphs(VclPtr<const OutputDevice> outputDevice,
55 const OUString& text, sal_Int32 nIndex, sal_Int32 nLen,
56 tools::Long nLogicWidth = 0,
57 const vcl::text::TextLayoutCache* layoutCache = nullptr);
58 void clear();
59
64 void SetCacheGlyphsWhenDoingFallbackFonts(bool bOK);
65
66 static SalLayoutGlyphsCache* self();
67 SalLayoutGlyphsCache(int size) // needs to be public for vcl::DeleteOnDeinit
68 : mCachedGlyphs(size)
69 {
70 }
71
72private:
74 {
75 OUString text;
76 sal_Int32 index;
77 sal_Int32 len;
80 double fontScaleX;
81 double fontScaleY;
83 bool rtl;
84 bool disabledLigatures; // because of fixed pitch
89 size_t hashValue;
90 CachedGlyphsKey(const VclPtr<const OutputDevice>& dev, OUString t, sal_Int32 i, sal_Int32 l,
91 tools::Long w);
92 bool operator==(const CachedGlyphsKey& other) const;
93 };
95 {
96 size_t operator()(const CachedGlyphsKey& key) const { return key.hashValue; }
97 };
99 {
100 size_t operator()(const SalLayoutGlyphs&) const;
101 };
103 std::equal_to<CachedGlyphsKey>, GlyphsCost>
106 // Last temporary glyphs returned (pointer is returned, so the object needs to be kept somewhere).
107 std::optional<CachedGlyphsKey> mLastTemporaryKey;
109 // If set, info about the last call which wanted a substring of the full text.
110 std::optional<CachedGlyphsKey> mLastSubstringKey;
111 bool mbCacheGlyphsWhenDoingFallbackFonts = false;
112
115};
116
117#endif // INCLUDED_VCL_GLYPHITEMCACHE_HXX
118
119/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A cache for SalLayoutGlyphs objects.
std::optional< CachedGlyphsKey > mLastTemporaryKey
SalLayoutGlyphs mLastTemporaryGlyphs
o3tl::lru_map< CachedGlyphsKey, SalLayoutGlyphs, CachedGlyphsHash, std::equal_to< CachedGlyphsKey >, GlyphsCost > GlyphsCache
std::optional< CachedGlyphsKey > mLastSubstringKey
SalLayoutGlyphsCache & operator=(const SalLayoutGlyphsCache &)=delete
SalLayoutGlyphsCache(const SalLayoutGlyphsCache &)=delete
const SalLayoutGlyphs * GetLayoutGlyphs(VclPtr< const OutputDevice > outputDevice, const OUString &text, const vcl::text::TextLayoutCache *layoutCache=nullptr)
SalLayoutGlyphsCache(int size)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
def text(shape, orig_st)
size
long Long
ComplexTextLayoutFlags
Definition: State.hxx:76
size_t operator()(const CachedGlyphsKey &key) const
vcl::text::ComplexTextLayoutFlags layoutMode
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:175