Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qoutlinemapper_p.h
Go to the documentation of this file.
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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QOUTLINEMAPPER_P_H
6
#
define
QOUTLINEMAPPER_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtGui
/
private
/
qtguiglobal_p
.
h
>
20
#
include
<
QtCore
/
qrect
.
h
>
21
22
#
include
<
QtGui
/
qtransform
.
h
>
23
#
include
<
QtGui
/
qpainterpath
.
h
>
24
25
#
define
QT_FT_BEGIN_HEADER
26
#
define
QT_FT_END_HEADER
27
28
#
include
<
private
/
qrasterdefs_p
.
h
>
29
#
include
<
private
/
qdatabuffer_p
.
h
>
30
#
include
"qpaintengineex_p.h"
31
32
QT_BEGIN_NAMESPACE
33
34
// These limitations comes from qrasterizer.cpp, qcosmeticstroker.cpp, and qgrayraster.c.
35
// Any higher and rasterization of shapes will produce incorrect results.
36
#
if
Q_PROCESSOR_WORDSIZE
==
8
37
constexpr
int
QT_RASTER_COORD_LIMIT = ((1<<23) - 1);
// F24dot8 in qgrayraster.c
38
#
else
39
constexpr
int
QT_RASTER_COORD_LIMIT
= ((1<<15) - 1);
// F16dot16 in qrasterizer.cpp and qcosmeticstroker.cpp
40
#
endif
41
//#define QT_DEBUG_CONVERT
42
43
Q_GUI_EXPORT
bool
qt_scaleForTransform
(
const
QTransform &transform, qreal *scale);
44
45
/********************************************************************************
46
* class QOutlineMapper
47
*
48
* Used to map between QPainterPath and the QT_FT_Outline structure used by the
49
* freetype scanconverter.
50
*
51
* The outline mapper uses a path iterator to get points from the path,
52
* so that it is possible to transform the points as they are converted. The
53
* callback can be a noop, translate or full-fledged xform. (Tests indicated
54
* that using a C callback was low cost).
55
*/
56
class
QOutlineMapper
57
{
58
public
:
59
QOutlineMapper
() :
60
m_element_types
(0),
61
m_elements
(0),
62
m_points
(0),
63
m_tags
(0),
64
m_contours
(0),
65
m_in_clip_elements
(
false
)
66
{
67
}
68
69
/*!
70
Sets up the matrix to be used for conversion. This also
71
sets up the qt_path_iterator function that is used as a callback
72
to get points.
73
*/
74
void
setMatrix
(
const
QTransform &m)
75
{
76
m_transform = m;
77
78
qreal scale;
79
qt_scaleForTransform(m, &scale);
80
m_curve_threshold = scale == 0 ? qreal(0.25) : (qreal(0.25) / scale);
81
}
82
83
void
setClipRect
(QRect clipRect);
84
85
void
beginOutline
(Qt::FillRule fillRule)
86
{
87
#
ifdef
QT_DEBUG_CONVERT
88
printf(
"QOutlineMapper::beginOutline rule=%d\n"
, fillRule);
89
#
endif
90
m_valid
=
true
;
91
m_elements.reset();
92
m_element_types.reset();
93
m_points.reset();
94
m_tags.reset();
95
m_contours.reset();
96
m_outline.flags = fillRule == Qt::WindingFill
97
? QT_FT_OUTLINE_NONE
98
: QT_FT_OUTLINE_EVEN_ODD_FILL;
99
m_subpath_start
= 0;
100
}
101
102
void
endOutline
();
103
104
void
clipElements
(
const
QPointF *points,
const
QPainterPath::ElementType *types,
int
count);
105
106
void
convertElements
(
const
QPointF *points,
const
QPainterPath::ElementType *types,
int
count);
107
108
inline
void
moveTo
(
const
QPointF &pt) {
109
#
ifdef
QT_DEBUG_CONVERT
110
printf(
"QOutlineMapper::moveTo() (%f, %f)\n"
, pt.x(), pt.y());
111
#
endif
112
closeSubpath
(
)
;
113
m_subpath_start
= m_elements.size();
114
m_elements << pt;
115
m_element_types << QPainterPath::MoveToElement;
116
}
117
118
inline
void
lineTo
(
const
QPointF &pt) {
119
#
ifdef
QT_DEBUG_CONVERT
120
printf(
"QOutlineMapper::lineTo() (%f, %f)\n"
, pt.x(), pt.y());
121
#
endif
122
m_elements.add(pt);
123
m_element_types << QPainterPath::LineToElement;
124
}
125
126
void
curveTo
(
const
QPointF &cp1,
const
QPointF &cp2,
const
QPointF &ep);
127
128
inline
void
closeSubpath
() {
129
int
element_count = m_elements.size();
130
if
(element_count > 0) {
131
if
(m_elements.at(element_count-1) != m_elements.at(m_subpath_start)) {
132
#
ifdef
QT_DEBUG_CONVERT
133
printf(
" - implicitly closing\n"
);
134
#
endif
135
// Put the object on the stack to avoid the odd case where
136
// lineTo reallocs the databuffer and the QPointF & will
137
// be invalidated.
138
QPointF pt = m_elements.at(m_subpath_start);
139
140
// only do lineTo if we have element_type array...
141
if
(m_element_types.size())
142
lineTo(pt);
143
else
144
m_elements << pt;
145
146
}
147
}
148
}
149
150
QT_FT_Outline
*
outline
() {
151
if
(m_valid)
152
return
&m_outline;
153
return
nullptr
;
154
}
155
156
QT_FT_Outline
*
convertPath
(
const
QPainterPath &path);
157
QT_FT_Outline
*
convertPath
(
const
QVectorPath &path);
158
159
inline
QPainterPath
::
ElementType
*
elementTypes
()
const
{
return
m_element_types.size() == 0 ?
nullptr
: m_element_types.data(); }
160
161
public
:
162
QDataBuffer
<
QPainterPath
::
ElementType
>
m_element_types
;
163
QDataBuffer
<
QPointF
>
m_elements
;
164
QDataBuffer
<
QT_FT_Vector
>
m_points
;
165
QDataBuffer
<
char
>
m_tags
;
166
QDataBuffer
<
int
>
m_contours
;
167
168
QRect
m_clip_rect
;
169
QRectF
m_clip_trigger_rect
;
170
QRectF
controlPointRect
;
// only valid after endOutline()
171
172
QT_FT_Outline
m_outline
;
173
174
int
m_subpath_start
;
175
176
QTransform
m_transform
;
177
178
qreal
m_curve_threshold
;
179
180
bool
m_valid
;
181
bool
m_in_clip_elements
;
182
};
183
184
QT_END_NAMESPACE
185
186
#
endif
// QOUTLINEMAPPER_P_H
QBezier
Definition
qbezier_p.h:32
QOutlineMapper
Definition
qoutlinemapper_p.h:57
QOutlineMapper::m_transform
QTransform m_transform
Definition
qoutlinemapper_p.h:176
QOutlineMapper::outline
QT_FT_Outline * outline()
Definition
qoutlinemapper_p.h:150
QOutlineMapper::clipElements
void clipElements(const QPointF *points, const QPainterPath::ElementType *types, int count)
Definition
qoutlinemapper.cpp:327
QOutlineMapper::m_points
QDataBuffer< QT_FT_Vector > m_points
Definition
qoutlinemapper_p.h:164
QOutlineMapper::convertElements
void convertElements(const QPointF *points, const QPainterPath::ElementType *types, int count)
Definition
qoutlinemapper.cpp:230
QOutlineMapper::setMatrix
void setMatrix(const QTransform &m)
Sets up the matrix to be used for conversion.
Definition
qoutlinemapper_p.h:74
QOutlineMapper::moveTo
void moveTo(const QPointF &pt)
Definition
qoutlinemapper_p.h:108
QOutlineMapper::controlPointRect
QRectF controlPointRect
Definition
qoutlinemapper_p.h:170
QOutlineMapper::endOutline
void endOutline()
Definition
qoutlinemapper.cpp:178
QOutlineMapper::m_in_clip_elements
bool m_in_clip_elements
Definition
qoutlinemapper_p.h:181
QOutlineMapper::m_subpath_start
int m_subpath_start
Definition
qoutlinemapper_p.h:174
QOutlineMapper::curveTo
void curveTo(const QPointF &cp1, const QPointF &cp2, const QPointF &ep)
Definition
qoutlinemapper.cpp:59
QOutlineMapper::m_clip_rect
QRect m_clip_rect
Definition
qoutlinemapper_p.h:168
QOutlineMapper::setClipRect
void setClipRect(QRect clipRect)
Definition
qoutlinemapper.cpp:41
QOutlineMapper::m_elements
QDataBuffer< QPointF > m_elements
Definition
qoutlinemapper_p.h:163
QOutlineMapper::elementTypes
QPainterPath::ElementType * elementTypes() const
Definition
qoutlinemapper_p.h:159
QOutlineMapper::m_tags
QDataBuffer< char > m_tags
Definition
qoutlinemapper_p.h:165
QOutlineMapper::QOutlineMapper
QOutlineMapper()
Definition
qoutlinemapper_p.h:59
QOutlineMapper::m_contours
QDataBuffer< int > m_contours
Definition
qoutlinemapper_p.h:166
QOutlineMapper::m_element_types
QDataBuffer< QPainterPath::ElementType > m_element_types
Definition
qoutlinemapper_p.h:162
QOutlineMapper::closeSubpath
void closeSubpath()
Definition
qoutlinemapper_p.h:128
QOutlineMapper::m_outline
QT_FT_Outline m_outline
Definition
qoutlinemapper_p.h:172
QOutlineMapper::m_curve_threshold
qreal m_curve_threshold
Definition
qoutlinemapper_p.h:178
QOutlineMapper::m_clip_trigger_rect
QRectF m_clip_trigger_rect
Definition
qoutlinemapper_p.h:169
QOutlineMapper::m_valid
bool m_valid
Definition
qoutlinemapper_p.h:180
QOutlineMapper::convertPath
QT_FT_Outline * convertPath(const QPainterPath &path)
Definition
qoutlinemapper.cpp:88
QOutlineMapper::beginOutline
void beginOutline(Qt::FillRule fillRule)
Definition
qoutlinemapper_p.h:85
QOutlineMapper::lineTo
void lineTo(const QPointF &pt)
Definition
qoutlinemapper_p.h:118
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qreal_to_fixed_26_6
#define qreal_to_fixed_26_6(f)
Definition
qoutlinemapper.cpp:16
qt_scaleForTransform
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
Definition
qtransform.cpp:2160
QT_RASTER_COORD_LIMIT
QT_BEGIN_NAMESPACE constexpr int QT_RASTER_COORD_LIMIT
Definition
qoutlinemapper_p.h:39
qtbase
src
gui
painting
qoutlinemapper_p.h
Generated on
for Qt by
1.18.0