QtBase  v6.3.1
qstatictext_p.h
Go to the documentation of this file.
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 
61 
62 class Q_GUI_EXPORT QStaticTextUserData
63 {
64 public:
65  enum Type {
67  OpenGLUserData
68  };
69 
71  virtual ~QStaticTextUserData();
72 
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 
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
100  };
101  union {
102  glyph_t *glyphs; // 4 bytes per glyph
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 };
123 
124 class QStaticText;
126 {
127 public:
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 
168 
169 #endif // QSTATICTEXT_P_H
The QAtomicInt class provides platform-independent atomic operations on int.
Definition: qatomic.h:158
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QFont class specifies a query for a font used for drawing text.
Definition: qfont.h:56
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:82
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:242
The QSizeF class defines the size of a two-dimensional object using floating point precision.
Definition: qsize.h:235
The QStaticText class enables optimized drawing of text when the text and its layout is updated rarel...
Definition: qstatictext.h:57
QStaticTextUserData * userData() const
Definition: qstatictext_p.h:88
char useBackendOptimizations
glyph_t * glyphs
void setUserData(QStaticTextUserData *newUserData)
Definition: qstatictext_p.h:84
QFixedPoint * glyphPositions
Definition: qstatictext_p.h:98
QFontEngine * fontEngine() const
Definition: qstatictext_p.h:95
void setFontEngine(QFontEngine *fe)
Definition: qstatictext_p.h:90
unsigned char textFormat
unsigned char useBackendOptimizations
QTextOption textOption
unsigned char needsRelayout
QFixedPoint * positionPool
QStaticTextItem * items
unsigned char untransformedCoordinates
QStaticTextUserData(Type t)
Definition: qstatictext_p.h:70
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QTextOption class provides a description of general rich text properties. \inmodule QtGui.
Definition: qtextoption.h:54
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:56
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld init[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:579
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
GLenum type
Definition: qopengl.h:270
GLint ref
GLdouble GLdouble t
[9]
Definition: qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition: qopenglext.h:259
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
Q_DECLARE_TYPEINFO(QStaticTextItem, Q_RELOCATABLE_TYPE)
unsigned int glyph_t
@ Q_RELOCATABLE_TYPE
Definition: qtypeinfo.h:156
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
http get(QUrl::toPercentEncoding("/index.html"))
Definition: moc.h:48