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 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QRawFont; |
26 | class QGlyphRun; |
27 | |
28 | namespace Qt3DCore { |
29 | class QNode; |
30 | } |
31 | |
32 | namespace Qt3DRender { |
33 | class QAbstractTexture; |
34 | } |
35 | |
36 | namespace Qt3DExtras { |
37 | |
38 | class DistanceFieldFont; |
39 | class QDistanceFieldGlyphCachePrivate; |
40 | |
41 | class QDistanceFieldGlyphCache |
42 | { |
43 | public: |
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 | |
64 | private: |
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 | |
74 | QT_END_NAMESPACE |
75 | |
76 | #endif // QT3DEXTRAS_QDISTANCEFIELDGLYPHCACHE_P_H |
77 |