1// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DEXTRAS_QDISTANCEFIELDGLYPHCACHE_P_H
5#define QT3DEXTRAS_QDISTANCEFIELDGLYPHCACHE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QRectF>
19#include <Qt3DCore/qnode.h>
20#include <Qt3DExtras/qt3dextras_global.h>
21#include <private/qglobal_p.h>
22
23QT_BEGIN_NAMESPACE
24
25class QRawFont;
26class QGlyphRun;
27
28namespace Qt3DCore {
29class QNode;
30}
31
32namespace Qt3DRender {
33class QAbstractTexture;
34}
35
36namespace Qt3DExtras {
37
38class DistanceFieldFont;
39class QDistanceFieldGlyphCachePrivate;
40
41class QDistanceFieldGlyphCache
42{
43public:
44 QDistanceFieldGlyphCache();
45 ~QDistanceFieldGlyphCache();
46
47 void setRootNode(Qt3DCore::QNode *rootNode);
48 Qt3DCore::QNode *rootNode() const;
49
50 struct Glyph {
51 Qt3DRender::QAbstractTexture *texture = nullptr;
52 QRectF glyphPathBoundingRect; // bounding rect of the QPainterPath used to draw the glyph
53 QRectF texCoords; // texture coordinates within texture
54 };
55
56 bool doubleGlyphResolution(const QRawFont &font);
57
58 QList<Glyph> refGlyphs(const QGlyphRun &run);
59 Glyph refGlyph(const QRawFont &font, quint32 glyph);
60
61 void derefGlyphs(const QGlyphRun &run);
62 void derefGlyph(const QRawFont &font, quint32 glyph);
63
64private:
65 DistanceFieldFont* getOrCreateDistanceFieldFont(const QRawFont &font);
66 static QString fontKey(const QRawFont &font);
67
68 QHash<QString, DistanceFieldFont*> m_fonts;
69 Qt3DCore::QNode *m_rootNode;
70};
71
72} // namespace Qt3DExtras
73
74QT_END_NAMESPACE
75
76#endif // QT3DEXTRAS_QDISTANCEFIELDGLYPHCACHE_P_H
77

source code of qt3d/src/extras/text/qdistancefieldglyphcache_p.h