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 QSTATICTEXT_P_H |
5 | #define QSTATICTEXT_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 internal files. This header file may change from version to version |
13 | // without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtGui/private/qtguiglobal_p.h> |
19 | #include "qstatictext.h" |
20 | |
21 | #include <private/qtextureglyphcache_p.h> |
22 | #include <QtGui/qcolor.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class Q_GUI_EXPORT QStaticTextUserData |
27 | { |
28 | public: |
29 | enum Type { |
30 | NoUserData, |
31 | OpenGLUserData |
32 | }; |
33 | |
34 | QStaticTextUserData(Type t) : ref(0), type(t) {} |
35 | virtual ~QStaticTextUserData(); |
36 | |
37 | QAtomicInt ref; |
38 | Type type; |
39 | }; |
40 | |
41 | class Q_GUI_EXPORT QStaticTextItem |
42 | { |
43 | public: |
44 | QStaticTextItem() : useBackendOptimizations(false), |
45 | userDataNeedsUpdate(0), usesRawFont(0), |
46 | m_fontEngine(nullptr), m_userData(nullptr) {} |
47 | |
48 | void setUserData(QStaticTextUserData *newUserData) |
49 | { |
50 | m_userData = newUserData; |
51 | } |
52 | QStaticTextUserData *userData() const { return m_userData.data(); } |
53 | |
54 | void setFontEngine(QFontEngine *fe) |
55 | { |
56 | m_fontEngine = fe; |
57 | } |
58 | |
59 | QFontEngine *fontEngine() const { return m_fontEngine.data(); } |
60 | |
61 | union { |
62 | QFixedPoint *glyphPositions; // 8 bytes per glyph |
63 | int positionOffset; |
64 | }; |
65 | union { |
66 | glyph_t *glyphs; // 4 bytes per glyph |
67 | int glyphOffset; |
68 | }; |
69 | // ================= |
70 | // 12 bytes per glyph |
71 | |
72 | // 8 bytes for pointers |
73 | int numGlyphs; // 4 bytes per item |
74 | QFont font; // 8 bytes per item |
75 | QColor color; // 10 bytes per item |
76 | char useBackendOptimizations : 1; // 1 byte per item |
77 | char userDataNeedsUpdate : 1; // |
78 | char usesRawFont : 1; // |
79 | |
80 | private: // private to avoid abuse |
81 | QExplicitlySharedDataPointer<QFontEngine> m_fontEngine; // 4 bytes per item |
82 | QExplicitlySharedDataPointer<QStaticTextUserData> m_userData; // 8 bytes per item |
83 | // ================ |
84 | // 43 bytes per item |
85 | }; |
86 | Q_DECLARE_TYPEINFO(QStaticTextItem, Q_RELOCATABLE_TYPE); |
87 | |
88 | class QStaticText; |
89 | class Q_AUTOTEST_EXPORT QStaticTextPrivate |
90 | { |
91 | public: |
92 | QStaticTextPrivate(); |
93 | QStaticTextPrivate(const QStaticTextPrivate &other); |
94 | ~QStaticTextPrivate(); |
95 | |
96 | void init(); |
97 | void paintText(const QPointF &pos, QPainter *p, const QColor &pen); |
98 | |
99 | void invalidate() |
100 | { |
101 | needsRelayout = true; |
102 | } |
103 | |
104 | QAtomicInt ref; // 4 bytes per text |
105 | |
106 | QString text; // 4 bytes per text |
107 | QFont font; // 8 bytes per text |
108 | qreal textWidth; // 8 bytes per text |
109 | QSizeF actualSize; // 16 bytes per text |
110 | QPointF position; // 16 bytes per text |
111 | |
112 | QTransform matrix; // 80 bytes per text |
113 | QStaticTextItem *items; // 4 bytes per text |
114 | int itemCount; // 4 bytes per text |
115 | |
116 | glyph_t *glyphPool; // 4 bytes per text |
117 | QFixedPoint *positionPool; // 4 bytes per text |
118 | |
119 | QTextOption textOption; // 28 bytes per text |
120 | |
121 | unsigned char needsRelayout : 1; // 1 byte per text |
122 | unsigned char useBackendOptimizations : 1; |
123 | unsigned char textFormat : 2; |
124 | unsigned char untransformedCoordinates : 1; |
125 | // ================ |
126 | // 191 bytes per text |
127 | |
128 | static QStaticTextPrivate *get(const QStaticText *q); |
129 | }; |
130 | |
131 | QT_END_NAMESPACE |
132 | |
133 | #endif // QSTATICTEXT_P_H |
134 | |