1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtGui module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QSTATICTEXT_P_H |
41 | #define QSTATICTEXT_P_H |
42 | |
43 | // |
44 | // W A R N I N G |
45 | // ------------- |
46 | // |
47 | // This file is not part of the Qt API. It exists for the convenience |
48 | // of internal files. This header file may change from version to version |
49 | // without notice, or even be removed. |
50 | // |
51 | // We mean it. |
52 | // |
53 | |
54 | #include <QtGui/private/qtguiglobal_p.h> |
55 | #include "qstatictext.h" |
56 | |
57 | #include <private/qtextureglyphcache_p.h> |
58 | #include <QtGui/qcolor.h> |
59 | |
60 | QT_BEGIN_NAMESPACE |
61 | |
62 | class Q_GUI_EXPORT QStaticTextUserData |
63 | { |
64 | public: |
65 | enum Type { |
66 | NoUserData, |
67 | OpenGLUserData |
68 | }; |
69 | |
70 | QStaticTextUserData(Type t) : ref(0), type(t) {} |
71 | virtual ~QStaticTextUserData(); |
72 | |
73 | QAtomicInt ref; |
74 | Type type; |
75 | }; |
76 | |
77 | class Q_GUI_EXPORT QStaticTextItem |
78 | { |
79 | public: |
80 | QStaticTextItem() : useBackendOptimizations(false), |
81 | userDataNeedsUpdate(0), usesRawFont(0), |
82 | m_fontEngine(nullptr), m_userData(nullptr) {} |
83 | |
84 | void setUserData(QStaticTextUserData *newUserData) |
85 | { |
86 | m_userData = newUserData; |
87 | } |
88 | QStaticTextUserData *userData() const { return m_userData.data(); } |
89 | |
90 | void setFontEngine(QFontEngine *fe) |
91 | { |
92 | m_fontEngine = fe; |
93 | } |
94 | |
95 | QFontEngine *fontEngine() const { return m_fontEngine.data(); } |
96 | |
97 | union { |
98 | QFixedPoint *glyphPositions; // 8 bytes per glyph |
99 | int positionOffset; |
100 | }; |
101 | union { |
102 | glyph_t *glyphs; // 4 bytes per glyph |
103 | int glyphOffset; |
104 | }; |
105 | // ================= |
106 | // 12 bytes per glyph |
107 | |
108 | // 8 bytes for pointers |
109 | int numGlyphs; // 4 bytes per item |
110 | QFont font; // 8 bytes per item |
111 | QColor color; // 10 bytes per item |
112 | char useBackendOptimizations : 1; // 1 byte per item |
113 | char userDataNeedsUpdate : 1; // |
114 | char usesRawFont : 1; // |
115 | |
116 | private: // private to avoid abuse |
117 | QExplicitlySharedDataPointer<QFontEngine> m_fontEngine; // 4 bytes per item |
118 | QExplicitlySharedDataPointer<QStaticTextUserData> m_userData; // 8 bytes per item |
119 | // ================ |
120 | // 43 bytes per item |
121 | }; |
122 | Q_DECLARE_TYPEINFO(QStaticTextItem, Q_MOVABLE_TYPE); |
123 | |
124 | class QStaticText; |
125 | class Q_AUTOTEST_EXPORT QStaticTextPrivate |
126 | { |
127 | public: |
128 | QStaticTextPrivate(); |
129 | QStaticTextPrivate(const QStaticTextPrivate &other); |
130 | ~QStaticTextPrivate(); |
131 | |
132 | void init(); |
133 | void paintText(const QPointF &pos, QPainter *p, const QColor &pen); |
134 | |
135 | void invalidate() |
136 | { |
137 | needsRelayout = true; |
138 | } |
139 | |
140 | QAtomicInt ref; // 4 bytes per text |
141 | |
142 | QString text; // 4 bytes per text |
143 | QFont font; // 8 bytes per text |
144 | qreal textWidth; // 8 bytes per text |
145 | QSizeF actualSize; // 16 bytes per text |
146 | QPointF position; // 16 bytes per text |
147 | |
148 | QTransform matrix; // 80 bytes per text |
149 | QStaticTextItem *items; // 4 bytes per text |
150 | int itemCount; // 4 bytes per text |
151 | |
152 | glyph_t *glyphPool; // 4 bytes per text |
153 | QFixedPoint *positionPool; // 4 bytes per text |
154 | |
155 | QTextOption textOption; // 28 bytes per text |
156 | |
157 | unsigned char needsRelayout : 1; // 1 byte per text |
158 | unsigned char useBackendOptimizations : 1; |
159 | unsigned char textFormat : 2; |
160 | unsigned char untransformedCoordinates : 1; |
161 | // ================ |
162 | // 191 bytes per text |
163 | |
164 | static QStaticTextPrivate *get(const QStaticText *q); |
165 | }; |
166 | |
167 | QT_END_NAMESPACE |
168 | |
169 | #endif // QSTATICTEXT_P_H |
170 | |