1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
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 QSGDISTANCEFIELDGLYPHNODE_P_H |
5 | #define QSGDISTANCEFIELDGLYPHNODE_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 purely as an |
12 | // implementation detail. 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 <private/qsgadaptationlayer_p.h> |
19 | #include <QtQuick/qsgtexture.h> |
20 | |
21 | #include <QtQuick/private/qquicktext_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QSGRenderContext; |
26 | class QSGDistanceFieldTextMaterial; |
27 | |
28 | class QSGDistanceFieldGlyphNode : public QSGGlyphNode, public QSGDistanceFieldGlyphConsumer |
29 | { |
30 | public: |
31 | QSGDistanceFieldGlyphNode(QSGRenderContext *context); |
32 | ~QSGDistanceFieldGlyphNode(); |
33 | |
34 | QPointF baseLine() const override { return m_baseLine; } |
35 | void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; |
36 | void setColor(const QColor &color) override; |
37 | |
38 | void setPreferredAntialiasingMode(AntialiasingMode mode) override; |
39 | void setRenderTypeQuality(int renderTypeQuality) override; |
40 | |
41 | void setStyle(QQuickText::TextStyle style) override; |
42 | void setStyleColor(const QColor &color) override; |
43 | |
44 | void update() override; |
45 | void preprocess() override; |
46 | |
47 | void invalidateGlyphs(const QVector<quint32> &glyphs) override; |
48 | |
49 | void updateGeometry(); |
50 | |
51 | private: |
52 | enum DistanceFieldGlyphNodeType { |
53 | RootGlyphNode, |
54 | SubGlyphNode |
55 | }; |
56 | |
57 | void setGlyphNodeType(DistanceFieldGlyphNodeType type) { m_glyphNodeType = type; } |
58 | void updateMaterial(); |
59 | |
60 | DistanceFieldGlyphNodeType m_glyphNodeType; |
61 | QColor m_color; |
62 | QPointF m_baseLine; |
63 | QSGRenderContext *m_context; |
64 | QSGDistanceFieldTextMaterial *m_material; |
65 | QPointF m_originalPosition; |
66 | QPointF m_position; |
67 | QGlyphRun m_glyphs; |
68 | QSGDistanceFieldGlyphCache *m_glyph_cache; |
69 | QSGGeometry m_geometry; |
70 | QQuickText::TextStyle m_style; |
71 | QColor m_styleColor; |
72 | AntialiasingMode m_antialiasingMode; |
73 | QRectF m_boundingRect; |
74 | const QSGDistanceFieldGlyphCache::Texture *m_texture; |
75 | int m_renderTypeQuality; |
76 | |
77 | struct GlyphInfo { |
78 | QVector<quint32> indexes; |
79 | QVector<QPointF> positions; |
80 | }; |
81 | QSet<quint32> m_allGlyphIndexesLookup; |
82 | // m_glyphs holds pointers to the GlyphInfo.indexes and positions arrays, so we need to hold on to them |
83 | QHash<const QSGDistanceFieldGlyphCache::Texture *, GlyphInfo> m_glyphsInOtherTextures; |
84 | |
85 | uint m_dirtyGeometry: 1; |
86 | uint m_dirtyMaterial: 1; |
87 | |
88 | static qint64 m_totalAllocation; // all SG glyph vertices and indices; only for qCDebug metrics |
89 | }; |
90 | |
91 | QT_END_NAMESPACE |
92 | |
93 | #endif |
94 |