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_QTEXT2DENTITY_P_H |
5 | #define QT3DEXTRAS_QTEXT2DENTITY_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 <Qt3DCore/private/qentity_p.h> |
19 | #include <Qt3DExtras/private/distancefieldtextrenderer_p.h> |
20 | #include <Qt3DExtras/private/qdistancefieldglyphcache_p.h> |
21 | #include <QFont> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | namespace Qt3DCore { |
26 | class QScene; |
27 | } |
28 | |
29 | namespace Qt3DRender { |
30 | class QGeometryRenderer; |
31 | class QGeometry; |
32 | class QMaterial; |
33 | class QAttribute; |
34 | class QBuffer; |
35 | } |
36 | |
37 | namespace Qt3DExtras { |
38 | |
39 | class QText2DMaterial; |
40 | class QText2DEntity; |
41 | |
42 | class QText2DEntityPrivate : public Qt3DCore::QEntityPrivate |
43 | { |
44 | public: |
45 | QText2DEntityPrivate(); |
46 | ~QText2DEntityPrivate(); |
47 | |
48 | Q_DECLARE_PUBLIC(QText2DEntity) |
49 | |
50 | // keep track of the glyphs currently being displayed, |
51 | // to guarantee proper glyph ref-counting in the |
52 | // QDistanceFieldGlyphCache |
53 | QList<QGlyphRun> m_currentGlyphRuns; |
54 | QDistanceFieldGlyphCache *m_glyphCache; |
55 | |
56 | void setScene(Qt3DCore::QScene *scene) override; |
57 | |
58 | QFont m_font; |
59 | QFont m_scaledFont; // ignore point or pixel size, set to default value |
60 | |
61 | QColor m_color; |
62 | QString m_text; |
63 | float m_width; |
64 | float m_height; |
65 | Qt::Alignment m_alignment; |
66 | |
67 | QList<DistanceFieldTextRenderer*> m_renderers; |
68 | |
69 | qreal computeActualScale() const; |
70 | |
71 | void setCurrentGlyphRuns(const QList<QGlyphRun> &runs); |
72 | void clearCurrentGlyphRuns(); |
73 | void updateGlyphs(); |
74 | |
75 | struct CacheEntry |
76 | { |
77 | QDistanceFieldGlyphCache *glyphCache = nullptr; |
78 | int count = 0; |
79 | }; |
80 | |
81 | static QHash<Qt3DCore::QScene *, CacheEntry> m_glyphCacheInstances; |
82 | }; |
83 | |
84 | } // namespace Qt3DExtras |
85 | |
86 | QT_END_NAMESPACE |
87 | |
88 | #endif // QT3DEXTRAS_QTEXT2DENTITY_P_H |
89 |