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
23QT_BEGIN_NAMESPACE
24
25namespace Qt3DCore {
26class QScene;
27}
28
29namespace Qt3DRender {
30class QGeometryRenderer;
31class QGeometry;
32class QMaterial;
33class QAttribute;
34class QBuffer;
35}
36
37namespace Qt3DExtras {
38
39class QText2DMaterial;
40class QText2DEntity;
41
42class QText2DEntityPrivate : public Qt3DCore::QEntityPrivate
43{
44public:
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
66 QList<DistanceFieldTextRenderer*> m_renderers;
67
68 qreal computeActualScale() const;
69
70 void setCurrentGlyphRuns(const QList<QGlyphRun> &runs);
71 void clearCurrentGlyphRuns();
72 void updateGlyphs();
73
74 struct CacheEntry
75 {
76 QDistanceFieldGlyphCache *glyphCache = nullptr;
77 int count = 0;
78 };
79
80 static QHash<Qt3DCore::QScene *, CacheEntry> m_glyphCacheInstances;
81};
82
83} // namespace Qt3DExtras
84
85QT_END_NAMESPACE
86
87#endif // QT3DEXTRAS_QTEXT2DENTITY_P_H
88

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