Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | // QtCore | - |
43 | #include <qdebug.h> | - |
44 | #include <qmath.h> | - |
45 | #include <qmutex.h> | - |
46 | | - |
47 | // QtGui | - |
48 | #include "qbitmap.h" | - |
49 | #include "qimage.h" | - |
50 | #include "qpaintdevice.h" | - |
51 | #include "qpaintengine.h" | - |
52 | #include "qpainter.h" | - |
53 | #include "qpainter_p.h" | - |
54 | #include "qpainterpath.h" | - |
55 | #include "qpicture.h" | - |
56 | #include "qpixmapcache.h" | - |
57 | #include "qpolygon.h" | - |
58 | #include "qtextlayout.h" | - |
59 | #include "qthread.h" | - |
60 | #include "qvarlengtharray.h" | - |
61 | #include "qstatictext.h" | - |
62 | #include "qglyphrun.h" | - |
63 | | - |
64 | #include <qpa/qplatformtheme.h> | - |
65 | | - |
66 | #include <private/qfontengine_p.h> | - |
67 | #include <private/qpaintengine_p.h> | - |
68 | #include <private/qemulationpaintengine_p.h> | - |
69 | #include <private/qpainterpath_p.h> | - |
70 | #include <private/qtextengine_p.h> | - |
71 | #include <private/qpaintengine_raster_p.h> | - |
72 | #include <private/qmath_p.h> | - |
73 | #include <private/qstatictext_p.h> | - |
74 | #include <private/qglyphrun_p.h> | - |
75 | #include <private/qhexstring_p.h> | - |
76 | #include <private/qguiapplication_p.h> | - |
77 | #include <private/qrawfont_p.h> | - |
78 | | - |
79 | QT_BEGIN_NAMESPACE | - |
80 | | - |
81 | #define QGradient_StretchToDevice 0x10000000 | - |
82 | #define QPaintEngine_OpaqueBackground 0x40000000 | - |
83 | | - |
84 | // #define QT_DEBUG_DRAW | - |
85 | #ifdef QT_DEBUG_DRAW | - |
86 | bool qt_show_painter_debug_output = true; | - |
87 | #endif | - |
88 | | - |
89 | extern QPixmap qt_pixmapForBrush(int style, bool invert); | - |
90 | | - |
91 | void qt_format_text(const QFont &font, | - |
92 | const QRectF &_r, int tf, const QTextOption *option, const QString& str, QRectF *brect, | - |
93 | int tabstops, int* tabarray, int tabarraylen, | - |
94 | QPainter *painter); | - |
95 | static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextEngine *textEngine, | - |
96 | QTextCharFormat::UnderlineStyle underlineStyle, | - |
97 | QTextItem::RenderFlags flags, qreal width, | - |
98 | const QTextCharFormat &charFormat); | - |
99 | // Helper function to calculate left most position, width and flags for decoration drawing | - |
100 | Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray, | - |
101 | const QFixedPoint *positions, int glyphCount, | - |
102 | QFontEngine *fontEngine, const QFont &font, | - |
103 | const QTextCharFormat &charFormat); | - |
104 | | - |
105 | static inline QGradient::CoordinateMode coordinateMode(const QBrush &brush) | - |
106 | { | - |
107 | switch (brush.style()) { | - |
108 | case Qt::LinearGradientPattern: | - |
109 | case Qt::RadialGradientPattern: | - |
110 | case Qt::ConicalGradientPattern: | - |
111 | return brush.gradient()->coordinateMode(); never executed: return brush.gradient()->coordinateMode(); | 0 |
112 | default: | - |
113 | ; | - |
114 | } | 0 |
115 | return QGradient::LogicalMode; never executed: return QGradient::LogicalMode; | 0 |
116 | } | - |
117 | | - |
118 | /* Returns true if the gradient requires stretch to device...*/ | - |
119 | static inline bool check_gradient(const QBrush &brush) | - |
120 | { | - |
121 | return coordinateMode(brush) == QGradient::StretchToDeviceMode; never executed: return coordinateMode(brush) == QGradient::StretchToDeviceMode; | 0 |
122 | } | - |
123 | | - |
124 | extern bool qHasPixmapTexture(const QBrush &); | - |
125 | | - |
126 | static inline bool is_brush_transparent(const QBrush &brush) { | - |
127 | Qt::BrushStyle s = brush.style(); never executed (the execution status of this line is deduced): Qt::BrushStyle s = brush.style(); | - |
128 | bool brushBitmap = qHasPixmapTexture(brush) never evaluated: qHasPixmapTexture(brush) | 0 |
129 | ? brush.texture().isQBitmap() never executed (the execution status of this line is deduced): ? brush.texture().isQBitmap() | - |
130 | : (brush.textureImage().depth() == 1); never executed (the execution status of this line is deduced): : (brush.textureImage().depth() == 1); | - |
131 | return ((s >= Qt::Dense1Pattern && s <= Qt::DiagCrossPattern) never executed: return ((s >= Qt::Dense1Pattern && s <= Qt::DiagCrossPattern) || (s == Qt::TexturePattern && brushBitmap)); | 0 |
132 | || (s == Qt::TexturePattern && brushBitmap)); never executed: return ((s >= Qt::Dense1Pattern && s <= Qt::DiagCrossPattern) || (s == Qt::TexturePattern && brushBitmap)); | 0 |
133 | } | - |
134 | | - |
135 | static inline bool is_pen_transparent(const QPen &pen) { | - |
136 | return pen.style() > Qt::SolidLine || is_brush_transparent(pen.brush()); never executed: return pen.style() > Qt::SolidLine || is_brush_transparent(pen.brush()); | 0 |
137 | } | - |
138 | | - |
139 | /* Discards the emulation flags that are not relevant for line drawing | - |
140 | and returns the result | - |
141 | */ | - |
142 | static inline uint line_emulation(uint emulation) | - |
143 | { | - |
144 | return emulation & (QPaintEngine::PrimitiveTransform executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000); Execution Count:6 | 6 |
145 | | QPaintEngine::AlphaBlend executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000); Execution Count:6 | 6 |
146 | | QPaintEngine::Antialiasing executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000); Execution Count:6 | 6 |
147 | | QPaintEngine::BrushStroke executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000); Execution Count:6 | 6 |
148 | | QPaintEngine::ConstantOpacity executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000); Execution Count:6 | 6 |
149 | | QGradient_StretchToDevice executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000); Execution Count:6 | 6 |
150 | | QPaintEngine::ObjectBoundingModeGradients executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000); Execution Count:6 | 6 |
151 | | QPaintEngine_OpaqueBackground); executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000); Execution Count:6 | 6 |
152 | } | - |
153 | | - |
154 | #ifndef QT_NO_DEBUG | - |
155 | static bool qt_painter_thread_test(int devType, const char *what, bool extraCondition = false) | - |
156 | { | - |
157 | switch (devType) { | - |
158 | case QInternal::Image: | - |
159 | case QInternal::Printer: | - |
160 | case QInternal::Picture: | - |
161 | // can be drawn onto these devices safely from any thread | - |
162 | if (extraCondition) | - |
163 | break; | - |
164 | default: | - |
165 | if (!extraCondition && QThread::currentThread() != qApp->thread()) { | - |
166 | qWarning("QPainter: It is not safe to use %s outside the GUI thread", what); | - |
167 | return false; | - |
168 | } | - |
169 | break; | - |
170 | } | - |
171 | return true; | - |
172 | } | - |
173 | #endif | - |
174 | | - |
175 | void QPainterPrivate::checkEmulation() | - |
176 | { | - |
177 | Q_ASSERT(extended); executed (the execution status of this line is deduced): qt_noop(); | - |
178 | if (extended->flags() & QPaintEngineEx::DoNotEmulate) evaluated: extended->flags() & QPaintEngineEx::DoNotEmulate yes Evaluation Count:15086 | yes Evaluation Count:61287 |
| 15086-61287 |
179 | return; executed: return; Execution Count:15086 | 15086 |
180 | | - |
181 | bool doEmulation = false; executed (the execution status of this line is deduced): bool doEmulation = false; | - |
182 | if (state->bgMode == Qt::OpaqueMode) evaluated: state->bgMode == Qt::OpaqueMode yes Evaluation Count:2939 | yes Evaluation Count:58348 |
| 2939-58348 |
183 | doEmulation = true; executed: doEmulation = true; Execution Count:2939 | 2939 |
184 | | - |
185 | const QGradient *bg = state->brush.gradient(); executed (the execution status of this line is deduced): const QGradient *bg = state->brush.gradient(); | - |
186 | if (bg && bg->coordinateMode() > QGradient::LogicalMode) evaluated: bg yes Evaluation Count:799 | yes Evaluation Count:60488 |
evaluated: bg->coordinateMode() > QGradient::LogicalMode yes Evaluation Count:3 | yes Evaluation Count:796 |
| 3-60488 |
187 | doEmulation = true; executed: doEmulation = true; Execution Count:3 | 3 |
188 | | - |
189 | const QGradient *pg = qpen_brush(state->pen).gradient(); executed (the execution status of this line is deduced): const QGradient *pg = qpen_brush(state->pen).gradient(); | - |
190 | if (pg && pg->coordinateMode() > QGradient::LogicalMode) evaluated: pg yes Evaluation Count:18 | yes Evaluation Count:61269 |
partially evaluated: pg->coordinateMode() > QGradient::LogicalMode no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-61269 |
191 | doEmulation = true; never executed: doEmulation = true; | 0 |
192 | | - |
193 | if (doEmulation) { evaluated: doEmulation yes Evaluation Count:2942 | yes Evaluation Count:58345 |
| 2942-58345 |
194 | if (extended != emulationEngine) { partially evaluated: extended != emulationEngine yes Evaluation Count:2942 | no Evaluation Count:0 |
| 0-2942 |
195 | if (!emulationEngine) partially evaluated: !emulationEngine yes Evaluation Count:2942 | no Evaluation Count:0 |
| 0-2942 |
196 | emulationEngine = new QEmulationPaintEngine(extended); executed: emulationEngine = new QEmulationPaintEngine(extended); Execution Count:2942 | 2942 |
197 | extended = emulationEngine; executed (the execution status of this line is deduced): extended = emulationEngine; | - |
198 | extended->setState(state); executed (the execution status of this line is deduced): extended->setState(state); | - |
199 | } executed: } Execution Count:2942 | 2942 |
200 | } else if (emulationEngine == extended) { executed: } Execution Count:2942 partially evaluated: emulationEngine == extended no Evaluation Count:0 | yes Evaluation Count:58345 |
| 0-58345 |
201 | extended = emulationEngine->real_engine; never executed (the execution status of this line is deduced): extended = emulationEngine->real_engine; | - |
202 | } | 0 |
203 | } | - |
204 | | - |
205 | | - |
206 | QPainterPrivate::~QPainterPrivate() | - |
207 | { | - |
208 | delete emulationEngine; executed (the execution status of this line is deduced): delete emulationEngine; | - |
209 | for (int i=0; i<states.size(); ++i) partially evaluated: i<states.size() no Evaluation Count:0 | yes Evaluation Count:27643 |
| 0-27643 |
210 | delete states.at(i); never executed: delete states.at(i); | 0 |
211 | | - |
212 | if (dummyState) evaluated: dummyState yes Evaluation Count:1 | yes Evaluation Count:27642 |
| 1-27642 |
213 | delete dummyState; executed: delete dummyState; Execution Count:1 | 1 |
214 | } executed: } Execution Count:27643 | 27643 |
215 | | - |
216 | | - |
217 | QTransform QPainterPrivate::viewTransform() const | - |
218 | { | - |
219 | if (state->VxF) { evaluated: state->VxF yes Evaluation Count:14 | yes Evaluation Count:2 |
| 2-14 |
220 | qreal scaleW = qreal(state->vw)/qreal(state->ww); executed (the execution status of this line is deduced): qreal scaleW = qreal(state->vw)/qreal(state->ww); | - |
221 | qreal scaleH = qreal(state->vh)/qreal(state->wh); executed (the execution status of this line is deduced): qreal scaleH = qreal(state->vh)/qreal(state->wh); | - |
222 | return QTransform(scaleW, 0, 0, scaleH, executed: return QTransform(scaleW, 0, 0, scaleH, state->vx - state->wx*scaleW, state->vy - state->wy*scaleH); Execution Count:14 | 14 |
223 | state->vx - state->wx*scaleW, state->vy - state->wy*scaleH); executed: return QTransform(scaleW, 0, 0, scaleH, state->vx - state->wx*scaleW, state->vy - state->wy*scaleH); Execution Count:14 | 14 |
224 | } | - |
225 | return QTransform(); executed: return QTransform(); Execution Count:2 | 2 |
226 | } | - |
227 | | - |
228 | QTransform QPainterPrivate::hidpiScaleTransform() const | - |
229 | { | - |
230 | #ifdef Q_OS_MAC | - |
231 | // Limited feature introduction for Qt 5.0.0, remove ifdef in a later release. | - |
232 | if (device->devType() == QInternal::Printer || device->physicalDpiX() == 0 || device->logicalDpiX() == 0) | - |
233 | return QTransform(); | - |
234 | const qreal deviceScale = (device->physicalDpiX() / device->logicalDpiX()); | - |
235 | if (deviceScale > 1.0) | - |
236 | return QTransform::fromScale(deviceScale, deviceScale); | - |
237 | #endif | - |
238 | return QTransform(); executed: return QTransform(); Execution Count:57707 | 57707 |
239 | } | - |
240 | | - |
241 | /* | - |
242 | \internal | - |
243 | Returns true if using a shared painter; otherwise false. | - |
244 | */ | - |
245 | bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev) | - |
246 | { | - |
247 | Q_ASSERT(q); executed (the execution status of this line is deduced): qt_noop(); | - |
248 | Q_ASSERT(pdev); executed (the execution status of this line is deduced): qt_noop(); | - |
249 | | - |
250 | QPainter *sp = pdev->sharedPainter(); executed (the execution status of this line is deduced): QPainter *sp = pdev->sharedPainter(); | - |
251 | if (!sp) evaluated: !sp yes Evaluation Count:54386 | yes Evaluation Count:40 |
| 40-54386 |
252 | return false; executed: return false; Execution Count:54386 | 54386 |
253 | | - |
254 | // Save the current state of the shared painter and assign | - |
255 | // the current d_ptr to the shared painter's d_ptr. | - |
256 | sp->save(); executed (the execution status of this line is deduced): sp->save(); | - |
257 | if (!sp->d_ptr->d_ptrs) { evaluated: !sp->d_ptr->d_ptrs yes Evaluation Count:13 | yes Evaluation Count:27 |
| 13-27 |
258 | // Allocate space for 4 d-pointers (enough for up to 4 sub-sequent | - |
259 | // redirections within the same paintEvent(), which should be enough | - |
260 | // in 99% of all cases). E.g: A renders B which renders C which renders D. | - |
261 | sp->d_ptr->d_ptrs_size = 4; executed (the execution status of this line is deduced): sp->d_ptr->d_ptrs_size = 4; | - |
262 | sp->d_ptr->d_ptrs = (QPainterPrivate **)malloc(4 * sizeof(QPainterPrivate *)); executed (the execution status of this line is deduced): sp->d_ptr->d_ptrs = (QPainterPrivate **)malloc(4 * sizeof(QPainterPrivate *)); | - |
263 | Q_CHECK_PTR(sp->d_ptr->d_ptrs); executed (the execution status of this line is deduced): qt_noop(); | - |
264 | } else if (sp->d_ptr->refcount - 1 == sp->d_ptr->d_ptrs_size) { executed: } Execution Count:13 partially evaluated: sp->d_ptr->refcount - 1 == sp->d_ptr->d_ptrs_size no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
265 | // However, to support corner cases we grow the array dynamically if needed. | - |
266 | sp->d_ptr->d_ptrs_size <<= 1; never executed (the execution status of this line is deduced): sp->d_ptr->d_ptrs_size <<= 1; | - |
267 | const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *); never executed (the execution status of this line is deduced): const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *); | - |
268 | sp->d_ptr->d_ptrs = q_check_ptr((QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize)); never executed (the execution status of this line is deduced): sp->d_ptr->d_ptrs = q_check_ptr((QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize)); | - |
269 | } | 0 |
270 | sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data(); executed (the execution status of this line is deduced): sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data(); | - |
271 | q->d_ptr.take(); executed (the execution status of this line is deduced): q->d_ptr.take(); | - |
272 | q->d_ptr.reset(sp->d_ptr.data()); executed (the execution status of this line is deduced): q->d_ptr.reset(sp->d_ptr.data()); | - |
273 | | - |
274 | Q_ASSERT(q->d_ptr->state); executed (the execution status of this line is deduced): qt_noop(); | - |
275 | | - |
276 | // Now initialize the painter with correct widget properties. | - |
277 | q->initFrom(pdev); executed (the execution status of this line is deduced): q->initFrom(pdev); | - |
278 | QPoint offset; executed (the execution status of this line is deduced): QPoint offset; | - |
279 | pdev->redirected(&offset); executed (the execution status of this line is deduced): pdev->redirected(&offset); | - |
280 | offset += q->d_ptr->engine->coordinateOffset(); executed (the execution status of this line is deduced): offset += q->d_ptr->engine->coordinateOffset(); | - |
281 | | - |
282 | // Update system rect. | - |
283 | q->d_ptr->state->ww = q->d_ptr->state->vw = pdev->width(); executed (the execution status of this line is deduced): q->d_ptr->state->ww = q->d_ptr->state->vw = pdev->width(); | - |
284 | q->d_ptr->state->wh = q->d_ptr->state->vh = pdev->height(); executed (the execution status of this line is deduced): q->d_ptr->state->wh = q->d_ptr->state->vh = pdev->height(); | - |
285 | | - |
286 | // Update matrix. | - |
287 | if (q->d_ptr->state->WxF) { evaluated: q->d_ptr->state->WxF yes Evaluation Count:29 | yes Evaluation Count:11 |
| 11-29 |
288 | q->d_ptr->state->redirectionMatrix = q->d_ptr->state->matrix; executed (the execution status of this line is deduced): q->d_ptr->state->redirectionMatrix = q->d_ptr->state->matrix; | - |
289 | q->d_ptr->state->redirectionMatrix.translate(-offset.x(), -offset.y()); executed (the execution status of this line is deduced): q->d_ptr->state->redirectionMatrix.translate(-offset.x(), -offset.y()); | - |
290 | q->d_ptr->state->worldMatrix = QTransform(); executed (the execution status of this line is deduced): q->d_ptr->state->worldMatrix = QTransform(); | - |
291 | q->d_ptr->state->WxF = false; executed (the execution status of this line is deduced): q->d_ptr->state->WxF = false; | - |
292 | } else { executed: } Execution Count:29 | 29 |
293 | q->d_ptr->state->redirectionMatrix = QTransform::fromTranslate(-offset.x(), -offset.y()); executed (the execution status of this line is deduced): q->d_ptr->state->redirectionMatrix = QTransform::fromTranslate(-offset.x(), -offset.y()); | - |
294 | } executed: } Execution Count:11 | 11 |
295 | q->d_ptr->updateMatrix(); executed (the execution status of this line is deduced): q->d_ptr->updateMatrix(); | - |
296 | | - |
297 | QPaintEnginePrivate *enginePrivate = q->d_ptr->engine->d_func(); executed (the execution status of this line is deduced): QPaintEnginePrivate *enginePrivate = q->d_ptr->engine->d_func(); | - |
298 | if (enginePrivate->currentClipDevice == pdev) { evaluated: enginePrivate->currentClipDevice == pdev yes Evaluation Count:14 | yes Evaluation Count:26 |
| 14-26 |
299 | enginePrivate->systemStateChanged(); executed (the execution status of this line is deduced): enginePrivate->systemStateChanged(); | - |
300 | return true; executed: return true; Execution Count:14 | 14 |
301 | } | - |
302 | | - |
303 | // Update system transform and clip. | - |
304 | enginePrivate->currentClipDevice = pdev; executed (the execution status of this line is deduced): enginePrivate->currentClipDevice = pdev; | - |
305 | enginePrivate->setSystemTransform(q->d_ptr->state->matrix); executed (the execution status of this line is deduced): enginePrivate->setSystemTransform(q->d_ptr->state->matrix); | - |
306 | return true; executed: return true; Execution Count:26 | 26 |
307 | } | - |
308 | | - |
309 | void QPainterPrivate::detachPainterPrivate(QPainter *q) | - |
310 | { | - |
311 | Q_ASSERT(refcount > 1); executed (the execution status of this line is deduced): qt_noop(); | - |
312 | Q_ASSERT(q); executed (the execution status of this line is deduced): qt_noop(); | - |
313 | | - |
314 | QPainterPrivate *original = d_ptrs[--refcount - 1]; executed (the execution status of this line is deduced): QPainterPrivate *original = d_ptrs[--refcount - 1]; | - |
315 | if (inDestructor) { evaluated: inDestructor yes Evaluation Count:39 | yes Evaluation Count:1 |
| 1-39 |
316 | inDestructor = false; executed (the execution status of this line is deduced): inDestructor = false; | - |
317 | if (original) evaluated: original yes Evaluation Count:6 | yes Evaluation Count:33 |
| 6-33 |
318 | original->inDestructor = true; executed: original->inDestructor = true; Execution Count:6 | 6 |
319 | } else if (!original) { executed: } Execution Count:39 partially evaluated: !original yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-39 |
320 | original = new QPainterPrivate(q); executed (the execution status of this line is deduced): original = new QPainterPrivate(q); | - |
321 | } executed: } Execution Count:1 | 1 |
322 | | - |
323 | d_ptrs[refcount - 1] = 0; executed (the execution status of this line is deduced): d_ptrs[refcount - 1] = 0; | - |
324 | q->restore(); executed (the execution status of this line is deduced): q->restore(); | - |
325 | q->d_ptr.take(); executed (the execution status of this line is deduced): q->d_ptr.take(); | - |
326 | q->d_ptr.reset(original); executed (the execution status of this line is deduced): q->d_ptr.reset(original); | - |
327 | | - |
328 | if (emulationEngine) { partially evaluated: emulationEngine no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
329 | extended = emulationEngine->real_engine; never executed (the execution status of this line is deduced): extended = emulationEngine->real_engine; | - |
330 | delete emulationEngine; never executed (the execution status of this line is deduced): delete emulationEngine; | - |
331 | emulationEngine = 0; never executed (the execution status of this line is deduced): emulationEngine = 0; | - |
332 | } | 0 |
333 | } executed: } Execution Count:40 | 40 |
334 | | - |
335 | | - |
336 | void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperation op) | - |
337 | { | - |
338 | #ifdef QT_DEBUG_DRAW | - |
339 | if (qt_show_painter_debug_output) { | - |
340 | printf("QPainter::drawHelper\n"); | - |
341 | } | - |
342 | #endif | - |
343 | | - |
344 | if (originalPath.isEmpty()) never evaluated: originalPath.isEmpty() | 0 |
345 | return; | 0 |
346 | | - |
347 | QPaintEngine::PaintEngineFeatures gradientStretch = never executed (the execution status of this line is deduced): QPaintEngine::PaintEngineFeatures gradientStretch = | - |
348 | QPaintEngine::PaintEngineFeatures(QGradient_StretchToDevice never executed (the execution status of this line is deduced): QPaintEngine::PaintEngineFeatures(0x10000000 | - |
349 | | QPaintEngine::ObjectBoundingModeGradients); never executed (the execution status of this line is deduced): | QPaintEngine::ObjectBoundingModeGradients); | - |
350 | | - |
351 | const bool mustEmulateObjectBoundingModeGradients = extended never evaluated: extended | 0 |
352 | || ((state->emulationSpecifier & QPaintEngine::ObjectBoundingModeGradients) never evaluated: (state->emulationSpecifier & QPaintEngine::ObjectBoundingModeGradients) | 0 |
353 | && !engine->hasFeature(QPaintEngine::PatternTransform)); never evaluated: !engine->hasFeature(QPaintEngine::PatternTransform) | 0 |
354 | | - |
355 | if (!(state->emulationSpecifier & ~gradientStretch) never evaluated: !(state->emulationSpecifier & ~gradientStretch) | 0 |
356 | && !mustEmulateObjectBoundingModeGradients) { never evaluated: !mustEmulateObjectBoundingModeGradients | 0 |
357 | drawStretchedGradient(originalPath, op); never executed (the execution status of this line is deduced): drawStretchedGradient(originalPath, op); | - |
358 | return; | 0 |
359 | } else if (state->emulationSpecifier & QPaintEngine_OpaqueBackground) { never evaluated: state->emulationSpecifier & 0x40000000 | 0 |
360 | drawOpaqueBackground(originalPath, op); never executed (the execution status of this line is deduced): drawOpaqueBackground(originalPath, op); | - |
361 | return; | 0 |
362 | } | - |
363 | | - |
364 | Q_Q(QPainter); never executed (the execution status of this line is deduced): QPainter * const q = q_func(); | - |
365 | | - |
366 | qreal strokeOffsetX = 0, strokeOffsetY = 0; never executed (the execution status of this line is deduced): qreal strokeOffsetX = 0, strokeOffsetY = 0; | - |
367 | | - |
368 | QPainterPath path = originalPath * state->matrix; never executed (the execution status of this line is deduced): QPainterPath path = originalPath * state->matrix; | - |
369 | QRectF pathBounds = path.boundingRect(); never executed (the execution status of this line is deduced): QRectF pathBounds = path.boundingRect(); | - |
370 | QRectF strokeBounds; never executed (the execution status of this line is deduced): QRectF strokeBounds; | - |
371 | bool doStroke = (op & StrokeDraw) && (state->pen.style() != Qt::NoPen); never evaluated: (op & StrokeDraw) never evaluated: (state->pen.style() != Qt::NoPen) | 0 |
372 | if (doStroke) { never evaluated: doStroke | 0 |
373 | qreal penWidth = state->pen.widthF(); never executed (the execution status of this line is deduced): qreal penWidth = state->pen.widthF(); | - |
374 | if (penWidth == 0) { never evaluated: penWidth == 0 | 0 |
375 | strokeOffsetX = 1; never executed (the execution status of this line is deduced): strokeOffsetX = 1; | - |
376 | strokeOffsetY = 1; never executed (the execution status of this line is deduced): strokeOffsetY = 1; | - |
377 | } else { | 0 |
378 | // In case of complex xform | - |
379 | if (state->matrix.type() > QTransform::TxScale) { never evaluated: state->matrix.type() > QTransform::TxScale | 0 |
380 | QPainterPathStroker stroker; never executed (the execution status of this line is deduced): QPainterPathStroker stroker; | - |
381 | stroker.setWidth(penWidth); never executed (the execution status of this line is deduced): stroker.setWidth(penWidth); | - |
382 | stroker.setJoinStyle(state->pen.joinStyle()); never executed (the execution status of this line is deduced): stroker.setJoinStyle(state->pen.joinStyle()); | - |
383 | stroker.setCapStyle(state->pen.capStyle()); never executed (the execution status of this line is deduced): stroker.setCapStyle(state->pen.capStyle()); | - |
384 | QPainterPath stroke = stroker.createStroke(originalPath); never executed (the execution status of this line is deduced): QPainterPath stroke = stroker.createStroke(originalPath); | - |
385 | strokeBounds = (stroke * state->matrix).boundingRect(); never executed (the execution status of this line is deduced): strokeBounds = (stroke * state->matrix).boundingRect(); | - |
386 | } else { | 0 |
387 | strokeOffsetX = qAbs(penWidth * state->matrix.m11() / 2.0); never executed (the execution status of this line is deduced): strokeOffsetX = qAbs(penWidth * state->matrix.m11() / 2.0); | - |
388 | strokeOffsetY = qAbs(penWidth * state->matrix.m22() / 2.0); never executed (the execution status of this line is deduced): strokeOffsetY = qAbs(penWidth * state->matrix.m22() / 2.0); | - |
389 | } | 0 |
390 | } | - |
391 | } | - |
392 | | - |
393 | QRect absPathRect; never executed (the execution status of this line is deduced): QRect absPathRect; | - |
394 | if (!strokeBounds.isEmpty()) { never evaluated: !strokeBounds.isEmpty() | 0 |
395 | absPathRect = strokeBounds.intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect(); never executed (the execution status of this line is deduced): absPathRect = strokeBounds.intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect(); | - |
396 | } else { | 0 |
397 | absPathRect = pathBounds.adjusted(-strokeOffsetX, -strokeOffsetY, strokeOffsetX, strokeOffsetY) never executed (the execution status of this line is deduced): absPathRect = pathBounds.adjusted(-strokeOffsetX, -strokeOffsetY, strokeOffsetX, strokeOffsetY) | - |
398 | .intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect(); never executed (the execution status of this line is deduced): .intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect(); | - |
399 | } | 0 |
400 | | - |
401 | if (q->hasClipping()) { never evaluated: q->hasClipping() | 0 |
402 | bool hasPerspectiveTransform = false; never executed (the execution status of this line is deduced): bool hasPerspectiveTransform = false; | - |
403 | for (int i = 0; i < state->clipInfo.size(); ++i) { never evaluated: i < state->clipInfo.size() | 0 |
404 | const QPainterClipInfo &info = state->clipInfo.at(i); never executed (the execution status of this line is deduced): const QPainterClipInfo &info = state->clipInfo.at(i); | - |
405 | if (info.matrix.type() == QTransform::TxProject) { never evaluated: info.matrix.type() == QTransform::TxProject | 0 |
406 | hasPerspectiveTransform = true; never executed (the execution status of this line is deduced): hasPerspectiveTransform = true; | - |
407 | break; | 0 |
408 | } | - |
409 | } | 0 |
410 | // avoid mapping QRegions with perspective transforms | - |
411 | if (!hasPerspectiveTransform) { never evaluated: !hasPerspectiveTransform | 0 |
412 | // The trick with txinv and invMatrix is done in order to | - |
413 | // avoid transforming the clip to logical coordinates, and | - |
414 | // then back to device coordinates. This is a problem with | - |
415 | // QRegion/QRect based clips, since they use integer | - |
416 | // coordinates and converting to/from logical coordinates will | - |
417 | // lose precision. | - |
418 | bool old_txinv = txinv; never executed (the execution status of this line is deduced): bool old_txinv = txinv; | - |
419 | QTransform old_invMatrix = invMatrix; never executed (the execution status of this line is deduced): QTransform old_invMatrix = invMatrix; | - |
420 | txinv = true; never executed (the execution status of this line is deduced): txinv = true; | - |
421 | invMatrix = QTransform(); never executed (the execution status of this line is deduced): invMatrix = QTransform(); | - |
422 | QPainterPath clipPath = q->clipPath(); never executed (the execution status of this line is deduced): QPainterPath clipPath = q->clipPath(); | - |
423 | QRectF r = clipPath.boundingRect().intersected(absPathRect); never executed (the execution status of this line is deduced): QRectF r = clipPath.boundingRect().intersected(absPathRect); | - |
424 | absPathRect = r.toAlignedRect(); never executed (the execution status of this line is deduced): absPathRect = r.toAlignedRect(); | - |
425 | txinv = old_txinv; never executed (the execution status of this line is deduced): txinv = old_txinv; | - |
426 | invMatrix = old_invMatrix; never executed (the execution status of this line is deduced): invMatrix = old_invMatrix; | - |
427 | } | 0 |
428 | } | 0 |
429 | | - |
430 | // qDebug("\nQPainterPrivate::draw_helper(), x=%d, y=%d, w=%d, h=%d", | - |
431 | // devMinX, devMinY, device->width(), device->height()); | - |
432 | // qDebug() << " - matrix" << state->matrix; | - |
433 | // qDebug() << " - originalPath.bounds" << originalPath.boundingRect(); | - |
434 | // qDebug() << " - path.bounds" << path.boundingRect(); | - |
435 | | - |
436 | if (absPathRect.width() <= 0 || absPathRect.height() <= 0) never evaluated: absPathRect.width() <= 0 never evaluated: absPathRect.height() <= 0 | 0 |
437 | return; | 0 |
438 | | - |
439 | QImage image(absPathRect.width(), absPathRect.height(), QImage::Format_ARGB32_Premultiplied); never executed (the execution status of this line is deduced): QImage image(absPathRect.width(), absPathRect.height(), QImage::Format_ARGB32_Premultiplied); | - |
440 | image.fill(0); never executed (the execution status of this line is deduced): image.fill(0); | - |
441 | | - |
442 | QPainter p(&image); never executed (the execution status of this line is deduced): QPainter p(&image); | - |
443 | | - |
444 | p.d_ptr->helper_device = helper_device; never executed (the execution status of this line is deduced): p.d_ptr->helper_device = helper_device; | - |
445 | | - |
446 | p.setOpacity(state->opacity); never executed (the execution status of this line is deduced): p.setOpacity(state->opacity); | - |
447 | p.translate(-absPathRect.x(), -absPathRect.y()); never executed (the execution status of this line is deduced): p.translate(-absPathRect.x(), -absPathRect.y()); | - |
448 | p.setTransform(state->matrix, true); never executed (the execution status of this line is deduced): p.setTransform(state->matrix, true); | - |
449 | p.setPen(doStroke ? state->pen : QPen(Qt::NoPen)); never executed (the execution status of this line is deduced): p.setPen(doStroke ? state->pen : QPen(Qt::NoPen)); | - |
450 | p.setBrush((op & FillDraw) ? state->brush : QBrush(Qt::NoBrush)); never executed (the execution status of this line is deduced): p.setBrush((op & FillDraw) ? state->brush : QBrush(Qt::NoBrush)); | - |
451 | p.setBackground(state->bgBrush); never executed (the execution status of this line is deduced): p.setBackground(state->bgBrush); | - |
452 | p.setBackgroundMode(state->bgMode); never executed (the execution status of this line is deduced): p.setBackgroundMode(state->bgMode); | - |
453 | p.setBrushOrigin(state->brushOrigin); never executed (the execution status of this line is deduced): p.setBrushOrigin(state->brushOrigin); | - |
454 | | - |
455 | p.setRenderHint(QPainter::Antialiasing, state->renderHints & QPainter::Antialiasing); never executed (the execution status of this line is deduced): p.setRenderHint(QPainter::Antialiasing, state->renderHints & QPainter::Antialiasing); | - |
456 | p.setRenderHint(QPainter::SmoothPixmapTransform, never executed (the execution status of this line is deduced): p.setRenderHint(QPainter::SmoothPixmapTransform, | - |
457 | state->renderHints & QPainter::SmoothPixmapTransform); never executed (the execution status of this line is deduced): state->renderHints & QPainter::SmoothPixmapTransform); | - |
458 | | - |
459 | p.drawPath(originalPath); never executed (the execution status of this line is deduced): p.drawPath(originalPath); | - |
460 | | - |
461 | #ifndef QT_NO_DEBUG | - |
462 | static bool do_fallback_overlay = qgetenv("QT_PAINT_FALLBACK_OVERLAY").size() > 0; | - |
463 | if (do_fallback_overlay) { | - |
464 | QImage block(8, 8, QImage::Format_ARGB32_Premultiplied); | - |
465 | QPainter pt(&block); | - |
466 | pt.fillRect(0, 0, 8, 8, QColor(196, 0, 196)); | - |
467 | pt.drawLine(0, 0, 8, 8); | - |
468 | pt.end(); | - |
469 | p.resetTransform(); | - |
470 | p.setCompositionMode(QPainter::CompositionMode_SourceAtop); | - |
471 | p.setOpacity(0.5); | - |
472 | p.fillRect(0, 0, image.width(), image.height(), QBrush(block)); | - |
473 | } | - |
474 | #endif | - |
475 | | - |
476 | p.end(); never executed (the execution status of this line is deduced): p.end(); | - |
477 | | - |
478 | q->save(); never executed (the execution status of this line is deduced): q->save(); | - |
479 | state->matrix = QTransform(); never executed (the execution status of this line is deduced): state->matrix = QTransform(); | - |
480 | if (extended) { never evaluated: extended | 0 |
481 | extended->transformChanged(); never executed (the execution status of this line is deduced): extended->transformChanged(); | - |
482 | } else { | 0 |
483 | state->dirtyFlags |= QPaintEngine::DirtyTransform; never executed (the execution status of this line is deduced): state->dirtyFlags |= QPaintEngine::DirtyTransform; | - |
484 | updateState(state); never executed (the execution status of this line is deduced): updateState(state); | - |
485 | } | 0 |
486 | engine->drawImage(absPathRect, never executed (the execution status of this line is deduced): engine->drawImage(absPathRect, | - |
487 | image, never executed (the execution status of this line is deduced): image, | - |
488 | QRectF(0, 0, absPathRect.width(), absPathRect.height()), never executed (the execution status of this line is deduced): QRectF(0, 0, absPathRect.width(), absPathRect.height()), | - |
489 | Qt::OrderedDither | Qt::OrderedAlphaDither); never executed (the execution status of this line is deduced): Qt::OrderedDither | Qt::OrderedAlphaDither); | - |
490 | q->restore(); never executed (the execution status of this line is deduced): q->restore(); | - |
491 | } | 0 |
492 | | - |
493 | void QPainterPrivate::drawOpaqueBackground(const QPainterPath &path, DrawOperation op) | - |
494 | { | - |
495 | Q_Q(QPainter); never executed (the execution status of this line is deduced): QPainter * const q = q_func(); | - |
496 | | - |
497 | q->setBackgroundMode(Qt::TransparentMode); never executed (the execution status of this line is deduced): q->setBackgroundMode(Qt::TransparentMode); | - |
498 | | - |
499 | if (op & FillDraw && state->brush.style() != Qt::NoBrush) { never evaluated: op & FillDraw never evaluated: state->brush.style() != Qt::NoBrush | 0 |
500 | q->fillPath(path, state->bgBrush.color()); never executed (the execution status of this line is deduced): q->fillPath(path, state->bgBrush.color()); | - |
501 | q->fillPath(path, state->brush); never executed (the execution status of this line is deduced): q->fillPath(path, state->brush); | - |
502 | } | 0 |
503 | | - |
504 | if (op & StrokeDraw && state->pen.style() != Qt::NoPen) { never evaluated: op & StrokeDraw never evaluated: state->pen.style() != Qt::NoPen | 0 |
505 | q->strokePath(path, QPen(state->bgBrush.color(), state->pen.width())); never executed (the execution status of this line is deduced): q->strokePath(path, QPen(state->bgBrush.color(), state->pen.width())); | - |
506 | q->strokePath(path, state->pen); never executed (the execution status of this line is deduced): q->strokePath(path, state->pen); | - |
507 | } | 0 |
508 | | - |
509 | q->setBackgroundMode(Qt::OpaqueMode); never executed (the execution status of this line is deduced): q->setBackgroundMode(Qt::OpaqueMode); | - |
510 | } | 0 |
511 | | - |
512 | static inline QBrush stretchGradientToUserSpace(const QBrush &brush, const QRectF &boundingRect) | - |
513 | { | - |
514 | Q_ASSERT(brush.style() >= Qt::LinearGradientPattern never executed (the execution status of this line is deduced): qt_noop(); | - |
515 | && brush.style() <= Qt::ConicalGradientPattern); | - |
516 | | - |
517 | QTransform gradientToUser(boundingRect.width(), 0, 0, boundingRect.height(), never executed (the execution status of this line is deduced): QTransform gradientToUser(boundingRect.width(), 0, 0, boundingRect.height(), | - |
518 | boundingRect.x(), boundingRect.y()); never executed (the execution status of this line is deduced): boundingRect.x(), boundingRect.y()); | - |
519 | | - |
520 | QGradient g = *brush.gradient(); never executed (the execution status of this line is deduced): QGradient g = *brush.gradient(); | - |
521 | g.setCoordinateMode(QGradient::LogicalMode); never executed (the execution status of this line is deduced): g.setCoordinateMode(QGradient::LogicalMode); | - |
522 | | - |
523 | QBrush b(g); never executed (the execution status of this line is deduced): QBrush b(g); | - |
524 | b.setTransform(gradientToUser * b.transform()); never executed (the execution status of this line is deduced): b.setTransform(gradientToUser * b.transform()); | - |
525 | return b; never executed: return b; | 0 |
526 | } | - |
527 | | - |
528 | void QPainterPrivate::drawStretchedGradient(const QPainterPath &path, DrawOperation op) | - |
529 | { | - |
530 | Q_Q(QPainter); never executed (the execution status of this line is deduced): QPainter * const q = q_func(); | - |
531 | | - |
532 | const qreal sw = helper_device->width(); never executed (the execution status of this line is deduced): const qreal sw = helper_device->width(); | - |
533 | const qreal sh = helper_device->height(); never executed (the execution status of this line is deduced): const qreal sh = helper_device->height(); | - |
534 | | - |
535 | bool changedPen = false; never executed (the execution status of this line is deduced): bool changedPen = false; | - |
536 | bool changedBrush = false; never executed (the execution status of this line is deduced): bool changedBrush = false; | - |
537 | bool needsFill = false; never executed (the execution status of this line is deduced): bool needsFill = false; | - |
538 | | - |
539 | const QPen pen = state->pen; never executed (the execution status of this line is deduced): const QPen pen = state->pen; | - |
540 | const QBrush brush = state->brush; never executed (the execution status of this line is deduced): const QBrush brush = state->brush; | - |
541 | | - |
542 | const QGradient::CoordinateMode penMode = coordinateMode(pen.brush()); never executed (the execution status of this line is deduced): const QGradient::CoordinateMode penMode = coordinateMode(pen.brush()); | - |
543 | const QGradient::CoordinateMode brushMode = coordinateMode(brush); never executed (the execution status of this line is deduced): const QGradient::CoordinateMode brushMode = coordinateMode(brush); | - |
544 | | - |
545 | QRectF boundingRect; never executed (the execution status of this line is deduced): QRectF boundingRect; | - |
546 | | - |
547 | // Draw the xformed fill if the brush is a stretch gradient. | - |
548 | if ((op & FillDraw) && brush.style() != Qt::NoBrush) { never evaluated: (op & FillDraw) never evaluated: brush.style() != Qt::NoBrush | 0 |
549 | if (brushMode == QGradient::StretchToDeviceMode) { never evaluated: brushMode == QGradient::StretchToDeviceMode | 0 |
550 | q->setPen(Qt::NoPen); never executed (the execution status of this line is deduced): q->setPen(Qt::NoPen); | - |
551 | changedPen = pen.style() != Qt::NoPen; never executed (the execution status of this line is deduced): changedPen = pen.style() != Qt::NoPen; | - |
552 | q->scale(sw, sh); never executed (the execution status of this line is deduced): q->scale(sw, sh); | - |
553 | updateState(state); never executed (the execution status of this line is deduced): updateState(state); | - |
554 | | - |
555 | const qreal isw = 1.0 / sw; never executed (the execution status of this line is deduced): const qreal isw = 1.0 / sw; | - |
556 | const qreal ish = 1.0 / sh; never executed (the execution status of this line is deduced): const qreal ish = 1.0 / sh; | - |
557 | QTransform inv(isw, 0, 0, ish, 0, 0); never executed (the execution status of this line is deduced): QTransform inv(isw, 0, 0, ish, 0, 0); | - |
558 | engine->drawPath(path * inv); never executed (the execution status of this line is deduced): engine->drawPath(path * inv); | - |
559 | q->scale(isw, ish); never executed (the execution status of this line is deduced): q->scale(isw, ish); | - |
560 | } else { | 0 |
561 | needsFill = true; never executed (the execution status of this line is deduced): needsFill = true; | - |
562 | | - |
563 | if (brushMode == QGradient::ObjectBoundingMode) { never evaluated: brushMode == QGradient::ObjectBoundingMode | 0 |
564 | Q_ASSERT(engine->hasFeature(QPaintEngine::PatternTransform)); never executed (the execution status of this line is deduced): qt_noop(); | - |
565 | boundingRect = path.boundingRect(); never executed (the execution status of this line is deduced): boundingRect = path.boundingRect(); | - |
566 | q->setBrush(stretchGradientToUserSpace(brush, boundingRect)); never executed (the execution status of this line is deduced): q->setBrush(stretchGradientToUserSpace(brush, boundingRect)); | - |
567 | changedBrush = true; never executed (the execution status of this line is deduced): changedBrush = true; | - |
568 | } | 0 |
569 | } | 0 |
570 | } | - |
571 | | - |
572 | if ((op & StrokeDraw) && pen.style() != Qt::NoPen) { never evaluated: (op & StrokeDraw) never evaluated: pen.style() != Qt::NoPen | 0 |
573 | // Draw the xformed outline if the pen is a stretch gradient. | - |
574 | if (penMode == QGradient::StretchToDeviceMode) { never evaluated: penMode == QGradient::StretchToDeviceMode | 0 |
575 | q->setPen(Qt::NoPen); never executed (the execution status of this line is deduced): q->setPen(Qt::NoPen); | - |
576 | changedPen = true; never executed (the execution status of this line is deduced): changedPen = true; | - |
577 | | - |
578 | if (needsFill) { never evaluated: needsFill | 0 |
579 | updateState(state); never executed (the execution status of this line is deduced): updateState(state); | - |
580 | engine->drawPath(path); never executed (the execution status of this line is deduced): engine->drawPath(path); | - |
581 | } | 0 |
582 | | - |
583 | q->scale(sw, sh); never executed (the execution status of this line is deduced): q->scale(sw, sh); | - |
584 | q->setBrush(pen.brush()); never executed (the execution status of this line is deduced): q->setBrush(pen.brush()); | - |
585 | changedBrush = true; never executed (the execution status of this line is deduced): changedBrush = true; | - |
586 | updateState(state); never executed (the execution status of this line is deduced): updateState(state); | - |
587 | | - |
588 | QPainterPathStroker stroker; never executed (the execution status of this line is deduced): QPainterPathStroker stroker; | - |
589 | stroker.setDashPattern(pen.style()); never executed (the execution status of this line is deduced): stroker.setDashPattern(pen.style()); | - |
590 | stroker.setWidth(pen.widthF()); never executed (the execution status of this line is deduced): stroker.setWidth(pen.widthF()); | - |
591 | stroker.setJoinStyle(pen.joinStyle()); never executed (the execution status of this line is deduced): stroker.setJoinStyle(pen.joinStyle()); | - |
592 | stroker.setCapStyle(pen.capStyle()); never executed (the execution status of this line is deduced): stroker.setCapStyle(pen.capStyle()); | - |
593 | stroker.setMiterLimit(pen.miterLimit()); never executed (the execution status of this line is deduced): stroker.setMiterLimit(pen.miterLimit()); | - |
594 | QPainterPath stroke = stroker.createStroke(path); never executed (the execution status of this line is deduced): QPainterPath stroke = stroker.createStroke(path); | - |
595 | | - |
596 | const qreal isw = 1.0 / sw; never executed (the execution status of this line is deduced): const qreal isw = 1.0 / sw; | - |
597 | const qreal ish = 1.0 / sh; never executed (the execution status of this line is deduced): const qreal ish = 1.0 / sh; | - |
598 | QTransform inv(isw, 0, 0, ish, 0, 0); never executed (the execution status of this line is deduced): QTransform inv(isw, 0, 0, ish, 0, 0); | - |
599 | engine->drawPath(stroke * inv); never executed (the execution status of this line is deduced): engine->drawPath(stroke * inv); | - |
600 | q->scale(isw, ish); never executed (the execution status of this line is deduced): q->scale(isw, ish); | - |
601 | } else { | 0 |
602 | if (!needsFill && brush.style() != Qt::NoBrush) { never evaluated: !needsFill never evaluated: brush.style() != Qt::NoBrush | 0 |
603 | q->setBrush(Qt::NoBrush); never executed (the execution status of this line is deduced): q->setBrush(Qt::NoBrush); | - |
604 | changedBrush = true; never executed (the execution status of this line is deduced): changedBrush = true; | - |
605 | } | 0 |
606 | | - |
607 | if (penMode == QGradient::ObjectBoundingMode) { never evaluated: penMode == QGradient::ObjectBoundingMode | 0 |
608 | Q_ASSERT(engine->hasFeature(QPaintEngine::PatternTransform)); never executed (the execution status of this line is deduced): qt_noop(); | - |
609 | | - |
610 | // avoid computing the bounding rect twice | - |
611 | if (!needsFill || brushMode != QGradient::ObjectBoundingMode) never evaluated: !needsFill never evaluated: brushMode != QGradient::ObjectBoundingMode | 0 |
612 | boundingRect = path.boundingRect(); never executed: boundingRect = path.boundingRect(); | 0 |
613 | | - |
614 | QPen p = pen; never executed (the execution status of this line is deduced): QPen p = pen; | - |
615 | p.setBrush(stretchGradientToUserSpace(pen.brush(), boundingRect)); never executed (the execution status of this line is deduced): p.setBrush(stretchGradientToUserSpace(pen.brush(), boundingRect)); | - |
616 | q->setPen(p); never executed (the execution status of this line is deduced): q->setPen(p); | - |
617 | changedPen = true; never executed (the execution status of this line is deduced): changedPen = true; | - |
618 | } else if (changedPen) { never executed: } never evaluated: changedPen | 0 |
619 | q->setPen(pen); never executed (the execution status of this line is deduced): q->setPen(pen); | - |
620 | changedPen = false; never executed (the execution status of this line is deduced): changedPen = false; | - |
621 | } | 0 |
622 | | - |
623 | updateState(state); never executed (the execution status of this line is deduced): updateState(state); | - |
624 | engine->drawPath(path); never executed (the execution status of this line is deduced): engine->drawPath(path); | - |
625 | } | 0 |
626 | } else if (needsFill) { never evaluated: needsFill | 0 |
627 | if (pen.style() != Qt::NoPen) { never evaluated: pen.style() != Qt::NoPen | 0 |
628 | q->setPen(Qt::NoPen); never executed (the execution status of this line is deduced): q->setPen(Qt::NoPen); | - |
629 | changedPen = true; never executed (the execution status of this line is deduced): changedPen = true; | - |
630 | } | 0 |
631 | | - |
632 | updateState(state); never executed (the execution status of this line is deduced): updateState(state); | - |
633 | engine->drawPath(path); never executed (the execution status of this line is deduced): engine->drawPath(path); | - |
634 | } | 0 |
635 | | - |
636 | if (changedPen) never evaluated: changedPen | 0 |
637 | q->setPen(pen); never executed: q->setPen(pen); | 0 |
638 | if (changedBrush) never evaluated: changedBrush | 0 |
639 | q->setBrush(brush); never executed: q->setBrush(brush); | 0 |
640 | } | 0 |
641 | | - |
642 | | - |
643 | void QPainterPrivate::updateMatrix() | - |
644 | { | - |
645 | state->matrix = state->WxF ? state->worldMatrix : QTransform(); evaluated: state->WxF yes Evaluation Count:42151 | yes Evaluation Count:15553 |
| 15553-42151 |
646 | if (state->VxF) evaluated: state->VxF yes Evaluation Count:13 | yes Evaluation Count:57691 |
| 13-57691 |
647 | state->matrix *= viewTransform(); executed: state->matrix *= viewTransform(); Execution Count:13 | 13 |
648 | | - |
649 | txinv = false; // no inverted matrix executed (the execution status of this line is deduced): txinv = false; | - |
650 | state->matrix *= state->redirectionMatrix; executed (the execution status of this line is deduced): state->matrix *= state->redirectionMatrix; | - |
651 | if (extended) evaluated: extended yes Evaluation Count:57703 | yes Evaluation Count:1 |
| 1-57703 |
652 | extended->transformChanged(); executed: extended->transformChanged(); Execution Count:57703 | 57703 |
653 | else | - |
654 | state->dirtyFlags |= QPaintEngine::DirtyTransform; executed: state->dirtyFlags |= QPaintEngine::DirtyTransform; Execution Count:1 | 1 |
655 | | - |
656 | state->matrix *= hidpiScaleTransform(); executed (the execution status of this line is deduced): state->matrix *= hidpiScaleTransform(); | - |
657 | | - |
658 | // printf("VxF=%d, WxF=%d\n", state->VxF, state->WxF); | - |
659 | // qDebug() << " --- using matrix" << state->matrix << redirection_offset; | - |
660 | } executed: } Execution Count:57704 | 57704 |
661 | | - |
662 | /*! \internal */ | - |
663 | void QPainterPrivate::updateInvMatrix() | - |
664 | { | - |
665 | Q_ASSERT(txinv == false); executed (the execution status of this line is deduced): qt_noop(); | - |
666 | txinv = true; // creating inverted matrix executed (the execution status of this line is deduced): txinv = true; | - |
667 | invMatrix = state->matrix.inverted(); executed (the execution status of this line is deduced): invMatrix = state->matrix.inverted(); | - |
668 | } executed: } Execution Count:2117 | 2117 |
669 | | - |
670 | extern bool qt_isExtendedRadialGradient(const QBrush &brush); | - |
671 | | - |
672 | void QPainterPrivate::updateEmulationSpecifier(QPainterState *s) | - |
673 | { | - |
674 | bool alpha = false; executed (the execution status of this line is deduced): bool alpha = false; | - |
675 | bool linearGradient = false; executed (the execution status of this line is deduced): bool linearGradient = false; | - |
676 | bool radialGradient = false; executed (the execution status of this line is deduced): bool radialGradient = false; | - |
677 | bool extendedRadialGradient = false; executed (the execution status of this line is deduced): bool extendedRadialGradient = false; | - |
678 | bool conicalGradient = false; executed (the execution status of this line is deduced): bool conicalGradient = false; | - |
679 | bool patternBrush = false; executed (the execution status of this line is deduced): bool patternBrush = false; | - |
680 | bool xform = false; executed (the execution status of this line is deduced): bool xform = false; | - |
681 | bool complexXform = false; executed (the execution status of this line is deduced): bool complexXform = false; | - |
682 | | - |
683 | bool skip = true; executed (the execution status of this line is deduced): bool skip = true; | - |
684 | | - |
685 | // Pen and brush properties (we have to check both if one changes because the | - |
686 | // one that's unchanged can still be in a state which requires emulation) | - |
687 | if (s->state() & (QPaintEngine::DirtyPen | QPaintEngine::DirtyBrush | QPaintEngine::DirtyHints)) { evaluated: s->state() & (QPaintEngine::DirtyPen | QPaintEngine::DirtyBrush | QPaintEngine::DirtyHints) yes Evaluation Count:18 | yes Evaluation Count:12 |
| 12-18 |
688 | // Check Brush stroke emulation | - |
689 | if (!s->pen.isSolid() && !engine->hasFeature(QPaintEngine::BrushStroke)) partially evaluated: !s->pen.isSolid() no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::BrushStroke) | 0-18 |
690 | s->emulationSpecifier |= QPaintEngine::BrushStroke; never executed: s->emulationSpecifier |= QPaintEngine::BrushStroke; | 0 |
691 | else | - |
692 | s->emulationSpecifier &= ~QPaintEngine::BrushStroke; executed: s->emulationSpecifier &= ~QPaintEngine::BrushStroke; Execution Count:18 | 18 |
693 | | - |
694 | skip = false; executed (the execution status of this line is deduced): skip = false; | - |
695 | | - |
696 | QBrush penBrush = (qpen_style(s->pen) == Qt::NoPen) ? QBrush(Qt::NoBrush) : qpen_brush(s->pen); evaluated: (qpen_style(s->pen) == Qt::NoPen) yes Evaluation Count:8 | yes Evaluation Count:10 |
| 8-10 |
697 | Qt::BrushStyle brushStyle = qbrush_style(s->brush); executed (the execution status of this line is deduced): Qt::BrushStyle brushStyle = qbrush_style(s->brush); | - |
698 | Qt::BrushStyle penBrushStyle = qbrush_style(penBrush); executed (the execution status of this line is deduced): Qt::BrushStyle penBrushStyle = qbrush_style(penBrush); | - |
699 | alpha = (penBrushStyle != Qt::NoBrush evaluated: penBrushStyle != Qt::NoBrush yes Evaluation Count:10 | yes Evaluation Count:8 |
| 8-10 |
700 | && (penBrushStyle < Qt::LinearGradientPattern && penBrush.color().alpha() != 255) partially evaluated: penBrushStyle < Qt::LinearGradientPattern yes Evaluation Count:10 | no Evaluation Count:0 |
partially evaluated: penBrush.color().alpha() != 255 no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
701 | && !penBrush.isOpaque()) never evaluated: !penBrush.isOpaque() | 0 |
702 | || (brushStyle != Qt::NoBrush evaluated: brushStyle != Qt::NoBrush yes Evaluation Count:8 | yes Evaluation Count:10 |
| 8-10 |
703 | && (brushStyle < Qt::LinearGradientPattern && s->brush.color().alpha() != 255) partially evaluated: brushStyle < Qt::LinearGradientPattern yes Evaluation Count:8 | no Evaluation Count:0 |
partially evaluated: s->brush.color().alpha() != 255 no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
704 | && !s->brush.isOpaque()); never evaluated: !s->brush.isOpaque() | 0 |
705 | linearGradient = ((penBrushStyle == Qt::LinearGradientPattern) || partially evaluated: (penBrushStyle == Qt::LinearGradientPattern) no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
706 | (brushStyle == Qt::LinearGradientPattern)); partially evaluated: (brushStyle == Qt::LinearGradientPattern) no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
707 | radialGradient = ((penBrushStyle == Qt::RadialGradientPattern) || partially evaluated: (penBrushStyle == Qt::RadialGradientPattern) no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
708 | (brushStyle == Qt::RadialGradientPattern)); partially evaluated: (brushStyle == Qt::RadialGradientPattern) no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
709 | extendedRadialGradient = radialGradient && (qt_isExtendedRadialGradient(penBrush) || qt_isExtendedRadialGradient(s->brush)); partially evaluated: radialGradient no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: qt_isExtendedRadialGradient(penBrush) never evaluated: qt_isExtendedRadialGradient(s->brush) | 0-18 |
710 | conicalGradient = ((penBrushStyle == Qt::ConicalGradientPattern) || partially evaluated: (penBrushStyle == Qt::ConicalGradientPattern) no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
711 | (brushStyle == Qt::ConicalGradientPattern)); partially evaluated: (brushStyle == Qt::ConicalGradientPattern) no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
712 | patternBrush = (((penBrushStyle > Qt::SolidPattern partially evaluated: penBrushStyle > Qt::SolidPattern no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
713 | && penBrushStyle < Qt::LinearGradientPattern) never evaluated: penBrushStyle < Qt::LinearGradientPattern | 0 |
714 | || penBrushStyle == Qt::TexturePattern) || partially evaluated: penBrushStyle == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
715 | ((brushStyle > Qt::SolidPattern partially evaluated: brushStyle > Qt::SolidPattern no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
716 | && brushStyle < Qt::LinearGradientPattern) never evaluated: brushStyle < Qt::LinearGradientPattern | 0 |
717 | || brushStyle == Qt::TexturePattern)); partially evaluated: brushStyle == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
718 | | - |
719 | bool penTextureAlpha = false; executed (the execution status of this line is deduced): bool penTextureAlpha = false; | - |
720 | if (penBrush.style() == Qt::TexturePattern) partially evaluated: penBrush.style() == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
721 | penTextureAlpha = qHasPixmapTexture(penBrush) never executed: penTextureAlpha = qHasPixmapTexture(penBrush) ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() : penBrush.textureImage().hasAlphaChannel(); never evaluated: qHasPixmapTexture(penBrush) | 0 |
722 | ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() never executed: penTextureAlpha = qHasPixmapTexture(penBrush) ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() : penBrush.textureImage().hasAlphaChannel(); | 0 |
723 | : penBrush.textureImage().hasAlphaChannel(); never executed: penTextureAlpha = qHasPixmapTexture(penBrush) ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() : penBrush.textureImage().hasAlphaChannel(); | 0 |
724 | bool brushTextureAlpha = false; executed (the execution status of this line is deduced): bool brushTextureAlpha = false; | - |
725 | if (s->brush.style() == Qt::TexturePattern) { partially evaluated: s->brush.style() == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
726 | brushTextureAlpha = qHasPixmapTexture(s->brush) never evaluated: qHasPixmapTexture(s->brush) | 0 |
727 | ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha() never executed (the execution status of this line is deduced): ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha() | - |
728 | : s->brush.textureImage().hasAlphaChannel(); never executed (the execution status of this line is deduced): : s->brush.textureImage().hasAlphaChannel(); | - |
729 | } | 0 |
730 | if (((penBrush.style() == Qt::TexturePattern && penTextureAlpha) partially evaluated: penBrush.style() == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: penTextureAlpha | 0-18 |
731 | || (s->brush.style() == Qt::TexturePattern && brushTextureAlpha)) partially evaluated: s->brush.style() == Qt::TexturePattern no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: brushTextureAlpha | 0-18 |
732 | && !engine->hasFeature(QPaintEngine::MaskedBrush)) never evaluated: !engine->hasFeature(QPaintEngine::MaskedBrush) | 0 |
733 | s->emulationSpecifier |= QPaintEngine::MaskedBrush; never executed: s->emulationSpecifier |= QPaintEngine::MaskedBrush; | 0 |
734 | else | - |
735 | s->emulationSpecifier &= ~QPaintEngine::MaskedBrush; executed: s->emulationSpecifier &= ~QPaintEngine::MaskedBrush; Execution Count:18 | 18 |
736 | } | - |
737 | | - |
738 | if (s->state() & (QPaintEngine::DirtyHints partially evaluated: s->state() & (QPaintEngine::DirtyHints | QPaintEngine::DirtyOpacity | QPaintEngine::DirtyBackgroundMode) no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
739 | | QPaintEngine::DirtyOpacity partially evaluated: s->state() & (QPaintEngine::DirtyHints | QPaintEngine::DirtyOpacity | QPaintEngine::DirtyBackgroundMode) no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
740 | | QPaintEngine::DirtyBackgroundMode)) { partially evaluated: s->state() & (QPaintEngine::DirtyHints | QPaintEngine::DirtyOpacity | QPaintEngine::DirtyBackgroundMode) no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
741 | skip = false; never executed (the execution status of this line is deduced): skip = false; | - |
742 | } | 0 |
743 | | - |
744 | if (skip) evaluated: skip yes Evaluation Count:12 | yes Evaluation Count:18 |
| 12-18 |
745 | return; executed: return; Execution Count:12 | 12 |
746 | | - |
747 | #if 0 | - |
748 | qDebug("QPainterPrivate::updateEmulationSpecifier, state=%p\n" | - |
749 | " - alpha: %d\n" | - |
750 | " - linearGradient: %d\n" | - |
751 | " - radialGradient: %d\n" | - |
752 | " - conicalGradient: %d\n" | - |
753 | " - patternBrush: %d\n" | - |
754 | " - hints: %x\n" | - |
755 | " - xform: %d\n", | - |
756 | s, | - |
757 | alpha, | - |
758 | linearGradient, | - |
759 | radialGradient, | - |
760 | conicalGradient, | - |
761 | patternBrush, | - |
762 | uint(s->renderHints), | - |
763 | xform); | - |
764 | #endif | - |
765 | | - |
766 | // XForm properties | - |
767 | if (s->state() & QPaintEngine::DirtyTransform) { partially evaluated: s->state() & QPaintEngine::DirtyTransform no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
768 | xform = !s->matrix.isIdentity(); never executed (the execution status of this line is deduced): xform = !s->matrix.isIdentity(); | - |
769 | complexXform = !s->matrix.isAffine(); never executed (the execution status of this line is deduced): complexXform = !s->matrix.isAffine(); | - |
770 | } else if (s->matrix.type() >= QTransform::TxTranslate) { never executed: } partially evaluated: s->matrix.type() >= QTransform::TxTranslate no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
771 | xform = true; never executed (the execution status of this line is deduced): xform = true; | - |
772 | complexXform = !s->matrix.isAffine(); never executed (the execution status of this line is deduced): complexXform = !s->matrix.isAffine(); | - |
773 | } | 0 |
774 | | - |
775 | const bool brushXform = (!s->brush.transform().type() == QTransform::TxNone); executed (the execution status of this line is deduced): const bool brushXform = (!s->brush.transform().type() == QTransform::TxNone); | - |
776 | const bool penXform = (!s->pen.brush().transform().type() == QTransform::TxNone); executed (the execution status of this line is deduced): const bool penXform = (!s->pen.brush().transform().type() == QTransform::TxNone); | - |
777 | | - |
778 | const bool patternXform = patternBrush && (xform || brushXform || penXform); partially evaluated: patternBrush no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: xform never evaluated: brushXform never evaluated: penXform | 0-18 |
779 | | - |
780 | // Check alphablending | - |
781 | if (alpha && !engine->hasFeature(QPaintEngine::AlphaBlend)) partially evaluated: alpha no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::AlphaBlend) | 0-18 |
782 | s->emulationSpecifier |= QPaintEngine::AlphaBlend; never executed: s->emulationSpecifier |= QPaintEngine::AlphaBlend; | 0 |
783 | else | - |
784 | s->emulationSpecifier &= ~QPaintEngine::AlphaBlend; executed: s->emulationSpecifier &= ~QPaintEngine::AlphaBlend; Execution Count:18 | 18 |
785 | | - |
786 | // Linear gradient emulation | - |
787 | if (linearGradient && !engine->hasFeature(QPaintEngine::LinearGradientFill)) partially evaluated: linearGradient no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::LinearGradientFill) | 0-18 |
788 | s->emulationSpecifier |= QPaintEngine::LinearGradientFill; never executed: s->emulationSpecifier |= QPaintEngine::LinearGradientFill; | 0 |
789 | else | - |
790 | s->emulationSpecifier &= ~QPaintEngine::LinearGradientFill; executed: s->emulationSpecifier &= ~QPaintEngine::LinearGradientFill; Execution Count:18 | 18 |
791 | | - |
792 | // Radial gradient emulation | - |
793 | if (extendedRadialGradient || (radialGradient && !engine->hasFeature(QPaintEngine::RadialGradientFill))) partially evaluated: extendedRadialGradient no Evaluation Count:0 | yes Evaluation Count:18 |
partially evaluated: radialGradient no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::RadialGradientFill) | 0-18 |
794 | s->emulationSpecifier |= QPaintEngine::RadialGradientFill; never executed: s->emulationSpecifier |= QPaintEngine::RadialGradientFill; | 0 |
795 | else | - |
796 | s->emulationSpecifier &= ~QPaintEngine::RadialGradientFill; executed: s->emulationSpecifier &= ~QPaintEngine::RadialGradientFill; Execution Count:18 | 18 |
797 | | - |
798 | // Conical gradient emulation | - |
799 | if (conicalGradient && !engine->hasFeature(QPaintEngine::ConicalGradientFill)) partially evaluated: conicalGradient no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::ConicalGradientFill) | 0-18 |
800 | s->emulationSpecifier |= QPaintEngine::ConicalGradientFill; never executed: s->emulationSpecifier |= QPaintEngine::ConicalGradientFill; | 0 |
801 | else | - |
802 | s->emulationSpecifier &= ~QPaintEngine::ConicalGradientFill; executed: s->emulationSpecifier &= ~QPaintEngine::ConicalGradientFill; Execution Count:18 | 18 |
803 | | - |
804 | // Pattern brushes | - |
805 | if (patternBrush && !engine->hasFeature(QPaintEngine::PatternBrush)) partially evaluated: patternBrush no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::PatternBrush) | 0-18 |
806 | s->emulationSpecifier |= QPaintEngine::PatternBrush; never executed: s->emulationSpecifier |= QPaintEngine::PatternBrush; | 0 |
807 | else | - |
808 | s->emulationSpecifier &= ~QPaintEngine::PatternBrush; executed: s->emulationSpecifier &= ~QPaintEngine::PatternBrush; Execution Count:18 | 18 |
809 | | - |
810 | // Pattern XForms | - |
811 | if (patternXform && !engine->hasFeature(QPaintEngine::PatternTransform)) partially evaluated: patternXform no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::PatternTransform) | 0-18 |
812 | s->emulationSpecifier |= QPaintEngine::PatternTransform; never executed: s->emulationSpecifier |= QPaintEngine::PatternTransform; | 0 |
813 | else | - |
814 | s->emulationSpecifier &= ~QPaintEngine::PatternTransform; executed: s->emulationSpecifier &= ~QPaintEngine::PatternTransform; Execution Count:18 | 18 |
815 | | - |
816 | // Primitive XForms | - |
817 | if (xform && !engine->hasFeature(QPaintEngine::PrimitiveTransform)) partially evaluated: xform no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::PrimitiveTransform) | 0-18 |
818 | s->emulationSpecifier |= QPaintEngine::PrimitiveTransform; never executed: s->emulationSpecifier |= QPaintEngine::PrimitiveTransform; | 0 |
819 | else | - |
820 | s->emulationSpecifier &= ~QPaintEngine::PrimitiveTransform; executed: s->emulationSpecifier &= ~QPaintEngine::PrimitiveTransform; Execution Count:18 | 18 |
821 | | - |
822 | // Perspective XForms | - |
823 | if (complexXform && !engine->hasFeature(QPaintEngine::PerspectiveTransform)) partially evaluated: complexXform no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::PerspectiveTransform) | 0-18 |
824 | s->emulationSpecifier |= QPaintEngine::PerspectiveTransform; never executed: s->emulationSpecifier |= QPaintEngine::PerspectiveTransform; | 0 |
825 | else | - |
826 | s->emulationSpecifier &= ~QPaintEngine::PerspectiveTransform; executed: s->emulationSpecifier &= ~QPaintEngine::PerspectiveTransform; Execution Count:18 | 18 |
827 | | - |
828 | // Constant opacity | - |
829 | if (state->opacity != 1 && !engine->hasFeature(QPaintEngine::ConstantOpacity)) partially evaluated: state->opacity != 1 no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::ConstantOpacity) | 0-18 |
830 | s->emulationSpecifier |= QPaintEngine::ConstantOpacity; never executed: s->emulationSpecifier |= QPaintEngine::ConstantOpacity; | 0 |
831 | else | - |
832 | s->emulationSpecifier &= ~QPaintEngine::ConstantOpacity; executed: s->emulationSpecifier &= ~QPaintEngine::ConstantOpacity; Execution Count:18 | 18 |
833 | | - |
834 | bool gradientStretch = false; executed (the execution status of this line is deduced): bool gradientStretch = false; | - |
835 | bool objectBoundingMode = false; executed (the execution status of this line is deduced): bool objectBoundingMode = false; | - |
836 | if (linearGradient || conicalGradient || radialGradient) { partially evaluated: linearGradient no Evaluation Count:0 | yes Evaluation Count:18 |
partially evaluated: conicalGradient no Evaluation Count:0 | yes Evaluation Count:18 |
partially evaluated: radialGradient no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
837 | QGradient::CoordinateMode brushMode = coordinateMode(s->brush); never executed (the execution status of this line is deduced): QGradient::CoordinateMode brushMode = coordinateMode(s->brush); | - |
838 | QGradient::CoordinateMode penMode = coordinateMode(s->pen.brush()); never executed (the execution status of this line is deduced): QGradient::CoordinateMode penMode = coordinateMode(s->pen.brush()); | - |
839 | | - |
840 | gradientStretch |= (brushMode == QGradient::StretchToDeviceMode); never executed (the execution status of this line is deduced): gradientStretch |= (brushMode == QGradient::StretchToDeviceMode); | - |
841 | gradientStretch |= (penMode == QGradient::StretchToDeviceMode); never executed (the execution status of this line is deduced): gradientStretch |= (penMode == QGradient::StretchToDeviceMode); | - |
842 | | - |
843 | objectBoundingMode |= (brushMode == QGradient::ObjectBoundingMode); never executed (the execution status of this line is deduced): objectBoundingMode |= (brushMode == QGradient::ObjectBoundingMode); | - |
844 | objectBoundingMode |= (penMode == QGradient::ObjectBoundingMode); never executed (the execution status of this line is deduced): objectBoundingMode |= (penMode == QGradient::ObjectBoundingMode); | - |
845 | } | 0 |
846 | if (gradientStretch) partially evaluated: gradientStretch no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
847 | s->emulationSpecifier |= QGradient_StretchToDevice; never executed: s->emulationSpecifier |= 0x10000000; | 0 |
848 | else | - |
849 | s->emulationSpecifier &= ~QGradient_StretchToDevice; executed: s->emulationSpecifier &= ~0x10000000; Execution Count:18 | 18 |
850 | | - |
851 | if (objectBoundingMode && !engine->hasFeature(QPaintEngine::ObjectBoundingModeGradients)) partially evaluated: objectBoundingMode no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: !engine->hasFeature(QPaintEngine::ObjectBoundingModeGradients) | 0-18 |
852 | s->emulationSpecifier |= QPaintEngine::ObjectBoundingModeGradients; never executed: s->emulationSpecifier |= QPaintEngine::ObjectBoundingModeGradients; | 0 |
853 | else | - |
854 | s->emulationSpecifier &= ~QPaintEngine::ObjectBoundingModeGradients; executed: s->emulationSpecifier &= ~QPaintEngine::ObjectBoundingModeGradients; Execution Count:18 | 18 |
855 | | - |
856 | // Opaque backgrounds... | - |
857 | if (s->bgMode == Qt::OpaqueMode && partially evaluated: s->bgMode == Qt::OpaqueMode no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
858 | (is_pen_transparent(s->pen) || is_brush_transparent(s->brush))) never evaluated: is_pen_transparent(s->pen) never evaluated: is_brush_transparent(s->brush) | 0 |
859 | s->emulationSpecifier |= QPaintEngine_OpaqueBackground; never executed: s->emulationSpecifier |= 0x40000000; | 0 |
860 | else | - |
861 | s->emulationSpecifier &= ~QPaintEngine_OpaqueBackground; executed: s->emulationSpecifier &= ~0x40000000; Execution Count:18 | 18 |
862 | | - |
863 | #if 0 | - |
864 | //won't be correct either way because the device can already have | - |
865 | // something rendered to it in which case subsequent emulation | - |
866 | // on a fully transparent qimage and then blitting the results | - |
867 | // won't produce correct results | - |
868 | // Blend modes | - |
869 | if (state->composition_mode > QPainter::CompositionMode_Xor && | - |
870 | !engine->hasFeature(QPaintEngine::BlendModes)) | - |
871 | s->emulationSpecifier |= QPaintEngine::BlendModes; | - |
872 | else | - |
873 | s->emulationSpecifier &= ~QPaintEngine::BlendModes; | - |
874 | #endif | - |
875 | } | - |
876 | | - |
877 | void QPainterPrivate::updateStateImpl(QPainterState *newState) | - |
878 | { | - |
879 | // ### we might have to call QPainter::begin() here... | - |
880 | if (!engine->state) { partially evaluated: !engine->state no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
881 | engine->state = newState; never executed (the execution status of this line is deduced): engine->state = newState; | - |
882 | engine->setDirty(QPaintEngine::AllDirty); never executed (the execution status of this line is deduced): engine->setDirty(QPaintEngine::AllDirty); | - |
883 | } | 0 |
884 | | - |
885 | if (engine->state->painter() != newState->painter) partially evaluated: engine->state->painter() != newState->painter no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
886 | // ### this could break with clip regions vs paths. | - |
887 | engine->setDirty(QPaintEngine::AllDirty); never executed: engine->setDirty(QPaintEngine::AllDirty); | 0 |
888 | | - |
889 | // Upon restore, revert all changes since last save | - |
890 | else if (engine->state != newState) evaluated: engine->state != newState yes Evaluation Count:9 | yes Evaluation Count:21 |
| 9-21 |
891 | newState->dirtyFlags |= QPaintEngine::DirtyFlags(static_cast<QPainterState *>(engine->state)->changeFlags); executed: newState->dirtyFlags |= QPaintEngine::DirtyFlags(static_cast<QPainterState *>(engine->state)->changeFlags); Execution Count:9 | 9 |
892 | | - |
893 | // We need to store all changes made so that restore can deal with them | - |
894 | else | - |
895 | newState->changeFlags |= newState->dirtyFlags; executed: newState->changeFlags |= newState->dirtyFlags; Execution Count:21 | 21 |
896 | | - |
897 | updateEmulationSpecifier(newState); executed (the execution status of this line is deduced): updateEmulationSpecifier(newState); | - |
898 | | - |
899 | // Unset potential dirty background mode | - |
900 | newState->dirtyFlags &= ~(QPaintEngine::DirtyBackgroundMode executed (the execution status of this line is deduced): newState->dirtyFlags &= ~(QPaintEngine::DirtyBackgroundMode | - |
901 | | QPaintEngine::DirtyBackground); executed (the execution status of this line is deduced): | QPaintEngine::DirtyBackground); | - |
902 | | - |
903 | engine->state = newState; executed (the execution status of this line is deduced): engine->state = newState; | - |
904 | engine->updateState(*newState); executed (the execution status of this line is deduced): engine->updateState(*newState); | - |
905 | engine->clearDirty(QPaintEngine::AllDirty); executed (the execution status of this line is deduced): engine->clearDirty(QPaintEngine::AllDirty); | - |
906 | | - |
907 | } executed: } Execution Count:30 | 30 |
908 | | - |
909 | void QPainterPrivate::updateState(QPainterState *newState) | - |
910 | { | - |
911 | | - |
912 | if (!newState) { evaluated: !newState yes Evaluation Count:28773 | yes Evaluation Count:57 |
| 57-28773 |
913 | engine->state = newState; executed (the execution status of this line is deduced): engine->state = newState; | - |
914 | } else if (newState->state() || engine->state!=newState) { executed: } Execution Count:28773 evaluated: newState->state() yes Evaluation Count:21 | yes Evaluation Count:36 |
evaluated: engine->state!=newState yes Evaluation Count:9 | yes Evaluation Count:27 |
| 9-28773 |
915 | updateStateImpl(newState); executed (the execution status of this line is deduced): updateStateImpl(newState); | - |
916 | } executed: } Execution Count:30 | 30 |
917 | } | - |
918 | | - |
919 | | - |
920 | /*! | - |
921 | \class QPainter | - |
922 | \brief The QPainter class performs low-level painting on widgets and | - |
923 | other paint devices. | - |
924 | | - |
925 | \inmodule QtGui | - |
926 | \ingroup painting | - |
927 | | - |
928 | \reentrant | - |
929 | | - |
930 | QPainter provides highly optimized functions to do most of the | - |
931 | drawing GUI programs require. It can draw everything from simple | - |
932 | lines to complex shapes like pies and chords. It can also draw | - |
933 | aligned text and pixmaps. Normally, it draws in a "natural" | - |
934 | coordinate system, but it can also do view and world | - |
935 | transformation. QPainter can operate on any object that inherits | - |
936 | the QPaintDevice class. | - |
937 | | - |
938 | The common use of QPainter is inside a widget's paint event: | - |
939 | Construct and customize (e.g. set the pen or the brush) the | - |
940 | painter. Then draw. Remember to destroy the QPainter object after | - |
941 | drawing. For example: | - |
942 | | - |
943 | \snippet code/src_gui_painting_qpainter.cpp 0 | - |
944 | | - |
945 | The core functionality of QPainter is drawing, but the class also | - |
946 | provide several functions that allows you to customize QPainter's | - |
947 | settings and its rendering quality, and others that enable | - |
948 | clipping. In addition you can control how different shapes are | - |
949 | merged together by specifying the painter's composition mode. | - |
950 | | - |
951 | The isActive() function indicates whether the painter is active. A | - |
952 | painter is activated by the begin() function and the constructor | - |
953 | that takes a QPaintDevice argument. The end() function, and the | - |
954 | destructor, deactivates it. | - |
955 | | - |
956 | Together with the QPaintDevice and QPaintEngine classes, QPainter | - |
957 | form the basis for Qt's paint system. QPainter is the class used | - |
958 | to perform drawing operations. QPaintDevice represents a device | - |
959 | that can be painted on using a QPainter. QPaintEngine provides the | - |
960 | interface that the painter uses to draw onto different types of | - |
961 | devices. If the painter is active, device() returns the paint | - |
962 | device on which the painter paints, and paintEngine() returns the | - |
963 | paint engine that the painter is currently operating on. For more | - |
964 | information, see the \l {Paint System}. | - |
965 | | - |
966 | Sometimes it is desirable to make someone else paint on an unusual | - |
967 | QPaintDevice. QPainter supports a static function to do this, | - |
968 | setRedirected(). | - |
969 | | - |
970 | \warning When the paintdevice is a widget, QPainter can only be | - |
971 | used inside a paintEvent() function or in a function called by | - |
972 | paintEvent(). | - |
973 | | - |
974 | \tableofcontents | - |
975 | | - |
976 | \section1 Settings | - |
977 | | - |
978 | There are several settings that you can customize to make QPainter | - |
979 | draw according to your preferences: | - |
980 | | - |
981 | \list | - |
982 | | - |
983 | \li font() is the font used for drawing text. If the painter | - |
984 | isActive(), you can retrieve information about the currently set | - |
985 | font, and its metrics, using the fontInfo() and fontMetrics() | - |
986 | functions respectively. | - |
987 | | - |
988 | \li brush() defines the color or pattern that is used for filling | - |
989 | shapes. | - |
990 | | - |
991 | \li pen() defines the color or stipple that is used for drawing | - |
992 | lines or boundaries. | - |
993 | | - |
994 | \li backgroundMode() defines whether there is a background() or | - |
995 | not, i.e it is either Qt::OpaqueMode or Qt::TransparentMode. | - |
996 | | - |
997 | \li background() only applies when backgroundMode() is \l | - |
998 | Qt::OpaqueMode and pen() is a stipple. In that case, it | - |
999 | describes the color of the background pixels in the stipple. | - |
1000 | | - |
1001 | \li brushOrigin() defines the origin of the tiled brushes, normally | - |
1002 | the origin of widget's background. | - |
1003 | | - |
1004 | \li viewport(), window(), worldTransform() make up the painter's coordinate | - |
1005 | transformation system. For more information, see the \l | - |
1006 | {Coordinate Transformations} section and the \l {Coordinate | - |
1007 | System} documentation. | - |
1008 | | - |
1009 | \li hasClipping() tells whether the painter clips at all. (The paint | - |
1010 | device clips, too.) If the painter clips, it clips to clipRegion(). | - |
1011 | | - |
1012 | \li layoutDirection() defines the layout direction used by the | - |
1013 | painter when drawing text. | - |
1014 | | - |
1015 | \li worldMatrixEnabled() tells whether world transformation is enabled. | - |
1016 | | - |
1017 | \li viewTransformEnabled() tells whether view transformation is | - |
1018 | enabled. | - |
1019 | | - |
1020 | \endlist | - |
1021 | | - |
1022 | Note that some of these settings mirror settings in some paint | - |
1023 | devices, e.g. QWidget::font(). The QPainter::begin() function (or | - |
1024 | equivalently the QPainter constructor) copies these attributes | - |
1025 | from the paint device. | - |
1026 | | - |
1027 | You can at any time save the QPainter's state by calling the | - |
1028 | save() function which saves all the available settings on an | - |
1029 | internal stack. The restore() function pops them back. | - |
1030 | | - |
1031 | \section1 Drawing | - |
1032 | | - |
1033 | QPainter provides functions to draw most primitives: drawPoint(), | - |
1034 | drawPoints(), drawLine(), drawRect(), drawRoundedRect(), | - |
1035 | drawEllipse(), drawArc(), drawPie(), drawChord(), drawPolyline(), | - |
1036 | drawPolygon(), drawConvexPolygon() and drawCubicBezier(). The two | - |
1037 | convenience functions, drawRects() and drawLines(), draw the given | - |
1038 | number of rectangles or lines in the given array of \l | - |
1039 | {QRect}{QRects} or \l {QLine}{QLines} using the current pen and | - |
1040 | brush. | - |
1041 | | - |
1042 | The QPainter class also provides the fillRect() function which | - |
1043 | fills the given QRect, with the given QBrush, and the eraseRect() | - |
1044 | function that erases the area inside the given rectangle. | - |
1045 | | - |
1046 | All of these functions have both integer and floating point | - |
1047 | versions. | - |
1048 | | - |
1049 | \table 100% | - |
1050 | \row | - |
1051 | \li \inlineimage qpainter-basicdrawing.png | - |
1052 | \li | - |
1053 | \b {Basic Drawing Example} | - |
1054 | | - |
1055 | The \l {painting/basicdrawing}{Basic Drawing} example shows how to | - |
1056 | display basic graphics primitives in a variety of styles using the | - |
1057 | QPainter class. | - |
1058 | | - |
1059 | \endtable | - |
1060 | | - |
1061 | If you need to draw a complex shape, especially if you need to do | - |
1062 | so repeatedly, consider creating a QPainterPath and drawing it | - |
1063 | using drawPath(). | - |
1064 | | - |
1065 | \table 100% | - |
1066 | \row | - |
1067 | \li | - |
1068 | \b {Painter Paths example} | - |
1069 | | - |
1070 | The QPainterPath class provides a container for painting | - |
1071 | operations, enabling graphical shapes to be constructed and | - |
1072 | reused. | - |
1073 | | - |
1074 | The \l {painting/painterpaths}{Painter Paths} example shows how | - |
1075 | painter paths can be used to build complex shapes for rendering. | - |
1076 | | - |
1077 | \li \inlineimage qpainter-painterpaths.png | - |
1078 | \endtable | - |
1079 | | - |
1080 | QPainter also provides the fillPath() function which fills the | - |
1081 | given QPainterPath with the given QBrush, and the strokePath() | - |
1082 | function that draws the outline of the given path (i.e. strokes | - |
1083 | the path). | - |
1084 | | - |
1085 | See also the \l {painting/deform}{Vector Deformation} example which | - |
1086 | shows how to use advanced vector techniques to draw text using a | - |
1087 | QPainterPath, the \l {painting/gradients}{Gradients} example which shows | - |
1088 | the different types of gradients that are available in Qt, and the \l | - |
1089 | {painting/pathstroke}{Path Stroking} example which shows Qt's built-in | - |
1090 | dash patterns and shows how custom patterns can be used to extend | - |
1091 | the range of available patterns. | - |
1092 | | - |
1093 | \table | - |
1094 | \header | - |
1095 | \li \l {painting/deform}{Vector Deformation} | - |
1096 | \li \l {painting/gradients}{Gradients} | - |
1097 | \li \l {painting/pathstroke}{Path Stroking} | - |
1098 | \row | - |
1099 | \li \inlineimage qpainter-vectordeformation.png | - |
1100 | \li \inlineimage qpainter-gradients.png | - |
1101 | \li \inlineimage qpainter-pathstroking.png | - |
1102 | \endtable | - |
1103 | | - |
1104 | | - |
1105 | There are functions to draw pixmaps/images, namely drawPixmap(), | - |
1106 | drawImage() and drawTiledPixmap(). Both drawPixmap() and drawImage() | - |
1107 | produce the same result, except that drawPixmap() is faster | - |
1108 | on-screen while drawImage() may be faster on a QPrinter or other | - |
1109 | devices. | - |
1110 | | - |
1111 | Text drawing is done using drawText(). When you need | - |
1112 | fine-grained positioning, boundingRect() tells you where a given | - |
1113 | drawText() command will draw. | - |
1114 | | - |
1115 | There is a drawPicture() function that draws the contents of an | - |
1116 | entire QPicture. The drawPicture() function is the only function | - |
1117 | that disregards all the painter's settings as QPicture has its own | - |
1118 | settings. | - |
1119 | | - |
1120 | \section1 Rendering Quality | - |
1121 | | - |
1122 | To get the optimal rendering result using QPainter, you should use | - |
1123 | the platform independent QImage as paint device; i.e. using QImage | - |
1124 | will ensure that the result has an identical pixel representation | - |
1125 | on any platform. | - |
1126 | | - |
1127 | The QPainter class also provides a means of controlling the | - |
1128 | rendering quality through its RenderHint enum and the support for | - |
1129 | floating point precision: All the functions for drawing primitives | - |
1130 | has a floating point version. These are often used in combination | - |
1131 | with the \l {RenderHint}{QPainter::Antialiasing} render hint. | - |
1132 | | - |
1133 | \table 100% | - |
1134 | \row | - |
1135 | \li \inlineimage qpainter-concentriccircles.png | - |
1136 | \li | - |
1137 | \b {Concentric Circles Example} | - |
1138 | | - |
1139 | The \l {painting/concentriccircles}{Concentric Circles} example | - |
1140 | shows the improved rendering quality that can be obtained using | - |
1141 | floating point precision and anti-aliasing when drawing custom | - |
1142 | widgets. | - |
1143 | | - |
1144 | The application's main window displays several widgets which are | - |
1145 | drawn using the various combinations of precision and | - |
1146 | anti-aliasing. | - |
1147 | | - |
1148 | \endtable | - |
1149 | | - |
1150 | The RenderHint enum specifies flags to QPainter that may or may | - |
1151 | not be respected by any given engine. \l | - |
1152 | {RenderHint}{QPainter::Antialiasing} indicates that the engine | - |
1153 | should antialias edges of primitives if possible, \l | - |
1154 | {RenderHint}{QPainter::TextAntialiasing} indicates that the engine | - |
1155 | should antialias text if possible, and the \l | - |
1156 | {RenderHint}{QPainter::SmoothPixmapTransform} indicates that the | - |
1157 | engine should use a smooth pixmap transformation algorithm. | - |
1158 | \l {RenderHint}{HighQualityAntialiasing} is an OpenGL-specific rendering hint | - |
1159 | indicating that the engine should use fragment programs and offscreen | - |
1160 | rendering for antialiasing. | - |
1161 | | - |
1162 | The renderHints() function returns a flag that specifies the | - |
1163 | rendering hints that are set for this painter. Use the | - |
1164 | setRenderHint() function to set or clear the currently set | - |
1165 | RenderHints. | - |
1166 | | - |
1167 | \section1 Coordinate Transformations | - |
1168 | | - |
1169 | Normally, the QPainter operates on the device's own coordinate | - |
1170 | system (usually pixels), but QPainter has good support for | - |
1171 | coordinate transformations. | - |
1172 | | - |
1173 | \table | - |
1174 | \header | - |
1175 | \li nop \li rotate() \li scale() \li translate() | - |
1176 | \row | - |
1177 | \li \inlineimage qpainter-clock.png | - |
1178 | \li \inlineimage qpainter-rotation.png | - |
1179 | \li \inlineimage qpainter-scale.png | - |
1180 | \li \inlineimage qpainter-translation.png | - |
1181 | \endtable | - |
1182 | | - |
1183 | The most commonly used transformations are scaling, rotation, | - |
1184 | translation and shearing. Use the scale() function to scale the | - |
1185 | coordinate system by a given offset, the rotate() function to | - |
1186 | rotate it clockwise and translate() to translate it (i.e. adding a | - |
1187 | given offset to the points). You can also twist the coordinate | - |
1188 | system around the origin using the shear() function. See the \l | - |
1189 | {painting/affine}{Affine Transformations} example for a visualization of | - |
1190 | a sheared coordinate system. | - |
1191 | | - |
1192 | See also the \l {painting/transformations}{Transformations} | - |
1193 | example which shows how transformations influence the way that | - |
1194 | QPainter renders graphics primitives. In particular it shows how | - |
1195 | the order of transformations affects the result. | - |
1196 | | - |
1197 | \table 100% | - |
1198 | \row | - |
1199 | \li | - |
1200 | \b {Affine Transformations Example} | - |
1201 | | - |
1202 | The \l {painting/affine}{Affine Transformations} example shows Qt's | - |
1203 | ability to perform affine transformations on painting | - |
1204 | operations. The demo also allows the user to experiment with the | - |
1205 | transformation operations and see the results immediately. | - |
1206 | | - |
1207 | \li \inlineimage qpainter-affinetransformations.png | - |
1208 | \endtable | - |
1209 | | - |
1210 | All the tranformation operations operate on the transformation | - |
1211 | worldTransform(). A matrix transforms a point in the plane to another | - |
1212 | point. For more information about the transformation matrix, see | - |
1213 | the \l {Coordinate System} and QTransform documentation. | - |
1214 | | - |
1215 | The setWorldTransform() function can replace or add to the currently | - |
1216 | set worldTransform(). The resetTransform() function resets any | - |
1217 | transformations that were made using translate(), scale(), | - |
1218 | shear(), rotate(), setWorldTransform(), setViewport() and setWindow() | - |
1219 | functions. The deviceTransform() returns the matrix that transforms | - |
1220 | from logical coordinates to device coordinates of the platform | - |
1221 | dependent paint device. The latter function is only needed when | - |
1222 | using platform painting commands on the platform dependent handle, | - |
1223 | and the platform does not do transformations nativly. | - |
1224 | | - |
1225 | When drawing with QPainter, we specify points using logical | - |
1226 | coordinates which then are converted into the physical coordinates | - |
1227 | of the paint device. The mapping of the logical coordinates to the | - |
1228 | physical coordinates are handled by QPainter's combinedTransform(), a | - |
1229 | combination of viewport() and window() and worldTransform(). The | - |
1230 | viewport() represents the physical coordinates specifying an | - |
1231 | arbitrary rectangle, the window() describes the same rectangle in | - |
1232 | logical coordinates, and the worldTransform() is identical with the | - |
1233 | transformation matrix. | - |
1234 | | - |
1235 | See also \l {Coordinate System} | - |
1236 | | - |
1237 | \section1 Clipping | - |
1238 | | - |
1239 | QPainter can clip any drawing operation to a rectangle, a region, | - |
1240 | or a vector path. The current clip is available using the | - |
1241 | functions clipRegion() and clipPath(). Whether paths or regions are | - |
1242 | preferred (faster) depends on the underlying paintEngine(). For | - |
1243 | example, the QImage paint engine prefers paths while the X11 paint | - |
1244 | engine prefers regions. Setting a clip is done in the painters | - |
1245 | logical coordinates. | - |
1246 | | - |
1247 | After QPainter's clipping, the paint device may also clip. For | - |
1248 | example, most widgets clip away the pixels used by child widgets, | - |
1249 | and most printers clip away an area near the edges of the paper. | - |
1250 | This additional clipping is not reflected by the return value of | - |
1251 | clipRegion() or hasClipping(). | - |
1252 | | - |
1253 | \section1 Composition Modes | - |
1254 | \target Composition Modes | - |
1255 | | - |
1256 | QPainter provides the CompositionMode enum which defines the | - |
1257 | Porter-Duff rules for digital image compositing; it describes a | - |
1258 | model for combining the pixels in one image, the source, with the | - |
1259 | pixels in another image, the destination. | - |
1260 | | - |
1261 | The two most common forms of composition are \l | - |
1262 | {QPainter::CompositionMode}{Source} and \l | - |
1263 | {QPainter::CompositionMode}{SourceOver}. \l | - |
1264 | {QPainter::CompositionMode}{Source} is used to draw opaque objects | - |
1265 | onto a paint device. In this mode, each pixel in the source | - |
1266 | replaces the corresponding pixel in the destination. In \l | - |
1267 | {QPainter::CompositionMode}{SourceOver} composition mode, the | - |
1268 | source object is transparent and is drawn on top of the | - |
1269 | destination. | - |
1270 | | - |
1271 | Note that composition transformation operates pixelwise. For that | - |
1272 | reason, there is a difference between using the graphic primitive | - |
1273 | itself and its bounding rectangle: The bounding rect contains | - |
1274 | pixels with alpha == 0 (i.e the pixels surrounding the | - |
1275 | primitive). These pixels will overwrite the other image's pixels, | - |
1276 | affectively clearing those, while the primitive only overwrites | - |
1277 | its own area. | - |
1278 | | - |
1279 | \table 100% | - |
1280 | \row | - |
1281 | \li \inlineimage qpainter-compositiondemo.png | - |
1282 | | - |
1283 | \li | - |
1284 | \b {Composition Modes Example} | - |
1285 | | - |
1286 | The \l {painting/composition}{Composition Modes} example, available in | - |
1287 | Qt's examples directory, allows you to experiment with the various | - |
1288 | composition modes and see the results immediately. | - |
1289 | | - |
1290 | \endtable | - |
1291 | | - |
1292 | \section1 Limitations | - |
1293 | \target Limitations | - |
1294 | | - |
1295 | If you are using coordinates with Qt's raster-based paint engine, it is | - |
1296 | important to note that, while coordinates greater than +/- 2\sup 15 can | - |
1297 | be used, any painting performed with coordinates outside this range is not | - |
1298 | guaranteed to be shown; the drawing may be clipped. This is due to the | - |
1299 | use of \c{short int} in the implementation. | - |
1300 | | - |
1301 | The outlines generated by Qt's stroker are only an approximation when dealing | - |
1302 | with curved shapes. It is in most cases impossible to represent the outline of | - |
1303 | a bezier curve segment using another bezier curve segment, and so Qt approximates | - |
1304 | the curve outlines by using several smaller curves. For performance reasons there | - |
1305 | is a limit to how many curves Qt uses for these outlines, and thus when using | - |
1306 | large pen widths or scales the outline error increases. To generate outlines with | - |
1307 | smaller errors it is possible to use the QPainterPathStroker class, which has the | - |
1308 | setCurveThreshold member function which let's the user specify the error tolerance. | - |
1309 | Another workaround is to convert the paths to polygons first and then draw the | - |
1310 | polygons instead. | - |
1311 | | - |
1312 | \section1 Performance | - |
1313 | | - |
1314 | QPainter is a rich framework that allows developers to do a great | - |
1315 | variety of graphical operations, such as gradients, composition | - |
1316 | modes and vector graphics. And QPainter can do this across a | - |
1317 | variety of different hardware and software stacks. Naturally the | - |
1318 | underlying combination of hardware and software has some | - |
1319 | implications for performance, and ensuring that every single | - |
1320 | operation is fast in combination with all the various combinations | - |
1321 | of composition modes, brushes, clipping, transformation, etc, is | - |
1322 | close to an impossible task because of the number of | - |
1323 | permutations. As a compromise we have selected a subset of the | - |
1324 | QPainter API and backends, where performance is guaranteed to be as | - |
1325 | good as we can sensibly get it for the given combination of | - |
1326 | hardware and software. | - |
1327 | | - |
1328 | The backends we focus on as high-performance engines are: | - |
1329 | | - |
1330 | \list | - |
1331 | | - |
1332 | \li Raster - This backend implements all rendering in pure software | - |
1333 | and is always used to render into QImages. For optimal performance | - |
1334 | only use the format types QImage::Format_ARGB32_Premultiplied, | - |
1335 | QImage::Format_RGB32 or QImage::Format_RGB16. Any other format, | - |
1336 | including QImage::Format_ARGB32, has significantly worse | - |
1337 | performance. This engine is used by default for QWidget and QPixmap. | - |
1338 | | - |
1339 | \li OpenGL 2.0 (ES) - This backend is the primary backend for | - |
1340 | hardware accelerated graphics. It can be run on desktop machines | - |
1341 | and embedded devices supporting the OpenGL 2.0 or OpenGL/ES 2.0 | - |
1342 | specification. This includes most graphics chips produced in the | - |
1343 | last couple of years. The engine can be enabled by using QPainter | - |
1344 | onto a QOpenGLWidget or by passing \c {-graphicssystem opengl} on the | - |
1345 | command line when the underlying system supports it. | - |
1346 | | - |
1347 | \li OpenVG - This backend implements the Khronos standard for 2D | - |
1348 | and Vector Graphics. It is primarily for embedded devices with | - |
1349 | hardware support for OpenVG. The engine can be enabled by | - |
1350 | passing \c {-graphicssystem openvg} on the command line when | - |
1351 | the underlying system supports it. | - |
1352 | | - |
1353 | \endlist | - |
1354 | | - |
1355 | These operations are: | - |
1356 | | - |
1357 | \list | - |
1358 | | - |
1359 | \li Simple transformations, meaning translation and scaling, pluss | - |
1360 | 0, 90, 180, 270 degree rotations. | - |
1361 | | - |
1362 | \li \c drawPixmap() in combination with simple transformations and | - |
1363 | opacity with non-smooth transformation mode | - |
1364 | (\c QPainter::SmoothPixmapTransform not enabled as a render hint). | - |
1365 | | - |
1366 | \li Rectangle fills with solid color, two-color linear gradients | - |
1367 | and simple transforms. | - |
1368 | | - |
1369 | \li Rectangular clipping with simple transformations and intersect | - |
1370 | clip. | - |
1371 | | - |
1372 | \li Composition Modes \c QPainter::CompositionMode_Source and | - |
1373 | QPainter::CompositionMode_SourceOver | - |
1374 | | - |
1375 | \li Rounded rectangle filling using solid color and two-color | - |
1376 | linear gradients fills. | - |
1377 | | - |
1378 | \li 3x3 patched pixmaps, via qDrawBorderPixmap. | - |
1379 | | - |
1380 | \endlist | - |
1381 | | - |
1382 | This list gives an indication of which features to safely use in | - |
1383 | an application where performance is critical. For certain setups, | - |
1384 | other operations may be fast too, but before making extensive use | - |
1385 | of them, it is recommended to benchmark and verify them on the | - |
1386 | system where the software will run in the end. There are also | - |
1387 | cases where expensive operations are ok to use, for instance when | - |
1388 | the result is cached in a QPixmap. | - |
1389 | | - |
1390 | \sa QPaintDevice, QPaintEngine, {Qt SVG}, {Basic Drawing Example}, | - |
1391 | {Drawing Utility Functions} | - |
1392 | */ | - |
1393 | | - |
1394 | /*! | - |
1395 | \enum QPainter::RenderHint | - |
1396 | | - |
1397 | Renderhints are used to specify flags to QPainter that may or | - |
1398 | may not be respected by any given engine. | - |
1399 | | - |
1400 | \value Antialiasing Indicates that the engine should antialias | - |
1401 | edges of primitives if possible. | - |
1402 | | - |
1403 | \value TextAntialiasing Indicates that the engine should antialias | - |
1404 | text if possible. To forcibly disable antialiasing for text, do not | - |
1405 | use this hint. Instead, set QFont::NoAntialias on your font's style | - |
1406 | strategy. | - |
1407 | | - |
1408 | \value SmoothPixmapTransform Indicates that the engine should use | - |
1409 | a smooth pixmap transformation algorithm (such as bilinear) rather | - |
1410 | than nearest neighbor. | - |
1411 | | - |
1412 | \value HighQualityAntialiasing An OpenGL-specific rendering hint | - |
1413 | indicating that the engine should use fragment programs and offscreen | - |
1414 | rendering for antialiasing. | - |
1415 | | - |
1416 | \value NonCosmeticDefaultPen This value is obsolete, the default for QPen | - |
1417 | is now non-cosmetic. | - |
1418 | | - |
1419 | \value Qt4CompatiblePainting Compatibility hint telling the engine to use the | - |
1420 | same X11 based fill rules as in Qt 4, where aliased rendering is offset | - |
1421 | by slightly less than half a pixel. Also will treat default constructed pens | - |
1422 | as cosmetic. Potentially useful when porting a Qt 4 application to Qt 5. | - |
1423 | | - |
1424 | \sa renderHints(), setRenderHint(), {QPainter#Rendering | - |
1425 | Quality}{Rendering Quality}, {Concentric Circles Example} | - |
1426 | | - |
1427 | */ | - |
1428 | | - |
1429 | /*! | - |
1430 | Constructs a painter. | - |
1431 | | - |
1432 | \sa begin(), end() | - |
1433 | */ | - |
1434 | | - |
1435 | QPainter::QPainter() | - |
1436 | : d_ptr(new QPainterPrivate(this)) | - |
1437 | { | - |
1438 | } executed: } Execution Count:2033 | 2033 |
1439 | | - |
1440 | /*! | - |
1441 | \fn QPainter::QPainter(QPaintDevice *device) | - |
1442 | | - |
1443 | Constructs a painter that begins painting the paint \a device | - |
1444 | immediately. | - |
1445 | | - |
1446 | This constructor is convenient for short-lived painters, e.g. in a | - |
1447 | QWidget::paintEvent() and should be used only once. The | - |
1448 | constructor calls begin() for you and the QPainter destructor | - |
1449 | automatically calls end(). | - |
1450 | | - |
1451 | Here's an example using begin() and end(): | - |
1452 | \snippet code/src_gui_painting_qpainter.cpp 1 | - |
1453 | | - |
1454 | The same example using this constructor: | - |
1455 | \snippet code/src_gui_painting_qpainter.cpp 2 | - |
1456 | | - |
1457 | Since the constructor cannot provide feedback when the initialization | - |
1458 | of the painter failed you should rather use begin() and end() to paint | - |
1459 | on external devices, e.g. printers. | - |
1460 | | - |
1461 | \sa begin(), end() | - |
1462 | */ | - |
1463 | | - |
1464 | QPainter::QPainter(QPaintDevice *pd) | - |
1465 | : d_ptr(0) | - |
1466 | { | - |
1467 | Q_ASSERT(pd != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1468 | if (!QPainterPrivate::attachPainterPrivate(this, pd)) { evaluated: !QPainterPrivate::attachPainterPrivate(this, pd) yes Evaluation Count:25609 | yes Evaluation Count:34 |
| 34-25609 |
1469 | d_ptr.reset(new QPainterPrivate(this)); executed (the execution status of this line is deduced): d_ptr.reset(new QPainterPrivate(this)); | - |
1470 | begin(pd); executed (the execution status of this line is deduced): begin(pd); | - |
1471 | } executed: } Execution Count:25609 | 25609 |
1472 | Q_ASSERT(d_ptr); executed (the execution status of this line is deduced): qt_noop(); | - |
1473 | } executed: } Execution Count:25643 | 25643 |
1474 | | - |
1475 | /*! | - |
1476 | Destroys the painter. | - |
1477 | */ | - |
1478 | QPainter::~QPainter() | - |
1479 | { | - |
1480 | d_ptr->inDestructor = true; executed (the execution status of this line is deduced): d_ptr->inDestructor = true; | - |
1481 | QT_TRY { partially evaluated: true yes Evaluation Count:27676 | no Evaluation Count:0 |
| 0-27676 |
1482 | if (isActive()) evaluated: isActive() yes Evaluation Count:22462 | yes Evaluation Count:5214 |
| 5214-22462 |
1483 | end(); executed: end(); Execution Count:22462 | 22462 |
1484 | else if (d_ptr->refcount > 1) partially evaluated: d_ptr->refcount > 1 no Evaluation Count:0 | yes Evaluation Count:5214 |
| 0-5214 |
1485 | d_ptr->detachPainterPrivate(this); never executed: d_ptr->detachPainterPrivate(this); | 0 |
1486 | } QT_CATCH(...) { | - |
1487 | // don't throw anything in the destructor. | - |
1488 | } | 0 |
1489 | if (d_ptr) { evaluated: d_ptr yes Evaluation Count:27643 | yes Evaluation Count:33 |
| 33-27643 |
1490 | // Make sure we haven't messed things up. | - |
1491 | Q_ASSERT(d_ptr->inDestructor); executed (the execution status of this line is deduced): qt_noop(); | - |
1492 | d_ptr->inDestructor = false; executed (the execution status of this line is deduced): d_ptr->inDestructor = false; | - |
1493 | Q_ASSERT(d_ptr->refcount == 1); executed (the execution status of this line is deduced): qt_noop(); | - |
1494 | if (d_ptr->d_ptrs) evaluated: d_ptr->d_ptrs yes Evaluation Count:13 | yes Evaluation Count:27630 |
| 13-27630 |
1495 | free(d_ptr->d_ptrs); executed: free(d_ptr->d_ptrs); Execution Count:13 | 13 |
1496 | } executed: } Execution Count:27643 | 27643 |
1497 | } executed: } Execution Count:27676 | 27676 |
1498 | | - |
1499 | /*! | - |
1500 | Returns the paint device on which this painter is currently | - |
1501 | painting, or 0 if the painter is not active. | - |
1502 | | - |
1503 | \sa isActive() | - |
1504 | */ | - |
1505 | | - |
1506 | QPaintDevice *QPainter::device() const | - |
1507 | { | - |
1508 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
1509 | if (isActive() && d->engine->d_func()->currentClipDevice) evaluated: isActive() yes Evaluation Count:30103 | yes Evaluation Count:1 |
evaluated: d->engine->d_func()->currentClipDevice yes Evaluation Count:6 | yes Evaluation Count:30097 |
| 1-30103 |
1510 | return d->engine->d_func()->currentClipDevice; executed: return d->engine->d_func()->currentClipDevice; Execution Count:6 | 6 |
1511 | return d->original_device; executed: return d->original_device; Execution Count:30098 | 30098 |
1512 | } | - |
1513 | | - |
1514 | /*! | - |
1515 | Returns true if begin() has been called and end() has not yet been | - |
1516 | called; otherwise returns false. | - |
1517 | | - |
1518 | \sa begin(), QPaintDevice::paintingActive() | - |
1519 | */ | - |
1520 | | - |
1521 | bool QPainter::isActive() const | - |
1522 | { | - |
1523 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
1524 | return d->engine; executed: return d->engine; Execution Count:57858 | 57858 |
1525 | } | - |
1526 | | - |
1527 | /*! | - |
1528 | Initializes the painters pen, background and font to the same as | - |
1529 | the given \a device. | - |
1530 | | - |
1531 | \obsolete | - |
1532 | | - |
1533 | \sa begin(), {QPainter#Settings}{Settings} | - |
1534 | */ | - |
1535 | void QPainter::initFrom(const QPaintDevice *device) | - |
1536 | { | - |
1537 | Q_ASSERT_X(device, "QPainter::initFrom(const QPaintDevice *device)", "QPaintDevice cannot be 0"); executed (the execution status of this line is deduced): qt_noop(); | - |
1538 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
1539 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:23461 |
| 0-23461 |
1540 | qWarning("QPainter::initFrom: Painter not active, aborted"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1540, __PRETTY_FUNCTION__).warning("QPainter::initFrom: Painter not active, aborted"); | - |
1541 | return; | 0 |
1542 | } | - |
1543 | | - |
1544 | device->initPainter(this); never executed (the execution status of this line is deduced): device->initPainter(this); | - |
1545 | | - |
1546 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:23461 | no Evaluation Count:0 |
| 0-23461 |
1547 | d->extended->penChanged(); executed (the execution status of this line is deduced): d->extended->penChanged(); | - |
1548 | } else if (d->engine) { executed: } Execution Count:23461 never evaluated: d->engine | 0-23461 |
1549 | d->engine->setDirty(QPaintEngine::DirtyPen); never executed (the execution status of this line is deduced): d->engine->setDirty(QPaintEngine::DirtyPen); | - |
1550 | d->engine->setDirty(QPaintEngine::DirtyBrush); never executed (the execution status of this line is deduced): d->engine->setDirty(QPaintEngine::DirtyBrush); | - |
1551 | d->engine->setDirty(QPaintEngine::DirtyFont); never executed (the execution status of this line is deduced): d->engine->setDirty(QPaintEngine::DirtyFont); | - |
1552 | } | 0 |
1553 | } | - |
1554 | | - |
1555 | | - |
1556 | /*! | - |
1557 | Saves the current painter state (pushes the state onto a stack). A | - |
1558 | save() must be followed by a corresponding restore(); the end() | - |
1559 | function unwinds the stack. | - |
1560 | | - |
1561 | \sa restore() | - |
1562 | */ | - |
1563 | | - |
1564 | void QPainter::save() | - |
1565 | { | - |
1566 | #ifdef QT_DEBUG_DRAW | - |
1567 | if (qt_show_painter_debug_output) | - |
1568 | printf("QPainter::save()\n"); | - |
1569 | #endif | - |
1570 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
1571 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:30787 |
| 1-30787 |
1572 | qWarning("QPainter::save: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1572, __PRETTY_FUNCTION__).warning("QPainter::save: Painter not active"); | - |
1573 | return; executed: return; Execution Count:1 | 1 |
1574 | } | - |
1575 | | - |
1576 | if (d->extended) { evaluated: d->extended yes Evaluation Count:30778 | yes Evaluation Count:9 |
| 9-30778 |
1577 | d->state = d->extended->createState(d->states.back()); executed (the execution status of this line is deduced): d->state = d->extended->createState(d->states.back()); | - |
1578 | d->extended->setState(d->state); executed (the execution status of this line is deduced): d->extended->setState(d->state); | - |
1579 | } else { executed: } Execution Count:30778 | 30778 |
1580 | d->updateState(d->state); executed (the execution status of this line is deduced): d->updateState(d->state); | - |
1581 | d->state = new QPainterState(d->states.back()); executed (the execution status of this line is deduced): d->state = new QPainterState(d->states.back()); | - |
1582 | d->engine->state = d->state; executed (the execution status of this line is deduced): d->engine->state = d->state; | - |
1583 | } executed: } Execution Count:9 | 9 |
1584 | d->states.push_back(d->state); executed (the execution status of this line is deduced): d->states.push_back(d->state); | - |
1585 | } executed: } Execution Count:30787 | 30787 |
1586 | | - |
1587 | /*! | - |
1588 | Restores the current painter state (pops a saved state off the | - |
1589 | stack). | - |
1590 | | - |
1591 | \sa save() | - |
1592 | */ | - |
1593 | | - |
1594 | void QPainter::restore() | - |
1595 | { | - |
1596 | #ifdef QT_DEBUG_DRAW | - |
1597 | if (qt_show_painter_debug_output) | - |
1598 | printf("QPainter::restore()\n"); | - |
1599 | #endif | - |
1600 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
1601 | if (d->states.size()<=1) { evaluated: d->states.size()<=1 yes Evaluation Count:1 | yes Evaluation Count:30787 |
| 1-30787 |
1602 | qWarning("QPainter::restore: Unbalanced save/restore"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1602, __PRETTY_FUNCTION__).warning("QPainter::restore: Unbalanced save/restore"); | - |
1603 | return; executed: return; Execution Count:1 | 1 |
1604 | } else if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:30787 |
| 0-30787 |
1605 | qWarning("QPainter::restore: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1605, __PRETTY_FUNCTION__).warning("QPainter::restore: Painter not active"); | - |
1606 | return; | 0 |
1607 | } | - |
1608 | | - |
1609 | QPainterState *tmp = d->state; executed (the execution status of this line is deduced): QPainterState *tmp = d->state; | - |
1610 | d->states.pop_back(); executed (the execution status of this line is deduced): d->states.pop_back(); | - |
1611 | d->state = d->states.back(); executed (the execution status of this line is deduced): d->state = d->states.back(); | - |
1612 | d->txinv = false; executed (the execution status of this line is deduced): d->txinv = false; | - |
1613 | | - |
1614 | if (d->extended) { evaluated: d->extended yes Evaluation Count:30778 | yes Evaluation Count:9 |
| 9-30778 |
1615 | d->checkEmulation(); executed (the execution status of this line is deduced): d->checkEmulation(); | - |
1616 | d->extended->setState(d->state); executed (the execution status of this line is deduced): d->extended->setState(d->state); | - |
1617 | delete tmp; executed (the execution status of this line is deduced): delete tmp; | - |
1618 | return; executed: return; Execution Count:30778 | 30778 |
1619 | } | - |
1620 | | - |
1621 | // trigger clip update if the clip path/region has changed since | - |
1622 | // last save | - |
1623 | if (!d->state->clipInfo.isEmpty() partially evaluated: !d->state->clipInfo.isEmpty() no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
1624 | && (tmp->changeFlags & (QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipPath))) { never evaluated: (tmp->changeFlags & (QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipPath)) | 0 |
1625 | // reuse the tmp state to avoid any extra allocs... | - |
1626 | tmp->dirtyFlags = QPaintEngine::DirtyClipPath; never executed (the execution status of this line is deduced): tmp->dirtyFlags = QPaintEngine::DirtyClipPath; | - |
1627 | tmp->clipOperation = Qt::NoClip; never executed (the execution status of this line is deduced): tmp->clipOperation = Qt::NoClip; | - |
1628 | tmp->clipPath = QPainterPath(); never executed (the execution status of this line is deduced): tmp->clipPath = QPainterPath(); | - |
1629 | d->engine->updateState(*tmp); never executed (the execution status of this line is deduced): d->engine->updateState(*tmp); | - |
1630 | // replay the list of clip states, | - |
1631 | for (int i=0; i<d->state->clipInfo.size(); ++i) { never evaluated: i<d->state->clipInfo.size() | 0 |
1632 | const QPainterClipInfo &info = d->state->clipInfo.at(i); never executed (the execution status of this line is deduced): const QPainterClipInfo &info = d->state->clipInfo.at(i); | - |
1633 | tmp->matrix = info.matrix; never executed (the execution status of this line is deduced): tmp->matrix = info.matrix; | - |
1634 | tmp->matrix *= d->state->redirectionMatrix; never executed (the execution status of this line is deduced): tmp->matrix *= d->state->redirectionMatrix; | - |
1635 | tmp->clipOperation = info.operation; never executed (the execution status of this line is deduced): tmp->clipOperation = info.operation; | - |
1636 | if (info.clipType == QPainterClipInfo::RectClip) { never evaluated: info.clipType == QPainterClipInfo::RectClip | 0 |
1637 | tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform; never executed (the execution status of this line is deduced): tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform; | - |
1638 | tmp->clipRegion = info.rect; never executed (the execution status of this line is deduced): tmp->clipRegion = info.rect; | - |
1639 | } else if (info.clipType == QPainterClipInfo::RegionClip) { never executed: } never evaluated: info.clipType == QPainterClipInfo::RegionClip | 0 |
1640 | tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform; never executed (the execution status of this line is deduced): tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform; | - |
1641 | tmp->clipRegion = info.region; never executed (the execution status of this line is deduced): tmp->clipRegion = info.region; | - |
1642 | } else { // clipType == QPainterClipInfo::PathClip | 0 |
1643 | tmp->dirtyFlags = QPaintEngine::DirtyClipPath | QPaintEngine::DirtyTransform; never executed (the execution status of this line is deduced): tmp->dirtyFlags = QPaintEngine::DirtyClipPath | QPaintEngine::DirtyTransform; | - |
1644 | tmp->clipPath = info.path; never executed (the execution status of this line is deduced): tmp->clipPath = info.path; | - |
1645 | } | 0 |
1646 | d->engine->updateState(*tmp); never executed (the execution status of this line is deduced): d->engine->updateState(*tmp); | - |
1647 | } | 0 |
1648 | | - |
1649 | | - |
1650 | //Since we've updated the clip region anyway, pretend that the clip path hasn't changed: | - |
1651 | d->state->dirtyFlags &= ~(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion); never executed (the execution status of this line is deduced): d->state->dirtyFlags &= ~(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion); | - |
1652 | tmp->changeFlags &= ~(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion); never executed (the execution status of this line is deduced): tmp->changeFlags &= ~(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion); | - |
1653 | tmp->changeFlags |= QPaintEngine::DirtyTransform; never executed (the execution status of this line is deduced): tmp->changeFlags |= QPaintEngine::DirtyTransform; | - |
1654 | } | 0 |
1655 | | - |
1656 | d->updateState(d->state); executed (the execution status of this line is deduced): d->updateState(d->state); | - |
1657 | delete tmp; executed (the execution status of this line is deduced): delete tmp; | - |
1658 | } executed: } Execution Count:9 | 9 |
1659 | | - |
1660 | | - |
1661 | /*! | - |
1662 | | - |
1663 | \fn bool QPainter::begin(QPaintDevice *device) | - |
1664 | | - |
1665 | Begins painting the paint \a device and returns true if | - |
1666 | successful; otherwise returns false. | - |
1667 | | - |
1668 | Notice that all painter settings (setPen(), setBrush() etc.) are reset | - |
1669 | to default values when begin() is called. | - |
1670 | | - |
1671 | The errors that can occur are serious problems, such as these: | - |
1672 | | - |
1673 | \snippet code/src_gui_painting_qpainter.cpp 3 | - |
1674 | | - |
1675 | Note that most of the time, you can use one of the constructors | - |
1676 | instead of begin(), and that end() is automatically done at | - |
1677 | destruction. | - |
1678 | | - |
1679 | \warning A paint device can only be painted by one painter at a | - |
1680 | time. | - |
1681 | | - |
1682 | \warning Painting on a QImage with the format | - |
1683 | QImage::Format_Indexed8 is not supported. | - |
1684 | | - |
1685 | \sa end(), QPainter() | - |
1686 | */ | - |
1687 | | - |
1688 | static inline void qt_cleanup_painter_state(QPainterPrivate *d) | - |
1689 | { | - |
1690 | d->states.clear(); executed (the execution status of this line is deduced): d->states.clear(); | - |
1691 | delete d->state; executed (the execution status of this line is deduced): delete d->state; | - |
1692 | d->state = 0; executed (the execution status of this line is deduced): d->state = 0; | - |
1693 | d->engine = 0; executed (the execution status of this line is deduced): d->engine = 0; | - |
1694 | d->device = 0; executed (the execution status of this line is deduced): d->device = 0; | - |
1695 | } executed: } Execution Count:28778 | 28778 |
1696 | | - |
1697 | bool QPainter::begin(QPaintDevice *pd) | - |
1698 | { | - |
1699 | Q_ASSERT(pd); executed (the execution status of this line is deduced): qt_noop(); | - |
1700 | | - |
1701 | if (pd->painters > 0) { evaluated: pd->painters > 0 yes Evaluation Count:1 | yes Evaluation Count:28784 |
| 1-28784 |
1702 | qWarning("QPainter::begin: A paint device can only be painted by one painter at a time."); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1702, __PRETTY_FUNCTION__).warning("QPainter::begin: A paint device can only be painted by one painter at a time."); | - |
1703 | return false; executed: return false; Execution Count:1 | 1 |
1704 | } | - |
1705 | | - |
1706 | if (d_ptr->engine) { evaluated: d_ptr->engine yes Evaluation Count:1 | yes Evaluation Count:28783 |
| 1-28783 |
1707 | qWarning("QPainter::begin: Painter already active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1707, __PRETTY_FUNCTION__).warning("QPainter::begin: Painter already active"); | - |
1708 | return false; executed: return false; Execution Count:1 | 1 |
1709 | } | - |
1710 | | - |
1711 | if (QPainterPrivate::attachPainterPrivate(this, pd)) evaluated: QPainterPrivate::attachPainterPrivate(this, pd) yes Evaluation Count:6 | yes Evaluation Count:28777 |
| 6-28777 |
1712 | return true; executed: return true; Execution Count:6 | 6 |
1713 | | - |
1714 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
1715 | | - |
1716 | d->helper_device = pd; executed (the execution status of this line is deduced): d->helper_device = pd; | - |
1717 | d->original_device = pd; executed (the execution status of this line is deduced): d->original_device = pd; | - |
1718 | | - |
1719 | QPoint redirectionOffset; executed (the execution status of this line is deduced): QPoint redirectionOffset; | - |
1720 | QPaintDevice *rpd = pd->redirected(&redirectionOffset); executed (the execution status of this line is deduced): QPaintDevice *rpd = pd->redirected(&redirectionOffset); | - |
1721 | if (rpd) evaluated: rpd yes Evaluation Count:23420 | yes Evaluation Count:5357 |
| 5357-23420 |
1722 | pd = rpd; executed: pd = rpd; Execution Count:23420 | 23420 |
1723 | | - |
1724 | #ifdef QT_DEBUG_DRAW | - |
1725 | if (qt_show_painter_debug_output) | - |
1726 | printf("QPainter::begin(), device=%p, type=%d\n", pd, pd->devType()); | - |
1727 | #endif | - |
1728 | | - |
1729 | if (pd->devType() == QInternal::Pixmap) evaluated: pd->devType() == QInternal::Pixmap yes Evaluation Count:834 | yes Evaluation Count:27943 |
| 834-27943 |
1730 | static_cast<QPixmap *>(pd)->detach(); executed: static_cast<QPixmap *>(pd)->detach(); Execution Count:834 | 834 |
1731 | else if (pd->devType() == QInternal::Image) evaluated: pd->devType() == QInternal::Image yes Evaluation Count:27905 | yes Evaluation Count:38 |
| 38-27905 |
1732 | static_cast<QImage *>(pd)->detach(); executed: static_cast<QImage *>(pd)->detach(); Execution Count:27905 | 27905 |
1733 | | - |
1734 | d->engine = pd->paintEngine(); executed (the execution status of this line is deduced): d->engine = pd->paintEngine(); | - |
1735 | | - |
1736 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:2 | yes Evaluation Count:28774 |
| 2-28774 |
1737 | qWarning("QPainter::begin: Paint device returned engine == 0, type: %d", pd->devType()); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1737, __PRETTY_FUNCTION__).warning("QPainter::begin: Paint device returned engine == 0, type: %d", pd->devType()); | - |
1738 | return false; executed: return false; Execution Count:2 | 2 |
1739 | } | - |
1740 | | - |
1741 | d->device = pd; executed (the execution status of this line is deduced): d->device = pd; | - |
1742 | | - |
1743 | d->extended = d->engine->isExtended() ? static_cast<QPaintEngineEx *>(d->engine) : 0; evaluated: d->engine->isExtended() yes Evaluation Count:28736 | yes Evaluation Count:38 |
| 38-28736 |
1744 | if (d->emulationEngine) partially evaluated: d->emulationEngine no Evaluation Count:0 | yes Evaluation Count:28774 |
| 0-28774 |
1745 | d->emulationEngine->real_engine = d->extended; never executed: d->emulationEngine->real_engine = d->extended; | 0 |
1746 | | - |
1747 | // Setup new state... | - |
1748 | Q_ASSERT(!d->state); executed (the execution status of this line is deduced): qt_noop(); | - |
1749 | d->state = d->extended ? d->extended->createState(0) : new QPainterState; evaluated: d->extended yes Evaluation Count:28736 | yes Evaluation Count:38 |
| 38-28736 |
1750 | d->state->painter = this; executed (the execution status of this line is deduced): d->state->painter = this; | - |
1751 | d->states.push_back(d->state); executed (the execution status of this line is deduced): d->states.push_back(d->state); | - |
1752 | | - |
1753 | d->state->redirectionMatrix.translate(-redirectionOffset.x(), -redirectionOffset.y()); executed (the execution status of this line is deduced): d->state->redirectionMatrix.translate(-redirectionOffset.x(), -redirectionOffset.y()); | - |
1754 | d->state->brushOrigin = QPointF(); executed (the execution status of this line is deduced): d->state->brushOrigin = QPointF(); | - |
1755 | | - |
1756 | // Slip a painter state into the engine before we do any other operations | - |
1757 | if (d->extended) evaluated: d->extended yes Evaluation Count:28737 | yes Evaluation Count:38 |
| 38-28737 |
1758 | d->extended->setState(d->state); executed: d->extended->setState(d->state); Execution Count:28737 | 28737 |
1759 | else | - |
1760 | d->engine->state = d->state; executed: d->engine->state = d->state; Execution Count:38 | 38 |
1761 | | - |
1762 | switch (pd->devType()) { | - |
1763 | case QInternal::Pixmap: | - |
1764 | { | - |
1765 | QPixmap *pm = static_cast<QPixmap *>(pd); executed (the execution status of this line is deduced): QPixmap *pm = static_cast<QPixmap *>(pd); | - |
1766 | Q_ASSERT(pm); executed (the execution status of this line is deduced): qt_noop(); | - |
1767 | if (pm->isNull()) { partially evaluated: pm->isNull() no Evaluation Count:0 | yes Evaluation Count:833 |
| 0-833 |
1768 | qWarning("QPainter::begin: Cannot paint on a null pixmap"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1768, __PRETTY_FUNCTION__).warning("QPainter::begin: Cannot paint on a null pixmap"); | - |
1769 | qt_cleanup_painter_state(d); never executed (the execution status of this line is deduced): qt_cleanup_painter_state(d); | - |
1770 | return false; never executed: return false; | 0 |
1771 | } | - |
1772 | | - |
1773 | if (pm->depth() == 1) { evaluated: pm->depth() == 1 yes Evaluation Count:5 | yes Evaluation Count:828 |
| 5-828 |
1774 | d->state->pen = QPen(Qt::color1); executed (the execution status of this line is deduced): d->state->pen = QPen(Qt::color1); | - |
1775 | d->state->brush = QBrush(Qt::color0); executed (the execution status of this line is deduced): d->state->brush = QBrush(Qt::color0); | - |
1776 | } executed: } Execution Count:5 | 5 |
1777 | break; executed: break; Execution Count:833 | 833 |
1778 | } | - |
1779 | case QInternal::Image: | - |
1780 | { | - |
1781 | QImage *img = static_cast<QImage *>(pd); executed (the execution status of this line is deduced): QImage *img = static_cast<QImage *>(pd); | - |
1782 | Q_ASSERT(img); executed (the execution status of this line is deduced): qt_noop(); | - |
1783 | if (img->isNull()) { partially evaluated: img->isNull() no Evaluation Count:0 | yes Evaluation Count:27904 |
| 0-27904 |
1784 | qWarning("QPainter::begin: Cannot paint on a null image"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1784, __PRETTY_FUNCTION__).warning("QPainter::begin: Cannot paint on a null image"); | - |
1785 | qt_cleanup_painter_state(d); never executed (the execution status of this line is deduced): qt_cleanup_painter_state(d); | - |
1786 | return false; never executed: return false; | 0 |
1787 | } else if (img->format() == QImage::Format_Indexed8) { evaluated: img->format() == QImage::Format_Indexed8 yes Evaluation Count:1 | yes Evaluation Count:27903 |
| 1-27903 |
1788 | // Painting on indexed8 images is not supported. | - |
1789 | qWarning("QPainter::begin: Cannot paint on an image with the QImage::Format_Indexed8 format"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1789, __PRETTY_FUNCTION__).warning("QPainter::begin: Cannot paint on an image with the QImage::Format_Indexed8 format"); | - |
1790 | qt_cleanup_painter_state(d); executed (the execution status of this line is deduced): qt_cleanup_painter_state(d); | - |
1791 | return false; executed: return false; Execution Count:1 | 1 |
1792 | } | - |
1793 | if (img->depth() == 1) { evaluated: img->depth() == 1 yes Evaluation Count:162 | yes Evaluation Count:27741 |
| 162-27741 |
1794 | d->state->pen = QPen(Qt::color1); executed (the execution status of this line is deduced): d->state->pen = QPen(Qt::color1); | - |
1795 | d->state->brush = QBrush(Qt::color0); executed (the execution status of this line is deduced): d->state->brush = QBrush(Qt::color0); | - |
1796 | } executed: } Execution Count:162 | 162 |
1797 | break; executed: break; Execution Count:27903 | 27903 |
1798 | } | - |
1799 | default: | - |
1800 | break; executed: break; Execution Count:38 | 38 |
1801 | } | - |
1802 | if (d->state->ww == 0) // For compat with 3.x painter defaults partially evaluated: d->state->ww == 0 yes Evaluation Count:28774 | no Evaluation Count:0 |
| 0-28774 |
1803 | d->state->ww = d->state->wh = d->state->vw = d->state->vh = 1024; executed: d->state->ww = d->state->wh = d->state->vw = d->state->vh = 1024; Execution Count:28774 | 28774 |
1804 | | - |
1805 | d->engine->setPaintDevice(pd); executed (the execution status of this line is deduced): d->engine->setPaintDevice(pd); | - |
1806 | | - |
1807 | bool begun = d->engine->begin(pd); executed (the execution status of this line is deduced): bool begun = d->engine->begin(pd); | - |
1808 | if (!begun) { evaluated: !begun yes Evaluation Count:1 | yes Evaluation Count:28773 |
| 1-28773 |
1809 | qWarning("QPainter::begin(): Returned false"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1809, __PRETTY_FUNCTION__).warning("QPainter::begin(): Returned false"); | - |
1810 | if (d->engine->isActive()) { partially evaluated: d->engine->isActive() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1811 | end(); never executed (the execution status of this line is deduced): end(); | - |
1812 | } else { | 0 |
1813 | qt_cleanup_painter_state(d); executed (the execution status of this line is deduced): qt_cleanup_painter_state(d); | - |
1814 | } executed: } Execution Count:1 | 1 |
1815 | return false; executed: return false; Execution Count:1 | 1 |
1816 | } else { | - |
1817 | d->engine->setActive(begun); executed (the execution status of this line is deduced): d->engine->setActive(begun); | - |
1818 | } executed: } Execution Count:28773 | 28773 |
1819 | | - |
1820 | // Copy painter properties from original paint device, | - |
1821 | // required for QPixmap::grabWidget() | - |
1822 | if (d->original_device->devType() == QInternal::Widget) { evaluated: d->original_device->devType() == QInternal::Widget yes Evaluation Count:23420 | yes Evaluation Count:5353 |
| 5353-23420 |
1823 | initFrom(d->original_device); executed (the execution status of this line is deduced): initFrom(d->original_device); | - |
1824 | } else { executed: } Execution Count:23420 | 23420 |
1825 | d->state->layoutDirection = Qt::LayoutDirectionAuto; executed (the execution status of this line is deduced): d->state->layoutDirection = Qt::LayoutDirectionAuto; | - |
1826 | // make sure we have a font compatible with the paintdevice | - |
1827 | d->state->deviceFont = d->state->font = QFont(d->state->deviceFont, device()); executed (the execution status of this line is deduced): d->state->deviceFont = d->state->font = QFont(d->state->deviceFont, device()); | - |
1828 | } executed: } Execution Count:5353 | 5353 |
1829 | | - |
1830 | QRect systemRect = d->engine->systemRect(); executed (the execution status of this line is deduced): QRect systemRect = d->engine->systemRect(); | - |
1831 | if (!systemRect.isEmpty()) { evaluated: !systemRect.isEmpty() yes Evaluation Count:23420 | yes Evaluation Count:5353 |
| 5353-23420 |
1832 | d->state->ww = d->state->vw = systemRect.width(); executed (the execution status of this line is deduced): d->state->ww = d->state->vw = systemRect.width(); | - |
1833 | d->state->wh = d->state->vh = systemRect.height(); executed (the execution status of this line is deduced): d->state->wh = d->state->vh = systemRect.height(); | - |
1834 | } else { executed: } Execution Count:23420 | 23420 |
1835 | d->state->ww = d->state->vw = pd->metric(QPaintDevice::PdmWidth); executed (the execution status of this line is deduced): d->state->ww = d->state->vw = pd->metric(QPaintDevice::PdmWidth); | - |
1836 | d->state->wh = d->state->vh = pd->metric(QPaintDevice::PdmHeight); executed (the execution status of this line is deduced): d->state->wh = d->state->vh = pd->metric(QPaintDevice::PdmHeight); | - |
1837 | } executed: } Execution Count:5353 | 5353 |
1838 | | - |
1839 | const QPoint coordinateOffset = d->engine->coordinateOffset(); executed (the execution status of this line is deduced): const QPoint coordinateOffset = d->engine->coordinateOffset(); | - |
1840 | d->state->redirectionMatrix.translate(-coordinateOffset.x(), -coordinateOffset.y()); executed (the execution status of this line is deduced): d->state->redirectionMatrix.translate(-coordinateOffset.x(), -coordinateOffset.y()); | - |
1841 | | - |
1842 | Q_ASSERT(d->engine->isActive()); executed (the execution status of this line is deduced): qt_noop(); | - |
1843 | | - |
1844 | #ifdef Q_OS_MAC | - |
1845 | // Limited feature introduction for Qt 5.0.0, remove ifdef in a later release. | - |
1846 | const bool isHighDpi = (pd->devType() == QInternal::Printer || d->device->physicalDpiX() == 0 || d->device->logicalDpiX() == 0) ? | - |
1847 | false : (d->device->physicalDpiX() / d->device->logicalDpiX() > 1); | - |
1848 | #else | - |
1849 | const bool isHighDpi = false; executed (the execution status of this line is deduced): const bool isHighDpi = false; | - |
1850 | #endif | - |
1851 | if (!d->state->redirectionMatrix.isIdentity() || isHighDpi) evaluated: !d->state->redirectionMatrix.isIdentity() yes Evaluation Count:15494 | yes Evaluation Count:13279 |
partially evaluated: isHighDpi no Evaluation Count:0 | yes Evaluation Count:13279 |
| 0-15494 |
1852 | d->updateMatrix(); executed: d->updateMatrix(); Execution Count:15494 | 15494 |
1853 | | - |
1854 | Q_ASSERT(d->engine->isActive()); executed (the execution status of this line is deduced): qt_noop(); | - |
1855 | d->state->renderHints = QPainter::TextAntialiasing; executed (the execution status of this line is deduced): d->state->renderHints = QPainter::TextAntialiasing; | - |
1856 | ++d->device->painters; executed (the execution status of this line is deduced): ++d->device->painters; | - |
1857 | | - |
1858 | d->state->emulationSpecifier = 0; executed (the execution status of this line is deduced): d->state->emulationSpecifier = 0; | - |
1859 | | - |
1860 | return true; executed: return true; Execution Count:28773 | 28773 |
1861 | } | - |
1862 | | - |
1863 | /*! | - |
1864 | Ends painting. Any resources used while painting are released. You | - |
1865 | don't normally need to call this since it is called by the | - |
1866 | destructor. | - |
1867 | | - |
1868 | Returns true if the painter is no longer active; otherwise returns false. | - |
1869 | | - |
1870 | \sa begin(), isActive() | - |
1871 | */ | - |
1872 | | - |
1873 | bool QPainter::end() | - |
1874 | { | - |
1875 | #ifdef QT_DEBUG_DRAW | - |
1876 | if (qt_show_painter_debug_output) | - |
1877 | printf("QPainter::end()\n"); | - |
1878 | #endif | - |
1879 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
1880 | | - |
1881 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:3 | yes Evaluation Count:28813 |
| 3-28813 |
1882 | qWarning("QPainter::end: Painter not active, aborted"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1882, __PRETTY_FUNCTION__).warning("QPainter::end: Painter not active, aborted"); | - |
1883 | qt_cleanup_painter_state(d); executed (the execution status of this line is deduced): qt_cleanup_painter_state(d); | - |
1884 | return false; executed: return false; Execution Count:3 | 3 |
1885 | } | - |
1886 | | - |
1887 | if (d->refcount > 1) { evaluated: d->refcount > 1 yes Evaluation Count:40 | yes Evaluation Count:28773 |
| 40-28773 |
1888 | d->detachPainterPrivate(this); executed (the execution status of this line is deduced): d->detachPainterPrivate(this); | - |
1889 | return true; executed: return true; Execution Count:40 | 40 |
1890 | } | - |
1891 | | - |
1892 | bool ended = true; executed (the execution status of this line is deduced): bool ended = true; | - |
1893 | | - |
1894 | if (d->engine->isActive()) { partially evaluated: d->engine->isActive() yes Evaluation Count:28773 | no Evaluation Count:0 |
| 0-28773 |
1895 | ended = d->engine->end(); executed (the execution status of this line is deduced): ended = d->engine->end(); | - |
1896 | d->updateState(0); executed (the execution status of this line is deduced): d->updateState(0); | - |
1897 | | - |
1898 | --d->device->painters; executed (the execution status of this line is deduced): --d->device->painters; | - |
1899 | if (d->device->painters == 0) { partially evaluated: d->device->painters == 0 yes Evaluation Count:28773 | no Evaluation Count:0 |
| 0-28773 |
1900 | d->engine->setPaintDevice(0); executed (the execution status of this line is deduced): d->engine->setPaintDevice(0); | - |
1901 | d->engine->setActive(false); executed (the execution status of this line is deduced): d->engine->setActive(false); | - |
1902 | } executed: } Execution Count:28773 | 28773 |
1903 | } executed: } Execution Count:28773 | 28773 |
1904 | | - |
1905 | if (d->states.size() > 1) { partially evaluated: d->states.size() > 1 no Evaluation Count:0 | yes Evaluation Count:28773 |
| 0-28773 |
1906 | qWarning("QPainter::end: Painter ended with %d saved states", never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1906, __PRETTY_FUNCTION__).warning("QPainter::end: Painter ended with %d saved states", | - |
1907 | d->states.size()); never executed (the execution status of this line is deduced): d->states.size()); | - |
1908 | } | 0 |
1909 | | - |
1910 | if (d->engine->autoDestruct()) { partially evaluated: d->engine->autoDestruct() no Evaluation Count:0 | yes Evaluation Count:28773 |
| 0-28773 |
1911 | delete d->engine; never executed (the execution status of this line is deduced): delete d->engine; | - |
1912 | } | 0 |
1913 | | - |
1914 | if (d->emulationEngine) { evaluated: d->emulationEngine yes Evaluation Count:2942 | yes Evaluation Count:25831 |
| 2942-25831 |
1915 | delete d->emulationEngine; executed (the execution status of this line is deduced): delete d->emulationEngine; | - |
1916 | d->emulationEngine = 0; executed (the execution status of this line is deduced): d->emulationEngine = 0; | - |
1917 | } executed: } Execution Count:2942 | 2942 |
1918 | | - |
1919 | if (d->extended) { evaluated: d->extended yes Evaluation Count:28736 | yes Evaluation Count:37 |
| 37-28736 |
1920 | d->extended = 0; executed (the execution status of this line is deduced): d->extended = 0; | - |
1921 | } executed: } Execution Count:28736 | 28736 |
1922 | | - |
1923 | qt_cleanup_painter_state(d); executed (the execution status of this line is deduced): qt_cleanup_painter_state(d); | - |
1924 | | - |
1925 | return ended; executed: return ended; Execution Count:28773 | 28773 |
1926 | } | - |
1927 | | - |
1928 | | - |
1929 | /*! | - |
1930 | Returns the paint engine that the painter is currently operating | - |
1931 | on if the painter is active; otherwise 0. | - |
1932 | | - |
1933 | \sa isActive() | - |
1934 | */ | - |
1935 | QPaintEngine *QPainter::paintEngine() const | - |
1936 | { | - |
1937 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
1938 | return d->engine; executed: return d->engine; Execution Count:135 | 135 |
1939 | } | - |
1940 | | - |
1941 | /*! | - |
1942 | \since 4.6 | - |
1943 | | - |
1944 | Flushes the painting pipeline and prepares for the user issuing commands | - |
1945 | directly to the underlying graphics context. Must be followed by a call to | - |
1946 | endNativePainting(). | - |
1947 | | - |
1948 | Note that only the states the underlying paint engine changes will be reset | - |
1949 | to their respective default states. The states we reset may change from | - |
1950 | release to release. The following states are currently reset in the OpenGL | - |
1951 | 2 engine: | - |
1952 | | - |
1953 | \list | - |
1954 | \li blending is disabled | - |
1955 | \li the depth, stencil and scissor tests are disabled | - |
1956 | \li the active texture unit is reset to 0 | - |
1957 | \li the depth mask, depth function and the clear depth are reset to their | - |
1958 | default values | - |
1959 | \li the stencil mask, stencil operation and stencil function are reset to | - |
1960 | their default values | - |
1961 | \li the current color is reset to solid white | - |
1962 | \endlist | - |
1963 | | - |
1964 | If, for example, the OpenGL polygon mode is changed by the user inside a | - |
1965 | beginNativePaint()/endNativePainting() block, it will not be reset to the | - |
1966 | default state by endNativePainting(). Here is an example that shows | - |
1967 | intermixing of painter commands and raw OpenGL commands: | - |
1968 | | - |
1969 | \snippet code/src_gui_painting_qpainter.cpp 21 | - |
1970 | | - |
1971 | \sa endNativePainting() | - |
1972 | */ | - |
1973 | void QPainter::beginNativePainting() | - |
1974 | { | - |
1975 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
1976 | if (!d->engine) { never evaluated: !d->engine | 0 |
1977 | qWarning("QPainter::beginNativePainting: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1977, __PRETTY_FUNCTION__).warning("QPainter::beginNativePainting: Painter not active"); | - |
1978 | return; | 0 |
1979 | } | - |
1980 | | - |
1981 | if (d->extended) never evaluated: d->extended | 0 |
1982 | d->extended->beginNativePainting(); never executed: d->extended->beginNativePainting(); | 0 |
1983 | } | 0 |
1984 | | - |
1985 | /*! | - |
1986 | \since 4.6 | - |
1987 | | - |
1988 | Restores the painter after manually issuing native painting commands. Lets | - |
1989 | the painter restore any native state that it relies on before calling any | - |
1990 | other painter commands. | - |
1991 | | - |
1992 | \sa beginNativePainting() | - |
1993 | */ | - |
1994 | void QPainter::endNativePainting() | - |
1995 | { | - |
1996 | Q_D(const QPainter); never executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
1997 | if (!d->engine) { never evaluated: !d->engine | 0 |
1998 | qWarning("QPainter::beginNativePainting: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 1998, __PRETTY_FUNCTION__).warning("QPainter::beginNativePainting: Painter not active"); | - |
1999 | return; | 0 |
2000 | } | - |
2001 | | - |
2002 | if (d->extended) never evaluated: d->extended | 0 |
2003 | d->extended->endNativePainting(); never executed: d->extended->endNativePainting(); | 0 |
2004 | else | - |
2005 | d->engine->syncState(); never executed: d->engine->syncState(); | 0 |
2006 | } | - |
2007 | | - |
2008 | /*! | - |
2009 | Returns the font metrics for the painter if the painter is | - |
2010 | active. Otherwise, the return value is undefined. | - |
2011 | | - |
2012 | \sa font(), isActive(), {QPainter#Settings}{Settings} | - |
2013 | */ | - |
2014 | | - |
2015 | QFontMetrics QPainter::fontMetrics() const | - |
2016 | { | - |
2017 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2018 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
2019 | qWarning("QPainter::fontMetrics: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2019, __PRETTY_FUNCTION__).warning("QPainter::fontMetrics: Painter not active"); | - |
2020 | return QFontMetrics(QFont()); executed: return QFontMetrics(QFont()); Execution Count:1 | 1 |
2021 | } | - |
2022 | return QFontMetrics(d->state->font); executed: return QFontMetrics(d->state->font); Execution Count:1 | 1 |
2023 | } | - |
2024 | | - |
2025 | | - |
2026 | /*! | - |
2027 | Returns the font info for the painter if the painter is | - |
2028 | active. Otherwise, the return value is undefined. | - |
2029 | | - |
2030 | \sa font(), isActive(), {QPainter#Settings}{Settings} | - |
2031 | */ | - |
2032 | | - |
2033 | QFontInfo QPainter::fontInfo() const | - |
2034 | { | - |
2035 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2036 | if (!d->engine) { partially evaluated: !d->engine yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2037 | qWarning("QPainter::fontInfo: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2037, __PRETTY_FUNCTION__).warning("QPainter::fontInfo: Painter not active"); | - |
2038 | return QFontInfo(QFont()); executed: return QFontInfo(QFont()); Execution Count:1 | 1 |
2039 | } | - |
2040 | return QFontInfo(d->state->font); never executed: return QFontInfo(d->state->font); | 0 |
2041 | } | - |
2042 | | - |
2043 | /*! | - |
2044 | \since 4.2 | - |
2045 | | - |
2046 | Returns the opacity of the painter. The default value is | - |
2047 | 1. | - |
2048 | */ | - |
2049 | | - |
2050 | qreal QPainter::opacity() const | - |
2051 | { | - |
2052 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2053 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:334 |
| 1-334 |
2054 | qWarning("QPainter::opacity: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2054, __PRETTY_FUNCTION__).warning("QPainter::opacity: Painter not active"); | - |
2055 | return 1.0; executed: return 1.0; Execution Count:1 | 1 |
2056 | } | - |
2057 | return d->state->opacity; executed: return d->state->opacity; Execution Count:334 | 334 |
2058 | } | - |
2059 | | - |
2060 | /*! | - |
2061 | \since 4.2 | - |
2062 | | - |
2063 | Sets the opacity of the painter to \a opacity. The value should | - |
2064 | be in the range 0.0 to 1.0, where 0.0 is fully transparent and | - |
2065 | 1.0 is fully opaque. | - |
2066 | | - |
2067 | Opacity set on the painter will apply to all drawing operations | - |
2068 | individually. | - |
2069 | */ | - |
2070 | | - |
2071 | void QPainter::setOpacity(qreal opacity) | - |
2072 | { | - |
2073 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
2074 | | - |
2075 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:3208 |
| 1-3208 |
2076 | qWarning("QPainter::setOpacity: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2076, __PRETTY_FUNCTION__).warning("QPainter::setOpacity: Painter not active"); | - |
2077 | return; executed: return; Execution Count:1 | 1 |
2078 | } | - |
2079 | | - |
2080 | opacity = qMin(qreal(1), qMax(qreal(0), opacity)); executed (the execution status of this line is deduced): opacity = qMin(qreal(1), qMax(qreal(0), opacity)); | - |
2081 | | - |
2082 | if (opacity == d->state->opacity) evaluated: opacity == d->state->opacity yes Evaluation Count:2792 | yes Evaluation Count:416 |
| 416-2792 |
2083 | return; executed: return; Execution Count:2792 | 2792 |
2084 | | - |
2085 | d->state->opacity = opacity; executed (the execution status of this line is deduced): d->state->opacity = opacity; | - |
2086 | | - |
2087 | if (d->extended) partially evaluated: d->extended yes Evaluation Count:416 | no Evaluation Count:0 |
| 0-416 |
2088 | d->extended->opacityChanged(); executed: d->extended->opacityChanged(); Execution Count:416 | 416 |
2089 | else | - |
2090 | d->state->dirtyFlags |= QPaintEngine::DirtyOpacity; never executed: d->state->dirtyFlags |= QPaintEngine::DirtyOpacity; | 0 |
2091 | } | - |
2092 | | - |
2093 | | - |
2094 | /*! | - |
2095 | Returns the currently set brush origin. | - |
2096 | | - |
2097 | \sa setBrushOrigin(), {QPainter#Settings}{Settings} | - |
2098 | */ | - |
2099 | | - |
2100 | QPoint QPainter::brushOrigin() const | - |
2101 | { | - |
2102 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2103 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:11546 |
| 1-11546 |
2104 | qWarning("QPainter::brushOrigin: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2104, __PRETTY_FUNCTION__).warning("QPainter::brushOrigin: Painter not active"); | - |
2105 | return QPoint(); executed: return QPoint(); Execution Count:1 | 1 |
2106 | } | - |
2107 | return QPointF(d->state->brushOrigin).toPoint(); executed: return QPointF(d->state->brushOrigin).toPoint(); Execution Count:11546 | 11546 |
2108 | } | - |
2109 | | - |
2110 | /*! | - |
2111 | \fn void QPainter::setBrushOrigin(const QPointF &position) | - |
2112 | | - |
2113 | Sets the brush origin to \a position. | - |
2114 | | - |
2115 | The brush origin specifies the (0, 0) coordinate of the painter's | - |
2116 | brush. | - |
2117 | | - |
2118 | Note that while the brushOrigin() was necessary to adopt the | - |
2119 | parent's background for a widget in Qt 3, this is no longer the | - |
2120 | case since the Qt 4 painter doesn't paint the background unless | - |
2121 | you explicitly tell it to do so by setting the widget's \l | - |
2122 | {QWidget::autoFillBackground}{autoFillBackground} property to | - |
2123 | true. | - |
2124 | | - |
2125 | \sa brushOrigin(), {QPainter#Settings}{Settings} | - |
2126 | */ | - |
2127 | | - |
2128 | void QPainter::setBrushOrigin(const QPointF &p) | - |
2129 | { | - |
2130 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
2131 | #ifdef QT_DEBUG_DRAW | - |
2132 | if (qt_show_painter_debug_output) | - |
2133 | printf("QPainter::setBrushOrigin(), (%.2f,%.2f)\n", p.x(), p.y()); | - |
2134 | #endif | - |
2135 | | - |
2136 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:2 | yes Evaluation Count:21057 |
| 2-21057 |
2137 | qWarning("QPainter::setBrushOrigin: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2137, __PRETTY_FUNCTION__).warning("QPainter::setBrushOrigin: Painter not active"); | - |
2138 | return; executed: return; Execution Count:2 | 2 |
2139 | } | - |
2140 | | - |
2141 | d->state->brushOrigin = p; executed (the execution status of this line is deduced): d->state->brushOrigin = p; | - |
2142 | | - |
2143 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:21057 | no Evaluation Count:0 |
| 0-21057 |
2144 | d->extended->brushOriginChanged(); executed (the execution status of this line is deduced): d->extended->brushOriginChanged(); | - |
2145 | return; executed: return; Execution Count:21057 | 21057 |
2146 | } | - |
2147 | | - |
2148 | d->state->dirtyFlags |= QPaintEngine::DirtyBrushOrigin; never executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyBrushOrigin; | - |
2149 | } | 0 |
2150 | | - |
2151 | /*! | - |
2152 | \fn void QPainter::setBrushOrigin(const QPoint &position) | - |
2153 | \overload | - |
2154 | | - |
2155 | Sets the brush's origin to the given \a position. | - |
2156 | */ | - |
2157 | | - |
2158 | /*! | - |
2159 | \fn void QPainter::setBrushOrigin(int x, int y) | - |
2160 | | - |
2161 | \overload | - |
2162 | | - |
2163 | Sets the brush's origin to point (\a x, \a y). | - |
2164 | */ | - |
2165 | | - |
2166 | /*! | - |
2167 | \enum QPainter::CompositionMode | - |
2168 | | - |
2169 | Defines the modes supported for digital image compositing. | - |
2170 | Composition modes are used to specify how the pixels in one image, | - |
2171 | the source, are merged with the pixel in another image, the | - |
2172 | destination. | - |
2173 | | - |
2174 | Please note that the bitwise raster operation modes, denoted with | - |
2175 | a RasterOp prefix, are only natively supported in the X11 and | - |
2176 | raster paint engines. This means that the only way to utilize | - |
2177 | these modes on the Mac is via a QImage. The RasterOp denoted blend | - |
2178 | modes are \e not supported for pens and brushes with alpha | - |
2179 | components. Also, turning on the QPainter::Antialiasing render | - |
2180 | hint will effectively disable the RasterOp modes. | - |
2181 | | - |
2182 | | - |
2183 | \image qpainter-compositionmode1.png | - |
2184 | \image qpainter-compositionmode2.png | - |
2185 | | - |
2186 | The most common type is SourceOver (often referred to as just | - |
2187 | alpha blending) where the source pixel is blended on top of the | - |
2188 | destination pixel in such a way that the alpha component of the | - |
2189 | source defines the translucency of the pixel. | - |
2190 | | - |
2191 | When the paint device is a QImage, the image format must be set to | - |
2192 | \l {QImage::Format}{Format_ARGB32_Premultiplied} or | - |
2193 | \l {QImage::Format}{Format_ARGB32} for the composition modes to have | - |
2194 | any effect. For performance the premultiplied version is the preferred | - |
2195 | format. | - |
2196 | | - |
2197 | When a composition mode is set it applies to all painting | - |
2198 | operator, pens, brushes, gradients and pixmap/image drawing. | - |
2199 | | - |
2200 | \value CompositionMode_SourceOver This is the default mode. The | - |
2201 | alpha of the source is used to blend the pixel on top of the | - |
2202 | destination. | - |
2203 | | - |
2204 | \value CompositionMode_DestinationOver The alpha of the | - |
2205 | destination is used to blend it on top of the source pixels. This | - |
2206 | mode is the inverse of CompositionMode_SourceOver. | - |
2207 | | - |
2208 | \value CompositionMode_Clear The pixels in the destination are | - |
2209 | cleared (set to fully transparent) independent of the source. | - |
2210 | | - |
2211 | \value CompositionMode_Source The output is the source | - |
2212 | pixel. (This means a basic copy operation and is identical to | - |
2213 | SourceOver when the source pixel is opaque). | - |
2214 | | - |
2215 | \value CompositionMode_Destination The output is the destination | - |
2216 | pixel. This means that the blending has no effect. This mode is | - |
2217 | the inverse of CompositionMode_Source. | - |
2218 | | - |
2219 | \value CompositionMode_SourceIn The output is the source, where | - |
2220 | the alpha is reduced by that of the destination. | - |
2221 | | - |
2222 | \value CompositionMode_DestinationIn The output is the | - |
2223 | destination, where the alpha is reduced by that of the | - |
2224 | source. This mode is the inverse of CompositionMode_SourceIn. | - |
2225 | | - |
2226 | \value CompositionMode_SourceOut The output is the source, where | - |
2227 | the alpha is reduced by the inverse of destination. | - |
2228 | | - |
2229 | \value CompositionMode_DestinationOut The output is the | - |
2230 | destination, where the alpha is reduced by the inverse of the | - |
2231 | source. This mode is the inverse of CompositionMode_SourceOut. | - |
2232 | | - |
2233 | \value CompositionMode_SourceAtop The source pixel is blended on | - |
2234 | top of the destination, with the alpha of the source pixel reduced | - |
2235 | by the alpha of the destination pixel. | - |
2236 | | - |
2237 | \value CompositionMode_DestinationAtop The destination pixel is | - |
2238 | blended on top of the source, with the alpha of the destination | - |
2239 | pixel is reduced by the alpha of the destination pixel. This mode | - |
2240 | is the inverse of CompositionMode_SourceAtop. | - |
2241 | | - |
2242 | \value CompositionMode_Xor The source, whose alpha is reduced with | - |
2243 | the inverse of the destination alpha, is merged with the | - |
2244 | destination, whose alpha is reduced by the inverse of the source | - |
2245 | alpha. CompositionMode_Xor is not the same as the bitwise Xor. | - |
2246 | | - |
2247 | \value CompositionMode_Plus Both the alpha and color of the source | - |
2248 | and destination pixels are added together. | - |
2249 | | - |
2250 | \value CompositionMode_Multiply The output is the source color | - |
2251 | multiplied by the destination. Multiplying a color with white | - |
2252 | leaves the color unchanged, while multiplying a color | - |
2253 | with black produces black. | - |
2254 | | - |
2255 | \value CompositionMode_Screen The source and destination colors | - |
2256 | are inverted and then multiplied. Screening a color with white | - |
2257 | produces white, whereas screening a color with black leaves the | - |
2258 | color unchanged. | - |
2259 | | - |
2260 | \value CompositionMode_Overlay Multiplies or screens the colors | - |
2261 | depending on the destination color. The destination color is mixed | - |
2262 | with the source color to reflect the lightness or darkness of the | - |
2263 | destination. | - |
2264 | | - |
2265 | \value CompositionMode_Darken The darker of the source and | - |
2266 | destination colors is selected. | - |
2267 | | - |
2268 | \value CompositionMode_Lighten The lighter of the source and | - |
2269 | destination colors is selected. | - |
2270 | | - |
2271 | \value CompositionMode_ColorDodge The destination color is | - |
2272 | brightened to reflect the source color. A black source color | - |
2273 | leaves the destination color unchanged. | - |
2274 | | - |
2275 | \value CompositionMode_ColorBurn The destination color is darkened | - |
2276 | to reflect the source color. A white source color leaves the | - |
2277 | destination color unchanged. | - |
2278 | | - |
2279 | \value CompositionMode_HardLight Multiplies or screens the colors | - |
2280 | depending on the source color. A light source color will lighten | - |
2281 | the destination color, whereas a dark source color will darken the | - |
2282 | destination color. | - |
2283 | | - |
2284 | \value CompositionMode_SoftLight Darkens or lightens the colors | - |
2285 | depending on the source color. Similar to | - |
2286 | CompositionMode_HardLight. | - |
2287 | | - |
2288 | \value CompositionMode_Difference Subtracts the darker of the | - |
2289 | colors from the lighter. Painting with white inverts the | - |
2290 | destination color, whereas painting with black leaves the | - |
2291 | destination color unchanged. | - |
2292 | | - |
2293 | \value CompositionMode_Exclusion Similar to | - |
2294 | CompositionMode_Difference, but with a lower contrast. Painting | - |
2295 | with white inverts the destination color, whereas painting with | - |
2296 | black leaves the destination color unchanged. | - |
2297 | | - |
2298 | \value RasterOp_SourceOrDestination Does a bitwise OR operation on | - |
2299 | the source and destination pixels (src OR dst). | - |
2300 | | - |
2301 | \value RasterOp_SourceAndDestination Does a bitwise AND operation | - |
2302 | on the source and destination pixels (src AND dst). | - |
2303 | | - |
2304 | \value RasterOp_SourceXorDestination Does a bitwise XOR operation | - |
2305 | on the source and destination pixels (src XOR dst). | - |
2306 | | - |
2307 | \value RasterOp_NotSourceAndNotDestination Does a bitwise NOR | - |
2308 | operation on the source and destination pixels ((NOT src) AND (NOT | - |
2309 | dst)). | - |
2310 | | - |
2311 | \value RasterOp_NotSourceOrNotDestination Does a bitwise NAND | - |
2312 | operation on the source and destination pixels ((NOT src) OR (NOT | - |
2313 | dst)). | - |
2314 | | - |
2315 | \value RasterOp_NotSourceXorDestination Does a bitwise operation | - |
2316 | where the source pixels are inverted and then XOR'ed with the | - |
2317 | destination ((NOT src) XOR dst). | - |
2318 | | - |
2319 | \value RasterOp_NotSource Does a bitwise operation where the | - |
2320 | source pixels are inverted (NOT src). | - |
2321 | | - |
2322 | \value RasterOp_NotSourceAndDestination Does a bitwise operation | - |
2323 | where the source is inverted and then AND'ed with the destination | - |
2324 | ((NOT src) AND dst). | - |
2325 | | - |
2326 | \value RasterOp_SourceAndNotDestination Does a bitwise operation | - |
2327 | where the source is AND'ed with the inverted destination pixels | - |
2328 | (src AND (NOT dst)). | - |
2329 | | - |
2330 | \value RasterOp_NotSourceOrDestination Does a bitwise operation | - |
2331 | where the source is inverted and then OR'ed with the destination | - |
2332 | ((NOT src) OR dst). | - |
2333 | | - |
2334 | \value RasterOp_ClearDestination The pixels in the destination are | - |
2335 | cleared (set to 0) independent of the source. | - |
2336 | | - |
2337 | \value RasterOp_SetDestination The pixels in the destination are | - |
2338 | set (set to 1) independent of the source. | - |
2339 | | - |
2340 | \value RasterOp_NotDestination Does a bitwise operation | - |
2341 | where the destination pixels are inverted (NOT dst). | - |
2342 | | - |
2343 | \value RasterOp_SourceOrNotDestination Does a bitwise operation | - |
2344 | where the source is OR'ed with the inverted destination pixels | - |
2345 | (src OR (NOT dst)). | - |
2346 | | - |
2347 | \sa compositionMode(), setCompositionMode(), {QPainter#Composition | - |
2348 | Modes}{Composition Modes}, {Image Composition Example} | - |
2349 | */ | - |
2350 | | - |
2351 | /*! | - |
2352 | Sets the composition mode to the given \a mode. | - |
2353 | | - |
2354 | \warning Only a QPainter operating on a QImage fully supports all | - |
2355 | composition modes. The RasterOp modes are supported for X11 as | - |
2356 | described in compositionMode(). | - |
2357 | | - |
2358 | \sa compositionMode() | - |
2359 | */ | - |
2360 | void QPainter::setCompositionMode(CompositionMode mode) | - |
2361 | { | - |
2362 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
2363 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:6989 |
| 1-6989 |
2364 | qWarning("QPainter::setCompositionMode: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2364, __PRETTY_FUNCTION__).warning("QPainter::setCompositionMode: Painter not active"); | - |
2365 | return; executed: return; Execution Count:1 | 1 |
2366 | } | - |
2367 | if (d->state->composition_mode == mode) evaluated: d->state->composition_mode == mode yes Evaluation Count:1 | yes Evaluation Count:6988 |
| 1-6988 |
2368 | return; executed: return; Execution Count:1 | 1 |
2369 | if (d->extended) { evaluated: d->extended yes Evaluation Count:6985 | yes Evaluation Count:3 |
| 3-6985 |
2370 | d->state->composition_mode = mode; executed (the execution status of this line is deduced): d->state->composition_mode = mode; | - |
2371 | d->extended->compositionModeChanged(); executed (the execution status of this line is deduced): d->extended->compositionModeChanged(); | - |
2372 | return; executed: return; Execution Count:6985 | 6985 |
2373 | } | - |
2374 | | - |
2375 | if (mode >= QPainter::RasterOp_SourceOrDestination) { partially evaluated: mode >= QPainter::RasterOp_SourceOrDestination no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
2376 | if (!d->engine->hasFeature(QPaintEngine::RasterOpModes)) { never evaluated: !d->engine->hasFeature(QPaintEngine::RasterOpModes) | 0 |
2377 | qWarning("QPainter::setCompositionMode: " never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2377, __PRETTY_FUNCTION__).warning("QPainter::setCompositionMode: " | - |
2378 | "Raster operation modes not supported on device"); never executed (the execution status of this line is deduced): "Raster operation modes not supported on device"); | - |
2379 | return; | 0 |
2380 | } | - |
2381 | } else if (mode >= QPainter::CompositionMode_Plus) { never executed: } partially evaluated: mode >= QPainter::CompositionMode_Plus no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
2382 | if (!d->engine->hasFeature(QPaintEngine::BlendModes)) { never evaluated: !d->engine->hasFeature(QPaintEngine::BlendModes) | 0 |
2383 | qWarning("QPainter::setCompositionMode: " never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2383, __PRETTY_FUNCTION__).warning("QPainter::setCompositionMode: " | - |
2384 | "Blend modes not supported on device"); never executed (the execution status of this line is deduced): "Blend modes not supported on device"); | - |
2385 | return; | 0 |
2386 | } | - |
2387 | } else if (!d->engine->hasFeature(QPaintEngine::PorterDuff)) { never executed: } partially evaluated: !d->engine->hasFeature(QPaintEngine::PorterDuff) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2388 | if (mode != CompositionMode_Source && mode != CompositionMode_SourceOver) { evaluated: mode != CompositionMode_Source yes Evaluation Count:2 | yes Evaluation Count:1 |
evaluated: mode != CompositionMode_SourceOver yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-2 |
2389 | qWarning("QPainter::setCompositionMode: " executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2389, __PRETTY_FUNCTION__).warning("QPainter::setCompositionMode: " | - |
2390 | "PorterDuff modes not supported on device"); executed (the execution status of this line is deduced): "PorterDuff modes not supported on device"); | - |
2391 | return; executed: return; Execution Count:1 | 1 |
2392 | } | - |
2393 | } executed: } Execution Count:2 | 2 |
2394 | | - |
2395 | d->state->composition_mode = mode; executed (the execution status of this line is deduced): d->state->composition_mode = mode; | - |
2396 | d->state->dirtyFlags |= QPaintEngine::DirtyCompositionMode; executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyCompositionMode; | - |
2397 | } executed: } Execution Count:2 | 2 |
2398 | | - |
2399 | /*! | - |
2400 | Returns the current composition mode. | - |
2401 | | - |
2402 | \sa CompositionMode, setCompositionMode() | - |
2403 | */ | - |
2404 | QPainter::CompositionMode QPainter::compositionMode() const | - |
2405 | { | - |
2406 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2407 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:3374 |
| 1-3374 |
2408 | qWarning("QPainter::compositionMode: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2408, __PRETTY_FUNCTION__).warning("QPainter::compositionMode: Painter not active"); | - |
2409 | return QPainter::CompositionMode_SourceOver; executed: return QPainter::CompositionMode_SourceOver; Execution Count:1 | 1 |
2410 | } | - |
2411 | return d->state->composition_mode; executed: return d->state->composition_mode; Execution Count:3374 | 3374 |
2412 | } | - |
2413 | | - |
2414 | /*! | - |
2415 | Returns the current background brush. | - |
2416 | | - |
2417 | \sa setBackground(), {QPainter#Settings}{Settings} | - |
2418 | */ | - |
2419 | | - |
2420 | const QBrush &QPainter::background() const | - |
2421 | { | - |
2422 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2423 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:5304 |
| 1-5304 |
2424 | qWarning("QPainter::background: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2424, __PRETTY_FUNCTION__).warning("QPainter::background: Painter not active"); | - |
2425 | return d->fakeState()->brush; executed: return d->fakeState()->brush; Execution Count:1 | 1 |
2426 | } | - |
2427 | return d->state->bgBrush; executed: return d->state->bgBrush; Execution Count:5304 | 5304 |
2428 | } | - |
2429 | | - |
2430 | | - |
2431 | /*! | - |
2432 | Returns true if clipping has been set; otherwise returns false. | - |
2433 | | - |
2434 | \sa setClipping(), {QPainter#Clipping}{Clipping} | - |
2435 | */ | - |
2436 | | - |
2437 | bool QPainter::hasClipping() const | - |
2438 | { | - |
2439 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2440 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:45 |
| 1-45 |
2441 | qWarning("QPainter::hasClipping: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2441, __PRETTY_FUNCTION__).warning("QPainter::hasClipping: Painter not active"); | - |
2442 | return false; executed: return false; Execution Count:1 | 1 |
2443 | } | - |
2444 | return d->state->clipEnabled && d->state->clipOperation != Qt::NoClip; executed: return d->state->clipEnabled && d->state->clipOperation != Qt::NoClip; Execution Count:45 | 45 |
2445 | } | - |
2446 | | - |
2447 | | - |
2448 | /*! | - |
2449 | Enables clipping if \a enable is true, or disables clipping if \a | - |
2450 | enable is false. | - |
2451 | | - |
2452 | \sa hasClipping(), {QPainter#Clipping}{Clipping} | - |
2453 | */ | - |
2454 | | - |
2455 | void QPainter::setClipping(bool enable) | - |
2456 | { | - |
2457 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
2458 | #ifdef QT_DEBUG_DRAW | - |
2459 | if (qt_show_painter_debug_output) | - |
2460 | printf("QPainter::setClipping(), enable=%s, was=%s\n", | - |
2461 | enable ? "on" : "off", | - |
2462 | hasClipping() ? "on" : "off"); | - |
2463 | #endif | - |
2464 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
2465 | qWarning("QPainter::setClipping: Painter not active, state will be reset by begin"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2465, __PRETTY_FUNCTION__).warning("QPainter::setClipping: Painter not active, state will be reset by begin"); | - |
2466 | return; executed: return; Execution Count:1 | 1 |
2467 | } | - |
2468 | | - |
2469 | if (hasClipping() == enable) partially evaluated: hasClipping() == enable no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
2470 | return; | 0 |
2471 | | - |
2472 | // we can't enable clipping if we don't have a clip | - |
2473 | if (enable evaluated: enable yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
2474 | && (d->state->clipInfo.isEmpty() || d->state->clipInfo.last().operation == Qt::NoClip)) partially evaluated: d->state->clipInfo.isEmpty() no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: d->state->clipInfo.last().operation == Qt::NoClip no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2475 | return; | 0 |
2476 | d->state->clipEnabled = enable; executed (the execution status of this line is deduced): d->state->clipEnabled = enable; | - |
2477 | | - |
2478 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
2479 | d->extended->clipEnabledChanged(); executed (the execution status of this line is deduced): d->extended->clipEnabledChanged(); | - |
2480 | return; executed: return; Execution Count:4 | 4 |
2481 | } | - |
2482 | | - |
2483 | d->state->dirtyFlags |= QPaintEngine::DirtyClipEnabled; never executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyClipEnabled; | - |
2484 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
2485 | } | 0 |
2486 | | - |
2487 | | - |
2488 | /*! | - |
2489 | Returns the currently set clip region. Note that the clip region | - |
2490 | is given in logical coordinates. | - |
2491 | | - |
2492 | \warning QPainter does not store the combined clip explicitly as | - |
2493 | this is handled by the underlying QPaintEngine, so the path is | - |
2494 | recreated on demand and transformed to the current logical | - |
2495 | coordinate system. This is potentially an expensive operation. | - |
2496 | | - |
2497 | \sa setClipRegion(), clipPath(), setClipping() | - |
2498 | */ | - |
2499 | | - |
2500 | QRegion QPainter::clipRegion() const | - |
2501 | { | - |
2502 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2503 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:2118 |
| 1-2118 |
2504 | qWarning("QPainter::clipRegion: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2504, __PRETTY_FUNCTION__).warning("QPainter::clipRegion: Painter not active"); | - |
2505 | return QRegion(); executed: return QRegion(); Execution Count:1 | 1 |
2506 | } | - |
2507 | | - |
2508 | QRegion region; executed (the execution status of this line is deduced): QRegion region; | - |
2509 | bool lastWasNothing = true; executed (the execution status of this line is deduced): bool lastWasNothing = true; | - |
2510 | | - |
2511 | if (!d->txinv) evaluated: !d->txinv yes Evaluation Count:2115 | yes Evaluation Count:3 |
| 3-2115 |
2512 | const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); Execution Count:2115 | 2115 |
2513 | | - |
2514 | // ### Falcon: Use QPainterPath | - |
2515 | for (int i=0; i<d->state->clipInfo.size(); ++i) { evaluated: i<d->state->clipInfo.size() yes Evaluation Count:6 | yes Evaluation Count:2118 |
| 6-2118 |
2516 | const QPainterClipInfo &info = d->state->clipInfo.at(i); executed (the execution status of this line is deduced): const QPainterClipInfo &info = d->state->clipInfo.at(i); | - |
2517 | switch (info.clipType) { | - |
2518 | | - |
2519 | case QPainterClipInfo::RegionClip: { | - |
2520 | QTransform matrix = (info.matrix * d->invMatrix); executed (the execution status of this line is deduced): QTransform matrix = (info.matrix * d->invMatrix); | - |
2521 | if (lastWasNothing) { partially evaluated: lastWasNothing yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2522 | region = info.region * matrix; executed (the execution status of this line is deduced): region = info.region * matrix; | - |
2523 | lastWasNothing = false; executed (the execution status of this line is deduced): lastWasNothing = false; | - |
2524 | continue; executed: continue; Execution Count:2 | 2 |
2525 | } | - |
2526 | if (info.operation == Qt::IntersectClip) never evaluated: info.operation == Qt::IntersectClip | 0 |
2527 | region &= info.region * matrix; never executed: region &= info.region * matrix; | 0 |
2528 | else if (info.operation == Qt::NoClip) { never evaluated: info.operation == Qt::NoClip | 0 |
2529 | lastWasNothing = true; never executed (the execution status of this line is deduced): lastWasNothing = true; | - |
2530 | region = QRegion(); never executed (the execution status of this line is deduced): region = QRegion(); | - |
2531 | } else | 0 |
2532 | region = info.region * matrix; never executed: region = info.region * matrix; | 0 |
2533 | break; | 0 |
2534 | } | - |
2535 | | - |
2536 | case QPainterClipInfo::PathClip: { | - |
2537 | QTransform matrix = (info.matrix * d->invMatrix); never executed (the execution status of this line is deduced): QTransform matrix = (info.matrix * d->invMatrix); | - |
2538 | if (lastWasNothing) { never evaluated: lastWasNothing | 0 |
2539 | region = QRegion((info.path * matrix).toFillPolygon().toPolygon(), never executed (the execution status of this line is deduced): region = QRegion((info.path * matrix).toFillPolygon().toPolygon(), | - |
2540 | info.path.fillRule()); never executed (the execution status of this line is deduced): info.path.fillRule()); | - |
2541 | lastWasNothing = false; never executed (the execution status of this line is deduced): lastWasNothing = false; | - |
2542 | continue; never executed: continue; | 0 |
2543 | } | - |
2544 | if (info.operation == Qt::IntersectClip) { never evaluated: info.operation == Qt::IntersectClip | 0 |
2545 | region &= QRegion((info.path * matrix).toFillPolygon().toPolygon(), never executed (the execution status of this line is deduced): region &= QRegion((info.path * matrix).toFillPolygon().toPolygon(), | - |
2546 | info.path.fillRule()); never executed (the execution status of this line is deduced): info.path.fillRule()); | - |
2547 | } else if (info.operation == Qt::NoClip) { never executed: } never evaluated: info.operation == Qt::NoClip | 0 |
2548 | lastWasNothing = true; never executed (the execution status of this line is deduced): lastWasNothing = true; | - |
2549 | region = QRegion(); never executed (the execution status of this line is deduced): region = QRegion(); | - |
2550 | } else { | 0 |
2551 | region = QRegion((info.path * matrix).toFillPolygon().toPolygon(), never executed (the execution status of this line is deduced): region = QRegion((info.path * matrix).toFillPolygon().toPolygon(), | - |
2552 | info.path.fillRule()); never executed (the execution status of this line is deduced): info.path.fillRule()); | - |
2553 | } | 0 |
2554 | break; | 0 |
2555 | } | - |
2556 | | - |
2557 | case QPainterClipInfo::RectClip: { | - |
2558 | QTransform matrix = (info.matrix * d->invMatrix); executed (the execution status of this line is deduced): QTransform matrix = (info.matrix * d->invMatrix); | - |
2559 | if (lastWasNothing) { partially evaluated: lastWasNothing yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2560 | region = QRegion(info.rect) * matrix; executed (the execution status of this line is deduced): region = QRegion(info.rect) * matrix; | - |
2561 | lastWasNothing = false; executed (the execution status of this line is deduced): lastWasNothing = false; | - |
2562 | continue; executed: continue; Execution Count:2 | 2 |
2563 | } | - |
2564 | if (info.operation == Qt::IntersectClip) { never evaluated: info.operation == Qt::IntersectClip | 0 |
2565 | // Use rect intersection if possible. | - |
2566 | if (matrix.type() <= QTransform::TxScale) never evaluated: matrix.type() <= QTransform::TxScale | 0 |
2567 | region &= matrix.mapRect(info.rect); never executed: region &= matrix.mapRect(info.rect); | 0 |
2568 | else | - |
2569 | region &= matrix.map(QRegion(info.rect)); never executed: region &= matrix.map(QRegion(info.rect)); | 0 |
2570 | } else if (info.operation == Qt::NoClip) { never evaluated: info.operation == Qt::NoClip | 0 |
2571 | lastWasNothing = true; never executed (the execution status of this line is deduced): lastWasNothing = true; | - |
2572 | region = QRegion(); never executed (the execution status of this line is deduced): region = QRegion(); | - |
2573 | } else { | 0 |
2574 | region = QRegion(info.rect) * matrix; never executed (the execution status of this line is deduced): region = QRegion(info.rect) * matrix; | - |
2575 | } | 0 |
2576 | break; | 0 |
2577 | } | - |
2578 | | - |
2579 | case QPainterClipInfo::RectFClip: { | - |
2580 | QTransform matrix = (info.matrix * d->invMatrix); executed (the execution status of this line is deduced): QTransform matrix = (info.matrix * d->invMatrix); | - |
2581 | if (lastWasNothing) { partially evaluated: lastWasNothing yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2582 | region = QRegion(info.rectf.toRect()) * matrix; executed (the execution status of this line is deduced): region = QRegion(info.rectf.toRect()) * matrix; | - |
2583 | lastWasNothing = false; executed (the execution status of this line is deduced): lastWasNothing = false; | - |
2584 | continue; executed: continue; Execution Count:2 | 2 |
2585 | } | - |
2586 | if (info.operation == Qt::IntersectClip) { never evaluated: info.operation == Qt::IntersectClip | 0 |
2587 | // Use rect intersection if possible. | - |
2588 | if (matrix.type() <= QTransform::TxScale) never evaluated: matrix.type() <= QTransform::TxScale | 0 |
2589 | region &= matrix.mapRect(info.rectf.toRect()); never executed: region &= matrix.mapRect(info.rectf.toRect()); | 0 |
2590 | else | - |
2591 | region &= matrix.map(QRegion(info.rectf.toRect())); never executed: region &= matrix.map(QRegion(info.rectf.toRect())); | 0 |
2592 | } else if (info.operation == Qt::NoClip) { never evaluated: info.operation == Qt::NoClip | 0 |
2593 | lastWasNothing = true; never executed (the execution status of this line is deduced): lastWasNothing = true; | - |
2594 | region = QRegion(); never executed (the execution status of this line is deduced): region = QRegion(); | - |
2595 | } else { | 0 |
2596 | region = QRegion(info.rectf.toRect()) * matrix; never executed (the execution status of this line is deduced): region = QRegion(info.rectf.toRect()) * matrix; | - |
2597 | } | 0 |
2598 | break; | 0 |
2599 | } | - |
2600 | } | - |
2601 | } | 0 |
2602 | | - |
2603 | return region; executed: return region; Execution Count:2118 | 2118 |
2604 | } | - |
2605 | | - |
2606 | extern QPainterPath qt_regionToPath(const QRegion ®ion); | - |
2607 | | - |
2608 | /*! | - |
2609 | Returns the currently clip as a path. Note that the clip path is | - |
2610 | given in logical coordinates. | - |
2611 | | - |
2612 | \warning QPainter does not store the combined clip explicitly as | - |
2613 | this is handled by the underlying QPaintEngine, so the path is | - |
2614 | recreated on demand and transformed to the current logical | - |
2615 | coordinate system. This is potentially an expensive operation. | - |
2616 | | - |
2617 | \sa setClipPath(), clipRegion(), setClipping() | - |
2618 | */ | - |
2619 | QPainterPath QPainter::clipPath() const | - |
2620 | { | - |
2621 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2622 | | - |
2623 | // ### Since we do not support path intersections and path unions yet, | - |
2624 | // we just use clipRegion() here... | - |
2625 | if (!d->engine) { partially evaluated: !d->engine yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2626 | qWarning("QPainter::clipPath: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2626, __PRETTY_FUNCTION__).warning("QPainter::clipPath: Painter not active"); | - |
2627 | return QPainterPath(); executed: return QPainterPath(); Execution Count:1 | 1 |
2628 | } | - |
2629 | | - |
2630 | // No clip, return empty | - |
2631 | if (d->state->clipInfo.size() == 0) { never evaluated: d->state->clipInfo.size() == 0 | 0 |
2632 | return QPainterPath(); never executed: return QPainterPath(); | 0 |
2633 | } else { | - |
2634 | | - |
2635 | // Update inverse matrix, used below. | - |
2636 | if (!d->txinv) never evaluated: !d->txinv | 0 |
2637 | const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); | 0 |
2638 | | - |
2639 | // For the simple case avoid conversion. | - |
2640 | if (d->state->clipInfo.size() == 1 never evaluated: d->state->clipInfo.size() == 1 | 0 |
2641 | && d->state->clipInfo.at(0).clipType == QPainterClipInfo::PathClip) { never evaluated: d->state->clipInfo.at(0).clipType == QPainterClipInfo::PathClip | 0 |
2642 | QTransform matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix); never executed (the execution status of this line is deduced): QTransform matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix); | - |
2643 | return d->state->clipInfo.at(0).path * matrix; never executed: return d->state->clipInfo.at(0).path * matrix; | 0 |
2644 | | - |
2645 | } else if (d->state->clipInfo.size() == 1 never evaluated: d->state->clipInfo.size() == 1 | 0 |
2646 | && d->state->clipInfo.at(0).clipType == QPainterClipInfo::RectClip) { never evaluated: d->state->clipInfo.at(0).clipType == QPainterClipInfo::RectClip | 0 |
2647 | QTransform matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix); never executed (the execution status of this line is deduced): QTransform matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix); | - |
2648 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
2649 | path.addRect(d->state->clipInfo.at(0).rect); never executed (the execution status of this line is deduced): path.addRect(d->state->clipInfo.at(0).rect); | - |
2650 | return path * matrix; never executed: return path * matrix; | 0 |
2651 | } else { | - |
2652 | // Fallback to clipRegion() for now, since we don't have isect/unite for paths | - |
2653 | return qt_regionToPath(clipRegion()); never executed: return qt_regionToPath(clipRegion()); | 0 |
2654 | } | - |
2655 | } | - |
2656 | } | - |
2657 | | - |
2658 | /*! | - |
2659 | Returns the bounding rectangle of the current clip if there is a clip; | - |
2660 | otherwise returns an empty rectangle. Note that the clip region is | - |
2661 | given in logical coordinates. | - |
2662 | | - |
2663 | The bounding rectangle is not guaranteed to be tight. | - |
2664 | | - |
2665 | \sa setClipRect(), setClipPath(), setClipRegion() | - |
2666 | | - |
2667 | \since 4.8 | - |
2668 | */ | - |
2669 | | - |
2670 | QRectF QPainter::clipBoundingRect() const | - |
2671 | { | - |
2672 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2673 | | - |
2674 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
2675 | qWarning("QPainter::clipBoundingRect: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2675, __PRETTY_FUNCTION__).warning("QPainter::clipBoundingRect: Painter not active"); | - |
2676 | return QRectF(); never executed: return QRectF(); | 0 |
2677 | } | - |
2678 | | - |
2679 | // Accumulate the bounding box in device space. This is not 100% | - |
2680 | // precise, but it fits within the guarantee and it is reasonably | - |
2681 | // fast. | - |
2682 | QRectF bounds; executed (the execution status of this line is deduced): QRectF bounds; | - |
2683 | for (int i=0; i<d->state->clipInfo.size(); ++i) { evaluated: i<d->state->clipInfo.size() yes Evaluation Count:740 | yes Evaluation Count:14 |
| 14-740 |
2684 | QRectF r; executed (the execution status of this line is deduced): QRectF r; | - |
2685 | const QPainterClipInfo &info = d->state->clipInfo.at(i); executed (the execution status of this line is deduced): const QPainterClipInfo &info = d->state->clipInfo.at(i); | - |
2686 | | - |
2687 | if (info.clipType == QPainterClipInfo::RectClip) evaluated: info.clipType == QPainterClipInfo::RectClip yes Evaluation Count:728 | yes Evaluation Count:12 |
| 12-728 |
2688 | r = info.rect; executed: r = info.rect; Execution Count:728 | 728 |
2689 | else if (info.clipType == QPainterClipInfo::RectFClip) evaluated: info.clipType == QPainterClipInfo::RectFClip yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
2690 | r = info.rectf; executed: r = info.rectf; Execution Count:6 | 6 |
2691 | else if (info.clipType == QPainterClipInfo::RegionClip) evaluated: info.clipType == QPainterClipInfo::RegionClip yes Evaluation Count:2 | yes Evaluation Count:4 |
| 2-4 |
2692 | r = info.region.boundingRect(); executed: r = info.region.boundingRect(); Execution Count:2 | 2 |
2693 | else | - |
2694 | r = info.path.boundingRect(); executed: r = info.path.boundingRect(); Execution Count:4 | 4 |
2695 | | - |
2696 | r = info.matrix.mapRect(r); executed (the execution status of this line is deduced): r = info.matrix.mapRect(r); | - |
2697 | | - |
2698 | if (i == 0) evaluated: i == 0 yes Evaluation Count:14 | yes Evaluation Count:726 |
| 14-726 |
2699 | bounds = r; executed: bounds = r; Execution Count:14 | 14 |
2700 | else if (info.operation == Qt::IntersectClip) partially evaluated: info.operation == Qt::IntersectClip yes Evaluation Count:726 | no Evaluation Count:0 |
| 0-726 |
2701 | bounds &= r; executed: bounds &= r; Execution Count:726 | 726 |
2702 | } | - |
2703 | | - |
2704 | | - |
2705 | // Map the rectangle back into logical space using the inverse | - |
2706 | // matrix. | - |
2707 | if (!d->txinv) evaluated: !d->txinv yes Evaluation Count:2 | yes Evaluation Count:12 |
| 2-12 |
2708 | const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); Execution Count:2 | 2 |
2709 | | - |
2710 | return d->invMatrix.mapRect(bounds); executed: return d->invMatrix.mapRect(bounds); Execution Count:14 | 14 |
2711 | } | - |
2712 | | - |
2713 | /*! | - |
2714 | \fn void QPainter::setClipRect(const QRectF &rectangle, Qt::ClipOperation operation) | - |
2715 | | - |
2716 | Enables clipping, and sets the clip region to the given \a | - |
2717 | rectangle using the given clip \a operation. The default operation | - |
2718 | is to replace the current clip rectangle. | - |
2719 | | - |
2720 | Note that the clip rectangle is specified in logical (painter) | - |
2721 | coordinates. | - |
2722 | | - |
2723 | \sa clipRegion(), setClipping(), {QPainter#Clipping}{Clipping} | - |
2724 | */ | - |
2725 | void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op) | - |
2726 | { | - |
2727 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
2728 | | - |
2729 | if (d->extended) { evaluated: d->extended yes Evaluation Count:336 | yes Evaluation Count:1 |
| 1-336 |
2730 | if ((!d->state->clipEnabled && op != Qt::NoClip)) partially evaluated: !d->state->clipEnabled no Evaluation Count:0 | yes Evaluation Count:336 |
never evaluated: op != Qt::NoClip | 0-336 |
2731 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
2732 | | - |
2733 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:336 |
| 0-336 |
2734 | qWarning("QPainter::setClipRect: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2734, __PRETTY_FUNCTION__).warning("QPainter::setClipRect: Painter not active"); | - |
2735 | return; | 0 |
2736 | } | - |
2737 | qreal right = rect.x() + rect.width(); executed (the execution status of this line is deduced): qreal right = rect.x() + rect.width(); | - |
2738 | qreal bottom = rect.y() + rect.height(); executed (the execution status of this line is deduced): qreal bottom = rect.y() + rect.height(); | - |
2739 | qreal pts[] = { rect.x(), rect.y(), executed (the execution status of this line is deduced): qreal pts[] = { rect.x(), rect.y(), | - |
2740 | right, rect.y(), executed (the execution status of this line is deduced): right, rect.y(), | - |
2741 | right, bottom, executed (the execution status of this line is deduced): right, bottom, | - |
2742 | rect.x(), bottom }; executed (the execution status of this line is deduced): rect.x(), bottom }; | - |
2743 | QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); executed (the execution status of this line is deduced): QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); | - |
2744 | d->state->clipEnabled = true; executed (the execution status of this line is deduced): d->state->clipEnabled = true; | - |
2745 | d->extended->clip(vp, op); executed (the execution status of this line is deduced): d->extended->clip(vp, op); | - |
2746 | if (op == Qt::ReplaceClip || op == Qt::NoClip) evaluated: op == Qt::ReplaceClip yes Evaluation Count:29 | yes Evaluation Count:307 |
partially evaluated: op == Qt::NoClip no Evaluation Count:0 | yes Evaluation Count:307 |
| 0-307 |
2747 | d->state->clipInfo.clear(); executed: d->state->clipInfo.clear(); Execution Count:29 | 29 |
2748 | d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); executed (the execution status of this line is deduced): d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); | - |
2749 | d->state->clipOperation = op; executed (the execution status of this line is deduced): d->state->clipOperation = op; | - |
2750 | return; executed: return; Execution Count:336 | 336 |
2751 | } | - |
2752 | | - |
2753 | if (qreal(int(rect.top())) == rect.top() partially evaluated: qreal(int(rect.top())) == rect.top() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2754 | && qreal(int(rect.bottom())) == rect.bottom() partially evaluated: qreal(int(rect.bottom())) == rect.bottom() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2755 | && qreal(int(rect.left())) == rect.left() partially evaluated: qreal(int(rect.left())) == rect.left() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2756 | && qreal(int(rect.right())) == rect.right()) partially evaluated: qreal(int(rect.right())) == rect.right() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2757 | { | - |
2758 | setClipRect(rect.toRect(), op); executed (the execution status of this line is deduced): setClipRect(rect.toRect(), op); | - |
2759 | return; executed: return; Execution Count:1 | 1 |
2760 | } | - |
2761 | | - |
2762 | if (rect.isEmpty()) { never evaluated: rect.isEmpty() | 0 |
2763 | setClipRegion(QRegion(), op); never executed (the execution status of this line is deduced): setClipRegion(QRegion(), op); | - |
2764 | return; | 0 |
2765 | } | - |
2766 | | - |
2767 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
2768 | path.addRect(rect); never executed (the execution status of this line is deduced): path.addRect(rect); | - |
2769 | setClipPath(path, op); never executed (the execution status of this line is deduced): setClipPath(path, op); | - |
2770 | } | 0 |
2771 | | - |
2772 | /*! | - |
2773 | \fn void QPainter::setClipRect(const QRect &rectangle, Qt::ClipOperation operation) | - |
2774 | \overload | - |
2775 | | - |
2776 | Enables clipping, and sets the clip region to the given \a rectangle using the given | - |
2777 | clip \a operation. | - |
2778 | */ | - |
2779 | void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) | - |
2780 | { | - |
2781 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
2782 | | - |
2783 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:2 | yes Evaluation Count:21930 |
| 2-21930 |
2784 | qWarning("QPainter::setClipRect: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2784, __PRETTY_FUNCTION__).warning("QPainter::setClipRect: Painter not active"); | - |
2785 | return; executed: return; Execution Count:2 | 2 |
2786 | } | - |
2787 | | - |
2788 | if ((!d->state->clipEnabled && op != Qt::NoClip)) partially evaluated: !d->state->clipEnabled no Evaluation Count:0 | yes Evaluation Count:21930 |
never evaluated: op != Qt::NoClip | 0-21930 |
2789 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
2790 | | - |
2791 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:21930 | no Evaluation Count:0 |
| 0-21930 |
2792 | d->state->clipEnabled = true; executed (the execution status of this line is deduced): d->state->clipEnabled = true; | - |
2793 | d->extended->clip(rect, op); executed (the execution status of this line is deduced): d->extended->clip(rect, op); | - |
2794 | if (op == Qt::ReplaceClip || op == Qt::NoClip) evaluated: op == Qt::ReplaceClip yes Evaluation Count:21568 | yes Evaluation Count:362 |
partially evaluated: op == Qt::NoClip no Evaluation Count:0 | yes Evaluation Count:362 |
| 0-21568 |
2795 | d->state->clipInfo.clear(); executed: d->state->clipInfo.clear(); Execution Count:21568 | 21568 |
2796 | d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); executed (the execution status of this line is deduced): d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); | - |
2797 | d->state->clipOperation = op; executed (the execution status of this line is deduced): d->state->clipOperation = op; | - |
2798 | return; executed: return; Execution Count:21930 | 21930 |
2799 | } | - |
2800 | | - |
2801 | if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip) never evaluated: d->state->clipOperation == Qt::NoClip never evaluated: op == Qt::IntersectClip | 0 |
2802 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
2803 | | - |
2804 | d->state->clipRegion = rect; never executed (the execution status of this line is deduced): d->state->clipRegion = rect; | - |
2805 | d->state->clipOperation = op; never executed (the execution status of this line is deduced): d->state->clipOperation = op; | - |
2806 | if (op == Qt::NoClip || op == Qt::ReplaceClip) never evaluated: op == Qt::NoClip never evaluated: op == Qt::ReplaceClip | 0 |
2807 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
2808 | d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); never executed (the execution status of this line is deduced): d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix); | - |
2809 | d->state->clipEnabled = true; never executed (the execution status of this line is deduced): d->state->clipEnabled = true; | - |
2810 | d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled; never executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled; | - |
2811 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
2812 | } | 0 |
2813 | | - |
2814 | /*! | - |
2815 | \fn void QPainter::setClipRect(int x, int y, int width, int height, Qt::ClipOperation operation) | - |
2816 | | - |
2817 | Enables clipping, and sets the clip region to the rectangle beginning at (\a x, \a y) | - |
2818 | with the given \a width and \a height. | - |
2819 | */ | - |
2820 | | - |
2821 | /*! | - |
2822 | \fn void QPainter::setClipRegion(const QRegion ®ion, Qt::ClipOperation operation) | - |
2823 | | - |
2824 | Sets the clip region to the given \a region using the specified clip | - |
2825 | \a operation. The default clip operation is to replace the current | - |
2826 | clip region. | - |
2827 | | - |
2828 | Note that the clip region is given in logical coordinates. | - |
2829 | | - |
2830 | \sa clipRegion(), setClipRect(), {QPainter#Clipping}{Clipping} | - |
2831 | */ | - |
2832 | void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) | - |
2833 | { | - |
2834 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
2835 | #ifdef QT_DEBUG_DRAW | - |
2836 | QRect rect = r.boundingRect(); | - |
2837 | if (qt_show_painter_debug_output) | - |
2838 | printf("QPainter::setClipRegion(), size=%d, [%d,%d,%d,%d]\n", | - |
2839 | r.rects().size(), rect.x(), rect.y(), rect.width(), rect.height()); | - |
2840 | #endif | - |
2841 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:2448 |
| 1-2448 |
2842 | qWarning("QPainter::setClipRegion: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2842, __PRETTY_FUNCTION__).warning("QPainter::setClipRegion: Painter not active"); | - |
2843 | return; executed: return; Execution Count:1 | 1 |
2844 | } | - |
2845 | | - |
2846 | if ((!d->state->clipEnabled && op != Qt::NoClip)) partially evaluated: !d->state->clipEnabled no Evaluation Count:0 | yes Evaluation Count:2448 |
never evaluated: op != Qt::NoClip | 0-2448 |
2847 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
2848 | | - |
2849 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:2448 | no Evaluation Count:0 |
| 0-2448 |
2850 | d->state->clipEnabled = true; executed (the execution status of this line is deduced): d->state->clipEnabled = true; | - |
2851 | d->extended->clip(r, op); executed (the execution status of this line is deduced): d->extended->clip(r, op); | - |
2852 | if (op == Qt::NoClip || op == Qt::ReplaceClip) partially evaluated: op == Qt::NoClip no Evaluation Count:0 | yes Evaluation Count:2448 |
evaluated: op == Qt::ReplaceClip yes Evaluation Count:2426 | yes Evaluation Count:22 |
| 0-2448 |
2853 | d->state->clipInfo.clear(); executed: d->state->clipInfo.clear(); Execution Count:2426 | 2426 |
2854 | d->state->clipInfo << QPainterClipInfo(r, op, d->state->matrix); executed (the execution status of this line is deduced): d->state->clipInfo << QPainterClipInfo(r, op, d->state->matrix); | - |
2855 | d->state->clipOperation = op; executed (the execution status of this line is deduced): d->state->clipOperation = op; | - |
2856 | return; executed: return; Execution Count:2448 | 2448 |
2857 | } | - |
2858 | | - |
2859 | if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip) never evaluated: d->state->clipOperation == Qt::NoClip never evaluated: op == Qt::IntersectClip | 0 |
2860 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
2861 | | - |
2862 | d->state->clipRegion = r; never executed (the execution status of this line is deduced): d->state->clipRegion = r; | - |
2863 | d->state->clipOperation = op; never executed (the execution status of this line is deduced): d->state->clipOperation = op; | - |
2864 | if (op == Qt::NoClip || op == Qt::ReplaceClip) never evaluated: op == Qt::NoClip never evaluated: op == Qt::ReplaceClip | 0 |
2865 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
2866 | d->state->clipInfo << QPainterClipInfo(r, op, d->state->matrix); never executed (the execution status of this line is deduced): d->state->clipInfo << QPainterClipInfo(r, op, d->state->matrix); | - |
2867 | d->state->clipEnabled = true; never executed (the execution status of this line is deduced): d->state->clipEnabled = true; | - |
2868 | d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled; never executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled; | - |
2869 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
2870 | } | 0 |
2871 | | - |
2872 | /*! | - |
2873 | \since 4.2 | - |
2874 | \obsolete | - |
2875 | | - |
2876 | Sets the transformation matrix to \a matrix and enables transformations. | - |
2877 | | - |
2878 | \note It is advisable to use setWorldTransform() instead of this function to | - |
2879 | preserve the properties of perspective transformations. | - |
2880 | | - |
2881 | If \a combine is true, then \a matrix is combined with the current | - |
2882 | transformation matrix; otherwise \a matrix replaces the current | - |
2883 | transformation matrix. | - |
2884 | | - |
2885 | If \a matrix is the identity matrix and \a combine is false, this | - |
2886 | function calls setWorldMatrixEnabled(false). (The identity matrix is the | - |
2887 | matrix where QMatrix::m11() and QMatrix::m22() are 1.0 and the | - |
2888 | rest are 0.0.) | - |
2889 | | - |
2890 | The following functions can transform the coordinate system without using | - |
2891 | a QMatrix: | - |
2892 | \list | - |
2893 | \li translate() | - |
2894 | \li scale() | - |
2895 | \li shear() | - |
2896 | \li rotate() | - |
2897 | \endlist | - |
2898 | | - |
2899 | They operate on the painter's worldMatrix() and are implemented like this: | - |
2900 | | - |
2901 | \snippet code/src_gui_painting_qpainter.cpp 4 | - |
2902 | | - |
2903 | Note that when using setWorldMatrix() function you should always have | - |
2904 | \a combine be true when you are drawing into a QPicture. Otherwise | - |
2905 | it may not be possible to replay the picture with additional | - |
2906 | transformations; using the translate(), scale(), etc. convenience | - |
2907 | functions is safe. | - |
2908 | | - |
2909 | For more information about the coordinate system, transformations | - |
2910 | and window-viewport conversion, see \l {Coordinate System}. | - |
2911 | | - |
2912 | \sa setWorldTransform(), QTransform | - |
2913 | */ | - |
2914 | | - |
2915 | void QPainter::setWorldMatrix(const QMatrix &matrix, bool combine) | - |
2916 | { | - |
2917 | setWorldTransform(QTransform(matrix), combine); executed (the execution status of this line is deduced): setWorldTransform(QTransform(matrix), combine); | - |
2918 | } executed: } Execution Count:1 | 1 |
2919 | | - |
2920 | /*! | - |
2921 | \since 4.2 | - |
2922 | \obsolete | - |
2923 | | - |
2924 | Returns the world transformation matrix. | - |
2925 | | - |
2926 | It is advisable to use worldTransform() because worldMatrix() does not | - |
2927 | preserve the properties of perspective transformations. | - |
2928 | | - |
2929 | \sa {QPainter#Coordinate Transformations}{Coordinate Transformations}, | - |
2930 | {Coordinate System} | - |
2931 | */ | - |
2932 | | - |
2933 | const QMatrix &QPainter::worldMatrix() const | - |
2934 | { | - |
2935 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
2936 | if (!d->engine) { partially evaluated: !d->engine yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2937 | qWarning("QPainter::worldMatrix: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 2937, __PRETTY_FUNCTION__).warning("QPainter::worldMatrix: Painter not active"); | - |
2938 | return d->fakeState()->transform.toAffine(); executed: return d->fakeState()->transform.toAffine(); Execution Count:1 | 1 |
2939 | } | - |
2940 | return d->state->worldMatrix.toAffine(); never executed: return d->state->worldMatrix.toAffine(); | 0 |
2941 | } | - |
2942 | | - |
2943 | /*! | - |
2944 | \obsolete | - |
2945 | | - |
2946 | Use setWorldTransform() instead. | - |
2947 | | - |
2948 | \sa setWorldTransform() | - |
2949 | */ | - |
2950 | | - |
2951 | void QPainter::setMatrix(const QMatrix &matrix, bool combine) | - |
2952 | { | - |
2953 | setWorldTransform(QTransform(matrix), combine); never executed (the execution status of this line is deduced): setWorldTransform(QTransform(matrix), combine); | - |
2954 | } | 0 |
2955 | | - |
2956 | /*! | - |
2957 | \obsolete | - |
2958 | | - |
2959 | Use worldTransform() instead. | - |
2960 | | - |
2961 | \sa worldTransform() | - |
2962 | */ | - |
2963 | | - |
2964 | const QMatrix &QPainter::matrix() const | - |
2965 | { | - |
2966 | return worldMatrix(); never executed: return worldMatrix(); | 0 |
2967 | } | - |
2968 | | - |
2969 | | - |
2970 | /*! | - |
2971 | \since 4.2 | - |
2972 | \obsolete | - |
2973 | | - |
2974 | Returns the transformation matrix combining the current | - |
2975 | window/viewport and world transformation. | - |
2976 | | - |
2977 | It is advisable to use combinedTransform() instead of this | - |
2978 | function to preserve the properties of perspective transformations. | - |
2979 | | - |
2980 | \sa setWorldTransform(), setWindow(), setViewport() | - |
2981 | */ | - |
2982 | QMatrix QPainter::combinedMatrix() const | - |
2983 | { | - |
2984 | return combinedTransform().toAffine(); executed: return combinedTransform().toAffine(); Execution Count:2 | 2 |
2985 | } | - |
2986 | | - |
2987 | | - |
2988 | /*! | - |
2989 | \obsolete | - |
2990 | | - |
2991 | Returns the matrix that transforms from logical coordinates to | - |
2992 | device coordinates of the platform dependent paint device. | - |
2993 | | - |
2994 | \note It is advisable to use deviceTransform() instead of this | - |
2995 | function to preserve the properties of perspective transformations. | - |
2996 | | - |
2997 | This function is \e only needed when using platform painting | - |
2998 | commands on the platform dependent handle (Qt::HANDLE), and the | - |
2999 | platform does not do transformations nativly. | - |
3000 | | - |
3001 | The QPaintEngine::PaintEngineFeature enum can be queried to | - |
3002 | determine whether the platform performs the transformations or | - |
3003 | not. | - |
3004 | | - |
3005 | \sa worldMatrix(), QPaintEngine::hasFeature(), | - |
3006 | */ | - |
3007 | const QMatrix &QPainter::deviceMatrix() const | - |
3008 | { | - |
3009 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
3010 | if (!d->engine) { partially evaluated: !d->engine yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
3011 | qWarning("QPainter::deviceMatrix: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3011, __PRETTY_FUNCTION__).warning("QPainter::deviceMatrix: Painter not active"); | - |
3012 | return d->fakeState()->transform.toAffine(); executed: return d->fakeState()->transform.toAffine(); Execution Count:1 | 1 |
3013 | } | - |
3014 | return d->state->matrix.toAffine(); never executed: return d->state->matrix.toAffine(); | 0 |
3015 | } | - |
3016 | | - |
3017 | /*! | - |
3018 | \obsolete | - |
3019 | | - |
3020 | Resets any transformations that were made using translate(), scale(), | - |
3021 | shear(), rotate(), setWorldMatrix(), setViewport() and | - |
3022 | setWindow(). | - |
3023 | | - |
3024 | It is advisable to use resetTransform() instead of this function | - |
3025 | to preserve the properties of perspective transformations. | - |
3026 | | - |
3027 | \sa {QPainter#Coordinate Transformations}{Coordinate | - |
3028 | Transformations} | - |
3029 | */ | - |
3030 | | - |
3031 | void QPainter::resetMatrix() | - |
3032 | { | - |
3033 | resetTransform(); executed (the execution status of this line is deduced): resetTransform(); | - |
3034 | } executed: } Execution Count:5 | 5 |
3035 | | - |
3036 | | - |
3037 | /*! | - |
3038 | \since 4.2 | - |
3039 | | - |
3040 | Enables transformations if \a enable is true, or disables | - |
3041 | transformations if \a enable is false. The world transformation | - |
3042 | matrix is not changed. | - |
3043 | | - |
3044 | \sa worldMatrixEnabled(), worldTransform(), {QPainter#Coordinate | - |
3045 | Transformations}{Coordinate Transformations} | - |
3046 | */ | - |
3047 | | - |
3048 | void QPainter::setWorldMatrixEnabled(bool enable) | - |
3049 | { | - |
3050 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3051 | #ifdef QT_DEBUG_DRAW | - |
3052 | if (qt_show_painter_debug_output) | - |
3053 | printf("QPainter::setMatrixEnabled(), enable=%d\n", enable); | - |
3054 | #endif | - |
3055 | | - |
3056 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:11 |
| 1-11 |
3057 | qWarning("QPainter::setMatrixEnabled: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3057, __PRETTY_FUNCTION__).warning("QPainter::setMatrixEnabled: Painter not active"); | - |
3058 | return; executed: return; Execution Count:1 | 1 |
3059 | } | - |
3060 | if (enable == d->state->WxF) evaluated: enable == d->state->WxF yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-9 |
3061 | return; executed: return; Execution Count:2 | 2 |
3062 | | - |
3063 | d->state->WxF = enable; executed (the execution status of this line is deduced): d->state->WxF = enable; | - |
3064 | d->updateMatrix(); executed (the execution status of this line is deduced): d->updateMatrix(); | - |
3065 | } executed: } Execution Count:9 | 9 |
3066 | | - |
3067 | /*! | - |
3068 | \since 4.2 | - |
3069 | | - |
3070 | Returns true if world transformation is enabled; otherwise returns | - |
3071 | false. | - |
3072 | | - |
3073 | \sa setWorldMatrixEnabled(), worldTransform(), {Coordinate System} | - |
3074 | */ | - |
3075 | | - |
3076 | bool QPainter::worldMatrixEnabled() const | - |
3077 | { | - |
3078 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
3079 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
3080 | qWarning("QPainter::worldMatrixEnabled: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3080, __PRETTY_FUNCTION__).warning("QPainter::worldMatrixEnabled: Painter not active"); | - |
3081 | return false; never executed: return false; | 0 |
3082 | } | - |
3083 | return d->state->WxF; executed: return d->state->WxF; Execution Count:2 | 2 |
3084 | } | - |
3085 | | - |
3086 | /*! | - |
3087 | \obsolete | - |
3088 | | - |
3089 | Use setWorldMatrixEnabled() instead. | - |
3090 | | - |
3091 | \sa setWorldMatrixEnabled() | - |
3092 | */ | - |
3093 | | - |
3094 | void QPainter::setMatrixEnabled(bool enable) | - |
3095 | { | - |
3096 | setWorldMatrixEnabled(enable); executed (the execution status of this line is deduced): setWorldMatrixEnabled(enable); | - |
3097 | } executed: } Execution Count:11 | 11 |
3098 | | - |
3099 | /*! | - |
3100 | \obsolete | - |
3101 | | - |
3102 | Use worldMatrixEnabled() instead | - |
3103 | | - |
3104 | \sa worldMatrixEnabled() | - |
3105 | */ | - |
3106 | | - |
3107 | bool QPainter::matrixEnabled() const | - |
3108 | { | - |
3109 | return worldMatrixEnabled(); executed: return worldMatrixEnabled(); Execution Count:2 | 2 |
3110 | } | - |
3111 | | - |
3112 | /*! | - |
3113 | Scales the coordinate system by (\a{sx}, \a{sy}). | - |
3114 | | - |
3115 | \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations} | - |
3116 | */ | - |
3117 | | - |
3118 | void QPainter::scale(qreal sx, qreal sy) | - |
3119 | { | - |
3120 | #ifdef QT_DEBUG_DRAW | - |
3121 | if (qt_show_painter_debug_output) | - |
3122 | printf("QPainter::scale(), sx=%f, sy=%f\n", sx, sy); | - |
3123 | #endif | - |
3124 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3125 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:26 |
| 1-26 |
3126 | qWarning("QPainter::scale: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3126, __PRETTY_FUNCTION__).warning("QPainter::scale: Painter not active"); | - |
3127 | return; executed: return; Execution Count:1 | 1 |
3128 | } | - |
3129 | | - |
3130 | d->state->worldMatrix.scale(sx,sy); executed (the execution status of this line is deduced): d->state->worldMatrix.scale(sx,sy); | - |
3131 | d->state->WxF = true; executed (the execution status of this line is deduced): d->state->WxF = true; | - |
3132 | d->updateMatrix(); executed (the execution status of this line is deduced): d->updateMatrix(); | - |
3133 | } executed: } Execution Count:26 | 26 |
3134 | | - |
3135 | /*! | - |
3136 | Shears the coordinate system by (\a{sh}, \a{sv}). | - |
3137 | | - |
3138 | \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations} | - |
3139 | */ | - |
3140 | | - |
3141 | void QPainter::shear(qreal sh, qreal sv) | - |
3142 | { | - |
3143 | #ifdef QT_DEBUG_DRAW | - |
3144 | if (qt_show_painter_debug_output) | - |
3145 | printf("QPainter::shear(), sh=%f, sv=%f\n", sh, sv); | - |
3146 | #endif | - |
3147 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3148 | if (!d->engine) { partially evaluated: !d->engine yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
3149 | qWarning("QPainter::shear: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3149, __PRETTY_FUNCTION__).warning("QPainter::shear: Painter not active"); | - |
3150 | return; executed: return; Execution Count:1 | 1 |
3151 | } | - |
3152 | | - |
3153 | d->state->worldMatrix.shear(sh, sv); never executed (the execution status of this line is deduced): d->state->worldMatrix.shear(sh, sv); | - |
3154 | d->state->WxF = true; never executed (the execution status of this line is deduced): d->state->WxF = true; | - |
3155 | d->updateMatrix(); never executed (the execution status of this line is deduced): d->updateMatrix(); | - |
3156 | } | 0 |
3157 | | - |
3158 | /*! | - |
3159 | \fn void QPainter::rotate(qreal angle) | - |
3160 | | - |
3161 | Rotates the coordinate system clockwise. The given \a angle parameter uses degree unit. | - |
3162 | | - |
3163 | \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations} | - |
3164 | */ | - |
3165 | | - |
3166 | void QPainter::rotate(qreal a) | - |
3167 | { | - |
3168 | #ifdef QT_DEBUG_DRAW | - |
3169 | if (qt_show_painter_debug_output) | - |
3170 | printf("QPainter::rotate(), angle=%f\n", a); | - |
3171 | #endif | - |
3172 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3173 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:388 |
| 1-388 |
3174 | qWarning("QPainter::rotate: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3174, __PRETTY_FUNCTION__).warning("QPainter::rotate: Painter not active"); | - |
3175 | return; executed: return; Execution Count:1 | 1 |
3176 | } | - |
3177 | | - |
3178 | d->state->worldMatrix.rotate(a); executed (the execution status of this line is deduced): d->state->worldMatrix.rotate(a); | - |
3179 | d->state->WxF = true; executed (the execution status of this line is deduced): d->state->WxF = true; | - |
3180 | d->updateMatrix(); executed (the execution status of this line is deduced): d->updateMatrix(); | - |
3181 | } executed: } Execution Count:388 | 388 |
3182 | | - |
3183 | /*! | - |
3184 | Translates the coordinate system by the given \a offset; i.e. the | - |
3185 | given \a offset is added to points. | - |
3186 | | - |
3187 | \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations} | - |
3188 | */ | - |
3189 | void QPainter::translate(const QPointF &offset) | - |
3190 | { | - |
3191 | qreal dx = offset.x(); executed (the execution status of this line is deduced): qreal dx = offset.x(); | - |
3192 | qreal dy = offset.y(); executed (the execution status of this line is deduced): qreal dy = offset.y(); | - |
3193 | #ifdef QT_DEBUG_DRAW | - |
3194 | if (qt_show_painter_debug_output) | - |
3195 | printf("QPainter::translate(), dx=%f, dy=%f\n", dx, dy); | - |
3196 | #endif | - |
3197 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3198 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:34906 |
| 1-34906 |
3199 | qWarning("QPainter::translate: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3199, __PRETTY_FUNCTION__).warning("QPainter::translate: Painter not active"); | - |
3200 | return; executed: return; Execution Count:1 | 1 |
3201 | } | - |
3202 | | - |
3203 | d->state->worldMatrix.translate(dx, dy); executed (the execution status of this line is deduced): d->state->worldMatrix.translate(dx, dy); | - |
3204 | d->state->WxF = true; executed (the execution status of this line is deduced): d->state->WxF = true; | - |
3205 | d->updateMatrix(); executed (the execution status of this line is deduced): d->updateMatrix(); | - |
3206 | } executed: } Execution Count:34906 | 34906 |
3207 | | - |
3208 | /*! | - |
3209 | \fn void QPainter::translate(const QPoint &offset) | - |
3210 | \overload | - |
3211 | | - |
3212 | Translates the coordinate system by the given \a offset. | - |
3213 | */ | - |
3214 | | - |
3215 | /*! | - |
3216 | \fn void QPainter::translate(qreal dx, qreal dy) | - |
3217 | \overload | - |
3218 | | - |
3219 | Translates the coordinate system by the vector (\a dx, \a dy). | - |
3220 | */ | - |
3221 | | - |
3222 | /*! | - |
3223 | \fn void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation operation) | - |
3224 | | - |
3225 | Enables clipping, and sets the clip path for the painter to the | - |
3226 | given \a path, with the clip \a operation. | - |
3227 | | - |
3228 | Note that the clip path is specified in logical (painter) | - |
3229 | coordinates. | - |
3230 | | - |
3231 | \sa clipPath(), clipRegion(), {QPainter#Clipping}{Clipping} | - |
3232 | | - |
3233 | */ | - |
3234 | void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) | - |
3235 | { | - |
3236 | #ifdef QT_DEBUG_DRAW | - |
3237 | if (qt_show_painter_debug_output) { | - |
3238 | QRectF b = path.boundingRect(); | - |
3239 | printf("QPainter::setClipPath(), size=%d, op=%d, bounds=[%.2f,%.2f,%.2f,%.2f]\n", | - |
3240 | path.elementCount(), op, b.x(), b.y(), b.width(), b.height()); | - |
3241 | } | - |
3242 | #endif | - |
3243 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3244 | | - |
3245 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:335 |
| 1-335 |
3246 | qWarning("QPainter::setClipPath: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3246, __PRETTY_FUNCTION__).warning("QPainter::setClipPath: Painter not active"); | - |
3247 | return; executed: return; Execution Count:1 | 1 |
3248 | } | - |
3249 | | - |
3250 | if ((!d->state->clipEnabled && op != Qt::NoClip)) partially evaluated: !d->state->clipEnabled no Evaluation Count:0 | yes Evaluation Count:335 |
never evaluated: op != Qt::NoClip | 0-335 |
3251 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
3252 | | - |
3253 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:335 | no Evaluation Count:0 |
| 0-335 |
3254 | d->state->clipEnabled = true; executed (the execution status of this line is deduced): d->state->clipEnabled = true; | - |
3255 | d->extended->clip(path, op); executed (the execution status of this line is deduced): d->extended->clip(path, op); | - |
3256 | if (op == Qt::NoClip || op == Qt::ReplaceClip) partially evaluated: op == Qt::NoClip no Evaluation Count:0 | yes Evaluation Count:335 |
evaluated: op == Qt::ReplaceClip yes Evaluation Count:200 | yes Evaluation Count:135 |
| 0-335 |
3257 | d->state->clipInfo.clear(); executed: d->state->clipInfo.clear(); Execution Count:200 | 200 |
3258 | d->state->clipInfo << QPainterClipInfo(path, op, d->state->matrix); executed (the execution status of this line is deduced): d->state->clipInfo << QPainterClipInfo(path, op, d->state->matrix); | - |
3259 | d->state->clipOperation = op; executed (the execution status of this line is deduced): d->state->clipOperation = op; | - |
3260 | return; executed: return; Execution Count:335 | 335 |
3261 | } | - |
3262 | | - |
3263 | if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip) never evaluated: d->state->clipOperation == Qt::NoClip never evaluated: op == Qt::IntersectClip | 0 |
3264 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
3265 | | - |
3266 | d->state->clipPath = path; never executed (the execution status of this line is deduced): d->state->clipPath = path; | - |
3267 | d->state->clipOperation = op; never executed (the execution status of this line is deduced): d->state->clipOperation = op; | - |
3268 | if (op == Qt::NoClip || op == Qt::ReplaceClip) never evaluated: op == Qt::NoClip never evaluated: op == Qt::ReplaceClip | 0 |
3269 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
3270 | d->state->clipInfo << QPainterClipInfo(path, op, d->state->matrix); never executed (the execution status of this line is deduced): d->state->clipInfo << QPainterClipInfo(path, op, d->state->matrix); | - |
3271 | d->state->clipEnabled = true; never executed (the execution status of this line is deduced): d->state->clipEnabled = true; | - |
3272 | d->state->dirtyFlags |= QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipEnabled; never executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipEnabled; | - |
3273 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
3274 | } | 0 |
3275 | | - |
3276 | /*! | - |
3277 | Draws the outline (strokes) the path \a path with the pen specified | - |
3278 | by \a pen | - |
3279 | | - |
3280 | \sa fillPath(), {QPainter#Drawing}{Drawing} | - |
3281 | */ | - |
3282 | void QPainter::strokePath(const QPainterPath &path, const QPen &pen) | - |
3283 | { | - |
3284 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3285 | | - |
3286 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
3287 | qWarning("QPainter::strokePath: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3287, __PRETTY_FUNCTION__).warning("QPainter::strokePath: Painter not active"); | - |
3288 | return; | 0 |
3289 | } | - |
3290 | | - |
3291 | if (path.isEmpty()) partially evaluated: path.isEmpty() no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
3292 | return; | 0 |
3293 | | - |
3294 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
3295 | const QGradient *g = qpen_brush(pen).gradient(); executed (the execution status of this line is deduced): const QGradient *g = qpen_brush(pen).gradient(); | - |
3296 | if (!g || g->coordinateMode() == QGradient::LogicalMode) { partially evaluated: !g yes Evaluation Count:12 | no Evaluation Count:0 |
never evaluated: g->coordinateMode() == QGradient::LogicalMode | 0-12 |
3297 | d->extended->stroke(qtVectorPathForPath(path), pen); executed (the execution status of this line is deduced): d->extended->stroke(qtVectorPathForPath(path), pen); | - |
3298 | return; executed: return; Execution Count:12 | 12 |
3299 | } | - |
3300 | } | 0 |
3301 | | - |
3302 | QBrush oldBrush = d->state->brush; never executed (the execution status of this line is deduced): QBrush oldBrush = d->state->brush; | - |
3303 | QPen oldPen = d->state->pen; never executed (the execution status of this line is deduced): QPen oldPen = d->state->pen; | - |
3304 | | - |
3305 | setPen(pen); never executed (the execution status of this line is deduced): setPen(pen); | - |
3306 | setBrush(Qt::NoBrush); never executed (the execution status of this line is deduced): setBrush(Qt::NoBrush); | - |
3307 | | - |
3308 | drawPath(path); never executed (the execution status of this line is deduced): drawPath(path); | - |
3309 | | - |
3310 | // Reset old state | - |
3311 | setPen(oldPen); never executed (the execution status of this line is deduced): setPen(oldPen); | - |
3312 | setBrush(oldBrush); never executed (the execution status of this line is deduced): setBrush(oldBrush); | - |
3313 | } | 0 |
3314 | | - |
3315 | /*! | - |
3316 | Fills the given \a path using the given \a brush. The outline is | - |
3317 | not drawn. | - |
3318 | | - |
3319 | Alternatively, you can specify a QColor instead of a QBrush; the | - |
3320 | QBrush constructor (taking a QColor argument) will automatically | - |
3321 | create a solid pattern brush. | - |
3322 | | - |
3323 | \sa drawPath() | - |
3324 | */ | - |
3325 | void QPainter::fillPath(const QPainterPath &path, const QBrush &brush) | - |
3326 | { | - |
3327 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3328 | | - |
3329 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:100002 |
| 0-100002 |
3330 | qWarning("QPainter::fillPath: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3330, __PRETTY_FUNCTION__).warning("QPainter::fillPath: Painter not active"); | - |
3331 | return; | 0 |
3332 | } | - |
3333 | | - |
3334 | if (path.isEmpty()) partially evaluated: path.isEmpty() no Evaluation Count:0 | yes Evaluation Count:100002 |
| 0-100002 |
3335 | return; | 0 |
3336 | | - |
3337 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:100002 | no Evaluation Count:0 |
| 0-100002 |
3338 | const QGradient *g = brush.gradient(); executed (the execution status of this line is deduced): const QGradient *g = brush.gradient(); | - |
3339 | if (!g || g->coordinateMode() == QGradient::LogicalMode) { evaluated: !g yes Evaluation Count:100001 | yes Evaluation Count:1 |
partially evaluated: g->coordinateMode() == QGradient::LogicalMode no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-100001 |
3340 | d->extended->fill(qtVectorPathForPath(path), brush); executed (the execution status of this line is deduced): d->extended->fill(qtVectorPathForPath(path), brush); | - |
3341 | return; executed: return; Execution Count:100001 | 100001 |
3342 | } | - |
3343 | } executed: } Execution Count:1 | 1 |
3344 | | - |
3345 | QBrush oldBrush = d->state->brush; executed (the execution status of this line is deduced): QBrush oldBrush = d->state->brush; | - |
3346 | QPen oldPen = d->state->pen; executed (the execution status of this line is deduced): QPen oldPen = d->state->pen; | - |
3347 | | - |
3348 | setPen(Qt::NoPen); executed (the execution status of this line is deduced): setPen(Qt::NoPen); | - |
3349 | setBrush(brush); executed (the execution status of this line is deduced): setBrush(brush); | - |
3350 | | - |
3351 | drawPath(path); executed (the execution status of this line is deduced): drawPath(path); | - |
3352 | | - |
3353 | // Reset old state | - |
3354 | setPen(oldPen); executed (the execution status of this line is deduced): setPen(oldPen); | - |
3355 | setBrush(oldBrush); executed (the execution status of this line is deduced): setBrush(oldBrush); | - |
3356 | } executed: } Execution Count:1 | 1 |
3357 | | - |
3358 | /*! | - |
3359 | Draws the given painter \a path using the current pen for outline | - |
3360 | and the current brush for filling. | - |
3361 | | - |
3362 | \table 100% | - |
3363 | \row | - |
3364 | \li \inlineimage qpainter-path.png | - |
3365 | \li | - |
3366 | \snippet code/src_gui_painting_qpainter.cpp 5 | - |
3367 | \endtable | - |
3368 | | - |
3369 | \sa {painting/painterpaths}{the Painter Paths | - |
3370 | example},{painting/deform}{the Vector Deformation example} | - |
3371 | */ | - |
3372 | void QPainter::drawPath(const QPainterPath &path) | - |
3373 | { | - |
3374 | #ifdef QT_DEBUG_DRAW | - |
3375 | QRectF pathBounds = path.boundingRect(); | - |
3376 | if (qt_show_painter_debug_output) | - |
3377 | printf("QPainter::drawPath(), size=%d, [%.2f,%.2f,%.2f,%.2f]\n", | - |
3378 | path.elementCount(), | - |
3379 | pathBounds.x(), pathBounds.y(), pathBounds.width(), pathBounds.height()); | - |
3380 | #endif | - |
3381 | | - |
3382 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3383 | | - |
3384 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:33309 |
| 0-33309 |
3385 | qWarning("QPainter::drawPath: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3385, __PRETTY_FUNCTION__).warning("QPainter::drawPath: Painter not active"); | - |
3386 | return; | 0 |
3387 | } | - |
3388 | | - |
3389 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:33309 | no Evaluation Count:0 |
| 0-33309 |
3390 | d->extended->drawPath(path); executed (the execution status of this line is deduced): d->extended->drawPath(path); | - |
3391 | return; executed: return; Execution Count:33309 | 33309 |
3392 | } | - |
3393 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
3394 | | - |
3395 | if (d->engine->hasFeature(QPaintEngine::PainterPaths) && d->state->emulationSpecifier == 0) { never evaluated: d->engine->hasFeature(QPaintEngine::PainterPaths) never evaluated: d->state->emulationSpecifier == 0 | 0 |
3396 | d->engine->drawPath(path); never executed (the execution status of this line is deduced): d->engine->drawPath(path); | - |
3397 | } else { | 0 |
3398 | d->draw_helper(path); never executed (the execution status of this line is deduced): d->draw_helper(path); | - |
3399 | } | 0 |
3400 | } | - |
3401 | | - |
3402 | /*! | - |
3403 | \fn void QPainter::drawLine(const QLineF &line) | - |
3404 | | - |
3405 | Draws a line defined by \a line. | - |
3406 | | - |
3407 | \table 100% | - |
3408 | \row | - |
3409 | \li \inlineimage qpainter-line.png | - |
3410 | \li | - |
3411 | \snippet code/src_gui_painting_qpainter.cpp 6 | - |
3412 | \endtable | - |
3413 | | - |
3414 | \sa drawLines(), drawPolyline(), {Coordinate System} | - |
3415 | */ | - |
3416 | | - |
3417 | /*! | - |
3418 | \fn void QPainter::drawLine(const QLine &line) | - |
3419 | \overload | - |
3420 | | - |
3421 | Draws a line defined by \a line. | - |
3422 | */ | - |
3423 | | - |
3424 | /*! | - |
3425 | \fn void QPainter::drawLine(const QPoint &p1, const QPoint &p2) | - |
3426 | \overload | - |
3427 | | - |
3428 | Draws a line from \a p1 to \a p2. | - |
3429 | */ | - |
3430 | | - |
3431 | /*! | - |
3432 | \fn void QPainter::drawLine(const QPointF &p1, const QPointF &p2) | - |
3433 | \overload | - |
3434 | | - |
3435 | Draws a line from \a p1 to \a p2. | - |
3436 | */ | - |
3437 | | - |
3438 | /*! | - |
3439 | \fn void QPainter::drawLine(int x1, int y1, int x2, int y2) | - |
3440 | \overload | - |
3441 | | - |
3442 | Draws a line from (\a x1, \a y1) to (\a x2, \a y2) and sets the | - |
3443 | current pen position to (\a x2, \a y2). | - |
3444 | */ | - |
3445 | | - |
3446 | /*! | - |
3447 | \fn void QPainter::drawRect(const QRectF &rectangle) | - |
3448 | | - |
3449 | Draws the current \a rectangle with the current pen and brush. | - |
3450 | | - |
3451 | A filled rectangle has a size of \a{rectangle}.size(). A stroked | - |
3452 | rectangle has a size of \a{rectangle}.size() plus the pen width. | - |
3453 | | - |
3454 | \table 100% | - |
3455 | \row | - |
3456 | \li \inlineimage qpainter-rectangle.png | - |
3457 | \li | - |
3458 | \snippet code/src_gui_painting_qpainter.cpp 7 | - |
3459 | \endtable | - |
3460 | | - |
3461 | \sa drawRects(), drawPolygon(), {Coordinate System} | - |
3462 | */ | - |
3463 | | - |
3464 | /*! | - |
3465 | \fn void QPainter::drawRect(const QRect &rectangle) | - |
3466 | | - |
3467 | \overload | - |
3468 | | - |
3469 | Draws the current \a rectangle with the current pen and brush. | - |
3470 | */ | - |
3471 | | - |
3472 | /*! | - |
3473 | \fn void QPainter::drawRect(int x, int y, int width, int height) | - |
3474 | | - |
3475 | \overload | - |
3476 | | - |
3477 | Draws a rectangle with upper left corner at (\a{x}, \a{y}) and | - |
3478 | with the given \a width and \a height. | - |
3479 | */ | - |
3480 | | - |
3481 | /*! | - |
3482 | \fn void QPainter::drawRects(const QRectF *rectangles, int rectCount) | - |
3483 | | - |
3484 | Draws the first \a rectCount of the given \a rectangles using the | - |
3485 | current pen and brush. | - |
3486 | | - |
3487 | \sa drawRect() | - |
3488 | */ | - |
3489 | void QPainter::drawRects(const QRectF *rects, int rectCount) | - |
3490 | { | - |
3491 | #ifdef QT_DEBUG_DRAW | - |
3492 | if (qt_show_painter_debug_output) | - |
3493 | printf("QPainter::drawRects(), count=%d\n", rectCount); | - |
3494 | #endif | - |
3495 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3496 | | - |
3497 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:614 |
| 0-614 |
3498 | qWarning("QPainter::drawRects: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3498, __PRETTY_FUNCTION__).warning("QPainter::drawRects: Painter not active"); | - |
3499 | return; | 0 |
3500 | } | - |
3501 | | - |
3502 | if (rectCount <= 0) partially evaluated: rectCount <= 0 no Evaluation Count:0 | yes Evaluation Count:614 |
| 0-614 |
3503 | return; | 0 |
3504 | | - |
3505 | if (d->extended) { evaluated: d->extended yes Evaluation Count:604 | yes Evaluation Count:10 |
| 10-604 |
3506 | d->extended->drawRects(rects, rectCount); executed (the execution status of this line is deduced): d->extended->drawRects(rects, rectCount); | - |
3507 | return; executed: return; Execution Count:604 | 604 |
3508 | } | - |
3509 | | - |
3510 | d->updateState(d->state); executed (the execution status of this line is deduced): d->updateState(d->state); | - |
3511 | | - |
3512 | if (!d->state->emulationSpecifier) { partially evaluated: !d->state->emulationSpecifier yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
3513 | d->engine->drawRects(rects, rectCount); executed (the execution status of this line is deduced): d->engine->drawRects(rects, rectCount); | - |
3514 | return; executed: return; Execution Count:10 | 10 |
3515 | } | - |
3516 | | - |
3517 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform never evaluated: d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | 0 |
3518 | && d->state->matrix.type() == QTransform::TxTranslate) { never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
3519 | for (int i=0; i<rectCount; ++i) { never evaluated: i<rectCount | 0 |
3520 | QRectF r(rects[i].x() + d->state->matrix.dx(), never executed (the execution status of this line is deduced): QRectF r(rects[i].x() + d->state->matrix.dx(), | - |
3521 | rects[i].y() + d->state->matrix.dy(), never executed (the execution status of this line is deduced): rects[i].y() + d->state->matrix.dy(), | - |
3522 | rects[i].width(), never executed (the execution status of this line is deduced): rects[i].width(), | - |
3523 | rects[i].height()); never executed (the execution status of this line is deduced): rects[i].height()); | - |
3524 | d->engine->drawRects(&r, 1); never executed (the execution status of this line is deduced): d->engine->drawRects(&r, 1); | - |
3525 | } | 0 |
3526 | } else { | 0 |
3527 | if (d->state->brushNeedsResolving() || d->state->penNeedsResolving()) { never evaluated: d->state->brushNeedsResolving() never evaluated: d->state->penNeedsResolving() | 0 |
3528 | for (int i=0; i<rectCount; ++i) { never evaluated: i<rectCount | 0 |
3529 | QPainterPath rectPath; never executed (the execution status of this line is deduced): QPainterPath rectPath; | - |
3530 | rectPath.addRect(rects[i]); never executed (the execution status of this line is deduced): rectPath.addRect(rects[i]); | - |
3531 | d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); never executed (the execution status of this line is deduced): d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); | - |
3532 | } | 0 |
3533 | } else { | 0 |
3534 | QPainterPath rectPath; never executed (the execution status of this line is deduced): QPainterPath rectPath; | - |
3535 | for (int i=0; i<rectCount; ++i) never evaluated: i<rectCount | 0 |
3536 | rectPath.addRect(rects[i]); never executed: rectPath.addRect(rects[i]); | 0 |
3537 | d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); never executed (the execution status of this line is deduced): d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); | - |
3538 | } | 0 |
3539 | } | - |
3540 | } | - |
3541 | | - |
3542 | /*! | - |
3543 | \fn void QPainter::drawRects(const QRect *rectangles, int rectCount) | - |
3544 | \overload | - |
3545 | | - |
3546 | Draws the first \a rectCount of the given \a rectangles using the | - |
3547 | current pen and brush. | - |
3548 | */ | - |
3549 | void QPainter::drawRects(const QRect *rects, int rectCount) | - |
3550 | { | - |
3551 | #ifdef QT_DEBUG_DRAW | - |
3552 | if (qt_show_painter_debug_output) | - |
3553 | printf("QPainter::drawRects(), count=%d\n", rectCount); | - |
3554 | #endif | - |
3555 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3556 | | - |
3557 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:13580 |
| 0-13580 |
3558 | qWarning("QPainter::drawRects: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3558, __PRETTY_FUNCTION__).warning("QPainter::drawRects: Painter not active"); | - |
3559 | return; | 0 |
3560 | } | - |
3561 | | - |
3562 | if (rectCount <= 0) partially evaluated: rectCount <= 0 no Evaluation Count:0 | yes Evaluation Count:13580 |
| 0-13580 |
3563 | return; | 0 |
3564 | | - |
3565 | if (d->extended) { evaluated: d->extended yes Evaluation Count:13578 | yes Evaluation Count:2 |
| 2-13578 |
3566 | d->extended->drawRects(rects, rectCount); executed (the execution status of this line is deduced): d->extended->drawRects(rects, rectCount); | - |
3567 | return; executed: return; Execution Count:13578 | 13578 |
3568 | } | - |
3569 | | - |
3570 | d->updateState(d->state); executed (the execution status of this line is deduced): d->updateState(d->state); | - |
3571 | | - |
3572 | if (!d->state->emulationSpecifier) { partially evaluated: !d->state->emulationSpecifier yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
3573 | d->engine->drawRects(rects, rectCount); executed (the execution status of this line is deduced): d->engine->drawRects(rects, rectCount); | - |
3574 | return; executed: return; Execution Count:2 | 2 |
3575 | } | - |
3576 | | - |
3577 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform never evaluated: d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | 0 |
3578 | && d->state->matrix.type() == QTransform::TxTranslate) { never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
3579 | for (int i=0; i<rectCount; ++i) { never evaluated: i<rectCount | 0 |
3580 | QRectF r(rects[i].x() + d->state->matrix.dx(), never executed (the execution status of this line is deduced): QRectF r(rects[i].x() + d->state->matrix.dx(), | - |
3581 | rects[i].y() + d->state->matrix.dy(), never executed (the execution status of this line is deduced): rects[i].y() + d->state->matrix.dy(), | - |
3582 | rects[i].width(), never executed (the execution status of this line is deduced): rects[i].width(), | - |
3583 | rects[i].height()); never executed (the execution status of this line is deduced): rects[i].height()); | - |
3584 | | - |
3585 | d->engine->drawRects(&r, 1); never executed (the execution status of this line is deduced): d->engine->drawRects(&r, 1); | - |
3586 | } | 0 |
3587 | } else { | 0 |
3588 | if (d->state->brushNeedsResolving() || d->state->penNeedsResolving()) { never evaluated: d->state->brushNeedsResolving() never evaluated: d->state->penNeedsResolving() | 0 |
3589 | for (int i=0; i<rectCount; ++i) { never evaluated: i<rectCount | 0 |
3590 | QPainterPath rectPath; never executed (the execution status of this line is deduced): QPainterPath rectPath; | - |
3591 | rectPath.addRect(rects[i]); never executed (the execution status of this line is deduced): rectPath.addRect(rects[i]); | - |
3592 | d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); never executed (the execution status of this line is deduced): d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); | - |
3593 | } | 0 |
3594 | } else { | 0 |
3595 | QPainterPath rectPath; never executed (the execution status of this line is deduced): QPainterPath rectPath; | - |
3596 | for (int i=0; i<rectCount; ++i) never evaluated: i<rectCount | 0 |
3597 | rectPath.addRect(rects[i]); never executed: rectPath.addRect(rects[i]); | 0 |
3598 | | - |
3599 | d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); never executed (the execution status of this line is deduced): d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); | - |
3600 | } | 0 |
3601 | } | - |
3602 | } | - |
3603 | | - |
3604 | /*! | - |
3605 | \fn void QPainter::drawRects(const QVector<QRectF> &rectangles) | - |
3606 | \overload | - |
3607 | | - |
3608 | Draws the given \a rectangles using the current pen and brush. | - |
3609 | */ | - |
3610 | | - |
3611 | /*! | - |
3612 | \fn void QPainter::drawRects(const QVector<QRect> &rectangles) | - |
3613 | | - |
3614 | \overload | - |
3615 | | - |
3616 | Draws the given \a rectangles using the current pen and brush. | - |
3617 | */ | - |
3618 | | - |
3619 | /*! | - |
3620 | \fn void QPainter::drawPoint(const QPointF &position) | - |
3621 | | - |
3622 | Draws a single point at the given \a position using the current | - |
3623 | pen's color. | - |
3624 | | - |
3625 | \sa {Coordinate System} | - |
3626 | */ | - |
3627 | | - |
3628 | /*! | - |
3629 | \fn void QPainter::drawPoint(const QPoint &position) | - |
3630 | \overload | - |
3631 | | - |
3632 | Draws a single point at the given \a position using the current | - |
3633 | pen's color. | - |
3634 | */ | - |
3635 | | - |
3636 | /*! \fn void QPainter::drawPoint(int x, int y) | - |
3637 | | - |
3638 | \overload | - |
3639 | | - |
3640 | Draws a single point at position (\a x, \a y). | - |
3641 | */ | - |
3642 | | - |
3643 | /*! | - |
3644 | Draws the first \a pointCount points in the array \a points using | - |
3645 | the current pen's color. | - |
3646 | | - |
3647 | \sa {Coordinate System} | - |
3648 | */ | - |
3649 | void QPainter::drawPoints(const QPointF *points, int pointCount) | - |
3650 | { | - |
3651 | #ifdef QT_DEBUG_DRAW | - |
3652 | if (qt_show_painter_debug_output) | - |
3653 | printf("QPainter::drawPoints(), count=%d\n", pointCount); | - |
3654 | #endif | - |
3655 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3656 | | - |
3657 | if (!d->engine) { never evaluated: !d->engine | 0 |
3658 | qWarning("QPainter::drawPoints: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3658, __PRETTY_FUNCTION__).warning("QPainter::drawPoints: Painter not active"); | - |
3659 | return; | 0 |
3660 | } | - |
3661 | | - |
3662 | if (pointCount <= 0) never evaluated: pointCount <= 0 | 0 |
3663 | return; | 0 |
3664 | | - |
3665 | if (d->extended) { never evaluated: d->extended | 0 |
3666 | d->extended->drawPoints(points, pointCount); never executed (the execution status of this line is deduced): d->extended->drawPoints(points, pointCount); | - |
3667 | return; | 0 |
3668 | } | - |
3669 | | - |
3670 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
3671 | | - |
3672 | if (!d->state->emulationSpecifier) { never evaluated: !d->state->emulationSpecifier | 0 |
3673 | d->engine->drawPoints(points, pointCount); never executed (the execution status of this line is deduced): d->engine->drawPoints(points, pointCount); | - |
3674 | return; | 0 |
3675 | } | - |
3676 | | - |
3677 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform never evaluated: d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | 0 |
3678 | && d->state->matrix.type() == QTransform::TxTranslate) { never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
3679 | // ### use drawPoints function | - |
3680 | for (int i=0; i<pointCount; ++i) { never evaluated: i<pointCount | 0 |
3681 | QPointF pt(points[i].x() + d->state->matrix.dx(), never executed (the execution status of this line is deduced): QPointF pt(points[i].x() + d->state->matrix.dx(), | - |
3682 | points[i].y() + d->state->matrix.dy()); never executed (the execution status of this line is deduced): points[i].y() + d->state->matrix.dy()); | - |
3683 | d->engine->drawPoints(&pt, 1); never executed (the execution status of this line is deduced): d->engine->drawPoints(&pt, 1); | - |
3684 | } | 0 |
3685 | } else { | 0 |
3686 | QPen pen = d->state->pen; never executed (the execution status of this line is deduced): QPen pen = d->state->pen; | - |
3687 | bool flat_pen = pen.capStyle() == Qt::FlatCap; never executed (the execution status of this line is deduced): bool flat_pen = pen.capStyle() == Qt::FlatCap; | - |
3688 | if (flat_pen) { never evaluated: flat_pen | 0 |
3689 | save(); never executed (the execution status of this line is deduced): save(); | - |
3690 | pen.setCapStyle(Qt::SquareCap); never executed (the execution status of this line is deduced): pen.setCapStyle(Qt::SquareCap); | - |
3691 | setPen(pen); never executed (the execution status of this line is deduced): setPen(pen); | - |
3692 | } | 0 |
3693 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
3694 | for (int i=0; i<pointCount; ++i) { never evaluated: i<pointCount | 0 |
3695 | path.moveTo(points[i].x(), points[i].y()); never executed (the execution status of this line is deduced): path.moveTo(points[i].x(), points[i].y()); | - |
3696 | path.lineTo(points[i].x() + 0.0001, points[i].y()); never executed (the execution status of this line is deduced): path.lineTo(points[i].x() + 0.0001, points[i].y()); | - |
3697 | } | 0 |
3698 | d->draw_helper(path, QPainterPrivate::StrokeDraw); never executed (the execution status of this line is deduced): d->draw_helper(path, QPainterPrivate::StrokeDraw); | - |
3699 | if (flat_pen) never evaluated: flat_pen | 0 |
3700 | restore(); never executed: restore(); | 0 |
3701 | } | 0 |
3702 | } | - |
3703 | | - |
3704 | /*! | - |
3705 | \overload | - |
3706 | | - |
3707 | Draws the first \a pointCount points in the array \a points using | - |
3708 | the current pen's color. | - |
3709 | */ | - |
3710 | | - |
3711 | void QPainter::drawPoints(const QPoint *points, int pointCount) | - |
3712 | { | - |
3713 | #ifdef QT_DEBUG_DRAW | - |
3714 | if (qt_show_painter_debug_output) | - |
3715 | printf("QPainter::drawPoints(), count=%d\n", pointCount); | - |
3716 | #endif | - |
3717 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3718 | | - |
3719 | if (!d->engine) { partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:144 |
| 0-144 |
3720 | qWarning("QPainter::drawPoints: Painter not active"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3720, __PRETTY_FUNCTION__).warning("QPainter::drawPoints: Painter not active"); | - |
3721 | return; | 0 |
3722 | } | - |
3723 | | - |
3724 | if (pointCount <= 0) partially evaluated: pointCount <= 0 no Evaluation Count:0 | yes Evaluation Count:144 |
| 0-144 |
3725 | return; | 0 |
3726 | | - |
3727 | if (d->extended) { evaluated: d->extended yes Evaluation Count:136 | yes Evaluation Count:8 |
| 8-136 |
3728 | d->extended->drawPoints(points, pointCount); executed (the execution status of this line is deduced): d->extended->drawPoints(points, pointCount); | - |
3729 | return; executed: return; Execution Count:136 | 136 |
3730 | } | - |
3731 | | - |
3732 | d->updateState(d->state); executed (the execution status of this line is deduced): d->updateState(d->state); | - |
3733 | | - |
3734 | if (!d->state->emulationSpecifier) { partially evaluated: !d->state->emulationSpecifier yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
3735 | d->engine->drawPoints(points, pointCount); executed (the execution status of this line is deduced): d->engine->drawPoints(points, pointCount); | - |
3736 | return; executed: return; Execution Count:8 | 8 |
3737 | } | - |
3738 | | - |
3739 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform never evaluated: d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | 0 |
3740 | && d->state->matrix.type() == QTransform::TxTranslate) { never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
3741 | // ### use drawPoints function | - |
3742 | for (int i=0; i<pointCount; ++i) { never evaluated: i<pointCount | 0 |
3743 | QPointF pt(points[i].x() + d->state->matrix.dx(), never executed (the execution status of this line is deduced): QPointF pt(points[i].x() + d->state->matrix.dx(), | - |
3744 | points[i].y() + d->state->matrix.dy()); never executed (the execution status of this line is deduced): points[i].y() + d->state->matrix.dy()); | - |
3745 | d->engine->drawPoints(&pt, 1); never executed (the execution status of this line is deduced): d->engine->drawPoints(&pt, 1); | - |
3746 | } | 0 |
3747 | } else { | 0 |
3748 | QPen pen = d->state->pen; never executed (the execution status of this line is deduced): QPen pen = d->state->pen; | - |
3749 | bool flat_pen = (pen.capStyle() == Qt::FlatCap); never executed (the execution status of this line is deduced): bool flat_pen = (pen.capStyle() == Qt::FlatCap); | - |
3750 | if (flat_pen) { never evaluated: flat_pen | 0 |
3751 | save(); never executed (the execution status of this line is deduced): save(); | - |
3752 | pen.setCapStyle(Qt::SquareCap); never executed (the execution status of this line is deduced): pen.setCapStyle(Qt::SquareCap); | - |
3753 | setPen(pen); never executed (the execution status of this line is deduced): setPen(pen); | - |
3754 | } | 0 |
3755 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
3756 | for (int i=0; i<pointCount; ++i) { never evaluated: i<pointCount | 0 |
3757 | path.moveTo(points[i].x(), points[i].y()); never executed (the execution status of this line is deduced): path.moveTo(points[i].x(), points[i].y()); | - |
3758 | path.lineTo(points[i].x() + 0.0001, points[i].y()); never executed (the execution status of this line is deduced): path.lineTo(points[i].x() + 0.0001, points[i].y()); | - |
3759 | } | 0 |
3760 | d->draw_helper(path, QPainterPrivate::StrokeDraw); never executed (the execution status of this line is deduced): d->draw_helper(path, QPainterPrivate::StrokeDraw); | - |
3761 | if (flat_pen) never evaluated: flat_pen | 0 |
3762 | restore(); never executed: restore(); | 0 |
3763 | } | 0 |
3764 | } | - |
3765 | | - |
3766 | /*! | - |
3767 | \fn void QPainter::drawPoints(const QPolygonF &points) | - |
3768 | | - |
3769 | \overload | - |
3770 | | - |
3771 | Draws the points in the vector \a points. | - |
3772 | */ | - |
3773 | | - |
3774 | /*! | - |
3775 | \fn void QPainter::drawPoints(const QPolygon &points) | - |
3776 | | - |
3777 | \overload | - |
3778 | | - |
3779 | Draws the points in the vector \a points. | - |
3780 | */ | - |
3781 | | - |
3782 | /*! | - |
3783 | Sets the background mode of the painter to the given \a mode | - |
3784 | | - |
3785 | Qt::TransparentMode (the default) draws stippled lines and text | - |
3786 | without setting the background pixels. Qt::OpaqueMode fills these | - |
3787 | space with the current background color. | - |
3788 | | - |
3789 | Note that in order to draw a bitmap or pixmap transparently, you | - |
3790 | must use QPixmap::setMask(). | - |
3791 | | - |
3792 | \sa backgroundMode(), setBackground(), | - |
3793 | {QPainter#Settings}{Settings} | - |
3794 | */ | - |
3795 | | - |
3796 | void QPainter::setBackgroundMode(Qt::BGMode mode) | - |
3797 | { | - |
3798 | #ifdef QT_DEBUG_DRAW | - |
3799 | if (qt_show_painter_debug_output) | - |
3800 | printf("QPainter::setBackgroundMode(), mode=%d\n", mode); | - |
3801 | #endif | - |
3802 | | - |
3803 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3804 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:11578 |
| 1-11578 |
3805 | qWarning("QPainter::setBackgroundMode: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3805, __PRETTY_FUNCTION__).warning("QPainter::setBackgroundMode: Painter not active"); | - |
3806 | return; executed: return; Execution Count:1 | 1 |
3807 | } | - |
3808 | if (d->state->bgMode == mode) evaluated: d->state->bgMode == mode yes Evaluation Count:1390 | yes Evaluation Count:10188 |
| 1390-10188 |
3809 | return; executed: return; Execution Count:1390 | 1390 |
3810 | | - |
3811 | d->state->bgMode = mode; executed (the execution status of this line is deduced): d->state->bgMode = mode; | - |
3812 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:10188 | no Evaluation Count:0 |
| 0-10188 |
3813 | d->checkEmulation(); executed (the execution status of this line is deduced): d->checkEmulation(); | - |
3814 | } else { executed: } Execution Count:10188 | 10188 |
3815 | d->state->dirtyFlags |= QPaintEngine::DirtyBackgroundMode; never executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyBackgroundMode; | - |
3816 | } | 0 |
3817 | } | - |
3818 | | - |
3819 | /*! | - |
3820 | Returns the current background mode. | - |
3821 | | - |
3822 | \sa setBackgroundMode(), {QPainter#Settings}{Settings} | - |
3823 | */ | - |
3824 | Qt::BGMode QPainter::backgroundMode() const | - |
3825 | { | - |
3826 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
3827 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:5028 |
| 1-5028 |
3828 | qWarning("QPainter::backgroundMode: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3828, __PRETTY_FUNCTION__).warning("QPainter::backgroundMode: Painter not active"); | - |
3829 | return Qt::TransparentMode; executed: return Qt::TransparentMode; Execution Count:1 | 1 |
3830 | } | - |
3831 | return d->state->bgMode; executed: return d->state->bgMode; Execution Count:5028 | 5028 |
3832 | } | - |
3833 | | - |
3834 | | - |
3835 | /*! | - |
3836 | \overload | - |
3837 | | - |
3838 | Sets the painter's pen to have style Qt::SolidLine, width 0 and the | - |
3839 | specified \a color. | - |
3840 | */ | - |
3841 | | - |
3842 | void QPainter::setPen(const QColor &color) | - |
3843 | { | - |
3844 | #ifdef QT_DEBUG_DRAW | - |
3845 | if (qt_show_painter_debug_output) | - |
3846 | printf("QPainter::setPen(), color=%04x\n", color.rgb()); | - |
3847 | #endif | - |
3848 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3849 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:83971 |
| 1-83971 |
3850 | qWarning("QPainter::setPen: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3850, __PRETTY_FUNCTION__).warning("QPainter::setPen: Painter not active"); | - |
3851 | return; executed: return; Execution Count:1 | 1 |
3852 | } | - |
3853 | | - |
3854 | QPen pen(color.isValid() ? color : QColor(Qt::black)); executed (the execution status of this line is deduced): QPen pen(color.isValid() ? color : QColor(Qt::black)); | - |
3855 | | - |
3856 | if (d->state->pen == pen) evaluated: d->state->pen == pen yes Evaluation Count:1861 | yes Evaluation Count:82110 |
| 1861-82110 |
3857 | return; executed: return; Execution Count:1861 | 1861 |
3858 | | - |
3859 | d->state->pen = pen; executed (the execution status of this line is deduced): d->state->pen = pen; | - |
3860 | if (d->extended) partially evaluated: d->extended yes Evaluation Count:82110 | no Evaluation Count:0 |
| 0-82110 |
3861 | d->extended->penChanged(); executed: d->extended->penChanged(); Execution Count:82110 | 82110 |
3862 | else | - |
3863 | d->state->dirtyFlags |= QPaintEngine::DirtyPen; never executed: d->state->dirtyFlags |= QPaintEngine::DirtyPen; | 0 |
3864 | } | - |
3865 | | - |
3866 | /*! | - |
3867 | Sets the painter's pen to be the given \a pen. | - |
3868 | | - |
3869 | The \a pen defines how to draw lines and outlines, and it also | - |
3870 | defines the text color. | - |
3871 | | - |
3872 | \sa pen(), {QPainter#Settings}{Settings} | - |
3873 | */ | - |
3874 | | - |
3875 | void QPainter::setPen(const QPen &pen) | - |
3876 | { | - |
3877 | | - |
3878 | #ifdef QT_DEBUG_DRAW | - |
3879 | if (qt_show_painter_debug_output) | - |
3880 | printf("QPainter::setPen(), color=%04x, (brushStyle=%d) style=%d, cap=%d, join=%d\n", | - |
3881 | pen.color().rgb(), pen.brush().style(), pen.style(), pen.capStyle(), pen.joinStyle()); | - |
3882 | #endif | - |
3883 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3884 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:58138 |
| 1-58138 |
3885 | qWarning("QPainter::setPen: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3885, __PRETTY_FUNCTION__).warning("QPainter::setPen: Painter not active"); | - |
3886 | return; executed: return; Execution Count:1 | 1 |
3887 | } | - |
3888 | | - |
3889 | if (d->state->pen == pen) evaluated: d->state->pen == pen yes Evaluation Count:33327 | yes Evaluation Count:24811 |
| 24811-33327 |
3890 | return; executed: return; Execution Count:33327 | 33327 |
3891 | | - |
3892 | d->state->pen = pen; executed (the execution status of this line is deduced): d->state->pen = pen; | - |
3893 | | - |
3894 | if (d->extended) { evaluated: d->extended yes Evaluation Count:24809 | yes Evaluation Count:2 |
| 2-24809 |
3895 | d->checkEmulation(); executed (the execution status of this line is deduced): d->checkEmulation(); | - |
3896 | d->extended->penChanged(); executed (the execution status of this line is deduced): d->extended->penChanged(); | - |
3897 | return; executed: return; Execution Count:24809 | 24809 |
3898 | } | - |
3899 | | - |
3900 | d->state->dirtyFlags |= QPaintEngine::DirtyPen; executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyPen; | - |
3901 | } executed: } Execution Count:2 | 2 |
3902 | | - |
3903 | /*! | - |
3904 | \overload | - |
3905 | | - |
3906 | Sets the painter's pen to have the given \a style, width 1 and | - |
3907 | black color. | - |
3908 | */ | - |
3909 | | - |
3910 | void QPainter::setPen(Qt::PenStyle style) | - |
3911 | { | - |
3912 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3913 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:7845 |
| 1-7845 |
3914 | qWarning("QPainter::setPen: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3914, __PRETTY_FUNCTION__).warning("QPainter::setPen: Painter not active"); | - |
3915 | return; executed: return; Execution Count:1 | 1 |
3916 | } | - |
3917 | | - |
3918 | QPen pen = QPen(style); executed (the execution status of this line is deduced): QPen pen = QPen(style); | - |
3919 | | - |
3920 | if (d->state->pen == pen) evaluated: d->state->pen == pen yes Evaluation Count:2259 | yes Evaluation Count:5586 |
| 2259-5586 |
3921 | return; executed: return; Execution Count:2259 | 2259 |
3922 | | - |
3923 | d->state->pen = pen; executed (the execution status of this line is deduced): d->state->pen = pen; | - |
3924 | | - |
3925 | if (d->extended) evaluated: d->extended yes Evaluation Count:5578 | yes Evaluation Count:8 |
| 8-5578 |
3926 | d->extended->penChanged(); executed: d->extended->penChanged(); Execution Count:5578 | 5578 |
3927 | else | - |
3928 | d->state->dirtyFlags |= QPaintEngine::DirtyPen; executed: d->state->dirtyFlags |= QPaintEngine::DirtyPen; Execution Count:8 | 8 |
3929 | | - |
3930 | } | - |
3931 | | - |
3932 | /*! | - |
3933 | Returns the painter's current pen. | - |
3934 | | - |
3935 | \sa setPen(), {QPainter#Settings}{Settings} | - |
3936 | */ | - |
3937 | | - |
3938 | const QPen &QPainter::pen() const | - |
3939 | { | - |
3940 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
3941 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:98458 |
| 1-98458 |
3942 | qWarning("QPainter::pen: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3942, __PRETTY_FUNCTION__).warning("QPainter::pen: Painter not active"); | - |
3943 | return d->fakeState()->pen; executed: return d->fakeState()->pen; Execution Count:1 | 1 |
3944 | } | - |
3945 | return d->state->pen; executed: return d->state->pen; Execution Count:98458 | 98458 |
3946 | } | - |
3947 | | - |
3948 | | - |
3949 | /*! | - |
3950 | Sets the painter's brush to the given \a brush. | - |
3951 | | - |
3952 | The painter's brush defines how shapes are filled. | - |
3953 | | - |
3954 | \sa brush(), {QPainter#Settings}{Settings} | - |
3955 | */ | - |
3956 | | - |
3957 | void QPainter::setBrush(const QBrush &brush) | - |
3958 | { | - |
3959 | #ifdef QT_DEBUG_DRAW | - |
3960 | if (qt_show_painter_debug_output) | - |
3961 | printf("QPainter::setBrush(), color=%04x, style=%d\n", brush.color().rgb(), brush.style()); | - |
3962 | #endif | - |
3963 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3964 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:2 | yes Evaluation Count:12040 |
| 2-12040 |
3965 | qWarning("QPainter::setBrush: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3965, __PRETTY_FUNCTION__).warning("QPainter::setBrush: Painter not active"); | - |
3966 | return; executed: return; Execution Count:2 | 2 |
3967 | } | - |
3968 | | - |
3969 | if (d->state->brush.d == brush.d) evaluated: d->state->brush.d == brush.d yes Evaluation Count:1434 | yes Evaluation Count:10606 |
| 1434-10606 |
3970 | return; executed: return; Execution Count:1434 | 1434 |
3971 | | - |
3972 | if (d->extended) { evaluated: d->extended yes Evaluation Count:10598 | yes Evaluation Count:8 |
| 8-10598 |
3973 | d->state->brush = brush; executed (the execution status of this line is deduced): d->state->brush = brush; | - |
3974 | d->checkEmulation(); executed (the execution status of this line is deduced): d->checkEmulation(); | - |
3975 | d->extended->brushChanged(); executed (the execution status of this line is deduced): d->extended->brushChanged(); | - |
3976 | return; executed: return; Execution Count:10598 | 10598 |
3977 | } | - |
3978 | | - |
3979 | d->state->brush = brush; executed (the execution status of this line is deduced): d->state->brush = brush; | - |
3980 | d->state->dirtyFlags |= QPaintEngine::DirtyBrush; executed (the execution status of this line is deduced): d->state->dirtyFlags |= QPaintEngine::DirtyBrush; | - |
3981 | } executed: } Execution Count:8 | 8 |
3982 | | - |
3983 | | - |
3984 | /*! | - |
3985 | \overload | - |
3986 | | - |
3987 | Sets the painter's brush to black color and the specified \a | - |
3988 | style. | - |
3989 | */ | - |
3990 | | - |
3991 | void QPainter::setBrush(Qt::BrushStyle style) | - |
3992 | { | - |
3993 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
3994 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:1236 |
| 1-1236 |
3995 | qWarning("QPainter::setBrush: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 3995, __PRETTY_FUNCTION__).warning("QPainter::setBrush: Painter not active"); | - |
3996 | return; executed: return; Execution Count:1 | 1 |
3997 | } | - |
3998 | if (d->state->brush.style() == style && evaluated: d->state->brush.style() == style yes Evaluation Count:871 | yes Evaluation Count:365 |
| 365-871 |
3999 | (style == Qt::NoBrush partially evaluated: style == Qt::NoBrush yes Evaluation Count:871 | no Evaluation Count:0 |
| 0-871 |
4000 | || (style == Qt::SolidPattern && d->state->brush.color() == QColor(0, 0, 0)))) never evaluated: style == Qt::SolidPattern never evaluated: d->state->brush.color() == QColor(0, 0, 0) | 0 |
4001 | return; executed: return; Execution Count:871 | 871 |
4002 | d->state->brush = QBrush(Qt::black, style); executed (the execution status of this line is deduced): d->state->brush = QBrush(Qt::black, style); | - |
4003 | if (d->extended) partially evaluated: d->extended yes Evaluation Count:365 | no Evaluation Count:0 |
| 0-365 |
4004 | d->extended->brushChanged(); executed: d->extended->brushChanged(); Execution Count:365 | 365 |
4005 | else | - |
4006 | d->state->dirtyFlags |= QPaintEngine::DirtyBrush; never executed: d->state->dirtyFlags |= QPaintEngine::DirtyBrush; | 0 |
4007 | } | - |
4008 | | - |
4009 | /*! | - |
4010 | Returns the painter's current brush. | - |
4011 | | - |
4012 | \sa QPainter::setBrush(), {QPainter#Settings}{Settings} | - |
4013 | */ | - |
4014 | | - |
4015 | const QBrush &QPainter::brush() const | - |
4016 | { | - |
4017 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
4018 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:875 |
| 1-875 |
4019 | qWarning("QPainter::brush: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 4019, __PRETTY_FUNCTION__).warning("QPainter::brush: Painter not active"); | - |
4020 | return d->fakeState()->brush; executed: return d->fakeState()->brush; Execution Count:1 | 1 |
4021 | } | - |
4022 | return d->state->brush; executed: return d->state->brush; Execution Count:875 | 875 |
4023 | } | - |
4024 | | - |
4025 | /*! | - |
4026 | \fn void QPainter::setBackground(const QBrush &brush) | - |
4027 | | - |
4028 | Sets the background brush of the painter to the given \a brush. | - |
4029 | | - |
4030 | The background brush is the brush that is filled in when drawing | - |
4031 | opaque text, stippled lines and bitmaps. The background brush has | - |
4032 | no effect in transparent background mode (which is the default). | - |
4033 | | - |
4034 | \sa background(), setBackgroundMode(), | - |
4035 | {QPainter#Settings}{Settings} | - |
4036 | */ | - |
4037 | | - |
4038 | void QPainter::setBackground(const QBrush &bg) | - |
4039 | { | - |
4040 | #ifdef QT_DEBUG_DRAW | - |
4041 | if (qt_show_painter_debug_output) | - |
4042 | printf("QPainter::setBackground(), color=%04x, style=%d\n", bg.color().rgb(), bg.style()); | - |
4043 | #endif | - |
4044 | | - |
4045 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4046 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:10159 |
| 1-10159 |
4047 | qWarning("QPainter::setBackground: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 4047, __PRETTY_FUNCTION__).warning("QPainter::setBackground: Painter not active"); | - |
4048 | return; executed: return; Execution Count:1 | 1 |
4049 | } | - |
4050 | d->state->bgBrush = bg; executed (the execution status of this line is deduced): d->state->bgBrush = bg; | - |
4051 | if (!d->extended) partially evaluated: !d->extended no Evaluation Count:0 | yes Evaluation Count:10159 |
| 0-10159 |
4052 | d->state->dirtyFlags |= QPaintEngine::DirtyBackground; never executed: d->state->dirtyFlags |= QPaintEngine::DirtyBackground; | 0 |
4053 | } executed: } Execution Count:10159 | 10159 |
4054 | | - |
4055 | /*! | - |
4056 | Sets the painter's font to the given \a font. | - |
4057 | | - |
4058 | This font is used by subsequent drawText() functions. The text | - |
4059 | color is the same as the pen color. | - |
4060 | | - |
4061 | If you set a font that isn't available, Qt finds a close match. | - |
4062 | font() will return what you set using setFont() and fontInfo() returns the | - |
4063 | font actually being used (which may be the same). | - |
4064 | | - |
4065 | \sa font(), drawText(), {QPainter#Settings}{Settings} | - |
4066 | */ | - |
4067 | | - |
4068 | void QPainter::setFont(const QFont &font) | - |
4069 | { | - |
4070 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4071 | | - |
4072 | #ifdef QT_DEBUG_DRAW | - |
4073 | if (qt_show_painter_debug_output) | - |
4074 | printf("QPainter::setFont(), family=%s, pointSize=%d\n", font.family().toLatin1().constData(), font.pointSize()); | - |
4075 | #endif | - |
4076 | | - |
4077 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:1696 |
| 1-1696 |
4078 | qWarning("QPainter::setFont: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 4078, __PRETTY_FUNCTION__).warning("QPainter::setFont: Painter not active"); | - |
4079 | return; executed: return; Execution Count:1 | 1 |
4080 | } | - |
4081 | | - |
4082 | d->state->font = QFont(font.resolve(d->state->deviceFont), device()); executed (the execution status of this line is deduced): d->state->font = QFont(font.resolve(d->state->deviceFont), device()); | - |
4083 | if (!d->extended) partially evaluated: !d->extended no Evaluation Count:0 | yes Evaluation Count:1696 |
| 0-1696 |
4084 | d->state->dirtyFlags |= QPaintEngine::DirtyFont; never executed: d->state->dirtyFlags |= QPaintEngine::DirtyFont; | 0 |
4085 | } executed: } Execution Count:1696 | 1696 |
4086 | | - |
4087 | /*! | - |
4088 | Returns the currently set font used for drawing text. | - |
4089 | | - |
4090 | \sa setFont(), drawText(), {QPainter#Settings}{Settings} | - |
4091 | */ | - |
4092 | const QFont &QPainter::font() const | - |
4093 | { | - |
4094 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
4095 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:503 |
| 1-503 |
4096 | qWarning("QPainter::font: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 4096, __PRETTY_FUNCTION__).warning("QPainter::font: Painter not active"); | - |
4097 | return d->fakeState()->font; executed: return d->fakeState()->font; Execution Count:1 | 1 |
4098 | } | - |
4099 | return d->state->font; executed: return d->state->font; Execution Count:503 | 503 |
4100 | } | - |
4101 | | - |
4102 | /*! | - |
4103 | \since 4.4 | - |
4104 | | - |
4105 | Draws the given rectangle \a rect with rounded corners. | - |
4106 | | - |
4107 | The \a xRadius and \a yRadius arguments specify the radii | - |
4108 | of the ellipses defining the corners of the rounded rectangle. | - |
4109 | When \a mode is Qt::RelativeSize, \a xRadius and | - |
4110 | \a yRadius are specified in percentage of half the rectangle's | - |
4111 | width and height respectively, and should be in the range | - |
4112 | 0.0 to 100.0. | - |
4113 | | - |
4114 | A filled rectangle has a size of rect.size(). A stroked rectangle | - |
4115 | has a size of rect.size() plus the pen width. | - |
4116 | | - |
4117 | \table 100% | - |
4118 | \row | - |
4119 | \li \inlineimage qpainter-roundrect.png | - |
4120 | \li | - |
4121 | \snippet code/src_gui_painting_qpainter.cpp 8 | - |
4122 | \endtable | - |
4123 | | - |
4124 | \sa drawRect(), QPen | - |
4125 | */ | - |
4126 | void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode) | - |
4127 | { | - |
4128 | #ifdef QT_DEBUG_DRAW | - |
4129 | if (qt_show_painter_debug_output) | - |
4130 | printf("QPainter::drawRoundedRect(), [%.2f,%.2f,%.2f,%.2f]\n", rect.x(), rect.y(), rect.width(), rect.height()); | - |
4131 | #endif | - |
4132 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4133 | | - |
4134 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:305 |
| 0-305 |
4135 | return; | 0 |
4136 | | - |
4137 | if (xRadius <= 0 || yRadius <= 0) { // draw normal rectangle partially evaluated: xRadius <= 0 no Evaluation Count:0 | yes Evaluation Count:305 |
partially evaluated: yRadius <= 0 no Evaluation Count:0 | yes Evaluation Count:305 |
| 0-305 |
4138 | drawRect(rect); never executed (the execution status of this line is deduced): drawRect(rect); | - |
4139 | return; | 0 |
4140 | } | - |
4141 | | - |
4142 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:305 | no Evaluation Count:0 |
| 0-305 |
4143 | d->extended->drawRoundedRect(rect, xRadius, yRadius, mode); executed (the execution status of this line is deduced): d->extended->drawRoundedRect(rect, xRadius, yRadius, mode); | - |
4144 | return; executed: return; Execution Count:305 | 305 |
4145 | } | - |
4146 | | - |
4147 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
4148 | path.addRoundedRect(rect, xRadius, yRadius, mode); never executed (the execution status of this line is deduced): path.addRoundedRect(rect, xRadius, yRadius, mode); | - |
4149 | drawPath(path); never executed (the execution status of this line is deduced): drawPath(path); | - |
4150 | } | 0 |
4151 | | - |
4152 | /*! | - |
4153 | \fn void QPainter::drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius, | - |
4154 | Qt::SizeMode mode = Qt::AbsoluteSize); | - |
4155 | \since 4.4 | - |
4156 | \overload | - |
4157 | | - |
4158 | Draws the given rectangle \a rect with rounded corners. | - |
4159 | */ | - |
4160 | | - |
4161 | /*! | - |
4162 | \fn void QPainter::drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius, | - |
4163 | Qt::SizeMode mode = Qt::AbsoluteSize); | - |
4164 | \since 4.4 | - |
4165 | \overload | - |
4166 | | - |
4167 | Draws the given rectangle \a x, \a y, \a w, \a h with rounded corners. | - |
4168 | */ | - |
4169 | | - |
4170 | /*! | - |
4171 | \obsolete | - |
4172 | | - |
4173 | Draws a rectangle \a r with rounded corners. | - |
4174 | | - |
4175 | The \a xRnd and \a yRnd arguments specify how rounded the corners | - |
4176 | should be. 0 is angled corners, 99 is maximum roundedness. | - |
4177 | | - |
4178 | A filled rectangle has a size of r.size(). A stroked rectangle | - |
4179 | has a size of r.size() plus the pen width. | - |
4180 | | - |
4181 | \sa drawRoundedRect() | - |
4182 | */ | - |
4183 | void QPainter::drawRoundRect(const QRectF &r, int xRnd, int yRnd) | - |
4184 | { | - |
4185 | drawRoundedRect(r, xRnd, yRnd, Qt::RelativeSize); executed (the execution status of this line is deduced): drawRoundedRect(r, xRnd, yRnd, Qt::RelativeSize); | - |
4186 | } executed: } Execution Count:223 | 223 |
4187 | | - |
4188 | | - |
4189 | /*! | - |
4190 | \fn void QPainter::drawRoundRect(const QRect &r, int xRnd = 25, int yRnd = 25) | - |
4191 | | - |
4192 | \overload | - |
4193 | \obsolete | - |
4194 | | - |
4195 | Draws the rectangle \a r with rounded corners. | - |
4196 | */ | - |
4197 | | - |
4198 | /*! | - |
4199 | \obsolete | - |
4200 | | - |
4201 | \fn QPainter::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd) | - |
4202 | | - |
4203 | \overload | - |
4204 | | - |
4205 | Draws the rectangle \a x, \a y, \a w, \a h with rounded corners. | - |
4206 | */ | - |
4207 | | - |
4208 | /*! | - |
4209 | \fn void QPainter::drawEllipse(const QRectF &rectangle) | - |
4210 | | - |
4211 | Draws the ellipse defined by the given \a rectangle. | - |
4212 | | - |
4213 | A filled ellipse has a size of \a{rectangle}.\l | - |
4214 | {QRect::size()}{size()}. A stroked ellipse has a size of | - |
4215 | \a{rectangle}.\l {QRect::size()}{size()} plus the pen width. | - |
4216 | | - |
4217 | \table 100% | - |
4218 | \row | - |
4219 | \li \inlineimage qpainter-ellipse.png | - |
4220 | \li | - |
4221 | \snippet code/src_gui_painting_qpainter.cpp 9 | - |
4222 | \endtable | - |
4223 | | - |
4224 | \sa drawPie(), {Coordinate System} | - |
4225 | */ | - |
4226 | void QPainter::drawEllipse(const QRectF &r) | - |
4227 | { | - |
4228 | #ifdef QT_DEBUG_DRAW | - |
4229 | if (qt_show_painter_debug_output) | - |
4230 | printf("QPainter::drawEllipse(), [%.2f,%.2f,%.2f,%.2f]\n", r.x(), r.y(), r.width(), r.height()); | - |
4231 | #endif | - |
4232 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4233 | | - |
4234 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:1042 |
| 0-1042 |
4235 | return; | 0 |
4236 | | - |
4237 | QRectF rect(r.normalized()); executed (the execution status of this line is deduced): QRectF rect(r.normalized()); | - |
4238 | | - |
4239 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:1042 | no Evaluation Count:0 |
| 0-1042 |
4240 | d->extended->drawEllipse(rect); executed (the execution status of this line is deduced): d->extended->drawEllipse(rect); | - |
4241 | return; executed: return; Execution Count:1042 | 1042 |
4242 | } | - |
4243 | | - |
4244 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4245 | if (d->state->emulationSpecifier) { never evaluated: d->state->emulationSpecifier | 0 |
4246 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform never evaluated: d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | 0 |
4247 | && d->state->matrix.type() == QTransform::TxTranslate) { never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
4248 | rect.translate(QPointF(d->state->matrix.dx(), d->state->matrix.dy())); never executed (the execution status of this line is deduced): rect.translate(QPointF(d->state->matrix.dx(), d->state->matrix.dy())); | - |
4249 | } else { | 0 |
4250 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
4251 | path.addEllipse(rect); never executed (the execution status of this line is deduced): path.addEllipse(rect); | - |
4252 | d->draw_helper(path, QPainterPrivate::StrokeAndFillDraw); never executed (the execution status of this line is deduced): d->draw_helper(path, QPainterPrivate::StrokeAndFillDraw); | - |
4253 | return; | 0 |
4254 | } | - |
4255 | } | - |
4256 | | - |
4257 | d->engine->drawEllipse(rect); never executed (the execution status of this line is deduced): d->engine->drawEllipse(rect); | - |
4258 | } | 0 |
4259 | | - |
4260 | /*! | - |
4261 | \fn QPainter::drawEllipse(const QRect &rectangle) | - |
4262 | | - |
4263 | \overload | - |
4264 | | - |
4265 | Draws the ellipse defined by the given \a rectangle. | - |
4266 | */ | - |
4267 | void QPainter::drawEllipse(const QRect &r) | - |
4268 | { | - |
4269 | #ifdef QT_DEBUG_DRAW | - |
4270 | if (qt_show_painter_debug_output) | - |
4271 | printf("QPainter::drawEllipse(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height()); | - |
4272 | #endif | - |
4273 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4274 | | - |
4275 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:985 |
| 0-985 |
4276 | return; | 0 |
4277 | | - |
4278 | QRect rect(r.normalized()); executed (the execution status of this line is deduced): QRect rect(r.normalized()); | - |
4279 | | - |
4280 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:985 | no Evaluation Count:0 |
| 0-985 |
4281 | d->extended->drawEllipse(rect); executed (the execution status of this line is deduced): d->extended->drawEllipse(rect); | - |
4282 | return; executed: return; Execution Count:985 | 985 |
4283 | } | - |
4284 | | - |
4285 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4286 | | - |
4287 | if (d->state->emulationSpecifier) { never evaluated: d->state->emulationSpecifier | 0 |
4288 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform never evaluated: d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | 0 |
4289 | && d->state->matrix.type() == QTransform::TxTranslate) { never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
4290 | rect.translate(QPoint(qRound(d->state->matrix.dx()), qRound(d->state->matrix.dy()))); never executed (the execution status of this line is deduced): rect.translate(QPoint(qRound(d->state->matrix.dx()), qRound(d->state->matrix.dy()))); | - |
4291 | } else { | 0 |
4292 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
4293 | path.addEllipse(rect); never executed (the execution status of this line is deduced): path.addEllipse(rect); | - |
4294 | d->draw_helper(path, QPainterPrivate::StrokeAndFillDraw); never executed (the execution status of this line is deduced): d->draw_helper(path, QPainterPrivate::StrokeAndFillDraw); | - |
4295 | return; | 0 |
4296 | } | - |
4297 | } | - |
4298 | | - |
4299 | d->engine->drawEllipse(rect); never executed (the execution status of this line is deduced): d->engine->drawEllipse(rect); | - |
4300 | } | 0 |
4301 | | - |
4302 | /*! | - |
4303 | \fn QPainter::drawEllipse(int x, int y, int width, int height) | - |
4304 | | - |
4305 | \overload | - |
4306 | | - |
4307 | Draws the ellipse defined by the rectangle beginning at (\a{x}, | - |
4308 | \a{y}) with the given \a width and \a height. | - |
4309 | */ | - |
4310 | | - |
4311 | /*! | - |
4312 | \since 4.4 | - |
4313 | | - |
4314 | \fn QPainter::drawEllipse(const QPointF ¢er, qreal rx, qreal ry) | - |
4315 | | - |
4316 | \overload | - |
4317 | | - |
4318 | Draws the ellipse positioned at \a{center} with radii \a{rx} and \a{ry}. | - |
4319 | */ | - |
4320 | | - |
4321 | /*! | - |
4322 | \since 4.4 | - |
4323 | | - |
4324 | \fn QPainter::drawEllipse(const QPoint ¢er, int rx, int ry) | - |
4325 | | - |
4326 | \overload | - |
4327 | | - |
4328 | Draws the ellipse positioned at \a{center} with radii \a{rx} and \a{ry}. | - |
4329 | */ | - |
4330 | | - |
4331 | /*! | - |
4332 | \fn void QPainter::drawArc(const QRectF &rectangle, int startAngle, int spanAngle) | - |
4333 | | - |
4334 | Draws the arc defined by the given \a rectangle, \a startAngle and | - |
4335 | \a spanAngle. | - |
4336 | | - |
4337 | The \a startAngle and \a spanAngle must be specified in 1/16th of | - |
4338 | a degree, i.e. a full circle equals 5760 (16 * 360). Positive | - |
4339 | values for the angles mean counter-clockwise while negative values | - |
4340 | mean the clockwise direction. Zero degrees is at the 3 o'clock | - |
4341 | position. | - |
4342 | | - |
4343 | \table 100% | - |
4344 | \row | - |
4345 | \li \inlineimage qpainter-arc.png | - |
4346 | \li | - |
4347 | \snippet code/src_gui_painting_qpainter.cpp 10 | - |
4348 | \endtable | - |
4349 | | - |
4350 | \sa drawPie(), drawChord(), {Coordinate System} | - |
4351 | */ | - |
4352 | | - |
4353 | void QPainter::drawArc(const QRectF &r, int a, int alen) | - |
4354 | { | - |
4355 | #ifdef QT_DEBUG_DRAW | - |
4356 | if (qt_show_painter_debug_output) | - |
4357 | printf("QPainter::drawArc(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n", | - |
4358 | r.x(), r.y(), r.width(), r.height(), a/16, alen/16); | - |
4359 | #endif | - |
4360 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4361 | | - |
4362 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
4363 | return; | 0 |
4364 | | - |
4365 | QRectF rect = r.normalized(); executed (the execution status of this line is deduced): QRectF rect = r.normalized(); | - |
4366 | | - |
4367 | QPainterPath path; executed (the execution status of this line is deduced): QPainterPath path; | - |
4368 | path.arcMoveTo(rect, a/16.0); executed (the execution status of this line is deduced): path.arcMoveTo(rect, a/16.0); | - |
4369 | path.arcTo(rect, a/16.0, alen/16.0); executed (the execution status of this line is deduced): path.arcTo(rect, a/16.0, alen/16.0); | - |
4370 | strokePath(path, d->state->pen); executed (the execution status of this line is deduced): strokePath(path, d->state->pen); | - |
4371 | } executed: } Execution Count:12 | 12 |
4372 | | - |
4373 | /*! \fn void QPainter::drawArc(const QRect &rectangle, int startAngle, | - |
4374 | int spanAngle) | - |
4375 | | - |
4376 | \overload | - |
4377 | | - |
4378 | Draws the arc defined by the given \a rectangle, \a startAngle and | - |
4379 | \a spanAngle. | - |
4380 | */ | - |
4381 | | - |
4382 | /*! | - |
4383 | \fn void QPainter::drawArc(int x, int y, int width, int height, | - |
4384 | int startAngle, int spanAngle) | - |
4385 | | - |
4386 | \overload | - |
4387 | | - |
4388 | Draws the arc defined by the rectangle beginning at (\a x, \a y) | - |
4389 | with the specified \a width and \a height, and the given \a | - |
4390 | startAngle and \a spanAngle. | - |
4391 | */ | - |
4392 | | - |
4393 | /*! | - |
4394 | \fn void QPainter::drawPie(const QRectF &rectangle, int startAngle, int spanAngle) | - |
4395 | | - |
4396 | Draws a pie defined by the given \a rectangle, \a startAngle and \a spanAngle. | - |
4397 | | - |
4398 | The pie is filled with the current brush(). | - |
4399 | | - |
4400 | The startAngle and spanAngle must be specified in 1/16th of a | - |
4401 | degree, i.e. a full circle equals 5760 (16 * 360). Positive values | - |
4402 | for the angles mean counter-clockwise while negative values mean | - |
4403 | the clockwise direction. Zero degrees is at the 3 o'clock | - |
4404 | position. | - |
4405 | | - |
4406 | \table 100% | - |
4407 | \row | - |
4408 | \li \inlineimage qpainter-pie.png | - |
4409 | \li | - |
4410 | \snippet code/src_gui_painting_qpainter.cpp 11 | - |
4411 | \endtable | - |
4412 | | - |
4413 | \sa drawEllipse(), drawChord(), {Coordinate System} | - |
4414 | */ | - |
4415 | void QPainter::drawPie(const QRectF &r, int a, int alen) | - |
4416 | { | - |
4417 | #ifdef QT_DEBUG_DRAW | - |
4418 | if (qt_show_painter_debug_output) | - |
4419 | printf("QPainter::drawPie(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n", | - |
4420 | r.x(), r.y(), r.width(), r.height(), a/16, alen/16); | - |
4421 | #endif | - |
4422 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4423 | | - |
4424 | if (!d->engine) never evaluated: !d->engine | 0 |
4425 | return; | 0 |
4426 | | - |
4427 | if (a > (360*16)) { never evaluated: a > (360*16) | 0 |
4428 | a = a % (360*16); never executed (the execution status of this line is deduced): a = a % (360*16); | - |
4429 | } else if (a < 0) { never executed: } never evaluated: a < 0 | 0 |
4430 | a = a % (360*16); never executed (the execution status of this line is deduced): a = a % (360*16); | - |
4431 | if (a < 0) a += (360*16); never executed: a += (360*16); never evaluated: a < 0 | 0 |
4432 | } | 0 |
4433 | | - |
4434 | QRectF rect = r.normalized(); never executed (the execution status of this line is deduced): QRectF rect = r.normalized(); | - |
4435 | | - |
4436 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
4437 | path.moveTo(rect.center()); never executed (the execution status of this line is deduced): path.moveTo(rect.center()); | - |
4438 | path.arcTo(rect.x(), rect.y(), rect.width(), rect.height(), a/16.0, alen/16.0); never executed (the execution status of this line is deduced): path.arcTo(rect.x(), rect.y(), rect.width(), rect.height(), a/16.0, alen/16.0); | - |
4439 | path.closeSubpath(); never executed (the execution status of this line is deduced): path.closeSubpath(); | - |
4440 | drawPath(path); never executed (the execution status of this line is deduced): drawPath(path); | - |
4441 | | - |
4442 | } | 0 |
4443 | | - |
4444 | /*! | - |
4445 | \fn void QPainter::drawPie(const QRect &rectangle, int startAngle, int spanAngle) | - |
4446 | \overload | - |
4447 | | - |
4448 | Draws a pie defined by the given \a rectangle, \a startAngle and | - |
4449 | and \a spanAngle. | - |
4450 | */ | - |
4451 | | - |
4452 | /*! | - |
4453 | \fn void QPainter::drawPie(int x, int y, int width, int height, int | - |
4454 | startAngle, int spanAngle) | - |
4455 | | - |
4456 | \overload | - |
4457 | | - |
4458 | Draws the pie defined by the rectangle beginning at (\a x, \a y) with | - |
4459 | the specified \a width and \a height, and the given \a startAngle and | - |
4460 | \a spanAngle. | - |
4461 | */ | - |
4462 | | - |
4463 | /*! | - |
4464 | \fn void QPainter::drawChord(const QRectF &rectangle, int startAngle, int spanAngle) | - |
4465 | | - |
4466 | Draws the chord defined by the given \a rectangle, \a startAngle and | - |
4467 | \a spanAngle. The chord is filled with the current brush(). | - |
4468 | | - |
4469 | The startAngle and spanAngle must be specified in 1/16th of a | - |
4470 | degree, i.e. a full circle equals 5760 (16 * 360). Positive values | - |
4471 | for the angles mean counter-clockwise while negative values mean | - |
4472 | the clockwise direction. Zero degrees is at the 3 o'clock | - |
4473 | position. | - |
4474 | | - |
4475 | \table 100% | - |
4476 | \row | - |
4477 | \li \inlineimage qpainter-chord.png | - |
4478 | \li | - |
4479 | \snippet code/src_gui_painting_qpainter.cpp 12 | - |
4480 | \endtable | - |
4481 | | - |
4482 | \sa drawArc(), drawPie(), {Coordinate System} | - |
4483 | */ | - |
4484 | void QPainter::drawChord(const QRectF &r, int a, int alen) | - |
4485 | { | - |
4486 | #ifdef QT_DEBUG_DRAW | - |
4487 | if (qt_show_painter_debug_output) | - |
4488 | printf("QPainter::drawChord(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n", | - |
4489 | r.x(), r.y(), r.width(), r.height(), a/16, alen/16); | - |
4490 | #endif | - |
4491 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4492 | | - |
4493 | if (!d->engine) never evaluated: !d->engine | 0 |
4494 | return; | 0 |
4495 | | - |
4496 | QRectF rect = r.normalized(); never executed (the execution status of this line is deduced): QRectF rect = r.normalized(); | - |
4497 | | - |
4498 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
4499 | path.arcMoveTo(rect, a/16.0); never executed (the execution status of this line is deduced): path.arcMoveTo(rect, a/16.0); | - |
4500 | path.arcTo(rect, a/16.0, alen/16.0); never executed (the execution status of this line is deduced): path.arcTo(rect, a/16.0, alen/16.0); | - |
4501 | path.closeSubpath(); never executed (the execution status of this line is deduced): path.closeSubpath(); | - |
4502 | drawPath(path); never executed (the execution status of this line is deduced): drawPath(path); | - |
4503 | } | 0 |
4504 | /*! | - |
4505 | \fn void QPainter::drawChord(const QRect &rectangle, int startAngle, int spanAngle) | - |
4506 | | - |
4507 | \overload | - |
4508 | | - |
4509 | Draws the chord defined by the given \a rectangle, \a startAngle and | - |
4510 | \a spanAngle. | - |
4511 | */ | - |
4512 | | - |
4513 | /*! | - |
4514 | \fn void QPainter::drawChord(int x, int y, int width, int height, int | - |
4515 | startAngle, int spanAngle) | - |
4516 | | - |
4517 | \overload | - |
4518 | | - |
4519 | Draws the chord defined by the rectangle beginning at (\a x, \a y) | - |
4520 | with the specified \a width and \a height, and the given \a | - |
4521 | startAngle and \a spanAngle. | - |
4522 | */ | - |
4523 | | - |
4524 | | - |
4525 | /*! | - |
4526 | Draws the first \a lineCount lines in the array \a lines | - |
4527 | using the current pen. | - |
4528 | | - |
4529 | \sa drawLine(), drawPolyline() | - |
4530 | */ | - |
4531 | void QPainter::drawLines(const QLineF *lines, int lineCount) | - |
4532 | { | - |
4533 | #ifdef QT_DEBUG_DRAW | - |
4534 | if (qt_show_painter_debug_output) | - |
4535 | printf("QPainter::drawLines(), line count=%d\n", lineCount); | - |
4536 | #endif | - |
4537 | | - |
4538 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4539 | | - |
4540 | if (!d->engine || lineCount < 1) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:1988 |
partially evaluated: lineCount < 1 no Evaluation Count:0 | yes Evaluation Count:1988 |
| 0-1988 |
4541 | return; | 0 |
4542 | | - |
4543 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:1988 | no Evaluation Count:0 |
| 0-1988 |
4544 | d->extended->drawLines(lines, lineCount); executed (the execution status of this line is deduced): d->extended->drawLines(lines, lineCount); | - |
4545 | return; executed: return; Execution Count:1988 | 1988 |
4546 | } | - |
4547 | | - |
4548 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4549 | | - |
4550 | uint lineEmulation = line_emulation(d->state->emulationSpecifier); never executed (the execution status of this line is deduced): uint lineEmulation = line_emulation(d->state->emulationSpecifier); | - |
4551 | | - |
4552 | if (lineEmulation) { never evaluated: lineEmulation | 0 |
4553 | if (lineEmulation == QPaintEngine::PrimitiveTransform never evaluated: lineEmulation == QPaintEngine::PrimitiveTransform | 0 |
4554 | && d->state->matrix.type() == QTransform::TxTranslate) { never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
4555 | for (int i = 0; i < lineCount; ++i) { never evaluated: i < lineCount | 0 |
4556 | QLineF line = lines[i]; never executed (the execution status of this line is deduced): QLineF line = lines[i]; | - |
4557 | line.translate(d->state->matrix.dx(), d->state->matrix.dy()); never executed (the execution status of this line is deduced): line.translate(d->state->matrix.dx(), d->state->matrix.dy()); | - |
4558 | d->engine->drawLines(&line, 1); never executed (the execution status of this line is deduced): d->engine->drawLines(&line, 1); | - |
4559 | } | 0 |
4560 | } else { | 0 |
4561 | QPainterPath linePath; never executed (the execution status of this line is deduced): QPainterPath linePath; | - |
4562 | for (int i = 0; i < lineCount; ++i) { never evaluated: i < lineCount | 0 |
4563 | linePath.moveTo(lines[i].p1()); never executed (the execution status of this line is deduced): linePath.moveTo(lines[i].p1()); | - |
4564 | linePath.lineTo(lines[i].p2()); never executed (the execution status of this line is deduced): linePath.lineTo(lines[i].p2()); | - |
4565 | } | 0 |
4566 | d->draw_helper(linePath, QPainterPrivate::StrokeDraw); never executed (the execution status of this line is deduced): d->draw_helper(linePath, QPainterPrivate::StrokeDraw); | - |
4567 | } | 0 |
4568 | return; | 0 |
4569 | } | - |
4570 | d->engine->drawLines(lines, lineCount); never executed (the execution status of this line is deduced): d->engine->drawLines(lines, lineCount); | - |
4571 | } | 0 |
4572 | | - |
4573 | /*! | - |
4574 | \fn void QPainter::drawLines(const QLine *lines, int lineCount) | - |
4575 | \overload | - |
4576 | | - |
4577 | Draws the first \a lineCount lines in the array \a lines | - |
4578 | using the current pen. | - |
4579 | */ | - |
4580 | void QPainter::drawLines(const QLine *lines, int lineCount) | - |
4581 | { | - |
4582 | #ifdef QT_DEBUG_DRAW | - |
4583 | if (qt_show_painter_debug_output) | - |
4584 | printf("QPainter::drawLine(), line count=%d\n", lineCount); | - |
4585 | #endif | - |
4586 | | - |
4587 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4588 | | - |
4589 | if (!d->engine || lineCount < 1) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:5045 |
partially evaluated: lineCount < 1 no Evaluation Count:0 | yes Evaluation Count:5045 |
| 0-5045 |
4590 | return; | 0 |
4591 | | - |
4592 | if (d->extended) { evaluated: d->extended yes Evaluation Count:5039 | yes Evaluation Count:6 |
| 6-5039 |
4593 | d->extended->drawLines(lines, lineCount); executed (the execution status of this line is deduced): d->extended->drawLines(lines, lineCount); | - |
4594 | return; executed: return; Execution Count:5039 | 5039 |
4595 | } | - |
4596 | | - |
4597 | d->updateState(d->state); executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4598 | | - |
4599 | uint lineEmulation = line_emulation(d->state->emulationSpecifier); executed (the execution status of this line is deduced): uint lineEmulation = line_emulation(d->state->emulationSpecifier); | - |
4600 | | - |
4601 | if (lineEmulation) { partially evaluated: lineEmulation no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
4602 | if (lineEmulation == QPaintEngine::PrimitiveTransform never evaluated: lineEmulation == QPaintEngine::PrimitiveTransform | 0 |
4603 | && d->state->matrix.type() == QTransform::TxTranslate) { never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
4604 | for (int i = 0; i < lineCount; ++i) { never evaluated: i < lineCount | 0 |
4605 | QLineF line = lines[i]; never executed (the execution status of this line is deduced): QLineF line = lines[i]; | - |
4606 | line.translate(d->state->matrix.dx(), d->state->matrix.dy()); never executed (the execution status of this line is deduced): line.translate(d->state->matrix.dx(), d->state->matrix.dy()); | - |
4607 | d->engine->drawLines(&line, 1); never executed (the execution status of this line is deduced): d->engine->drawLines(&line, 1); | - |
4608 | } | 0 |
4609 | } else { | 0 |
4610 | QPainterPath linePath; never executed (the execution status of this line is deduced): QPainterPath linePath; | - |
4611 | for (int i = 0; i < lineCount; ++i) { never evaluated: i < lineCount | 0 |
4612 | linePath.moveTo(lines[i].p1()); never executed (the execution status of this line is deduced): linePath.moveTo(lines[i].p1()); | - |
4613 | linePath.lineTo(lines[i].p2()); never executed (the execution status of this line is deduced): linePath.lineTo(lines[i].p2()); | - |
4614 | } | 0 |
4615 | d->draw_helper(linePath, QPainterPrivate::StrokeDraw); never executed (the execution status of this line is deduced): d->draw_helper(linePath, QPainterPrivate::StrokeDraw); | - |
4616 | } | 0 |
4617 | return; | 0 |
4618 | } | - |
4619 | d->engine->drawLines(lines, lineCount); executed (the execution status of this line is deduced): d->engine->drawLines(lines, lineCount); | - |
4620 | } executed: } Execution Count:6 | 6 |
4621 | | - |
4622 | /*! | - |
4623 | \overload | - |
4624 | | - |
4625 | Draws the first \a lineCount lines in the array \a pointPairs | - |
4626 | using the current pen. The lines are specified as pairs of points | - |
4627 | so the number of entries in \a pointPairs must be at least \a | - |
4628 | lineCount * 2. | - |
4629 | */ | - |
4630 | void QPainter::drawLines(const QPointF *pointPairs, int lineCount) | - |
4631 | { | - |
4632 | Q_ASSERT(sizeof(QLineF) == 2*sizeof(QPointF)); executed (the execution status of this line is deduced): qt_noop(); | - |
4633 | | - |
4634 | drawLines((QLineF*)pointPairs, lineCount); executed (the execution status of this line is deduced): drawLines((QLineF*)pointPairs, lineCount); | - |
4635 | } executed: } Execution Count:5 | 5 |
4636 | | - |
4637 | /*! | - |
4638 | \overload | - |
4639 | | - |
4640 | Draws the first \a lineCount lines in the array \a pointPairs | - |
4641 | using the current pen. | - |
4642 | */ | - |
4643 | void QPainter::drawLines(const QPoint *pointPairs, int lineCount) | - |
4644 | { | - |
4645 | Q_ASSERT(sizeof(QLine) == 2*sizeof(QPoint)); never executed (the execution status of this line is deduced): qt_noop(); | - |
4646 | | - |
4647 | drawLines((QLine*)pointPairs, lineCount); never executed (the execution status of this line is deduced): drawLines((QLine*)pointPairs, lineCount); | - |
4648 | } | 0 |
4649 | | - |
4650 | | - |
4651 | /*! | - |
4652 | \fn void QPainter::drawLines(const QVector<QPointF> &pointPairs) | - |
4653 | \overload | - |
4654 | | - |
4655 | Draws a line for each pair of points in the vector \a pointPairs | - |
4656 | using the current pen. If there is an odd number of points in the | - |
4657 | array, the last point will be ignored. | - |
4658 | */ | - |
4659 | | - |
4660 | /*! | - |
4661 | \fn void QPainter::drawLines(const QVector<QPoint> &pointPairs) | - |
4662 | \overload | - |
4663 | | - |
4664 | Draws a line for each pair of points in the vector \a pointPairs | - |
4665 | using the current pen. | - |
4666 | */ | - |
4667 | | - |
4668 | /*! | - |
4669 | \fn void QPainter::drawLines(const QVector<QLineF> &lines) | - |
4670 | \overload | - |
4671 | | - |
4672 | Draws the set of lines defined by the list \a lines using the | - |
4673 | current pen and brush. | - |
4674 | */ | - |
4675 | | - |
4676 | /*! | - |
4677 | \fn void QPainter::drawLines(const QVector<QLine> &lines) | - |
4678 | \overload | - |
4679 | | - |
4680 | Draws the set of lines defined by the list \a lines using the | - |
4681 | current pen and brush. | - |
4682 | */ | - |
4683 | | - |
4684 | /*! | - |
4685 | Draws the polyline defined by the first \a pointCount points in \a | - |
4686 | points using the current pen. | - |
4687 | | - |
4688 | Note that unlike the drawPolygon() function the last point is \e | - |
4689 | not connected to the first, neither is the polyline filled. | - |
4690 | | - |
4691 | \table 100% | - |
4692 | \row | - |
4693 | \li | - |
4694 | \snippet code/src_gui_painting_qpainter.cpp 13 | - |
4695 | \endtable | - |
4696 | | - |
4697 | \sa drawLines(), drawPolygon(), {Coordinate System} | - |
4698 | */ | - |
4699 | void QPainter::drawPolyline(const QPointF *points, int pointCount) | - |
4700 | { | - |
4701 | #ifdef QT_DEBUG_DRAW | - |
4702 | if (qt_show_painter_debug_output) | - |
4703 | printf("QPainter::drawPolyline(), count=%d\n", pointCount); | - |
4704 | #endif | - |
4705 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4706 | | - |
4707 | if (!d->engine || pointCount < 2) never evaluated: !d->engine never evaluated: pointCount < 2 | 0 |
4708 | return; | 0 |
4709 | | - |
4710 | if (d->extended) { never evaluated: d->extended | 0 |
4711 | d->extended->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); never executed (the execution status of this line is deduced): d->extended->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); | - |
4712 | return; | 0 |
4713 | } | - |
4714 | | - |
4715 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4716 | | - |
4717 | uint lineEmulation = line_emulation(d->state->emulationSpecifier); never executed (the execution status of this line is deduced): uint lineEmulation = line_emulation(d->state->emulationSpecifier); | - |
4718 | | - |
4719 | if (lineEmulation) { never evaluated: lineEmulation | 0 |
4720 | // ### | - |
4721 | // if (lineEmulation == QPaintEngine::PrimitiveTransform | - |
4722 | // && d->state->matrix.type() == QTransform::TxTranslate) { | - |
4723 | // } else { | - |
4724 | QPainterPath polylinePath(points[0]); never executed (the execution status of this line is deduced): QPainterPath polylinePath(points[0]); | - |
4725 | for (int i=1; i<pointCount; ++i) never evaluated: i<pointCount | 0 |
4726 | polylinePath.lineTo(points[i]); never executed: polylinePath.lineTo(points[i]); | 0 |
4727 | d->draw_helper(polylinePath, QPainterPrivate::StrokeDraw); never executed (the execution status of this line is deduced): d->draw_helper(polylinePath, QPainterPrivate::StrokeDraw); | - |
4728 | // } | - |
4729 | } else { | 0 |
4730 | d->engine->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); never executed (the execution status of this line is deduced): d->engine->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); | - |
4731 | } | 0 |
4732 | } | - |
4733 | | - |
4734 | /*! | - |
4735 | \overload | - |
4736 | | - |
4737 | Draws the polyline defined by the first \a pointCount points in \a | - |
4738 | points using the current pen. | - |
4739 | */ | - |
4740 | void QPainter::drawPolyline(const QPoint *points, int pointCount) | - |
4741 | { | - |
4742 | #ifdef QT_DEBUG_DRAW | - |
4743 | if (qt_show_painter_debug_output) | - |
4744 | printf("QPainter::drawPolyline(), count=%d\n", pointCount); | - |
4745 | #endif | - |
4746 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4747 | | - |
4748 | if (!d->engine || pointCount < 2) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:61214 |
partially evaluated: pointCount < 2 no Evaluation Count:0 | yes Evaluation Count:61214 |
| 0-61214 |
4749 | return; | 0 |
4750 | | - |
4751 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:61214 | no Evaluation Count:0 |
| 0-61214 |
4752 | d->extended->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); executed (the execution status of this line is deduced): d->extended->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); | - |
4753 | return; executed: return; Execution Count:61214 | 61214 |
4754 | } | - |
4755 | | - |
4756 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4757 | | - |
4758 | uint lineEmulation = line_emulation(d->state->emulationSpecifier); never executed (the execution status of this line is deduced): uint lineEmulation = line_emulation(d->state->emulationSpecifier); | - |
4759 | | - |
4760 | if (lineEmulation) { never evaluated: lineEmulation | 0 |
4761 | // ### | - |
4762 | // if (lineEmulation == QPaintEngine::PrimitiveTransform | - |
4763 | // && d->state->matrix.type() == QTransform::TxTranslate) { | - |
4764 | // } else { | - |
4765 | QPainterPath polylinePath(points[0]); never executed (the execution status of this line is deduced): QPainterPath polylinePath(points[0]); | - |
4766 | for (int i=1; i<pointCount; ++i) never evaluated: i<pointCount | 0 |
4767 | polylinePath.lineTo(points[i]); never executed: polylinePath.lineTo(points[i]); | 0 |
4768 | d->draw_helper(polylinePath, QPainterPrivate::StrokeDraw); never executed (the execution status of this line is deduced): d->draw_helper(polylinePath, QPainterPrivate::StrokeDraw); | - |
4769 | // } | - |
4770 | } else { | 0 |
4771 | d->engine->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); never executed (the execution status of this line is deduced): d->engine->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); | - |
4772 | } | 0 |
4773 | } | - |
4774 | | - |
4775 | /*! | - |
4776 | \fn void QPainter::drawPolyline(const QPolygonF &points) | - |
4777 | | - |
4778 | \overload | - |
4779 | | - |
4780 | Draws the polyline defined by the given \a points using the | - |
4781 | current pen. | - |
4782 | */ | - |
4783 | | - |
4784 | /*! | - |
4785 | \fn void QPainter::drawPolyline(const QPolygon &points) | - |
4786 | | - |
4787 | \overload | - |
4788 | | - |
4789 | Draws the polyline defined by the given \a points using the | - |
4790 | current pen. | - |
4791 | */ | - |
4792 | | - |
4793 | /*! | - |
4794 | Draws the polygon defined by the first \a pointCount points in the | - |
4795 | array \a points using the current pen and brush. | - |
4796 | | - |
4797 | \table 100% | - |
4798 | \row | - |
4799 | \li \inlineimage qpainter-polygon.png | - |
4800 | \li | - |
4801 | \snippet code/src_gui_painting_qpainter.cpp 14 | - |
4802 | \endtable | - |
4803 | | - |
4804 | The first point is implicitly connected to the last point, and the | - |
4805 | polygon is filled with the current brush(). | - |
4806 | | - |
4807 | If \a fillRule is Qt::WindingFill, the polygon is filled using the | - |
4808 | winding fill algorithm. If \a fillRule is Qt::OddEvenFill, the | - |
4809 | polygon is filled using the odd-even fill algorithm. See | - |
4810 | \l{Qt::FillRule} for a more detailed description of these fill | - |
4811 | rules. | - |
4812 | | - |
4813 | \sa drawConvexPolygon(), drawPolyline(), {Coordinate System} | - |
4814 | */ | - |
4815 | void QPainter::drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule) | - |
4816 | { | - |
4817 | #ifdef QT_DEBUG_DRAW | - |
4818 | if (qt_show_painter_debug_output) | - |
4819 | printf("QPainter::drawPolygon(), count=%d\n", pointCount); | - |
4820 | #endif | - |
4821 | | - |
4822 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4823 | | - |
4824 | if (!d->engine || pointCount < 2) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:450 |
partially evaluated: pointCount < 2 no Evaluation Count:0 | yes Evaluation Count:450 |
| 0-450 |
4825 | return; | 0 |
4826 | | - |
4827 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:450 | no Evaluation Count:0 |
| 0-450 |
4828 | d->extended->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); executed (the execution status of this line is deduced): d->extended->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); | - |
4829 | return; executed: return; Execution Count:450 | 450 |
4830 | } | - |
4831 | | - |
4832 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4833 | | - |
4834 | uint emulationSpecifier = d->state->emulationSpecifier; never executed (the execution status of this line is deduced): uint emulationSpecifier = d->state->emulationSpecifier; | - |
4835 | | - |
4836 | if (emulationSpecifier) { never evaluated: emulationSpecifier | 0 |
4837 | QPainterPath polygonPath(points[0]); never executed (the execution status of this line is deduced): QPainterPath polygonPath(points[0]); | - |
4838 | for (int i=1; i<pointCount; ++i) never evaluated: i<pointCount | 0 |
4839 | polygonPath.lineTo(points[i]); never executed: polygonPath.lineTo(points[i]); | 0 |
4840 | polygonPath.closeSubpath(); never executed (the execution status of this line is deduced): polygonPath.closeSubpath(); | - |
4841 | polygonPath.setFillRule(fillRule); never executed (the execution status of this line is deduced): polygonPath.setFillRule(fillRule); | - |
4842 | d->draw_helper(polygonPath); never executed (the execution status of this line is deduced): d->draw_helper(polygonPath); | - |
4843 | return; | 0 |
4844 | } | - |
4845 | | - |
4846 | d->engine->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); never executed (the execution status of this line is deduced): d->engine->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); | - |
4847 | } | 0 |
4848 | | - |
4849 | /*! \overload | - |
4850 | | - |
4851 | Draws the polygon defined by the first \a pointCount points in the | - |
4852 | array \a points. | - |
4853 | */ | - |
4854 | void QPainter::drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fillRule) | - |
4855 | { | - |
4856 | #ifdef QT_DEBUG_DRAW | - |
4857 | if (qt_show_painter_debug_output) | - |
4858 | printf("QPainter::drawPolygon(), count=%d\n", pointCount); | - |
4859 | #endif | - |
4860 | | - |
4861 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4862 | | - |
4863 | if (!d->engine || pointCount < 2) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:906 |
partially evaluated: pointCount < 2 no Evaluation Count:0 | yes Evaluation Count:906 |
| 0-906 |
4864 | return; | 0 |
4865 | | - |
4866 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:906 | no Evaluation Count:0 |
| 0-906 |
4867 | d->extended->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); executed (the execution status of this line is deduced): d->extended->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); | - |
4868 | return; executed: return; Execution Count:906 | 906 |
4869 | } | - |
4870 | | - |
4871 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4872 | | - |
4873 | uint emulationSpecifier = d->state->emulationSpecifier; never executed (the execution status of this line is deduced): uint emulationSpecifier = d->state->emulationSpecifier; | - |
4874 | | - |
4875 | if (emulationSpecifier) { never evaluated: emulationSpecifier | 0 |
4876 | QPainterPath polygonPath(points[0]); never executed (the execution status of this line is deduced): QPainterPath polygonPath(points[0]); | - |
4877 | for (int i=1; i<pointCount; ++i) never evaluated: i<pointCount | 0 |
4878 | polygonPath.lineTo(points[i]); never executed: polygonPath.lineTo(points[i]); | 0 |
4879 | polygonPath.closeSubpath(); never executed (the execution status of this line is deduced): polygonPath.closeSubpath(); | - |
4880 | polygonPath.setFillRule(fillRule); never executed (the execution status of this line is deduced): polygonPath.setFillRule(fillRule); | - |
4881 | d->draw_helper(polygonPath); never executed (the execution status of this line is deduced): d->draw_helper(polygonPath); | - |
4882 | return; | 0 |
4883 | } | - |
4884 | | - |
4885 | d->engine->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); never executed (the execution status of this line is deduced): d->engine->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); | - |
4886 | } | 0 |
4887 | | - |
4888 | /*! \fn void QPainter::drawPolygon(const QPolygonF &points, Qt::FillRule fillRule) | - |
4889 | | - |
4890 | \overload | - |
4891 | | - |
4892 | Draws the polygon defined by the given \a points using the fill | - |
4893 | rule \a fillRule. | - |
4894 | */ | - |
4895 | | - |
4896 | /*! \fn void QPainter::drawPolygon(const QPolygon &points, Qt::FillRule fillRule) | - |
4897 | | - |
4898 | \overload | - |
4899 | | - |
4900 | Draws the polygon defined by the given \a points using the fill | - |
4901 | rule \a fillRule. | - |
4902 | */ | - |
4903 | | - |
4904 | /*! | - |
4905 | \fn void QPainter::drawConvexPolygon(const QPointF *points, int pointCount) | - |
4906 | | - |
4907 | Draws the convex polygon defined by the first \a pointCount points | - |
4908 | in the array \a points using the current pen. | - |
4909 | | - |
4910 | \table 100% | - |
4911 | \row | - |
4912 | \li \inlineimage qpainter-polygon.png | - |
4913 | \li | - |
4914 | \snippet code/src_gui_painting_qpainter.cpp 15 | - |
4915 | \endtable | - |
4916 | | - |
4917 | The first point is implicitly connected to the last point, and the | - |
4918 | polygon is filled with the current brush(). If the supplied | - |
4919 | polygon is not convex, i.e. it contains at least one angle larger | - |
4920 | than 180 degrees, the results are undefined. | - |
4921 | | - |
4922 | On some platforms (e.g. X11), the drawConvexPolygon() function can | - |
4923 | be faster than the drawPolygon() function. | - |
4924 | | - |
4925 | \sa drawPolygon(), drawPolyline(), {Coordinate System} | - |
4926 | */ | - |
4927 | | - |
4928 | /*! | - |
4929 | \fn void QPainter::drawConvexPolygon(const QPoint *points, int pointCount) | - |
4930 | \overload | - |
4931 | | - |
4932 | Draws the convex polygon defined by the first \a pointCount points | - |
4933 | in the array \a points using the current pen. | - |
4934 | */ | - |
4935 | | - |
4936 | /*! | - |
4937 | \fn void QPainter::drawConvexPolygon(const QPolygonF &polygon) | - |
4938 | | - |
4939 | \overload | - |
4940 | | - |
4941 | Draws the convex polygon defined by \a polygon using the current | - |
4942 | pen and brush. | - |
4943 | */ | - |
4944 | | - |
4945 | /*! | - |
4946 | \fn void QPainter::drawConvexPolygon(const QPolygon &polygon) | - |
4947 | \overload | - |
4948 | | - |
4949 | Draws the convex polygon defined by \a polygon using the current | - |
4950 | pen and brush. | - |
4951 | */ | - |
4952 | | - |
4953 | void QPainter::drawConvexPolygon(const QPoint *points, int pointCount) | - |
4954 | { | - |
4955 | #ifdef QT_DEBUG_DRAW | - |
4956 | if (qt_show_painter_debug_output) | - |
4957 | printf("QPainter::drawConvexPolygon(), count=%d\n", pointCount); | - |
4958 | #endif | - |
4959 | | - |
4960 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4961 | | - |
4962 | if (!d->engine || pointCount < 2) never evaluated: !d->engine never evaluated: pointCount < 2 | 0 |
4963 | return; | 0 |
4964 | | - |
4965 | if (d->extended) { never evaluated: d->extended | 0 |
4966 | d->extended->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); never executed (the execution status of this line is deduced): d->extended->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); | - |
4967 | return; | 0 |
4968 | } | - |
4969 | | - |
4970 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
4971 | | - |
4972 | uint emulationSpecifier = d->state->emulationSpecifier; never executed (the execution status of this line is deduced): uint emulationSpecifier = d->state->emulationSpecifier; | - |
4973 | | - |
4974 | if (emulationSpecifier) { never evaluated: emulationSpecifier | 0 |
4975 | QPainterPath polygonPath(points[0]); never executed (the execution status of this line is deduced): QPainterPath polygonPath(points[0]); | - |
4976 | for (int i=1; i<pointCount; ++i) never evaluated: i<pointCount | 0 |
4977 | polygonPath.lineTo(points[i]); never executed: polygonPath.lineTo(points[i]); | 0 |
4978 | polygonPath.closeSubpath(); never executed (the execution status of this line is deduced): polygonPath.closeSubpath(); | - |
4979 | polygonPath.setFillRule(Qt::WindingFill); never executed (the execution status of this line is deduced): polygonPath.setFillRule(Qt::WindingFill); | - |
4980 | d->draw_helper(polygonPath); never executed (the execution status of this line is deduced): d->draw_helper(polygonPath); | - |
4981 | return; | 0 |
4982 | } | - |
4983 | | - |
4984 | d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); never executed (the execution status of this line is deduced): d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); | - |
4985 | } | 0 |
4986 | | - |
4987 | void QPainter::drawConvexPolygon(const QPointF *points, int pointCount) | - |
4988 | { | - |
4989 | #ifdef QT_DEBUG_DRAW | - |
4990 | if (qt_show_painter_debug_output) | - |
4991 | printf("QPainter::drawConvexPolygon(), count=%d\n", pointCount); | - |
4992 | #endif | - |
4993 | | - |
4994 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
4995 | | - |
4996 | if (!d->engine || pointCount < 2) never evaluated: !d->engine never evaluated: pointCount < 2 | 0 |
4997 | return; | 0 |
4998 | | - |
4999 | if (d->extended) { never evaluated: d->extended | 0 |
5000 | d->extended->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); never executed (the execution status of this line is deduced): d->extended->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); | - |
5001 | return; | 0 |
5002 | } | - |
5003 | | - |
5004 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
5005 | | - |
5006 | uint emulationSpecifier = d->state->emulationSpecifier; never executed (the execution status of this line is deduced): uint emulationSpecifier = d->state->emulationSpecifier; | - |
5007 | | - |
5008 | if (emulationSpecifier) { never evaluated: emulationSpecifier | 0 |
5009 | QPainterPath polygonPath(points[0]); never executed (the execution status of this line is deduced): QPainterPath polygonPath(points[0]); | - |
5010 | for (int i=1; i<pointCount; ++i) never evaluated: i<pointCount | 0 |
5011 | polygonPath.lineTo(points[i]); never executed: polygonPath.lineTo(points[i]); | 0 |
5012 | polygonPath.closeSubpath(); never executed (the execution status of this line is deduced): polygonPath.closeSubpath(); | - |
5013 | polygonPath.setFillRule(Qt::WindingFill); never executed (the execution status of this line is deduced): polygonPath.setFillRule(Qt::WindingFill); | - |
5014 | d->draw_helper(polygonPath); never executed (the execution status of this line is deduced): d->draw_helper(polygonPath); | - |
5015 | return; | 0 |
5016 | } | - |
5017 | | - |
5018 | d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); never executed (the execution status of this line is deduced): d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); | - |
5019 | } | 0 |
5020 | | - |
5021 | static inline QPointF roundInDeviceCoordinates(const QPointF &p, const QTransform &m) | - |
5022 | { | - |
5023 | return m.inverted().map(QPointF(m.map(p).toPoint())); never executed: return m.inverted().map(QPointF(m.map(p).toPoint())); | 0 |
5024 | } | - |
5025 | | - |
5026 | /*! | - |
5027 | \fn void QPainter::drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source) | - |
5028 | | - |
5029 | Draws the rectangular portion \a source of the given \a pixmap | - |
5030 | into the given \a target in the paint device. | - |
5031 | | - |
5032 | \note The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree. | - |
5033 | | - |
5034 | \table 100% | - |
5035 | \row | - |
5036 | \li | - |
5037 | \snippet code/src_gui_painting_qpainter.cpp 16 | - |
5038 | \endtable | - |
5039 | | - |
5040 | If \a pixmap is a QBitmap it is drawn with the bits that are "set" | - |
5041 | using the pens color. If backgroundMode is Qt::OpaqueMode, the | - |
5042 | "unset" bits are drawn using the color of the background brush; if | - |
5043 | backgroundMode is Qt::TransparentMode, the "unset" bits are | - |
5044 | transparent. Drawing bitmaps with gradient or texture colors is | - |
5045 | not supported. | - |
5046 | | - |
5047 | \sa drawImage() | - |
5048 | */ | - |
5049 | void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) | - |
5050 | { | - |
5051 | #if defined QT_DEBUG_DRAW | - |
5052 | if (qt_show_painter_debug_output) | - |
5053 | printf("QPainter::drawPixmap(), p=[%.2f,%.2f], pix=[%d,%d]\n", | - |
5054 | p.x(), p.y(), | - |
5055 | pm.width(), pm.height()); | - |
5056 | #endif | - |
5057 | | - |
5058 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
5059 | | - |
5060 | if (!d->engine || pm.isNull()) evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:6284 |
evaluated: pm.isNull() yes Evaluation Count:71 | yes Evaluation Count:6213 |
| 1-6284 |
5061 | return; executed: return; Execution Count:72 | 72 |
5062 | | - |
5063 | #ifndef QT_NO_DEBUG | - |
5064 | qt_painter_thread_test(d->device->devType(), "drawPixmap()", true); | - |
5065 | #endif | - |
5066 | | - |
5067 | if (d->extended) { evaluated: d->extended yes Evaluation Count:6212 | yes Evaluation Count:1 |
| 1-6212 |
5068 | d->extended->drawPixmap(p, pm); executed (the execution status of this line is deduced): d->extended->drawPixmap(p, pm); | - |
5069 | return; executed: return; Execution Count:6212 | 6212 |
5070 | } | - |
5071 | | - |
5072 | qreal x = p.x(); executed (the execution status of this line is deduced): qreal x = p.x(); | - |
5073 | qreal y = p.y(); executed (the execution status of this line is deduced): qreal y = p.y(); | - |
5074 | | - |
5075 | int w = pm.width(); executed (the execution status of this line is deduced): int w = pm.width(); | - |
5076 | int h = pm.height(); executed (the execution status of this line is deduced): int h = pm.height(); | - |
5077 | | - |
5078 | if (w <= 0) partially evaluated: w <= 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
5079 | return; | 0 |
5080 | | - |
5081 | // Emulate opaque background for bitmaps | - |
5082 | if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap()) { partially evaluated: d->state->bgMode == Qt::OpaqueMode no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: pm.isQBitmap() | 0-1 |
5083 | fillRect(QRectF(x, y, w, h), d->state->bgBrush.color()); never executed (the execution status of this line is deduced): fillRect(QRectF(x, y, w, h), d->state->bgBrush.color()); | - |
5084 | } | 0 |
5085 | | - |
5086 | d->updateState(d->state); executed (the execution status of this line is deduced): d->updateState(d->state); | - |
5087 | | - |
5088 | if ((d->state->matrix.type() > QTransform::TxTranslate partially evaluated: d->state->matrix.type() > QTransform::TxTranslate no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
5089 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
5090 | || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform)) partially evaluated: !d->state->matrix.isAffine() no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: !d->engine->hasFeature(QPaintEngine::PerspectiveTransform) | 0-1 |
5091 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) partially evaluated: d->state->opacity != 1.0 no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: !d->engine->hasFeature(QPaintEngine::ConstantOpacity) | 0-1 |
5092 | { | - |
5093 | save(); never executed (the execution status of this line is deduced): save(); | - |
5094 | // If there is no rotation involved we have to make sure we use the | - |
5095 | // antialiased and not the aliased coordinate system by rounding the coordinates. | - |
5096 | if (d->state->matrix.type() <= QTransform::TxScale) { never evaluated: d->state->matrix.type() <= QTransform::TxScale | 0 |
5097 | const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); never executed (the execution status of this line is deduced): const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); | - |
5098 | x = p.x(); never executed (the execution status of this line is deduced): x = p.x(); | - |
5099 | y = p.y(); never executed (the execution status of this line is deduced): y = p.y(); | - |
5100 | } | 0 |
5101 | translate(x, y); never executed (the execution status of this line is deduced): translate(x, y); | - |
5102 | setBackgroundMode(Qt::TransparentMode); never executed (the execution status of this line is deduced): setBackgroundMode(Qt::TransparentMode); | - |
5103 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); never executed (the execution status of this line is deduced): setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
5104 | QBrush brush(d->state->pen.color(), pm); never executed (the execution status of this line is deduced): QBrush brush(d->state->pen.color(), pm); | - |
5105 | setBrush(brush); never executed (the execution status of this line is deduced): setBrush(brush); | - |
5106 | setPen(Qt::NoPen); never executed (the execution status of this line is deduced): setPen(Qt::NoPen); | - |
5107 | setBrushOrigin(QPointF(0, 0)); never executed (the execution status of this line is deduced): setBrushOrigin(QPointF(0, 0)); | - |
5108 | | - |
5109 | drawRect(pm.rect()); never executed (the execution status of this line is deduced): drawRect(pm.rect()); | - |
5110 | restore(); never executed (the execution status of this line is deduced): restore(); | - |
5111 | } else { | 0 |
5112 | if (!d->engine->hasFeature(QPaintEngine::PixmapTransform)) { partially evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
5113 | x += d->state->matrix.dx(); never executed (the execution status of this line is deduced): x += d->state->matrix.dx(); | - |
5114 | y += d->state->matrix.dy(); never executed (the execution status of this line is deduced): y += d->state->matrix.dy(); | - |
5115 | } | 0 |
5116 | int scale = pm.devicePixelRatio(); executed (the execution status of this line is deduced): int scale = pm.devicePixelRatio(); | - |
5117 | d->engine->drawPixmap(QRectF(x, y, w / scale, h / scale), pm, QRectF(0, 0, w, h)); executed (the execution status of this line is deduced): d->engine->drawPixmap(QRectF(x, y, w / scale, h / scale), pm, QRectF(0, 0, w, h)); | - |
5118 | } executed: } Execution Count:1 | 1 |
5119 | } | - |
5120 | | - |
5121 | void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) | - |
5122 | { | - |
5123 | #if defined QT_DEBUG_DRAW | - |
5124 | if (qt_show_painter_debug_output) | - |
5125 | printf("QPainter::drawPixmap(), target=[%.2f,%.2f,%.2f,%.2f], pix=[%d,%d], source=[%.2f,%.2f,%.2f,%.2f]\n", | - |
5126 | r.x(), r.y(), r.width(), r.height(), | - |
5127 | pm.width(), pm.height(), | - |
5128 | sr.x(), sr.y(), sr.width(), sr.height()); | - |
5129 | #endif | - |
5130 | | - |
5131 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
5132 | if (!d->engine || pm.isNull()) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:4185 |
evaluated: pm.isNull() yes Evaluation Count:12 | yes Evaluation Count:4173 |
| 0-4185 |
5133 | return; executed: return; Execution Count:12 | 12 |
5134 | #ifndef QT_NO_DEBUG | - |
5135 | qt_painter_thread_test(d->device->devType(), "drawPixmap()", true); | - |
5136 | #endif | - |
5137 | | - |
5138 | qreal x = r.x(); executed (the execution status of this line is deduced): qreal x = r.x(); | - |
5139 | qreal y = r.y(); executed (the execution status of this line is deduced): qreal y = r.y(); | - |
5140 | qreal w = r.width(); executed (the execution status of this line is deduced): qreal w = r.width(); | - |
5141 | qreal h = r.height(); executed (the execution status of this line is deduced): qreal h = r.height(); | - |
5142 | qreal sx = sr.x(); executed (the execution status of this line is deduced): qreal sx = sr.x(); | - |
5143 | qreal sy = sr.y(); executed (the execution status of this line is deduced): qreal sy = sr.y(); | - |
5144 | qreal sw = sr.width(); executed (the execution status of this line is deduced): qreal sw = sr.width(); | - |
5145 | qreal sh = sr.height(); executed (the execution status of this line is deduced): qreal sh = sr.height(); | - |
5146 | | - |
5147 | // Get pixmap scale. Use it when calculating the target | - |
5148 | // rect size from pixmap size. For example, a 2X 64x64 pixel | - |
5149 | // pixmap should result in a 32x32 point target rect. | - |
5150 | const qreal pmscale = pm.devicePixelRatio(); executed (the execution status of this line is deduced): const qreal pmscale = pm.devicePixelRatio(); | - |
5151 | | - |
5152 | // Sanity-check clipping | - |
5153 | if (sw <= 0) evaluated: sw <= 0 yes Evaluation Count:2597 | yes Evaluation Count:1576 |
| 1576-2597 |
5154 | sw = pm.width() - sx; executed: sw = pm.width() - sx; Execution Count:2597 | 2597 |
5155 | | - |
5156 | if (sh <= 0) evaluated: sh <= 0 yes Evaluation Count:2597 | yes Evaluation Count:1576 |
| 1576-2597 |
5157 | sh = pm.height() - sy; executed: sh = pm.height() - sy; Execution Count:2597 | 2597 |
5158 | | - |
5159 | if (w < 0) evaluated: w < 0 yes Evaluation Count:1283 | yes Evaluation Count:2890 |
| 1283-2890 |
5160 | w = sw / pmscale; executed: w = sw / pmscale; Execution Count:1283 | 1283 |
5161 | if (h < 0) evaluated: h < 0 yes Evaluation Count:1283 | yes Evaluation Count:2890 |
| 1283-2890 |
5162 | h = sh / pmscale; executed: h = sh / pmscale; Execution Count:1283 | 1283 |
5163 | | - |
5164 | if (sx < 0) { partially evaluated: sx < 0 no Evaluation Count:0 | yes Evaluation Count:4173 |
| 0-4173 |
5165 | qreal w_ratio = sx * w/sw; never executed (the execution status of this line is deduced): qreal w_ratio = sx * w/sw; | - |
5166 | x -= w_ratio; never executed (the execution status of this line is deduced): x -= w_ratio; | - |
5167 | w += w_ratio; never executed (the execution status of this line is deduced): w += w_ratio; | - |
5168 | sw += sx; never executed (the execution status of this line is deduced): sw += sx; | - |
5169 | sx = 0; never executed (the execution status of this line is deduced): sx = 0; | - |
5170 | } | 0 |
5171 | | - |
5172 | if (sy < 0) { partially evaluated: sy < 0 no Evaluation Count:0 | yes Evaluation Count:4173 |
| 0-4173 |
5173 | qreal h_ratio = sy * h/sh; never executed (the execution status of this line is deduced): qreal h_ratio = sy * h/sh; | - |
5174 | y -= h_ratio; never executed (the execution status of this line is deduced): y -= h_ratio; | - |
5175 | h += h_ratio; never executed (the execution status of this line is deduced): h += h_ratio; | - |
5176 | sh += sy; never executed (the execution status of this line is deduced): sh += sy; | - |
5177 | sy = 0; never executed (the execution status of this line is deduced): sy = 0; | - |
5178 | } | 0 |
5179 | | - |
5180 | if (sw + sx > pm.width()) { partially evaluated: sw + sx > pm.width() no Evaluation Count:0 | yes Evaluation Count:4173 |
| 0-4173 |
5181 | qreal delta = sw - (pm.width() - sx); never executed (the execution status of this line is deduced): qreal delta = sw - (pm.width() - sx); | - |
5182 | qreal w_ratio = delta * w/sw; never executed (the execution status of this line is deduced): qreal w_ratio = delta * w/sw; | - |
5183 | sw -= delta; never executed (the execution status of this line is deduced): sw -= delta; | - |
5184 | w -= w_ratio; never executed (the execution status of this line is deduced): w -= w_ratio; | - |
5185 | } | 0 |
5186 | | - |
5187 | if (sh + sy > pm.height()) { evaluated: sh + sy > pm.height() yes Evaluation Count:1 | yes Evaluation Count:4172 |
| 1-4172 |
5188 | qreal delta = sh - (pm.height() - sy); executed (the execution status of this line is deduced): qreal delta = sh - (pm.height() - sy); | - |
5189 | qreal h_ratio = delta * h/sh; executed (the execution status of this line is deduced): qreal h_ratio = delta * h/sh; | - |
5190 | sh -= delta; executed (the execution status of this line is deduced): sh -= delta; | - |
5191 | h -= h_ratio; executed (the execution status of this line is deduced): h -= h_ratio; | - |
5192 | } executed: } Execution Count:1 | 1 |
5193 | | - |
5194 | if (w == 0 || h == 0 || sw <= 0 || sh <= 0) partially evaluated: w == 0 no Evaluation Count:0 | yes Evaluation Count:4173 |
partially evaluated: h == 0 no Evaluation Count:0 | yes Evaluation Count:4173 |
partially evaluated: sw <= 0 no Evaluation Count:0 | yes Evaluation Count:4173 |
partially evaluated: sh <= 0 no Evaluation Count:0 | yes Evaluation Count:4173 |
| 0-4173 |
5195 | return; | 0 |
5196 | | - |
5197 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:4173 | no Evaluation Count:0 |
| 0-4173 |
5198 | d->extended->drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh)); executed (the execution status of this line is deduced): d->extended->drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh)); | - |
5199 | return; executed: return; Execution Count:4173 | 4173 |
5200 | } | - |
5201 | | - |
5202 | // Emulate opaque background for bitmaps | - |
5203 | if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap()) never evaluated: d->state->bgMode == Qt::OpaqueMode never evaluated: pm.isQBitmap() | 0 |
5204 | fillRect(QRectF(x, y, w, h), d->state->bgBrush.color()); never executed: fillRect(QRectF(x, y, w, h), d->state->bgBrush.color()); | 0 |
5205 | | - |
5206 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
5207 | | - |
5208 | if ((d->state->matrix.type() > QTransform::TxTranslate never evaluated: d->state->matrix.type() > QTransform::TxTranslate | 0 |
5209 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
5210 | || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform)) never evaluated: !d->state->matrix.isAffine() never evaluated: !d->engine->hasFeature(QPaintEngine::PerspectiveTransform) | 0 |
5211 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity)) never evaluated: d->state->opacity != 1.0 never evaluated: !d->engine->hasFeature(QPaintEngine::ConstantOpacity) | 0 |
5212 | || ((sw != w || sh != h) && !d->engine->hasFeature(QPaintEngine::PixmapTransform))) never evaluated: sw != w never evaluated: sh != h never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
5213 | { | - |
5214 | save(); never executed (the execution status of this line is deduced): save(); | - |
5215 | // If there is no rotation involved we have to make sure we use the | - |
5216 | // antialiased and not the aliased coordinate system by rounding the coordinates. | - |
5217 | if (d->state->matrix.type() <= QTransform::TxScale) { never evaluated: d->state->matrix.type() <= QTransform::TxScale | 0 |
5218 | const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); never executed (the execution status of this line is deduced): const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); | - |
5219 | x = p.x(); never executed (the execution status of this line is deduced): x = p.x(); | - |
5220 | y = p.y(); never executed (the execution status of this line is deduced): y = p.y(); | - |
5221 | } | 0 |
5222 | | - |
5223 | if (d->state->matrix.type() <= QTransform::TxTranslate && sw == w && sh == h) { never evaluated: d->state->matrix.type() <= QTransform::TxTranslate never evaluated: sw == w never evaluated: sh == h | 0 |
5224 | sx = qRound(sx); never executed (the execution status of this line is deduced): sx = qRound(sx); | - |
5225 | sy = qRound(sy); never executed (the execution status of this line is deduced): sy = qRound(sy); | - |
5226 | sw = qRound(sw); never executed (the execution status of this line is deduced): sw = qRound(sw); | - |
5227 | sh = qRound(sh); never executed (the execution status of this line is deduced): sh = qRound(sh); | - |
5228 | } | 0 |
5229 | | - |
5230 | translate(x, y); never executed (the execution status of this line is deduced): translate(x, y); | - |
5231 | scale(w / sw, h / sh); never executed (the execution status of this line is deduced): scale(w / sw, h / sh); | - |
5232 | setBackgroundMode(Qt::TransparentMode); never executed (the execution status of this line is deduced): setBackgroundMode(Qt::TransparentMode); | - |
5233 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); never executed (the execution status of this line is deduced): setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
5234 | QBrush brush; never executed (the execution status of this line is deduced): QBrush brush; | - |
5235 | | - |
5236 | if (sw == pm.width() && sh == pm.height()) never evaluated: sw == pm.width() never evaluated: sh == pm.height() | 0 |
5237 | brush = QBrush(d->state->pen.color(), pm); never executed: brush = QBrush(d->state->pen.color(), pm); | 0 |
5238 | else | - |
5239 | brush = QBrush(d->state->pen.color(), pm.copy(sx, sy, sw, sh)); never executed: brush = QBrush(d->state->pen.color(), pm.copy(sx, sy, sw, sh)); | 0 |
5240 | | - |
5241 | setBrush(brush); never executed (the execution status of this line is deduced): setBrush(brush); | - |
5242 | setPen(Qt::NoPen); never executed (the execution status of this line is deduced): setPen(Qt::NoPen); | - |
5243 | | - |
5244 | drawRect(QRectF(0, 0, sw, sh)); never executed (the execution status of this line is deduced): drawRect(QRectF(0, 0, sw, sh)); | - |
5245 | restore(); never executed (the execution status of this line is deduced): restore(); | - |
5246 | } else { | 0 |
5247 | if (!d->engine->hasFeature(QPaintEngine::PixmapTransform)) { never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
5248 | x += d->state->matrix.dx(); never executed (the execution status of this line is deduced): x += d->state->matrix.dx(); | - |
5249 | y += d->state->matrix.dy(); never executed (the execution status of this line is deduced): y += d->state->matrix.dy(); | - |
5250 | } | 0 |
5251 | d->engine->drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh)); never executed (the execution status of this line is deduced): d->engine->drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh)); | - |
5252 | } | 0 |
5253 | } | - |
5254 | | - |
5255 | | - |
5256 | /*! | - |
5257 | \fn void QPainter::drawPixmap(const QRect &target, const QPixmap &pixmap, | - |
5258 | const QRect &source) | - |
5259 | \overload | - |
5260 | | - |
5261 | Draws the rectangular portion \a source of the given \a pixmap | - |
5262 | into the given \a target in the paint device. | - |
5263 | | - |
5264 | \note The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree. | - |
5265 | */ | - |
5266 | | - |
5267 | /*! | - |
5268 | \fn void QPainter::drawPixmap(const QPointF &point, const QPixmap &pixmap, | - |
5269 | const QRectF &source) | - |
5270 | \overload | - |
5271 | | - |
5272 | Draws the rectangular portion \a source of the given \a pixmap | - |
5273 | with its origin at the given \a point. | - |
5274 | */ | - |
5275 | | - |
5276 | /*! | - |
5277 | \fn void QPainter::drawPixmap(const QPoint &point, const QPixmap &pixmap, | - |
5278 | const QRect &source) | - |
5279 | | - |
5280 | \overload | - |
5281 | | - |
5282 | Draws the rectangular portion \a source of the given \a pixmap | - |
5283 | with its origin at the given \a point. | - |
5284 | */ | - |
5285 | | - |
5286 | /*! | - |
5287 | \fn void QPainter::drawPixmap(const QPointF &point, const QPixmap &pixmap) | - |
5288 | \overload | - |
5289 | | - |
5290 | Draws the given \a pixmap with its origin at the given \a point. | - |
5291 | */ | - |
5292 | | - |
5293 | /*! | - |
5294 | \fn void QPainter::drawPixmap(const QPoint &point, const QPixmap &pixmap) | - |
5295 | \overload | - |
5296 | | - |
5297 | Draws the given \a pixmap with its origin at the given \a point. | - |
5298 | */ | - |
5299 | | - |
5300 | /*! | - |
5301 | \fn void QPainter::drawPixmap(int x, int y, const QPixmap &pixmap) | - |
5302 | | - |
5303 | \overload | - |
5304 | | - |
5305 | Draws the given \a pixmap at position (\a{x}, \a{y}). | - |
5306 | */ | - |
5307 | | - |
5308 | /*! | - |
5309 | \fn void QPainter::drawPixmap(const QRect &rectangle, const QPixmap &pixmap) | - |
5310 | \overload | - |
5311 | | - |
5312 | Draws the given \a pixmap into the given \a rectangle. | - |
5313 | | - |
5314 | \note The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree. | - |
5315 | */ | - |
5316 | | - |
5317 | /*! | - |
5318 | \fn void QPainter::drawPixmap(int x, int y, int width, int height, | - |
5319 | const QPixmap &pixmap) | - |
5320 | | - |
5321 | \overload | - |
5322 | | - |
5323 | Draws the \a pixmap into the rectangle at position (\a{x}, \a{y}) | - |
5324 | with the given \a width and \a height. | - |
5325 | */ | - |
5326 | | - |
5327 | /*! | - |
5328 | \fn void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pixmap, | - |
5329 | int sx, int sy, int sw, int sh) | - |
5330 | | - |
5331 | \overload | - |
5332 | | - |
5333 | Draws the rectangular portion with the origin (\a{sx}, \a{sy}), | - |
5334 | width \a sw and height \a sh, of the given \a pixmap , at the | - |
5335 | point (\a{x}, \a{y}), with a width of \a w and a height of \a h. | - |
5336 | If sw or sh are equal to zero the width/height of the pixmap | - |
5337 | is used and adjusted by the offset sx/sy; | - |
5338 | */ | - |
5339 | | - |
5340 | /*! | - |
5341 | \fn void QPainter::drawPixmap(int x, int y, const QPixmap &pixmap, | - |
5342 | int sx, int sy, int sw, int sh) | - |
5343 | | - |
5344 | \overload | - |
5345 | | - |
5346 | Draws a pixmap at (\a{x}, \a{y}) by copying a part of the given \a | - |
5347 | pixmap into the paint device. | - |
5348 | | - |
5349 | (\a{x}, \a{y}) specifies the top-left point in the paint device that is | - |
5350 | to be drawn onto. (\a{sx}, \a{sy}) specifies the top-left point in \a | - |
5351 | pixmap that is to be drawn. The default is (0, 0). | - |
5352 | | - |
5353 | (\a{sw}, \a{sh}) specifies the size of the pixmap that is to be drawn. | - |
5354 | The default, (0, 0) (and negative) means all the way to the | - |
5355 | bottom-right of the pixmap. | - |
5356 | */ | - |
5357 | | - |
5358 | void QPainter::drawImage(const QPointF &p, const QImage &image) | - |
5359 | { | - |
5360 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
5361 | | - |
5362 | if (!d->engine || image.isNull()) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:2319 |
partially evaluated: image.isNull() no Evaluation Count:0 | yes Evaluation Count:2319 |
| 0-2319 |
5363 | return; | 0 |
5364 | | - |
5365 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:2319 | no Evaluation Count:0 |
| 0-2319 |
5366 | d->extended->drawImage(p, image); executed (the execution status of this line is deduced): d->extended->drawImage(p, image); | - |
5367 | return; executed: return; Execution Count:2319 | 2319 |
5368 | } | - |
5369 | | - |
5370 | qreal x = p.x(); never executed (the execution status of this line is deduced): qreal x = p.x(); | - |
5371 | qreal y = p.y(); never executed (the execution status of this line is deduced): qreal y = p.y(); | - |
5372 | | - |
5373 | int w = image.width(); never executed (the execution status of this line is deduced): int w = image.width(); | - |
5374 | int h = image.height(); never executed (the execution status of this line is deduced): int h = image.height(); | - |
5375 | qreal scale = image.devicePixelRatio(); never executed (the execution status of this line is deduced): qreal scale = image.devicePixelRatio(); | - |
5376 | | - |
5377 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
5378 | | - |
5379 | if (((d->state->matrix.type() > QTransform::TxTranslate) never evaluated: (d->state->matrix.type() > QTransform::TxTranslate) | 0 |
5380 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
5381 | || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform)) never evaluated: !d->state->matrix.isAffine() never evaluated: !d->engine->hasFeature(QPaintEngine::PerspectiveTransform) | 0 |
5382 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) never evaluated: d->state->opacity != 1.0 never evaluated: !d->engine->hasFeature(QPaintEngine::ConstantOpacity) | 0 |
5383 | { | - |
5384 | save(); never executed (the execution status of this line is deduced): save(); | - |
5385 | // If there is no rotation involved we have to make sure we use the | - |
5386 | // antialiased and not the aliased coordinate system by rounding the coordinates. | - |
5387 | if (d->state->matrix.type() <= QTransform::TxScale) { never evaluated: d->state->matrix.type() <= QTransform::TxScale | 0 |
5388 | const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); never executed (the execution status of this line is deduced): const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); | - |
5389 | x = p.x(); never executed (the execution status of this line is deduced): x = p.x(); | - |
5390 | y = p.y(); never executed (the execution status of this line is deduced): y = p.y(); | - |
5391 | } | 0 |
5392 | translate(x, y); never executed (the execution status of this line is deduced): translate(x, y); | - |
5393 | setBackgroundMode(Qt::TransparentMode); never executed (the execution status of this line is deduced): setBackgroundMode(Qt::TransparentMode); | - |
5394 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); never executed (the execution status of this line is deduced): setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
5395 | QBrush brush(image); never executed (the execution status of this line is deduced): QBrush brush(image); | - |
5396 | setBrush(brush); never executed (the execution status of this line is deduced): setBrush(brush); | - |
5397 | setPen(Qt::NoPen); never executed (the execution status of this line is deduced): setPen(Qt::NoPen); | - |
5398 | setBrushOrigin(QPointF(0, 0)); never executed (the execution status of this line is deduced): setBrushOrigin(QPointF(0, 0)); | - |
5399 | drawRect(QRect(QPoint(0, 0), image.size() / scale)); never executed (the execution status of this line is deduced): drawRect(QRect(QPoint(0, 0), image.size() / scale)); | - |
5400 | restore(); never executed (the execution status of this line is deduced): restore(); | - |
5401 | return; | 0 |
5402 | } | - |
5403 | | - |
5404 | if (d->state->matrix.type() == QTransform::TxTranslate never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
5405 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) { never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
5406 | x += d->state->matrix.dx(); never executed (the execution status of this line is deduced): x += d->state->matrix.dx(); | - |
5407 | y += d->state->matrix.dy(); never executed (the execution status of this line is deduced): y += d->state->matrix.dy(); | - |
5408 | } | 0 |
5409 | | - |
5410 | d->engine->drawImage(QRectF(x, y, w / scale, h / scale), image, QRectF(0, 0, w, h), Qt::AutoColor); never executed (the execution status of this line is deduced): d->engine->drawImage(QRectF(x, y, w / scale, h / scale), image, QRectF(0, 0, w, h), Qt::AutoColor); | - |
5411 | } | 0 |
5412 | | - |
5413 | void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, | - |
5414 | Qt::ImageConversionFlags flags) | - |
5415 | { | - |
5416 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
5417 | | - |
5418 | if (!d->engine || image.isNull()) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:227 |
partially evaluated: image.isNull() no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5419 | return; | 0 |
5420 | | - |
5421 | qreal x = targetRect.x(); executed (the execution status of this line is deduced): qreal x = targetRect.x(); | - |
5422 | qreal y = targetRect.y(); executed (the execution status of this line is deduced): qreal y = targetRect.y(); | - |
5423 | qreal w = targetRect.width(); executed (the execution status of this line is deduced): qreal w = targetRect.width(); | - |
5424 | qreal h = targetRect.height(); executed (the execution status of this line is deduced): qreal h = targetRect.height(); | - |
5425 | qreal sx = sourceRect.x(); executed (the execution status of this line is deduced): qreal sx = sourceRect.x(); | - |
5426 | qreal sy = sourceRect.y(); executed (the execution status of this line is deduced): qreal sy = sourceRect.y(); | - |
5427 | qreal sw = sourceRect.width(); executed (the execution status of this line is deduced): qreal sw = sourceRect.width(); | - |
5428 | qreal sh = sourceRect.height(); executed (the execution status of this line is deduced): qreal sh = sourceRect.height(); | - |
5429 | qreal imageScale = image.devicePixelRatio(); executed (the execution status of this line is deduced): qreal imageScale = image.devicePixelRatio(); | - |
5430 | | - |
5431 | // Sanity-check clipping | - |
5432 | if (sw <= 0) partially evaluated: sw <= 0 no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5433 | sw = image.width() - sx; never executed: sw = image.width() - sx; | 0 |
5434 | | - |
5435 | if (sh <= 0) partially evaluated: sh <= 0 no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5436 | sh = image.height() - sy; never executed: sh = image.height() - sy; | 0 |
5437 | | - |
5438 | if (w < 0) partially evaluated: w < 0 no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5439 | w = sw / imageScale; never executed: w = sw / imageScale; | 0 |
5440 | if (h < 0) partially evaluated: h < 0 no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5441 | h = sh / imageScale; never executed: h = sh / imageScale; | 0 |
5442 | | - |
5443 | if (sx < 0) { partially evaluated: sx < 0 no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5444 | qreal w_ratio = sx * w/sw; never executed (the execution status of this line is deduced): qreal w_ratio = sx * w/sw; | - |
5445 | x -= w_ratio; never executed (the execution status of this line is deduced): x -= w_ratio; | - |
5446 | w += w_ratio; never executed (the execution status of this line is deduced): w += w_ratio; | - |
5447 | sw += sx; never executed (the execution status of this line is deduced): sw += sx; | - |
5448 | sx = 0; never executed (the execution status of this line is deduced): sx = 0; | - |
5449 | } | 0 |
5450 | | - |
5451 | if (sy < 0) { partially evaluated: sy < 0 no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5452 | qreal h_ratio = sy * h/sh; never executed (the execution status of this line is deduced): qreal h_ratio = sy * h/sh; | - |
5453 | y -= h_ratio; never executed (the execution status of this line is deduced): y -= h_ratio; | - |
5454 | h += h_ratio; never executed (the execution status of this line is deduced): h += h_ratio; | - |
5455 | sh += sy; never executed (the execution status of this line is deduced): sh += sy; | - |
5456 | sy = 0; never executed (the execution status of this line is deduced): sy = 0; | - |
5457 | } | 0 |
5458 | | - |
5459 | if (sw + sx > image.width()) { partially evaluated: sw + sx > image.width() no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5460 | qreal delta = sw - (image.width() - sx); never executed (the execution status of this line is deduced): qreal delta = sw - (image.width() - sx); | - |
5461 | qreal w_ratio = delta * w/sw; never executed (the execution status of this line is deduced): qreal w_ratio = delta * w/sw; | - |
5462 | sw -= delta; never executed (the execution status of this line is deduced): sw -= delta; | - |
5463 | w -= w_ratio; never executed (the execution status of this line is deduced): w -= w_ratio; | - |
5464 | } | 0 |
5465 | | - |
5466 | if (sh + sy > image.height()) { partially evaluated: sh + sy > image.height() no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5467 | qreal delta = sh - (image.height() - sy); never executed (the execution status of this line is deduced): qreal delta = sh - (image.height() - sy); | - |
5468 | qreal h_ratio = delta * h/sh; never executed (the execution status of this line is deduced): qreal h_ratio = delta * h/sh; | - |
5469 | sh -= delta; never executed (the execution status of this line is deduced): sh -= delta; | - |
5470 | h -= h_ratio; never executed (the execution status of this line is deduced): h -= h_ratio; | - |
5471 | } | 0 |
5472 | | - |
5473 | if (w == 0 || h == 0 || sw <= 0 || sh <= 0) partially evaluated: w == 0 no Evaluation Count:0 | yes Evaluation Count:227 |
partially evaluated: h == 0 no Evaluation Count:0 | yes Evaluation Count:227 |
partially evaluated: sw <= 0 no Evaluation Count:0 | yes Evaluation Count:227 |
partially evaluated: sh <= 0 no Evaluation Count:0 | yes Evaluation Count:227 |
| 0-227 |
5474 | return; | 0 |
5475 | | - |
5476 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:227 | no Evaluation Count:0 |
| 0-227 |
5477 | d->extended->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags); executed (the execution status of this line is deduced): d->extended->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags); | - |
5478 | return; executed: return; Execution Count:227 | 227 |
5479 | } | - |
5480 | | - |
5481 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
5482 | | - |
5483 | if (((d->state->matrix.type() > QTransform::TxTranslate || (sw != w || sh != h)) never evaluated: d->state->matrix.type() > QTransform::TxTranslate never evaluated: sw != w never evaluated: sh != h | 0 |
5484 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
5485 | || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform)) never evaluated: !d->state->matrix.isAffine() never evaluated: !d->engine->hasFeature(QPaintEngine::PerspectiveTransform) | 0 |
5486 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) never evaluated: d->state->opacity != 1.0 never evaluated: !d->engine->hasFeature(QPaintEngine::ConstantOpacity) | 0 |
5487 | { | - |
5488 | save(); never executed (the execution status of this line is deduced): save(); | - |
5489 | // If there is no rotation involved we have to make sure we use the | - |
5490 | // antialiased and not the aliased coordinate system by rounding the coordinates. | - |
5491 | if (d->state->matrix.type() <= QTransform::TxScale) { never evaluated: d->state->matrix.type() <= QTransform::TxScale | 0 |
5492 | const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); never executed (the execution status of this line is deduced): const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); | - |
5493 | x = p.x(); never executed (the execution status of this line is deduced): x = p.x(); | - |
5494 | y = p.y(); never executed (the execution status of this line is deduced): y = p.y(); | - |
5495 | } | 0 |
5496 | | - |
5497 | if (d->state->matrix.type() <= QTransform::TxTranslate && sw == w && sh == h) { never evaluated: d->state->matrix.type() <= QTransform::TxTranslate never evaluated: sw == w never evaluated: sh == h | 0 |
5498 | sx = qRound(sx); never executed (the execution status of this line is deduced): sx = qRound(sx); | - |
5499 | sy = qRound(sy); never executed (the execution status of this line is deduced): sy = qRound(sy); | - |
5500 | sw = qRound(sw); never executed (the execution status of this line is deduced): sw = qRound(sw); | - |
5501 | sh = qRound(sh); never executed (the execution status of this line is deduced): sh = qRound(sh); | - |
5502 | } | 0 |
5503 | translate(x, y); never executed (the execution status of this line is deduced): translate(x, y); | - |
5504 | scale(w / sw, h / sh); never executed (the execution status of this line is deduced): scale(w / sw, h / sh); | - |
5505 | setBackgroundMode(Qt::TransparentMode); never executed (the execution status of this line is deduced): setBackgroundMode(Qt::TransparentMode); | - |
5506 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); never executed (the execution status of this line is deduced): setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
5507 | QBrush brush(image); never executed (the execution status of this line is deduced): QBrush brush(image); | - |
5508 | setBrush(brush); never executed (the execution status of this line is deduced): setBrush(brush); | - |
5509 | setPen(Qt::NoPen); never executed (the execution status of this line is deduced): setPen(Qt::NoPen); | - |
5510 | setBrushOrigin(QPointF(-sx, -sy)); never executed (the execution status of this line is deduced): setBrushOrigin(QPointF(-sx, -sy)); | - |
5511 | | - |
5512 | drawRect(QRectF(0, 0, sw, sh)); never executed (the execution status of this line is deduced): drawRect(QRectF(0, 0, sw, sh)); | - |
5513 | restore(); never executed (the execution status of this line is deduced): restore(); | - |
5514 | return; | 0 |
5515 | } | - |
5516 | | - |
5517 | if (d->state->matrix.type() == QTransform::TxTranslate never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
5518 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) { never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
5519 | x += d->state->matrix.dx(); never executed (the execution status of this line is deduced): x += d->state->matrix.dx(); | - |
5520 | y += d->state->matrix.dy(); never executed (the execution status of this line is deduced): y += d->state->matrix.dy(); | - |
5521 | } | 0 |
5522 | | - |
5523 | d->engine->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags); never executed (the execution status of this line is deduced): d->engine->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags); | - |
5524 | } | 0 |
5525 | | - |
5526 | /*! | - |
5527 | \fn void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphs) | - |
5528 | | - |
5529 | Draws the glyphs represented by \a glyphs at \a position. The \a position gives the | - |
5530 | edge of the baseline for the string of glyphs. The glyphs will be retrieved from the font | - |
5531 | selected on \a glyphs and at offsets given by the positions in \a glyphs. | - |
5532 | | - |
5533 | \since 4.8 | - |
5534 | | - |
5535 | \sa QGlyphRun::setRawFont(), QGlyphRun::setPositions(), QGlyphRun::setGlyphIndexes() | - |
5536 | */ | - |
5537 | #if !defined(QT_NO_RAWFONT) | - |
5538 | void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun) | - |
5539 | { | - |
5540 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
5541 | | - |
5542 | QRawFont font = glyphRun.rawFont(); executed (the execution status of this line is deduced): QRawFont font = glyphRun.rawFont(); | - |
5543 | if (!font.isValid()) partially evaluated: !font.isValid() no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
5544 | return; | 0 |
5545 | | - |
5546 | QGlyphRunPrivate *glyphRun_d = QGlyphRunPrivate::get(glyphRun); executed (the execution status of this line is deduced): QGlyphRunPrivate *glyphRun_d = QGlyphRunPrivate::get(glyphRun); | - |
5547 | | - |
5548 | const quint32 *glyphIndexes = glyphRun_d->glyphIndexData; executed (the execution status of this line is deduced): const quint32 *glyphIndexes = glyphRun_d->glyphIndexData; | - |
5549 | const QPointF *glyphPositions = glyphRun_d->glyphPositionData; executed (the execution status of this line is deduced): const QPointF *glyphPositions = glyphRun_d->glyphPositionData; | - |
5550 | | - |
5551 | int count = qMin(glyphRun_d->glyphIndexDataSize, glyphRun_d->glyphPositionDataSize); executed (the execution status of this line is deduced): int count = qMin(glyphRun_d->glyphIndexDataSize, glyphRun_d->glyphPositionDataSize); | - |
5552 | QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count); executed (the execution status of this line is deduced): QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count); | - |
5553 | | - |
5554 | QRawFontPrivate *fontD = QRawFontPrivate::get(font); executed (the execution status of this line is deduced): QRawFontPrivate *fontD = QRawFontPrivate::get(font); | - |
5555 | bool supportsTransformations = d->extended partially evaluated: d->extended yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
5556 | ? d->extended->supportsTransformations(fontD->fontEngine, d->state->matrix) executed (the execution status of this line is deduced): ? d->extended->supportsTransformations(fontD->fontEngine, d->state->matrix) | - |
5557 | : d->engine->type() == QPaintEngine::CoreGraphics || d->state->matrix.isAffine(); executed (the execution status of this line is deduced): : d->engine->type() == QPaintEngine::CoreGraphics || d->state->matrix.isAffine(); | - |
5558 | | - |
5559 | for (int i=0; i<count; ++i) { evaluated: i<count yes Evaluation Count:35 | yes Evaluation Count:12 |
| 12-35 |
5560 | QPointF processedPosition = position + glyphPositions[i]; executed (the execution status of this line is deduced): QPointF processedPosition = position + glyphPositions[i]; | - |
5561 | if (!supportsTransformations) partially evaluated: !supportsTransformations yes Evaluation Count:35 | no Evaluation Count:0 |
| 0-35 |
5562 | processedPosition = d->state->transform().map(processedPosition); executed: processedPosition = d->state->transform().map(processedPosition); Execution Count:35 | 35 |
5563 | fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition); executed (the execution status of this line is deduced): fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition); | - |
5564 | } executed: } Execution Count:35 | 35 |
5565 | | - |
5566 | d->drawGlyphs(glyphIndexes, fixedPointPositions.data(), count, font, glyphRun.overline(), executed (the execution status of this line is deduced): d->drawGlyphs(glyphIndexes, fixedPointPositions.data(), count, font, glyphRun.overline(), | - |
5567 | glyphRun.underline(), glyphRun.strikeOut()); executed (the execution status of this line is deduced): glyphRun.underline(), glyphRun.strikeOut()); | - |
5568 | } executed: } Execution Count:12 | 12 |
5569 | | - |
5570 | void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positions, | - |
5571 | int glyphCount, | - |
5572 | const QRawFont &font, bool overline, bool underline, | - |
5573 | bool strikeOut) | - |
5574 | { | - |
5575 | Q_Q(QPainter); executed (the execution status of this line is deduced): QPainter * const q = q_func(); | - |
5576 | | - |
5577 | updateState(state); executed (the execution status of this line is deduced): updateState(state); | - |
5578 | | - |
5579 | QRawFontPrivate *fontD = QRawFontPrivate::get(font); executed (the execution status of this line is deduced): QRawFontPrivate *fontD = QRawFontPrivate::get(font); | - |
5580 | QFontEngine *fontEngine = fontD->fontEngine; executed (the execution status of this line is deduced): QFontEngine *fontEngine = fontD->fontEngine; | - |
5581 | | - |
5582 | QFixed leftMost; executed (the execution status of this line is deduced): QFixed leftMost; | - |
5583 | QFixed rightMost; executed (the execution status of this line is deduced): QFixed rightMost; | - |
5584 | QFixed baseLine; executed (the execution status of this line is deduced): QFixed baseLine; | - |
5585 | for (int i=0; i<glyphCount; ++i) { evaluated: i<glyphCount yes Evaluation Count:35 | yes Evaluation Count:12 |
| 12-35 |
5586 | glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]); executed (the execution status of this line is deduced): glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]); | - |
5587 | if (i == 0 || leftMost > positions[i].x) evaluated: i == 0 yes Evaluation Count:12 | yes Evaluation Count:23 |
evaluated: leftMost > positions[i].x yes Evaluation Count:1 | yes Evaluation Count:22 |
| 1-23 |
5588 | leftMost = positions[i].x; executed: leftMost = positions[i].x; Execution Count:13 | 13 |
5589 | | - |
5590 | // We don't support glyphs that do not share a common baseline. If this turns out to | - |
5591 | // be a relevant use case, then we need to find clusters of glyphs that share a baseline | - |
5592 | // and do a drawTextItemDecorations call per cluster. | - |
5593 | if (i == 0 || baseLine < positions[i].y) evaluated: i == 0 yes Evaluation Count:12 | yes Evaluation Count:23 |
evaluated: baseLine < positions[i].y yes Evaluation Count:3 | yes Evaluation Count:20 |
| 3-23 |
5594 | baseLine = positions[i].y; executed: baseLine = positions[i].y; Execution Count:15 | 15 |
5595 | | - |
5596 | // We use the advance rather than the actual bounds to match the algorithm in drawText() | - |
5597 | if (i == 0 || rightMost < positions[i].x + gm.xoff) evaluated: i == 0 yes Evaluation Count:12 | yes Evaluation Count:23 |
evaluated: rightMost < positions[i].x + gm.xoff yes Evaluation Count:19 | yes Evaluation Count:4 |
| 4-23 |
5598 | rightMost = positions[i].x + gm.xoff; executed: rightMost = positions[i].x + gm.xoff; Execution Count:31 | 31 |
5599 | } executed: } Execution Count:35 | 35 |
5600 | | - |
5601 | QFixed width = rightMost - leftMost; executed (the execution status of this line is deduced): QFixed width = rightMost - leftMost; | - |
5602 | | - |
5603 | if (extended != 0 && state->matrix.isAffine()) { partially evaluated: extended != 0 yes Evaluation Count:12 | no Evaluation Count:0 |
partially evaluated: state->matrix.isAffine() yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
5604 | QStaticTextItem staticTextItem; executed (the execution status of this line is deduced): QStaticTextItem staticTextItem; | - |
5605 | staticTextItem.color = state->pen.color(); executed (the execution status of this line is deduced): staticTextItem.color = state->pen.color(); | - |
5606 | staticTextItem.font = state->font; executed (the execution status of this line is deduced): staticTextItem.font = state->font; | - |
5607 | staticTextItem.setFontEngine(fontEngine); executed (the execution status of this line is deduced): staticTextItem.setFontEngine(fontEngine); | - |
5608 | staticTextItem.numGlyphs = glyphCount; executed (the execution status of this line is deduced): staticTextItem.numGlyphs = glyphCount; | - |
5609 | staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray)); executed (the execution status of this line is deduced): staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray)); | - |
5610 | staticTextItem.glyphPositions = positions; executed (the execution status of this line is deduced): staticTextItem.glyphPositions = positions; | - |
5611 | | - |
5612 | extended->drawStaticTextItem(&staticTextItem); executed (the execution status of this line is deduced): extended->drawStaticTextItem(&staticTextItem); | - |
5613 | } else { executed: } Execution Count:12 | 12 |
5614 | QTextItemInt textItem; never executed (the execution status of this line is deduced): QTextItemInt textItem; | - |
5615 | textItem.fontEngine = fontEngine; never executed (the execution status of this line is deduced): textItem.fontEngine = fontEngine; | - |
5616 | | - |
5617 | QVarLengthArray<QFixed, 128> advances(glyphCount); never executed (the execution status of this line is deduced): QVarLengthArray<QFixed, 128> advances(glyphCount); | - |
5618 | QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount); never executed (the execution status of this line is deduced): QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount); | - |
5619 | QVarLengthArray<HB_GlyphAttributes, 128> glyphAttributes(glyphCount); never executed (the execution status of this line is deduced): QVarLengthArray<HB_GlyphAttributes, 128> glyphAttributes(glyphCount); | - |
5620 | memset(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(HB_GlyphAttributes)); never executed (the execution status of this line is deduced): memset(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(HB_GlyphAttributes)); | - |
5621 | memset(advances.data(), 0, advances.size() * sizeof(QFixed)); never executed (the execution status of this line is deduced): memset(advances.data(), 0, advances.size() * sizeof(QFixed)); | - |
5622 | memset(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification)); never executed (the execution status of this line is deduced): memset(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification)); | - |
5623 | | - |
5624 | textItem.glyphs.numGlyphs = glyphCount; never executed (the execution status of this line is deduced): textItem.glyphs.numGlyphs = glyphCount; | - |
5625 | textItem.glyphs.glyphs = reinterpret_cast<HB_Glyph *>(const_cast<quint32 *>(glyphArray)); never executed (the execution status of this line is deduced): textItem.glyphs.glyphs = reinterpret_cast<HB_Glyph *>(const_cast<quint32 *>(glyphArray)); | - |
5626 | textItem.glyphs.offsets = positions; never executed (the execution status of this line is deduced): textItem.glyphs.offsets = positions; | - |
5627 | textItem.glyphs.advances_x = advances.data(); never executed (the execution status of this line is deduced): textItem.glyphs.advances_x = advances.data(); | - |
5628 | textItem.glyphs.advances_y = advances.data(); never executed (the execution status of this line is deduced): textItem.glyphs.advances_y = advances.data(); | - |
5629 | textItem.glyphs.justifications = glyphJustifications.data(); never executed (the execution status of this line is deduced): textItem.glyphs.justifications = glyphJustifications.data(); | - |
5630 | textItem.glyphs.attributes = glyphAttributes.data(); never executed (the execution status of this line is deduced): textItem.glyphs.attributes = glyphAttributes.data(); | - |
5631 | | - |
5632 | engine->drawTextItem(QPointF(0, 0), textItem); never executed (the execution status of this line is deduced): engine->drawTextItem(QPointF(0, 0), textItem); | - |
5633 | } | 0 |
5634 | | - |
5635 | QTextItemInt::RenderFlags flags; executed (the execution status of this line is deduced): QTextItemInt::RenderFlags flags; | - |
5636 | if (underline) evaluated: underline yes Evaluation Count:2 | yes Evaluation Count:10 |
| 2-10 |
5637 | flags |= QTextItemInt::Underline; executed: flags |= QTextItemInt::Underline; Execution Count:2 | 2 |
5638 | if (overline) evaluated: overline yes Evaluation Count:1 | yes Evaluation Count:11 |
| 1-11 |
5639 | flags |= QTextItemInt::Overline; executed: flags |= QTextItemInt::Overline; Execution Count:1 | 1 |
5640 | if (strikeOut) evaluated: strikeOut yes Evaluation Count:1 | yes Evaluation Count:11 |
| 1-11 |
5641 | flags |= QTextItemInt::StrikeOut; executed: flags |= QTextItemInt::StrikeOut; Execution Count:1 | 1 |
5642 | | - |
5643 | drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()), executed (the execution status of this line is deduced): drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()), | - |
5644 | fontEngine, executed (the execution status of this line is deduced): fontEngine, | - |
5645 | 0, // textEngine executed (the execution status of this line is deduced): 0, | - |
5646 | (underline executed (the execution status of this line is deduced): (underline | - |
5647 | ? QTextCharFormat::SingleUnderline executed (the execution status of this line is deduced): ? QTextCharFormat::SingleUnderline | - |
5648 | : QTextCharFormat::NoUnderline), executed (the execution status of this line is deduced): : QTextCharFormat::NoUnderline), | - |
5649 | flags, width.toReal(), QTextCharFormat()); executed (the execution status of this line is deduced): flags, width.toReal(), QTextCharFormat()); | - |
5650 | } executed: } Execution Count:12 | 12 |
5651 | #endif // QT_NO_RAWFONT | - |
5652 | | - |
5653 | /*! | - |
5654 | | - |
5655 | \fn void QPainter::drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText) | - |
5656 | \since 4.7 | - |
5657 | \overload | - |
5658 | | - |
5659 | Draws the \a staticText at the \a topLeftPosition. | - |
5660 | | - |
5661 | \note The y-position is used as the top of the font. | - |
5662 | | - |
5663 | */ | - |
5664 | | - |
5665 | /*! | - |
5666 | \fn void QPainter::drawStaticText(int left, int top, const QStaticText &staticText) | - |
5667 | \since 4.7 | - |
5668 | \overload | - |
5669 | | - |
5670 | Draws the \a staticText at coordinates \a left and \a top. | - |
5671 | | - |
5672 | \note The y-position is used as the top of the font. | - |
5673 | */ | - |
5674 | | - |
5675 | /*! | - |
5676 | \fn void QPainter::drawText(const QPointF &position, const QString &text) | - |
5677 | | - |
5678 | Draws the given \a text with the currently defined text direction, | - |
5679 | beginning at the given \a position. | - |
5680 | | - |
5681 | This function does not handle the newline character (\\n), as it cannot | - |
5682 | break text into multiple lines, and it cannot display the newline character. | - |
5683 | Use the QPainter::drawText() overload that takes a rectangle instead | - |
5684 | if you want to draw multiple lines of text with the newline character, or | - |
5685 | if you want the text to be wrapped. | - |
5686 | | - |
5687 | By default, QPainter draws text anti-aliased. | - |
5688 | | - |
5689 | \note The y-position is used as the baseline of the font. | - |
5690 | | - |
5691 | \sa setFont(), setPen() | - |
5692 | */ | - |
5693 | | - |
5694 | void QPainter::drawText(const QPointF &p, const QString &str) | - |
5695 | { | - |
5696 | drawText(p, str, 0, 0); executed (the execution status of this line is deduced): drawText(p, str, 0, 0); | - |
5697 | } executed: } Execution Count:899 | 899 |
5698 | | - |
5699 | /*! | - |
5700 | \since 4.7 | - |
5701 | | - |
5702 | Draws the given \a staticText at the given \a topLeftPosition. | - |
5703 | | - |
5704 | The text will be drawn using the font and the transformation set on the painter. If the | - |
5705 | font and/or transformation set on the painter are different from the ones used to initialize | - |
5706 | the layout of the QStaticText, then the layout will have to be recalculated. Use | - |
5707 | QStaticText::prepare() to initialize \a staticText with the font and transformation with which | - |
5708 | it will later be drawn. | - |
5709 | | - |
5710 | If \a topLeftPosition is not the same as when \a staticText was initialized, or when it was | - |
5711 | last drawn, then there will be a slight overhead when translating the text to its new position. | - |
5712 | | - |
5713 | \note If the painter's transformation is not affine, then \a staticText will be drawn using | - |
5714 | regular calls to drawText(), losing any potential for performance improvement. | - |
5715 | | - |
5716 | \note The y-position is used as the top of the font. | - |
5717 | | - |
5718 | \sa QStaticText | - |
5719 | */ | - |
5720 | void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText) | - |
5721 | { | - |
5722 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
5723 | if (!d->engine || staticText.text().isEmpty() || pen().style() == Qt::NoPen) never evaluated: !d->engine never evaluated: staticText.text().isEmpty() never evaluated: pen().style() == Qt::NoPen | 0 |
5724 | return; | 0 |
5725 | | - |
5726 | QStaticTextPrivate *staticText_d = never executed (the execution status of this line is deduced): QStaticTextPrivate *staticText_d = | - |
5727 | const_cast<QStaticTextPrivate *>(QStaticTextPrivate::get(&staticText)); never executed (the execution status of this line is deduced): const_cast<QStaticTextPrivate *>(QStaticTextPrivate::get(&staticText)); | - |
5728 | | - |
5729 | if (font() != staticText_d->font) { never evaluated: font() != staticText_d->font | 0 |
5730 | staticText_d->font = font(); never executed (the execution status of this line is deduced): staticText_d->font = font(); | - |
5731 | staticText_d->needsRelayout = true; never executed (the execution status of this line is deduced): staticText_d->needsRelayout = true; | - |
5732 | } | 0 |
5733 | | - |
5734 | // If we don't have an extended paint engine, or if the painter is projected, | - |
5735 | // we go through standard code path | - |
5736 | if (d->extended == 0 || !d->state->matrix.isAffine()) { never evaluated: d->extended == 0 never evaluated: !d->state->matrix.isAffine() | 0 |
5737 | staticText_d->paintText(topLeftPosition, this); never executed (the execution status of this line is deduced): staticText_d->paintText(topLeftPosition, this); | - |
5738 | return; | 0 |
5739 | } | - |
5740 | | - |
5741 | QFontEngine *fe = staticText_d->font.d->engineForScript(QUnicodeTables::Common); never executed (the execution status of this line is deduced): QFontEngine *fe = staticText_d->font.d->engineForScript(QUnicodeTables::Common); | - |
5742 | if (fe->type() == QFontEngine::Multi) never evaluated: fe->type() == QFontEngine::Multi | 0 |
5743 | fe = static_cast<QFontEngineMulti *>(fe)->engine(0); never executed: fe = static_cast<QFontEngineMulti *>(fe)->engine(0); | 0 |
5744 | bool supportsTransformations = d->extended->supportsTransformations(fe, never executed (the execution status of this line is deduced): bool supportsTransformations = d->extended->supportsTransformations(fe, | - |
5745 | d->state->matrix); never executed (the execution status of this line is deduced): d->state->matrix); | - |
5746 | if (supportsTransformations && !staticText_d->untransformedCoordinates) { never evaluated: supportsTransformations never evaluated: !staticText_d->untransformedCoordinates | 0 |
5747 | staticText_d->untransformedCoordinates = true; never executed (the execution status of this line is deduced): staticText_d->untransformedCoordinates = true; | - |
5748 | staticText_d->needsRelayout = true; never executed (the execution status of this line is deduced): staticText_d->needsRelayout = true; | - |
5749 | } else if (!supportsTransformations && staticText_d->untransformedCoordinates) { never executed: } never evaluated: !supportsTransformations never evaluated: staticText_d->untransformedCoordinates | 0 |
5750 | staticText_d->untransformedCoordinates = false; never executed (the execution status of this line is deduced): staticText_d->untransformedCoordinates = false; | - |
5751 | staticText_d->needsRelayout = true; never executed (the execution status of this line is deduced): staticText_d->needsRelayout = true; | - |
5752 | } | 0 |
5753 | | - |
5754 | // Don't recalculate entire layout because of translation, rather add the dx and dy | - |
5755 | // into the position to move each text item the correct distance. | - |
5756 | QPointF transformedPosition = topLeftPosition; never executed (the execution status of this line is deduced): QPointF transformedPosition = topLeftPosition; | - |
5757 | if (!staticText_d->untransformedCoordinates) never evaluated: !staticText_d->untransformedCoordinates | 0 |
5758 | transformedPosition = transformedPosition * d->state->matrix; never executed: transformedPosition = transformedPosition * d->state->matrix; | 0 |
5759 | QTransform oldMatrix; never executed (the execution status of this line is deduced): QTransform oldMatrix; | - |
5760 | | - |
5761 | // The translation has been applied to transformedPosition. Remove translation | - |
5762 | // component from matrix. | - |
5763 | if (d->state->matrix.isTranslating() && !staticText_d->untransformedCoordinates) { never evaluated: d->state->matrix.isTranslating() never evaluated: !staticText_d->untransformedCoordinates | 0 |
5764 | qreal m11 = d->state->matrix.m11(); never executed (the execution status of this line is deduced): qreal m11 = d->state->matrix.m11(); | - |
5765 | qreal m12 = d->state->matrix.m12(); never executed (the execution status of this line is deduced): qreal m12 = d->state->matrix.m12(); | - |
5766 | qreal m13 = d->state->matrix.m13(); never executed (the execution status of this line is deduced): qreal m13 = d->state->matrix.m13(); | - |
5767 | qreal m21 = d->state->matrix.m21(); never executed (the execution status of this line is deduced): qreal m21 = d->state->matrix.m21(); | - |
5768 | qreal m22 = d->state->matrix.m22(); never executed (the execution status of this line is deduced): qreal m22 = d->state->matrix.m22(); | - |
5769 | qreal m23 = d->state->matrix.m23(); never executed (the execution status of this line is deduced): qreal m23 = d->state->matrix.m23(); | - |
5770 | qreal m33 = d->state->matrix.m33(); never executed (the execution status of this line is deduced): qreal m33 = d->state->matrix.m33(); | - |
5771 | | - |
5772 | oldMatrix = d->state->matrix; never executed (the execution status of this line is deduced): oldMatrix = d->state->matrix; | - |
5773 | d->state->matrix.setMatrix(m11, m12, m13, never executed (the execution status of this line is deduced): d->state->matrix.setMatrix(m11, m12, m13, | - |
5774 | m21, m22, m23, never executed (the execution status of this line is deduced): m21, m22, m23, | - |
5775 | 0.0, 0.0, m33); never executed (the execution status of this line is deduced): 0.0, 0.0, m33); | - |
5776 | } | 0 |
5777 | | - |
5778 | // If the transform is not identical to the text transform, | - |
5779 | // we have to relayout the text (for other transformations than plain translation) | - |
5780 | bool staticTextNeedsReinit = staticText_d->needsRelayout; never executed (the execution status of this line is deduced): bool staticTextNeedsReinit = staticText_d->needsRelayout; | - |
5781 | if (!staticText_d->untransformedCoordinates && staticText_d->matrix != d->state->matrix) { never evaluated: !staticText_d->untransformedCoordinates never evaluated: staticText_d->matrix != d->state->matrix | 0 |
5782 | staticText_d->matrix = d->state->matrix; never executed (the execution status of this line is deduced): staticText_d->matrix = d->state->matrix; | - |
5783 | staticTextNeedsReinit = true; never executed (the execution status of this line is deduced): staticTextNeedsReinit = true; | - |
5784 | } | 0 |
5785 | | - |
5786 | // Recreate the layout of the static text because the matrix or font has changed | - |
5787 | if (staticTextNeedsReinit) never evaluated: staticTextNeedsReinit | 0 |
5788 | staticText_d->init(); never executed: staticText_d->init(); | 0 |
5789 | | - |
5790 | if (transformedPosition != staticText_d->position) { // Translate to actual position never evaluated: transformedPosition != staticText_d->position | 0 |
5791 | QFixed fx = QFixed::fromReal(transformedPosition.x()); never executed (the execution status of this line is deduced): QFixed fx = QFixed::fromReal(transformedPosition.x()); | - |
5792 | QFixed fy = QFixed::fromReal(transformedPosition.y()); never executed (the execution status of this line is deduced): QFixed fy = QFixed::fromReal(transformedPosition.y()); | - |
5793 | QFixed oldX = QFixed::fromReal(staticText_d->position.x()); never executed (the execution status of this line is deduced): QFixed oldX = QFixed::fromReal(staticText_d->position.x()); | - |
5794 | QFixed oldY = QFixed::fromReal(staticText_d->position.y()); never executed (the execution status of this line is deduced): QFixed oldY = QFixed::fromReal(staticText_d->position.y()); | - |
5795 | for (int item=0; item<staticText_d->itemCount;++item) { never evaluated: item<staticText_d->itemCount | 0 |
5796 | QStaticTextItem *textItem = staticText_d->items + item; never executed (the execution status of this line is deduced): QStaticTextItem *textItem = staticText_d->items + item; | - |
5797 | for (int i=0; i<textItem->numGlyphs; ++i) { never evaluated: i<textItem->numGlyphs | 0 |
5798 | textItem->glyphPositions[i].x += fx - oldX; never executed (the execution status of this line is deduced): textItem->glyphPositions[i].x += fx - oldX; | - |
5799 | textItem->glyphPositions[i].y += fy - oldY; never executed (the execution status of this line is deduced): textItem->glyphPositions[i].y += fy - oldY; | - |
5800 | } | 0 |
5801 | textItem->userDataNeedsUpdate = true; never executed (the execution status of this line is deduced): textItem->userDataNeedsUpdate = true; | - |
5802 | } | 0 |
5803 | | - |
5804 | staticText_d->position = transformedPosition; never executed (the execution status of this line is deduced): staticText_d->position = transformedPosition; | - |
5805 | } | 0 |
5806 | | - |
5807 | QPen oldPen = d->state->pen; never executed (the execution status of this line is deduced): QPen oldPen = d->state->pen; | - |
5808 | QColor currentColor = oldPen.color(); never executed (the execution status of this line is deduced): QColor currentColor = oldPen.color(); | - |
5809 | for (int i=0; i<staticText_d->itemCount; ++i) { never evaluated: i<staticText_d->itemCount | 0 |
5810 | QStaticTextItem *item = staticText_d->items + i; never executed (the execution status of this line is deduced): QStaticTextItem *item = staticText_d->items + i; | - |
5811 | if (item->color.isValid() && currentColor != item->color) { never evaluated: item->color.isValid() never evaluated: currentColor != item->color | 0 |
5812 | setPen(item->color); never executed (the execution status of this line is deduced): setPen(item->color); | - |
5813 | currentColor = item->color; never executed (the execution status of this line is deduced): currentColor = item->color; | - |
5814 | } | 0 |
5815 | d->extended->drawStaticTextItem(item); never executed (the execution status of this line is deduced): d->extended->drawStaticTextItem(item); | - |
5816 | | - |
5817 | qt_draw_decoration_for_glyphs(this, item->glyphs, item->glyphPositions, never executed (the execution status of this line is deduced): qt_draw_decoration_for_glyphs(this, item->glyphs, item->glyphPositions, | - |
5818 | item->numGlyphs, item->fontEngine(), staticText_d->font, never executed (the execution status of this line is deduced): item->numGlyphs, item->fontEngine(), staticText_d->font, | - |
5819 | QTextCharFormat()); never executed (the execution status of this line is deduced): QTextCharFormat()); | - |
5820 | } | 0 |
5821 | if (currentColor != oldPen.color()) never evaluated: currentColor != oldPen.color() | 0 |
5822 | setPen(oldPen); never executed: setPen(oldPen); | 0 |
5823 | | - |
5824 | if (!staticText_d->untransformedCoordinates && oldMatrix.isTranslating()) never evaluated: !staticText_d->untransformedCoordinates never evaluated: oldMatrix.isTranslating() | 0 |
5825 | d->state->matrix = oldMatrix; never executed: d->state->matrix = oldMatrix; | 0 |
5826 | } | 0 |
5827 | | - |
5828 | /*! | - |
5829 | \internal | - |
5830 | */ | - |
5831 | void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justificationPadding) | - |
5832 | { | - |
5833 | #ifdef QT_DEBUG_DRAW | - |
5834 | if (qt_show_painter_debug_output) | - |
5835 | printf("QPainter::drawText(), pos=[%.2f,%.2f], str='%s'\n", p.x(), p.y(), str.toLatin1().constData()); | - |
5836 | #endif | - |
5837 | | - |
5838 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
5839 | | - |
5840 | if (!d->engine || str.isEmpty() || pen().style() == Qt::NoPen) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:899 |
evaluated: str.isEmpty() yes Evaluation Count:2 | yes Evaluation Count:897 |
partially evaluated: pen().style() == Qt::NoPen no Evaluation Count:0 | yes Evaluation Count:897 |
| 0-899 |
5841 | return; executed: return; Execution Count:2 | 2 |
5842 | | - |
5843 | if (tf & Qt::TextBypassShaping) { partially evaluated: tf & Qt::TextBypassShaping no Evaluation Count:0 | yes Evaluation Count:897 |
| 0-897 |
5844 | // Skip harfbuzz complex shaping, shape using glyph advances only | - |
5845 | int len = str.length(); never executed (the execution status of this line is deduced): int len = str.length(); | - |
5846 | int numGlyphs = len; never executed (the execution status of this line is deduced): int numGlyphs = len; | - |
5847 | QVarLengthGlyphLayoutArray glyphs(len); never executed (the execution status of this line is deduced): QVarLengthGlyphLayoutArray glyphs(len); | - |
5848 | QFontEngine *fontEngine = d->state->font.d->engineForScript(QUnicodeTables::Common); never executed (the execution status of this line is deduced): QFontEngine *fontEngine = d->state->font.d->engineForScript(QUnicodeTables::Common); | - |
5849 | if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) { never evaluated: !fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0) | 0 |
5850 | glyphs.resize(numGlyphs); never executed (the execution status of this line is deduced): glyphs.resize(numGlyphs); | - |
5851 | if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) never evaluated: !fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0) | 0 |
5852 | Q_ASSERT_X(false, Q_FUNC_INFO, "stringToCMap shouldn't fail twice"); never executed: qt_noop(); | 0 |
5853 | } | 0 |
5854 | | - |
5855 | QTextItemInt gf(glyphs, &d->state->font, str.data(), len, fontEngine); never executed (the execution status of this line is deduced): QTextItemInt gf(glyphs, &d->state->font, str.data(), len, fontEngine); | - |
5856 | drawTextItem(p, gf); never executed (the execution status of this line is deduced): drawTextItem(p, gf); | - |
5857 | return; | 0 |
5858 | } | - |
5859 | | - |
5860 | QStackTextEngine engine(str, d->state->font); executed (the execution status of this line is deduced): QStackTextEngine engine(str, d->state->font); | - |
5861 | engine.option.setTextDirection(d->state->layoutDirection); executed (the execution status of this line is deduced): engine.option.setTextDirection(d->state->layoutDirection); | - |
5862 | if (tf & (Qt::TextForceLeftToRight|Qt::TextForceRightToLeft)) { partially evaluated: tf & (Qt::TextForceLeftToRight|Qt::TextForceRightToLeft) no Evaluation Count:0 | yes Evaluation Count:897 |
| 0-897 |
5863 | engine.ignoreBidi = true; never executed (the execution status of this line is deduced): engine.ignoreBidi = true; | - |
5864 | engine.option.setTextDirection((tf & Qt::TextForceLeftToRight) ? Qt::LeftToRight : Qt::RightToLeft); never executed (the execution status of this line is deduced): engine.option.setTextDirection((tf & Qt::TextForceLeftToRight) ? Qt::LeftToRight : Qt::RightToLeft); | - |
5865 | } | 0 |
5866 | engine.itemize(); executed (the execution status of this line is deduced): engine.itemize(); | - |
5867 | QScriptLine line; executed (the execution status of this line is deduced): QScriptLine line; | - |
5868 | line.length = str.length(); executed (the execution status of this line is deduced): line.length = str.length(); | - |
5869 | engine.shapeLine(line); executed (the execution status of this line is deduced): engine.shapeLine(line); | - |
5870 | | - |
5871 | int nItems = engine.layoutData->items.size(); executed (the execution status of this line is deduced): int nItems = engine.layoutData->items.size(); | - |
5872 | QVarLengthArray<int> visualOrder(nItems); executed (the execution status of this line is deduced): QVarLengthArray<int> visualOrder(nItems); | - |
5873 | QVarLengthArray<uchar> levels(nItems); executed (the execution status of this line is deduced): QVarLengthArray<uchar> levels(nItems); | - |
5874 | for (int i = 0; i < nItems; ++i) evaluated: i < nItems yes Evaluation Count:897 | yes Evaluation Count:897 |
| 897 |
5875 | levels[i] = engine.layoutData->items[i].analysis.bidiLevel; executed: levels[i] = engine.layoutData->items[i].analysis.bidiLevel; Execution Count:897 | 897 |
5876 | QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); executed (the execution status of this line is deduced): QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); | - |
5877 | | - |
5878 | if (justificationPadding > 0) { partially evaluated: justificationPadding > 0 no Evaluation Count:0 | yes Evaluation Count:897 |
| 0-897 |
5879 | engine.option.setAlignment(Qt::AlignJustify); never executed (the execution status of this line is deduced): engine.option.setAlignment(Qt::AlignJustify); | - |
5880 | engine.forceJustification = true; never executed (the execution status of this line is deduced): engine.forceJustification = true; | - |
5881 | // this works because justify() is only interested in the difference between width and textWidth | - |
5882 | line.width = justificationPadding; never executed (the execution status of this line is deduced): line.width = justificationPadding; | - |
5883 | engine.justify(line); never executed (the execution status of this line is deduced): engine.justify(line); | - |
5884 | } | 0 |
5885 | QFixed x = QFixed::fromReal(p.x()); executed (the execution status of this line is deduced): QFixed x = QFixed::fromReal(p.x()); | - |
5886 | | - |
5887 | for (int i = 0; i < nItems; ++i) { evaluated: i < nItems yes Evaluation Count:897 | yes Evaluation Count:897 |
| 897 |
5888 | int item = visualOrder[i]; executed (the execution status of this line is deduced): int item = visualOrder[i]; | - |
5889 | const QScriptItem &si = engine.layoutData->items.at(item); executed (the execution status of this line is deduced): const QScriptItem &si = engine.layoutData->items.at(item); | - |
5890 | if (si.analysis.flags >= QScriptAnalysis::TabOrObject) { partially evaluated: si.analysis.flags >= QScriptAnalysis::TabOrObject no Evaluation Count:0 | yes Evaluation Count:897 |
| 0-897 |
5891 | x += si.width; never executed (the execution status of this line is deduced): x += si.width; | - |
5892 | continue; never executed: continue; | 0 |
5893 | } | - |
5894 | QFont f = engine.font(si); executed (the execution status of this line is deduced): QFont f = engine.font(si); | - |
5895 | QTextItemInt gf(si, &f); executed (the execution status of this line is deduced): QTextItemInt gf(si, &f); | - |
5896 | gf.glyphs = engine.shapedGlyphs(&si); executed (the execution status of this line is deduced): gf.glyphs = engine.shapedGlyphs(&si); | - |
5897 | gf.chars = engine.layoutData->string.unicode() + si.position; executed (the execution status of this line is deduced): gf.chars = engine.layoutData->string.unicode() + si.position; | - |
5898 | gf.num_chars = engine.length(item); executed (the execution status of this line is deduced): gf.num_chars = engine.length(item); | - |
5899 | if (engine.forceJustification) { partially evaluated: engine.forceJustification no Evaluation Count:0 | yes Evaluation Count:897 |
| 0-897 |
5900 | for (int j=0; j<gf.glyphs.numGlyphs; ++j) never evaluated: j<gf.glyphs.numGlyphs | 0 |
5901 | gf.width += gf.glyphs.effectiveAdvance(j); never executed: gf.width += gf.glyphs.effectiveAdvance(j); | 0 |
5902 | } else { | 0 |
5903 | gf.width = si.width; executed (the execution status of this line is deduced): gf.width = si.width; | - |
5904 | } executed: } Execution Count:897 | 897 |
5905 | gf.logClusters = engine.logClusters(&si); executed (the execution status of this line is deduced): gf.logClusters = engine.logClusters(&si); | - |
5906 | | - |
5907 | drawTextItem(QPointF(x.toReal(), p.y()), gf); executed (the execution status of this line is deduced): drawTextItem(QPointF(x.toReal(), p.y()), gf); | - |
5908 | | - |
5909 | x += gf.width; executed (the execution status of this line is deduced): x += gf.width; | - |
5910 | } executed: } Execution Count:897 | 897 |
5911 | } executed: } Execution Count:897 | 897 |
5912 | | - |
5913 | void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br) | - |
5914 | { | - |
5915 | #ifdef QT_DEBUG_DRAW | - |
5916 | if (qt_show_painter_debug_output) | - |
5917 | printf("QPainter::drawText(), r=[%d,%d,%d,%d], flags=%d, str='%s'\n", | - |
5918 | r.x(), r.y(), r.width(), r.height(), flags, str.toLatin1().constData()); | - |
5919 | #endif | - |
5920 | | - |
5921 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
5922 | | - |
5923 | if (!d->engine || str.length() == 0 || pen().style() == Qt::NoPen) evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:3930 |
evaluated: str.length() == 0 yes Evaluation Count:189 | yes Evaluation Count:3741 |
partially evaluated: pen().style() == Qt::NoPen no Evaluation Count:0 | yes Evaluation Count:3741 |
| 0-3930 |
5924 | return; executed: return; Execution Count:190 | 190 |
5925 | | - |
5926 | if (!d->extended) partially evaluated: !d->extended no Evaluation Count:0 | yes Evaluation Count:3741 |
| 0-3741 |
5927 | d->updateState(d->state); never executed: d->updateState(d->state); | 0 |
5928 | | - |
5929 | QRectF bounds; executed (the execution status of this line is deduced): QRectF bounds; | - |
5930 | qt_format_text(d->state->font, r, flags, 0, str, br ? &bounds : 0, 0, 0, 0, this); executed (the execution status of this line is deduced): qt_format_text(d->state->font, r, flags, 0, str, br ? &bounds : 0, 0, 0, 0, this); | - |
5931 | if (br) partially evaluated: br no Evaluation Count:0 | yes Evaluation Count:3741 |
| 0-3741 |
5932 | *br = bounds.toAlignedRect(); never executed: *br = bounds.toAlignedRect(); | 0 |
5933 | } executed: } Execution Count:3741 | 3741 |
5934 | | - |
5935 | /*! | - |
5936 | \fn void QPainter::drawText(const QPoint &position, const QString &text) | - |
5937 | | - |
5938 | \overload | - |
5939 | | - |
5940 | Draws the given \a text with the currently defined text direction, | - |
5941 | beginning at the given \a position. | - |
5942 | | - |
5943 | By default, QPainter draws text anti-aliased. | - |
5944 | | - |
5945 | \note The y-position is used as the baseline of the font. | - |
5946 | | - |
5947 | \sa setFont(), setPen() | - |
5948 | */ | - |
5949 | | - |
5950 | /*! | - |
5951 | \fn void QPainter::drawText(const QRectF &rectangle, int flags, const QString &text, QRectF *boundingRect) | - |
5952 | \overload | - |
5953 | | - |
5954 | Draws the given \a text within the provided \a rectangle. | - |
5955 | The \a rectangle along with alignment \a flags defines the anchors for the \a text. | - |
5956 | | - |
5957 | \table 100% | - |
5958 | \row | - |
5959 | \li \inlineimage qpainter-text.png | - |
5960 | \li | - |
5961 | \snippet code/src_gui_painting_qpainter.cpp 17 | - |
5962 | \endtable | - |
5963 | | - |
5964 | The \a boundingRect (if not null) is set to the what the bounding rectangle | - |
5965 | should be in order to enclose the whole text. The \a flags argument is a bitwise | - |
5966 | OR of the following flags: | - |
5967 | | - |
5968 | \list | - |
5969 | \li Qt::AlignLeft | - |
5970 | \li Qt::AlignRight | - |
5971 | \li Qt::AlignHCenter | - |
5972 | \li Qt::AlignJustify | - |
5973 | \li Qt::AlignTop | - |
5974 | \li Qt::AlignBottom | - |
5975 | \li Qt::AlignVCenter | - |
5976 | \li Qt::AlignCenter | - |
5977 | \li Qt::TextDontClip | - |
5978 | \li Qt::TextSingleLine | - |
5979 | \li Qt::TextExpandTabs | - |
5980 | \li Qt::TextShowMnemonic | - |
5981 | \li Qt::TextWordWrap | - |
5982 | \li Qt::TextIncludeTrailingSpaces | - |
5983 | \endlist | - |
5984 | | - |
5985 | \sa Qt::AlignmentFlag, Qt::TextFlag, boundingRect(), layoutDirection() | - |
5986 | | - |
5987 | By default, QPainter draws text anti-aliased. | - |
5988 | | - |
5989 | \note The y-coordinate of \a rectangle is used as the top of the font. | - |
5990 | */ | - |
5991 | void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF *br) | - |
5992 | { | - |
5993 | #ifdef QT_DEBUG_DRAW | - |
5994 | if (qt_show_painter_debug_output) | - |
5995 | printf("QPainter::drawText(), r=[%.2f,%.2f,%.2f,%.2f], flags=%d, str='%s'\n", | - |
5996 | r.x(), r.y(), r.width(), r.height(), flags, str.toLatin1().constData()); | - |
5997 | #endif | - |
5998 | | - |
5999 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6000 | | - |
6001 | if (!d->engine || str.length() == 0 || pen().style() == Qt::NoPen) partially evaluated: !d->engine yes Evaluation Count:1 | no Evaluation Count:0 |
never evaluated: str.length() == 0 never evaluated: pen().style() == Qt::NoPen | 0-1 |
6002 | return; executed: return; Execution Count:1 | 1 |
6003 | | - |
6004 | if (!d->extended) never evaluated: !d->extended | 0 |
6005 | d->updateState(d->state); never executed: d->updateState(d->state); | 0 |
6006 | | - |
6007 | qt_format_text(d->state->font, r, flags, 0, str, br, 0, 0, 0, this); never executed (the execution status of this line is deduced): qt_format_text(d->state->font, r, flags, 0, str, br, 0, 0, 0, this); | - |
6008 | } | 0 |
6009 | | - |
6010 | /*! | - |
6011 | \fn void QPainter::drawText(const QRect &rectangle, int flags, const QString &text, QRect *boundingRect) | - |
6012 | \overload | - |
6013 | | - |
6014 | Draws the given \a text within the provided \a rectangle according | - |
6015 | to the specified \a flags. The \a boundingRect (if not null) is set to | - |
6016 | the what the bounding rectangle should be in order to enclose the whole text. | - |
6017 | | - |
6018 | By default, QPainter draws text anti-aliased. | - |
6019 | | - |
6020 | \note The y-coordinate of \a rectangle is used as the top of the font. | - |
6021 | | - |
6022 | \sa setFont(), setPen() | - |
6023 | */ | - |
6024 | | - |
6025 | /*! | - |
6026 | \fn void QPainter::drawText(int x, int y, const QString &text) | - |
6027 | | - |
6028 | \overload | - |
6029 | | - |
6030 | Draws the given \a text at position (\a{x}, \a{y}), using the painter's | - |
6031 | currently defined text direction. | - |
6032 | | - |
6033 | By default, QPainter draws text anti-aliased. | - |
6034 | | - |
6035 | \note The y-position is used as the baseline of the font. | - |
6036 | | - |
6037 | \sa setFont(), setPen() | - |
6038 | */ | - |
6039 | | - |
6040 | /*! | - |
6041 | \fn void QPainter::drawText(int x, int y, int width, int height, int flags, | - |
6042 | const QString &text, QRect *boundingRect) | - |
6043 | | - |
6044 | \overload | - |
6045 | | - |
6046 | Draws the given \a text within the rectangle with origin (\a{x}, | - |
6047 | \a{y}), \a width and \a height. | - |
6048 | | - |
6049 | The \a boundingRect (if not null) is set to the actual bounding | - |
6050 | rectangle of the output. The \a flags argument is a bitwise OR of | - |
6051 | the following flags: | - |
6052 | | - |
6053 | \list | - |
6054 | \li Qt::AlignLeft | - |
6055 | \li Qt::AlignRight | - |
6056 | \li Qt::AlignHCenter | - |
6057 | \li Qt::AlignJustify | - |
6058 | \li Qt::AlignTop | - |
6059 | \li Qt::AlignBottom | - |
6060 | \li Qt::AlignVCenter | - |
6061 | \li Qt::AlignCenter | - |
6062 | \li Qt::TextSingleLine | - |
6063 | \li Qt::TextExpandTabs | - |
6064 | \li Qt::TextShowMnemonic | - |
6065 | \li Qt::TextWordWrap | - |
6066 | \endlist | - |
6067 | | - |
6068 | By default, QPainter draws text anti-aliased. | - |
6069 | | - |
6070 | \note The y-position is used as the top of the font. | - |
6071 | | - |
6072 | \sa Qt::AlignmentFlag, Qt::TextFlag, setFont(), setPen() | - |
6073 | */ | - |
6074 | | - |
6075 | /*! | - |
6076 | \fn void QPainter::drawText(const QRectF &rectangle, const QString &text, | - |
6077 | const QTextOption &option) | - |
6078 | \overload | - |
6079 | | - |
6080 | Draws the given \a text in the \a rectangle specified using the \a option | - |
6081 | to control its positioning and orientation. | - |
6082 | | - |
6083 | By default, QPainter draws text anti-aliased. | - |
6084 | | - |
6085 | \note The y-coordinate of \a rectangle is used as the top of the font. | - |
6086 | | - |
6087 | \sa setFont(), setPen() | - |
6088 | */ | - |
6089 | void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption &o) | - |
6090 | { | - |
6091 | #ifdef QT_DEBUG_DRAW | - |
6092 | if (qt_show_painter_debug_output) | - |
6093 | printf("QPainter::drawText(), r=[%.2f,%.2f,%.2f,%.2f], str='%s'\n", | - |
6094 | r.x(), r.y(), r.width(), r.height(), text.toLatin1().constData()); | - |
6095 | #endif | - |
6096 | | - |
6097 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6098 | | - |
6099 | if (!d->engine || text.length() == 0 || pen().style() == Qt::NoPen) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: text.length() == 0 yes Evaluation Count:3 | no Evaluation Count:0 |
never evaluated: pen().style() == Qt::NoPen | 0-3 |
6100 | return; executed: return; Execution Count:3 | 3 |
6101 | | - |
6102 | if (!d->extended) never evaluated: !d->extended | 0 |
6103 | d->updateState(d->state); never executed: d->updateState(d->state); | 0 |
6104 | | - |
6105 | qt_format_text(d->state->font, r, 0, &o, text, 0, 0, 0, 0, this); never executed (the execution status of this line is deduced): qt_format_text(d->state->font, r, 0, &o, text, 0, 0, 0, 0, this); | - |
6106 | } | 0 |
6107 | | - |
6108 | /*! | - |
6109 | \fn void QPainter::drawTextItem(int x, int y, const QTextItem &ti) | - |
6110 | | - |
6111 | \internal | - |
6112 | \overload | - |
6113 | */ | - |
6114 | | - |
6115 | /*! | - |
6116 | \fn void QPainter::drawTextItem(const QPoint &p, const QTextItem &ti) | - |
6117 | | - |
6118 | \internal | - |
6119 | \overload | - |
6120 | | - |
6121 | Draws the text item \a ti at position \a p. | - |
6122 | */ | - |
6123 | | - |
6124 | /*! | - |
6125 | \fn void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti) | - |
6126 | | - |
6127 | \internal | - |
6128 | \since 4.1 | - |
6129 | | - |
6130 | Draws the text item \a ti at position \a p. | - |
6131 | | - |
6132 | This method ignores the painters background mode and | - |
6133 | color. drawText and qt_format_text have to do it themselves, as | - |
6134 | only they know the extents of the complete string. | - |
6135 | | - |
6136 | It ignores the font set on the painter as the text item has one of its own. | - |
6137 | | - |
6138 | The underline and strikeout parameters of the text items font are | - |
6139 | ignored aswell. You'll need to pass in the correct flags to get | - |
6140 | underlining and strikeout. | - |
6141 | */ | - |
6142 | | - |
6143 | static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen) | - |
6144 | { | - |
6145 | const qreal radiusBase = qMax(qreal(1), maxRadius); never executed (the execution status of this line is deduced): const qreal radiusBase = qMax(qreal(1), maxRadius); | - |
6146 | | - |
6147 | QString key = QLatin1String("WaveUnderline-") never executed (the execution status of this line is deduced): QString key = QLatin1String("WaveUnderline-") | - |
6148 | % pen.color().name() never executed (the execution status of this line is deduced): % pen.color().name() | - |
6149 | % HexString<qreal>(radiusBase); never executed (the execution status of this line is deduced): % HexString<qreal>(radiusBase); | - |
6150 | | - |
6151 | QPixmap pixmap; never executed (the execution status of this line is deduced): QPixmap pixmap; | - |
6152 | if (QPixmapCache::find(key, pixmap)) never evaluated: QPixmapCache::find(key, pixmap) | 0 |
6153 | return pixmap; never executed: return pixmap; | 0 |
6154 | | - |
6155 | const qreal halfPeriod = qMax(qreal(2), qreal(radiusBase * 1.61803399)); // the golden ratio never executed (the execution status of this line is deduced): const qreal halfPeriod = qMax(qreal(2), qreal(radiusBase * 1.61803399)); | - |
6156 | const int width = qCeil(100 / (2 * halfPeriod)) * (2 * halfPeriod); never executed (the execution status of this line is deduced): const int width = qCeil(100 / (2 * halfPeriod)) * (2 * halfPeriod); | - |
6157 | const int radius = qFloor(radiusBase); never executed (the execution status of this line is deduced): const int radius = qFloor(radiusBase); | - |
6158 | | - |
6159 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
6160 | | - |
6161 | qreal xs = 0; never executed (the execution status of this line is deduced): qreal xs = 0; | - |
6162 | qreal ys = radius; never executed (the execution status of this line is deduced): qreal ys = radius; | - |
6163 | | - |
6164 | while (xs < width) { never evaluated: xs < width | 0 |
6165 | xs += halfPeriod; never executed (the execution status of this line is deduced): xs += halfPeriod; | - |
6166 | ys = -ys; never executed (the execution status of this line is deduced): ys = -ys; | - |
6167 | path.quadTo(xs - halfPeriod / 2, ys, xs, 0); never executed (the execution status of this line is deduced): path.quadTo(xs - halfPeriod / 2, ys, xs, 0); | - |
6168 | } | 0 |
6169 | | - |
6170 | pixmap = QPixmap(width, radius * 2); never executed (the execution status of this line is deduced): pixmap = QPixmap(width, radius * 2); | - |
6171 | pixmap.fill(Qt::transparent); never executed (the execution status of this line is deduced): pixmap.fill(Qt::transparent); | - |
6172 | { | - |
6173 | QPen wavePen = pen; never executed (the execution status of this line is deduced): QPen wavePen = pen; | - |
6174 | wavePen.setCapStyle(Qt::SquareCap); never executed (the execution status of this line is deduced): wavePen.setCapStyle(Qt::SquareCap); | - |
6175 | | - |
6176 | // This is to protect against making the line too fat, as happens on Mac OS X | - |
6177 | // due to it having a rather thick width for the regular underline. | - |
6178 | const qreal maxPenWidth = .8 * radius; never executed (the execution status of this line is deduced): const qreal maxPenWidth = .8 * radius; | - |
6179 | if (wavePen.widthF() > maxPenWidth) never evaluated: wavePen.widthF() > maxPenWidth | 0 |
6180 | wavePen.setWidth(maxPenWidth); never executed: wavePen.setWidth(maxPenWidth); | 0 |
6181 | | - |
6182 | QPainter imgPainter(&pixmap); never executed (the execution status of this line is deduced): QPainter imgPainter(&pixmap); | - |
6183 | imgPainter.setPen(wavePen); never executed (the execution status of this line is deduced): imgPainter.setPen(wavePen); | - |
6184 | imgPainter.setRenderHint(QPainter::Antialiasing); never executed (the execution status of this line is deduced): imgPainter.setRenderHint(QPainter::Antialiasing); | - |
6185 | imgPainter.translate(0, radius); never executed (the execution status of this line is deduced): imgPainter.translate(0, radius); | - |
6186 | imgPainter.drawPath(path); never executed (the execution status of this line is deduced): imgPainter.drawPath(path); | - |
6187 | } | - |
6188 | | - |
6189 | QPixmapCache::insert(key, pixmap); never executed (the execution status of this line is deduced): QPixmapCache::insert(key, pixmap); | - |
6190 | | - |
6191 | return pixmap; never executed: return pixmap; | 0 |
6192 | } | - |
6193 | | - |
6194 | static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextEngine *textEngine, | - |
6195 | QTextCharFormat::UnderlineStyle underlineStyle, | - |
6196 | QTextItem::RenderFlags flags, qreal width, | - |
6197 | const QTextCharFormat &charFormat) | - |
6198 | { | - |
6199 | if (underlineStyle == QTextCharFormat::NoUnderline evaluated: underlineStyle == QTextCharFormat::NoUnderline yes Evaluation Count:22491 | yes Evaluation Count:540 |
| 540-22491 |
6200 | && !(flags & (QTextItem::StrikeOut | QTextItem::Overline))) evaluated: !(flags & (QTextItem::StrikeOut | QTextItem::Overline)) yes Evaluation Count:22487 | yes Evaluation Count:4 |
| 4-22487 |
6201 | return; executed: return; Execution Count:22487 | 22487 |
6202 | | - |
6203 | const QPen oldPen = painter->pen(); executed (the execution status of this line is deduced): const QPen oldPen = painter->pen(); | - |
6204 | const QBrush oldBrush = painter->brush(); executed (the execution status of this line is deduced): const QBrush oldBrush = painter->brush(); | - |
6205 | painter->setBrush(Qt::NoBrush); executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush); | - |
6206 | QPen pen = oldPen; executed (the execution status of this line is deduced): QPen pen = oldPen; | - |
6207 | pen.setStyle(Qt::SolidLine); executed (the execution status of this line is deduced): pen.setStyle(Qt::SolidLine); | - |
6208 | pen.setWidthF(fe->lineThickness().toReal()); executed (the execution status of this line is deduced): pen.setWidthF(fe->lineThickness().toReal()); | - |
6209 | pen.setCapStyle(Qt::FlatCap); executed (the execution status of this line is deduced): pen.setCapStyle(Qt::FlatCap); | - |
6210 | | - |
6211 | QLineF line(pos.x(), pos.y(), pos.x() + qFloor(width), pos.y()); executed (the execution status of this line is deduced): QLineF line(pos.x(), pos.y(), pos.x() + qFloor(width), pos.y()); | - |
6212 | | - |
6213 | bool wasCompatiblePainting = painter->renderHints() executed (the execution status of this line is deduced): bool wasCompatiblePainting = painter->renderHints() | - |
6214 | & QPainter::Qt4CompatiblePainting; executed (the execution status of this line is deduced): & QPainter::Qt4CompatiblePainting; | - |
6215 | | - |
6216 | if (wasCompatiblePainting) partially evaluated: wasCompatiblePainting no Evaluation Count:0 | yes Evaluation Count:544 |
| 0-544 |
6217 | painter->setRenderHint(QPainter::Qt4CompatiblePainting, false); never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting, false); | 0 |
6218 | | - |
6219 | const qreal underlineOffset = fe->underlinePosition().toReal(); executed (the execution status of this line is deduced): const qreal underlineOffset = fe->underlinePosition().toReal(); | - |
6220 | // deliberately ceil the offset to avoid the underline coming too close to | - |
6221 | // the text above it. | - |
6222 | const qreal underlinePos = pos.y() + qCeil(underlineOffset) + 0.5; executed (the execution status of this line is deduced): const qreal underlinePos = pos.y() + qCeil(underlineOffset) + 0.5; | - |
6223 | | - |
6224 | if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { partially evaluated: underlineStyle == QTextCharFormat::SpellCheckUnderline no Evaluation Count:0 | yes Evaluation Count:544 |
| 0-544 |
6225 | QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); never executed (the execution status of this line is deduced): QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); | - |
6226 | if (theme) | 0 |
6227 | underlineStyle = QTextCharFormat::UnderlineStyle(theme->themeHint(QPlatformTheme::SpellCheckUnderlineStyle).toInt()); never executed: underlineStyle = QTextCharFormat::UnderlineStyle(theme->themeHint(QPlatformTheme::SpellCheckUnderlineStyle).toInt()); | 0 |
6228 | } | 0 |
6229 | | - |
6230 | if (underlineStyle == QTextCharFormat::WaveUnderline) { partially evaluated: underlineStyle == QTextCharFormat::WaveUnderline no Evaluation Count:0 | yes Evaluation Count:544 |
| 0-544 |
6231 | painter->save(); never executed (the execution status of this line is deduced): painter->save(); | - |
6232 | painter->translate(0, pos.y() + 1); never executed (the execution status of this line is deduced): painter->translate(0, pos.y() + 1); | - |
6233 | | - |
6234 | QColor uc = charFormat.underlineColor(); never executed (the execution status of this line is deduced): QColor uc = charFormat.underlineColor(); | - |
6235 | if (uc.isValid()) never evaluated: uc.isValid() | 0 |
6236 | pen.setColor(uc); never executed: pen.setColor(uc); | 0 |
6237 | | - |
6238 | // Adapt wave to underlineOffset or pen width, whatever is larger, to make it work on all platforms | - |
6239 | const QPixmap wave = generateWavyPixmap(qMax(underlineOffset, pen.widthF()), pen); never executed (the execution status of this line is deduced): const QPixmap wave = generateWavyPixmap(qMax(underlineOffset, pen.widthF()), pen); | - |
6240 | const int descent = (int) fe->descent().toReal(); never executed (the execution status of this line is deduced): const int descent = (int) fe->descent().toReal(); | - |
6241 | | - |
6242 | painter->setBrushOrigin(painter->brushOrigin().x(), 0); never executed (the execution status of this line is deduced): painter->setBrushOrigin(painter->brushOrigin().x(), 0); | - |
6243 | painter->fillRect(pos.x(), 0, qCeil(width), qMin(wave.height(), descent), wave); never executed (the execution status of this line is deduced): painter->fillRect(pos.x(), 0, qCeil(width), qMin(wave.height(), descent), wave); | - |
6244 | painter->restore(); never executed (the execution status of this line is deduced): painter->restore(); | - |
6245 | } else if (underlineStyle != QTextCharFormat::NoUnderline) { never executed: } evaluated: underlineStyle != QTextCharFormat::NoUnderline yes Evaluation Count:540 | yes Evaluation Count:4 |
| 0-540 |
6246 | QColor uc = charFormat.underlineColor(); executed (the execution status of this line is deduced): QColor uc = charFormat.underlineColor(); | - |
6247 | if (uc.isValid()) partially evaluated: uc.isValid() no Evaluation Count:0 | yes Evaluation Count:540 |
| 0-540 |
6248 | pen.setColor(uc); never executed: pen.setColor(uc); | 0 |
6249 | | - |
6250 | pen.setStyle((Qt::PenStyle)(underlineStyle)); executed (the execution status of this line is deduced): pen.setStyle((Qt::PenStyle)(underlineStyle)); | - |
6251 | painter->setPen(pen); executed (the execution status of this line is deduced): painter->setPen(pen); | - |
6252 | QLineF underline(line.x1(), underlinePos, line.x2(), underlinePos); executed (the execution status of this line is deduced): QLineF underline(line.x1(), underlinePos, line.x2(), underlinePos); | - |
6253 | if (textEngine) evaluated: textEngine yes Evaluation Count:538 | yes Evaluation Count:2 |
| 2-538 |
6254 | textEngine->addUnderline(painter, underline); executed: textEngine->addUnderline(painter, underline); Execution Count:538 | 538 |
6255 | else | - |
6256 | painter->drawLine(underline); executed: painter->drawLine(underline); Execution Count:2 | 2 |
6257 | } | - |
6258 | | - |
6259 | pen.setStyle(Qt::SolidLine); executed (the execution status of this line is deduced): pen.setStyle(Qt::SolidLine); | - |
6260 | pen.setColor(oldPen.color()); executed (the execution status of this line is deduced): pen.setColor(oldPen.color()); | - |
6261 | | - |
6262 | if (flags & QTextItem::StrikeOut) { evaluated: flags & QTextItem::StrikeOut yes Evaluation Count:2 | yes Evaluation Count:542 |
| 2-542 |
6263 | QLineF strikeOutLine = line; executed (the execution status of this line is deduced): QLineF strikeOutLine = line; | - |
6264 | strikeOutLine.translate(0., - fe->ascent().toReal() / 3.); executed (the execution status of this line is deduced): strikeOutLine.translate(0., - fe->ascent().toReal() / 3.); | - |
6265 | painter->setPen(pen); executed (the execution status of this line is deduced): painter->setPen(pen); | - |
6266 | if (textEngine) evaluated: textEngine yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
6267 | textEngine->addStrikeOut(painter, strikeOutLine); executed: textEngine->addStrikeOut(painter, strikeOutLine); Execution Count:1 | 1 |
6268 | else | - |
6269 | painter->drawLine(strikeOutLine); executed: painter->drawLine(strikeOutLine); Execution Count:1 | 1 |
6270 | } | - |
6271 | | - |
6272 | if (flags & QTextItem::Overline) { evaluated: flags & QTextItem::Overline yes Evaluation Count:2 | yes Evaluation Count:542 |
| 2-542 |
6273 | QLineF overline = line; executed (the execution status of this line is deduced): QLineF overline = line; | - |
6274 | overline.translate(0., - fe->ascent().toReal()); executed (the execution status of this line is deduced): overline.translate(0., - fe->ascent().toReal()); | - |
6275 | painter->setPen(pen); executed (the execution status of this line is deduced): painter->setPen(pen); | - |
6276 | if (textEngine) evaluated: textEngine yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
6277 | textEngine->addOverline(painter, overline); executed: textEngine->addOverline(painter, overline); Execution Count:1 | 1 |
6278 | else | - |
6279 | painter->drawLine(overline); executed: painter->drawLine(overline); Execution Count:1 | 1 |
6280 | } | - |
6281 | | - |
6282 | painter->setPen(oldPen); executed (the execution status of this line is deduced): painter->setPen(oldPen); | - |
6283 | painter->setBrush(oldBrush); executed (the execution status of this line is deduced): painter->setBrush(oldBrush); | - |
6284 | | - |
6285 | if (wasCompatiblePainting) partially evaluated: wasCompatiblePainting no Evaluation Count:0 | yes Evaluation Count:544 |
| 0-544 |
6286 | painter->setRenderHint(QPainter::Qt4CompatiblePainting); never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting); | 0 |
6287 | } executed: } Execution Count:544 | 544 |
6288 | | - |
6289 | Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray, | - |
6290 | const QFixedPoint *positions, int glyphCount, | - |
6291 | QFontEngine *fontEngine, const QFont &font, | - |
6292 | const QTextCharFormat &charFormat) | - |
6293 | { | - |
6294 | if (!(font.underline() || font.strikeOut() || font.overline())) never evaluated: font.underline() never evaluated: font.strikeOut() never evaluated: font.overline() | 0 |
6295 | return; | 0 |
6296 | | - |
6297 | QFixed leftMost; never executed (the execution status of this line is deduced): QFixed leftMost; | - |
6298 | QFixed rightMost; never executed (the execution status of this line is deduced): QFixed rightMost; | - |
6299 | QFixed baseLine; never executed (the execution status of this line is deduced): QFixed baseLine; | - |
6300 | for (int i=0; i<glyphCount; ++i) { never evaluated: i<glyphCount | 0 |
6301 | glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]); never executed (the execution status of this line is deduced): glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]); | - |
6302 | if (i == 0 || leftMost > positions[i].x) never evaluated: i == 0 never evaluated: leftMost > positions[i].x | 0 |
6303 | leftMost = positions[i].x; never executed: leftMost = positions[i].x; | 0 |
6304 | | - |
6305 | // We don't support glyphs that do not share a common baseline. If this turns out to | - |
6306 | // be a relevant use case, then we need to find clusters of glyphs that share a baseline | - |
6307 | // and do a drawTextItemDecoration call per cluster. | - |
6308 | if (i == 0 || baseLine < positions[i].y) never evaluated: i == 0 never evaluated: baseLine < positions[i].y | 0 |
6309 | baseLine = positions[i].y; never executed: baseLine = positions[i].y; | 0 |
6310 | | - |
6311 | // We use the advance rather than the actual bounds to match the algorithm in drawText() | - |
6312 | if (i == 0 || rightMost < positions[i].x + gm.xoff) never evaluated: i == 0 never evaluated: rightMost < positions[i].x + gm.xoff | 0 |
6313 | rightMost = positions[i].x + gm.xoff; never executed: rightMost = positions[i].x + gm.xoff; | 0 |
6314 | } | 0 |
6315 | | - |
6316 | QFixed width = rightMost - leftMost; never executed (the execution status of this line is deduced): QFixed width = rightMost - leftMost; | - |
6317 | QTextItem::RenderFlags flags = 0; never executed (the execution status of this line is deduced): QTextItem::RenderFlags flags = 0; | - |
6318 | | - |
6319 | if (font.underline()) never evaluated: font.underline() | 0 |
6320 | flags |= QTextItem::Underline; never executed: flags |= QTextItem::Underline; | 0 |
6321 | if (font.overline()) never evaluated: font.overline() | 0 |
6322 | flags |= QTextItem::Overline; never executed: flags |= QTextItem::Overline; | 0 |
6323 | if (font.strikeOut()) never evaluated: font.strikeOut() | 0 |
6324 | flags |= QTextItem::StrikeOut; never executed: flags |= QTextItem::StrikeOut; | 0 |
6325 | | - |
6326 | drawTextItemDecoration(painter, QPointF(leftMost.toReal(), baseLine.toReal()), never executed (the execution status of this line is deduced): drawTextItemDecoration(painter, QPointF(leftMost.toReal(), baseLine.toReal()), | - |
6327 | fontEngine, never executed (the execution status of this line is deduced): fontEngine, | - |
6328 | 0, // textEngine never executed (the execution status of this line is deduced): 0, | - |
6329 | font.underline() ? QTextCharFormat::SingleUnderline never executed (the execution status of this line is deduced): font.underline() ? QTextCharFormat::SingleUnderline | - |
6330 | : QTextCharFormat::NoUnderline, flags, never executed (the execution status of this line is deduced): : QTextCharFormat::NoUnderline, flags, | - |
6331 | width.toReal(), charFormat); never executed (the execution status of this line is deduced): width.toReal(), charFormat); | - |
6332 | } | 0 |
6333 | | - |
6334 | void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti) | - |
6335 | { | - |
6336 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6337 | | - |
6338 | d->drawTextItem(p, ti, static_cast<QTextEngine *>(0)); executed (the execution status of this line is deduced): d->drawTextItem(p, ti, static_cast<QTextEngine *>(0)); | - |
6339 | } executed: } Execution Count:897 | 897 |
6340 | | - |
6341 | void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QTextEngine *textEngine) | - |
6342 | { | - |
6343 | #ifdef QT_DEBUG_DRAW | - |
6344 | if (qt_show_painter_debug_output) | - |
6345 | printf("QPainter::drawTextItem(), pos=[%.f,%.f], str='%s'\n", | - |
6346 | p.x(), p.y(), qPrintable(_ti.text())); | - |
6347 | #endif | - |
6348 | | - |
6349 | Q_Q(QPainter); executed (the execution status of this line is deduced): QPainter * const q = q_func(); | - |
6350 | | - |
6351 | if (!engine) partially evaluated: !engine no Evaluation Count:0 | yes Evaluation Count:23019 |
| 0-23019 |
6352 | return; | 0 |
6353 | | - |
6354 | #ifndef QT_NO_DEBUG | - |
6355 | qt_painter_thread_test(device->devType(), | - |
6356 | "text and fonts", | - |
6357 | QFontDatabase::supportsThreadedFontRendering()); | - |
6358 | #endif | - |
6359 | | - |
6360 | QTextItemInt &ti = const_cast<QTextItemInt &>(static_cast<const QTextItemInt &>(_ti)); executed (the execution status of this line is deduced): QTextItemInt &ti = const_cast<QTextItemInt &>(static_cast<const QTextItemInt &>(_ti)); | - |
6361 | | - |
6362 | if (!extended && state->bgMode == Qt::OpaqueMode) { partially evaluated: !extended no Evaluation Count:0 | yes Evaluation Count:23019 |
never evaluated: state->bgMode == Qt::OpaqueMode | 0-23019 |
6363 | QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); never executed (the execution status of this line is deduced): QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); | - |
6364 | q->fillRect(rect, state->bgBrush); never executed (the execution status of this line is deduced): q->fillRect(rect, state->bgBrush); | - |
6365 | } | 0 |
6366 | | - |
6367 | if (q->pen().style() == Qt::NoPen) partially evaluated: q->pen().style() == Qt::NoPen no Evaluation Count:0 | yes Evaluation Count:23019 |
| 0-23019 |
6368 | return; | 0 |
6369 | | - |
6370 | const QPainter::RenderHints oldRenderHints = state->renderHints; executed (the execution status of this line is deduced): const QPainter::RenderHints oldRenderHints = state->renderHints; | - |
6371 | if (!state->renderHints & QPainter::Antialiasing && state->matrix.type() >= QTransform::TxScale) { partially evaluated: !state->renderHints & QPainter::Antialiasing no Evaluation Count:0 | yes Evaluation Count:23019 |
never evaluated: state->matrix.type() >= QTransform::TxScale | 0-23019 |
6372 | // draw antialias decoration (underline/overline/strikeout) with | - |
6373 | // transformed text | - |
6374 | | - |
6375 | bool aa = true; never executed (the execution status of this line is deduced): bool aa = true; | - |
6376 | const QTransform &m = state->matrix; never executed (the execution status of this line is deduced): const QTransform &m = state->matrix; | - |
6377 | if (state->matrix.type() < QTransform::TxShear) { never evaluated: state->matrix.type() < QTransform::TxShear | 0 |
6378 | bool isPlain90DegreeRotation = never executed (the execution status of this line is deduced): bool isPlain90DegreeRotation = | - |
6379 | (qFuzzyIsNull(m.m11()) never evaluated: qFuzzyIsNull(m.m11()) | 0 |
6380 | && qFuzzyIsNull(m.m12() - qreal(1)) never evaluated: qFuzzyIsNull(m.m12() - qreal(1)) | 0 |
6381 | && qFuzzyIsNull(m.m21() + qreal(1)) never evaluated: qFuzzyIsNull(m.m21() + qreal(1)) | 0 |
6382 | && qFuzzyIsNull(m.m22()) never evaluated: qFuzzyIsNull(m.m22()) | 0 |
6383 | ) never executed (the execution status of this line is deduced): ) | - |
6384 | || never executed (the execution status of this line is deduced): || | - |
6385 | (qFuzzyIsNull(m.m11() + qreal(1)) never evaluated: qFuzzyIsNull(m.m11() + qreal(1)) | 0 |
6386 | && qFuzzyIsNull(m.m12()) never evaluated: qFuzzyIsNull(m.m12()) | 0 |
6387 | && qFuzzyIsNull(m.m21()) never evaluated: qFuzzyIsNull(m.m21()) | 0 |
6388 | && qFuzzyIsNull(m.m22() + qreal(1)) never evaluated: qFuzzyIsNull(m.m22() + qreal(1)) | 0 |
6389 | ) never executed (the execution status of this line is deduced): ) | - |
6390 | || never executed (the execution status of this line is deduced): || | - |
6391 | (qFuzzyIsNull(m.m11()) never evaluated: qFuzzyIsNull(m.m11()) | 0 |
6392 | && qFuzzyIsNull(m.m12() + qreal(1)) never evaluated: qFuzzyIsNull(m.m12() + qreal(1)) | 0 |
6393 | && qFuzzyIsNull(m.m21() - qreal(1)) never evaluated: qFuzzyIsNull(m.m21() - qreal(1)) | 0 |
6394 | && qFuzzyIsNull(m.m22()) never evaluated: qFuzzyIsNull(m.m22()) | 0 |
6395 | ) never executed (the execution status of this line is deduced): ) | - |
6396 | ; never executed (the execution status of this line is deduced): ; | - |
6397 | aa = !isPlain90DegreeRotation; never executed (the execution status of this line is deduced): aa = !isPlain90DegreeRotation; | - |
6398 | } | 0 |
6399 | if (aa) | 0 |
6400 | q->setRenderHint(QPainter::Antialiasing, true); never executed: q->setRenderHint(QPainter::Antialiasing, true); | 0 |
6401 | } | 0 |
6402 | | - |
6403 | if (!extended) partially evaluated: !extended no Evaluation Count:0 | yes Evaluation Count:23019 |
| 0-23019 |
6404 | updateState(state); never executed: updateState(state); | 0 |
6405 | | - |
6406 | if (!ti.glyphs.numGlyphs) { evaluated: !ti.glyphs.numGlyphs yes Evaluation Count:2 | yes Evaluation Count:23017 |
| 2-23017 |
6407 | // nothing to do | - |
6408 | } else if (ti.fontEngine->type() == QFontEngine::Multi) { executed: } Execution Count:2 evaluated: ti.fontEngine->type() == QFontEngine::Multi yes Evaluation Count:23009 | yes Evaluation Count:8 |
| 2-23009 |
6409 | QFontEngineMulti *multi = static_cast<QFontEngineMulti *>(ti.fontEngine); executed (the execution status of this line is deduced): QFontEngineMulti *multi = static_cast<QFontEngineMulti *>(ti.fontEngine); | - |
6410 | | - |
6411 | const QGlyphLayout &glyphs = ti.glyphs; executed (the execution status of this line is deduced): const QGlyphLayout &glyphs = ti.glyphs; | - |
6412 | int which = glyphs.glyphs[0] >> 24; executed (the execution status of this line is deduced): int which = glyphs.glyphs[0] >> 24; | - |
6413 | | - |
6414 | qreal x = p.x(); executed (the execution status of this line is deduced): qreal x = p.x(); | - |
6415 | qreal y = p.y(); executed (the execution status of this line is deduced): qreal y = p.y(); | - |
6416 | | - |
6417 | bool rtl = ti.flags & QTextItem::RightToLeft; executed (the execution status of this line is deduced): bool rtl = ti.flags & QTextItem::RightToLeft; | - |
6418 | if (rtl) evaluated: rtl yes Evaluation Count:13 | yes Evaluation Count:22996 |
| 13-22996 |
6419 | x += ti.width.toReal(); executed: x += ti.width.toReal(); Execution Count:13 | 13 |
6420 | | - |
6421 | int start = 0; executed (the execution status of this line is deduced): int start = 0; | - |
6422 | int end, i; executed (the execution status of this line is deduced): int end, i; | - |
6423 | for (end = 0; end < ti.glyphs.numGlyphs; ++end) { evaluated: end < ti.glyphs.numGlyphs yes Evaluation Count:145541 | yes Evaluation Count:23009 |
| 23009-145541 |
6424 | const int e = glyphs.glyphs[end] >> 24; executed (the execution status of this line is deduced): const int e = glyphs.glyphs[end] >> 24; | - |
6425 | if (e == which) partially evaluated: e == which yes Evaluation Count:145541 | no Evaluation Count:0 |
| 0-145541 |
6426 | continue; executed: continue; Execution Count:145541 | 145541 |
6427 | | - |
6428 | | - |
6429 | QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); never executed (the execution status of this line is deduced): QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); | - |
6430 | ti2.width = 0; never executed (the execution status of this line is deduced): ti2.width = 0; | - |
6431 | // set the high byte to zero and calc the width | - |
6432 | for (i = start; i < end; ++i) { | 0 |
6433 | glyphs.glyphs[i] = glyphs.glyphs[i] & 0xffffff; never executed (the execution status of this line is deduced): glyphs.glyphs[i] = glyphs.glyphs[i] & 0xffffff; | - |
6434 | ti2.width += ti.glyphs.effectiveAdvance(i); never executed (the execution status of this line is deduced): ti2.width += ti.glyphs.effectiveAdvance(i); | - |
6435 | } | 0 |
6436 | | - |
6437 | if (rtl) | 0 |
6438 | x -= ti2.width.toReal(); never executed: x -= ti2.width.toReal(); | 0 |
6439 | | - |
6440 | engine->drawTextItem(QPointF(x, y), ti2); never executed (the execution status of this line is deduced): engine->drawTextItem(QPointF(x, y), ti2); | - |
6441 | | - |
6442 | if (!rtl) | 0 |
6443 | x += ti2.width.toReal(); never executed: x += ti2.width.toReal(); | 0 |
6444 | | - |
6445 | // reset the high byte for all glyphs and advance to the next sub-string | - |
6446 | const int hi = which << 24; never executed (the execution status of this line is deduced): const int hi = which << 24; | - |
6447 | for (i = start; i < end; ++i) { | 0 |
6448 | glyphs.glyphs[i] = hi | glyphs.glyphs[i]; never executed (the execution status of this line is deduced): glyphs.glyphs[i] = hi | glyphs.glyphs[i]; | - |
6449 | } | 0 |
6450 | | - |
6451 | // change engine | - |
6452 | start = end; never executed (the execution status of this line is deduced): start = end; | - |
6453 | which = e; never executed (the execution status of this line is deduced): which = e; | - |
6454 | } | 0 |
6455 | | - |
6456 | QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); executed (the execution status of this line is deduced): QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); | - |
6457 | ti2.width = 0; executed (the execution status of this line is deduced): ti2.width = 0; | - |
6458 | // set the high byte to zero and calc the width | - |
6459 | for (i = start; i < end; ++i) { evaluated: i < end yes Evaluation Count:145541 | yes Evaluation Count:23009 |
| 23009-145541 |
6460 | glyphs.glyphs[i] = glyphs.glyphs[i] & 0xffffff; executed (the execution status of this line is deduced): glyphs.glyphs[i] = glyphs.glyphs[i] & 0xffffff; | - |
6461 | ti2.width += ti.glyphs.effectiveAdvance(i); executed (the execution status of this line is deduced): ti2.width += ti.glyphs.effectiveAdvance(i); | - |
6462 | } executed: } Execution Count:145541 | 145541 |
6463 | | - |
6464 | if (rtl) evaluated: rtl yes Evaluation Count:13 | yes Evaluation Count:22996 |
| 13-22996 |
6465 | x -= ti2.width.toReal(); executed: x -= ti2.width.toReal(); Execution Count:13 | 13 |
6466 | | - |
6467 | if (extended) partially evaluated: extended yes Evaluation Count:23009 | no Evaluation Count:0 |
| 0-23009 |
6468 | extended->drawTextItem(QPointF(x, y), ti2); executed: extended->drawTextItem(QPointF(x, y), ti2); Execution Count:23009 | 23009 |
6469 | else | - |
6470 | engine->drawTextItem(QPointF(x,y), ti2); never executed: engine->drawTextItem(QPointF(x,y), ti2); | 0 |
6471 | | - |
6472 | // reset the high byte for all glyphs | - |
6473 | const int hi = which << 24; executed (the execution status of this line is deduced): const int hi = which << 24; | - |
6474 | for (i = start; i < end; ++i) evaluated: i < end yes Evaluation Count:145541 | yes Evaluation Count:23009 |
| 23009-145541 |
6475 | glyphs.glyphs[i] = hi | glyphs.glyphs[i]; executed: glyphs.glyphs[i] = hi | glyphs.glyphs[i]; Execution Count:145541 | 145541 |
6476 | | - |
6477 | } else { executed: } Execution Count:23009 | 23009 |
6478 | if (extended) partially evaluated: extended yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
6479 | extended->drawTextItem(p, ti); executed: extended->drawTextItem(p, ti); Execution Count:8 | 8 |
6480 | else | - |
6481 | engine->drawTextItem(p, ti); never executed: engine->drawTextItem(p, ti); | 0 |
6482 | } | - |
6483 | drawTextItemDecoration(q, p, ti.fontEngine, textEngine, ti.underlineStyle, executed (the execution status of this line is deduced): drawTextItemDecoration(q, p, ti.fontEngine, textEngine, ti.underlineStyle, | - |
6484 | ti.flags, ti.width.toReal(), ti.charFormat); executed (the execution status of this line is deduced): ti.flags, ti.width.toReal(), ti.charFormat); | - |
6485 | | - |
6486 | if (state->renderHints != oldRenderHints) { partially evaluated: state->renderHints != oldRenderHints no Evaluation Count:0 | yes Evaluation Count:23019 |
| 0-23019 |
6487 | state->renderHints = oldRenderHints; never executed (the execution status of this line is deduced): state->renderHints = oldRenderHints; | - |
6488 | if (extended) never evaluated: extended | 0 |
6489 | extended->renderHintsChanged(); never executed: extended->renderHintsChanged(); | 0 |
6490 | else | - |
6491 | state->dirtyFlags |= QPaintEngine::DirtyHints; never executed: state->dirtyFlags |= QPaintEngine::DirtyHints; | 0 |
6492 | } | - |
6493 | } executed: } Execution Count:23019 | 23019 |
6494 | | - |
6495 | /*! | - |
6496 | \fn QRectF QPainter::boundingRect(const QRectF &rectangle, int flags, const QString &text) | - |
6497 | | - |
6498 | Returns the bounding rectangle of the \a text as it will appear | - |
6499 | when drawn inside the given \a rectangle with the specified \a | - |
6500 | flags using the currently set font(); i.e the function tells you | - |
6501 | where the drawText() function will draw when given the same | - |
6502 | arguments. | - |
6503 | | - |
6504 | If the \a text does not fit within the given \a rectangle using | - |
6505 | the specified \a flags, the function returns the required | - |
6506 | rectangle. | - |
6507 | | - |
6508 | The \a flags argument is a bitwise OR of the following flags: | - |
6509 | \list | - |
6510 | \li Qt::AlignLeft | - |
6511 | \li Qt::AlignRight | - |
6512 | \li Qt::AlignHCenter | - |
6513 | \li Qt::AlignTop | - |
6514 | \li Qt::AlignBottom | - |
6515 | \li Qt::AlignVCenter | - |
6516 | \li Qt::AlignCenter | - |
6517 | \li Qt::TextSingleLine | - |
6518 | \li Qt::TextExpandTabs | - |
6519 | \li Qt::TextShowMnemonic | - |
6520 | \li Qt::TextWordWrap | - |
6521 | \li Qt::TextIncludeTrailingSpaces | - |
6522 | \endlist | - |
6523 | If several of the horizontal or several of the vertical alignment | - |
6524 | flags are set, the resulting alignment is undefined. | - |
6525 | | - |
6526 | \sa drawText(), Qt::Alignment, Qt::TextFlag | - |
6527 | */ | - |
6528 | | - |
6529 | /*! | - |
6530 | \fn QRect QPainter::boundingRect(const QRect &rectangle, int flags, | - |
6531 | const QString &text) | - |
6532 | | - |
6533 | \overload | - |
6534 | | - |
6535 | Returns the bounding rectangle of the \a text as it will appear | - |
6536 | when drawn inside the given \a rectangle with the specified \a | - |
6537 | flags using the currently set font(). | - |
6538 | */ | - |
6539 | | - |
6540 | /*! | - |
6541 | \fn QRect QPainter::boundingRect(int x, int y, int w, int h, int flags, | - |
6542 | const QString &text); | - |
6543 | | - |
6544 | \overload | - |
6545 | | - |
6546 | Returns the bounding rectangle of the given \a text as it will | - |
6547 | appear when drawn inside the rectangle beginning at the point | - |
6548 | (\a{x}, \a{y}) with width \a w and height \a h. | - |
6549 | */ | - |
6550 | QRect QPainter::boundingRect(const QRect &rect, int flags, const QString &str) | - |
6551 | { | - |
6552 | if (str.isEmpty()) partially evaluated: str.isEmpty() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
6553 | return QRect(rect.x(),rect.y(), 0,0); never executed: return QRect(rect.x(),rect.y(), 0,0); | 0 |
6554 | QRect brect; executed (the execution status of this line is deduced): QRect brect; | - |
6555 | drawText(rect, flags | Qt::TextDontPrint, str, &brect); executed (the execution status of this line is deduced): drawText(rect, flags | Qt::TextDontPrint, str, &brect); | - |
6556 | return brect; executed: return brect; Execution Count:1 | 1 |
6557 | } | - |
6558 | | - |
6559 | | - |
6560 | | - |
6561 | QRectF QPainter::boundingRect(const QRectF &rect, int flags, const QString &str) | - |
6562 | { | - |
6563 | if (str.isEmpty()) partially evaluated: str.isEmpty() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
6564 | return QRectF(rect.x(),rect.y(), 0,0); never executed: return QRectF(rect.x(),rect.y(), 0,0); | 0 |
6565 | QRectF brect; executed (the execution status of this line is deduced): QRectF brect; | - |
6566 | drawText(rect, flags | Qt::TextDontPrint, str, &brect); executed (the execution status of this line is deduced): drawText(rect, flags | Qt::TextDontPrint, str, &brect); | - |
6567 | return brect; executed: return brect; Execution Count:1 | 1 |
6568 | } | - |
6569 | | - |
6570 | /*! | - |
6571 | \fn QRectF QPainter::boundingRect(const QRectF &rectangle, | - |
6572 | const QString &text, const QTextOption &option) | - |
6573 | | - |
6574 | \overload | - |
6575 | | - |
6576 | Instead of specifying flags as a bitwise OR of the | - |
6577 | Qt::AlignmentFlag and Qt::TextFlag, this overloaded function takes | - |
6578 | an \a option argument. The QTextOption class provides a | - |
6579 | description of general rich text properties. | - |
6580 | | - |
6581 | \sa QTextOption | - |
6582 | */ | - |
6583 | QRectF QPainter::boundingRect(const QRectF &r, const QString &text, const QTextOption &o) | - |
6584 | { | - |
6585 | Q_D(QPainter); never executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6586 | | - |
6587 | if (!d->engine || text.length() == 0) never evaluated: !d->engine never evaluated: text.length() == 0 | 0 |
6588 | return QRectF(r.x(),r.y(), 0,0); never executed: return QRectF(r.x(),r.y(), 0,0); | 0 |
6589 | | - |
6590 | QRectF br; never executed (the execution status of this line is deduced): QRectF br; | - |
6591 | qt_format_text(d->state->font, r, Qt::TextDontPrint, &o, text, &br, 0, 0, 0, this); never executed (the execution status of this line is deduced): qt_format_text(d->state->font, r, Qt::TextDontPrint, &o, text, &br, 0, 0, 0, this); | - |
6592 | return br; never executed: return br; | 0 |
6593 | } | - |
6594 | | - |
6595 | /*! | - |
6596 | \fn void QPainter::drawTiledPixmap(const QRectF &rectangle, const QPixmap &pixmap, const QPointF &position) | - |
6597 | | - |
6598 | Draws a tiled \a pixmap, inside the given \a rectangle with its | - |
6599 | origin at the given \a position. | - |
6600 | | - |
6601 | Calling drawTiledPixmap() is similar to calling drawPixmap() | - |
6602 | several times to fill (tile) an area with a pixmap, but is | - |
6603 | potentially much more efficient depending on the underlying window | - |
6604 | system. | - |
6605 | | - |
6606 | \sa drawPixmap() | - |
6607 | */ | - |
6608 | void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &sp) | - |
6609 | { | - |
6610 | #ifdef QT_DEBUG_DRAW | - |
6611 | if (qt_show_painter_debug_output) | - |
6612 | printf("QPainter::drawTiledPixmap(), target=[%.2f,%.2f,%.2f,%.2f], pix=[%d,%d], offset=[%.2f,%.2f]\n", | - |
6613 | r.x(), r.y(), r.width(), r.height(), | - |
6614 | pixmap.width(), pixmap.height(), | - |
6615 | sp.x(), sp.y()); | - |
6616 | #endif | - |
6617 | | - |
6618 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6619 | if (!d->engine || pixmap.isNull() || r.isEmpty()) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:9 |
partially evaluated: pixmap.isNull() no Evaluation Count:0 | yes Evaluation Count:9 |
partially evaluated: r.isEmpty() no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
6620 | return; | 0 |
6621 | | - |
6622 | #ifndef QT_NO_DEBUG | - |
6623 | qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()", true); | - |
6624 | #endif | - |
6625 | | - |
6626 | qreal sw = pixmap.width(); executed (the execution status of this line is deduced): qreal sw = pixmap.width(); | - |
6627 | qreal sh = pixmap.height(); executed (the execution status of this line is deduced): qreal sh = pixmap.height(); | - |
6628 | qreal sx = sp.x(); executed (the execution status of this line is deduced): qreal sx = sp.x(); | - |
6629 | qreal sy = sp.y(); executed (the execution status of this line is deduced): qreal sy = sp.y(); | - |
6630 | if (sx < 0) partially evaluated: sx < 0 no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
6631 | sx = qRound(sw) - qRound(-sx) % qRound(sw); never executed: sx = qRound(sw) - qRound(-sx) % qRound(sw); | 0 |
6632 | else | - |
6633 | sx = qRound(sx) % qRound(sw); executed: sx = qRound(sx) % qRound(sw); Execution Count:9 | 9 |
6634 | if (sy < 0) partially evaluated: sy < 0 no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
6635 | sy = qRound(sh) - -qRound(sy) % qRound(sh); never executed: sy = qRound(sh) - -qRound(sy) % qRound(sh); | 0 |
6636 | else | - |
6637 | sy = qRound(sy) % qRound(sh); executed: sy = qRound(sy) % qRound(sh); Execution Count:9 | 9 |
6638 | | - |
6639 | | - |
6640 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
6641 | d->extended->drawTiledPixmap(r, pixmap, QPointF(sx, sy)); executed (the execution status of this line is deduced): d->extended->drawTiledPixmap(r, pixmap, QPointF(sx, sy)); | - |
6642 | return; executed: return; Execution Count:9 | 9 |
6643 | } | - |
6644 | | - |
6645 | if (d->state->bgMode == Qt::OpaqueMode && pixmap.isQBitmap()) never evaluated: d->state->bgMode == Qt::OpaqueMode never evaluated: pixmap.isQBitmap() | 0 |
6646 | fillRect(r, d->state->bgBrush); never executed: fillRect(r, d->state->bgBrush); | 0 |
6647 | | - |
6648 | d->updateState(d->state); never executed (the execution status of this line is deduced): d->updateState(d->state); | - |
6649 | if ((d->state->matrix.type() > QTransform::TxTranslate never evaluated: d->state->matrix.type() > QTransform::TxTranslate | 0 |
6650 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
6651 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) never evaluated: d->state->opacity != 1.0 never evaluated: !d->engine->hasFeature(QPaintEngine::ConstantOpacity) | 0 |
6652 | { | - |
6653 | save(); never executed (the execution status of this line is deduced): save(); | - |
6654 | setBackgroundMode(Qt::TransparentMode); never executed (the execution status of this line is deduced): setBackgroundMode(Qt::TransparentMode); | - |
6655 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); never executed (the execution status of this line is deduced): setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
6656 | setBrush(QBrush(d->state->pen.color(), pixmap)); never executed (the execution status of this line is deduced): setBrush(QBrush(d->state->pen.color(), pixmap)); | - |
6657 | setPen(Qt::NoPen); never executed (the execution status of this line is deduced): setPen(Qt::NoPen); | - |
6658 | | - |
6659 | // If there is no rotation involved we have to make sure we use the | - |
6660 | // antialiased and not the aliased coordinate system by rounding the coordinates. | - |
6661 | if (d->state->matrix.type() <= QTransform::TxScale) { never evaluated: d->state->matrix.type() <= QTransform::TxScale | 0 |
6662 | const QPointF p = roundInDeviceCoordinates(r.topLeft(), d->state->matrix); never executed (the execution status of this line is deduced): const QPointF p = roundInDeviceCoordinates(r.topLeft(), d->state->matrix); | - |
6663 | | - |
6664 | if (d->state->matrix.type() <= QTransform::TxTranslate) { never evaluated: d->state->matrix.type() <= QTransform::TxTranslate | 0 |
6665 | sx = qRound(sx); never executed (the execution status of this line is deduced): sx = qRound(sx); | - |
6666 | sy = qRound(sy); never executed (the execution status of this line is deduced): sy = qRound(sy); | - |
6667 | } | 0 |
6668 | | - |
6669 | setBrushOrigin(QPointF(r.x()-sx, r.y()-sy)); never executed (the execution status of this line is deduced): setBrushOrigin(QPointF(r.x()-sx, r.y()-sy)); | - |
6670 | drawRect(QRectF(p, r.size())); never executed (the execution status of this line is deduced): drawRect(QRectF(p, r.size())); | - |
6671 | } else { | 0 |
6672 | setBrushOrigin(QPointF(r.x()-sx, r.y()-sy)); never executed (the execution status of this line is deduced): setBrushOrigin(QPointF(r.x()-sx, r.y()-sy)); | - |
6673 | drawRect(r); never executed (the execution status of this line is deduced): drawRect(r); | - |
6674 | } | 0 |
6675 | restore(); never executed (the execution status of this line is deduced): restore(); | - |
6676 | return; | 0 |
6677 | } | - |
6678 | | - |
6679 | qreal x = r.x(); never executed (the execution status of this line is deduced): qreal x = r.x(); | - |
6680 | qreal y = r.y(); never executed (the execution status of this line is deduced): qreal y = r.y(); | - |
6681 | if (d->state->matrix.type() == QTransform::TxTranslate never evaluated: d->state->matrix.type() == QTransform::TxTranslate | 0 |
6682 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) { never evaluated: !d->engine->hasFeature(QPaintEngine::PixmapTransform) | 0 |
6683 | x += d->state->matrix.dx(); never executed (the execution status of this line is deduced): x += d->state->matrix.dx(); | - |
6684 | y += d->state->matrix.dy(); never executed (the execution status of this line is deduced): y += d->state->matrix.dy(); | - |
6685 | } | 0 |
6686 | | - |
6687 | d->engine->drawTiledPixmap(QRectF(x, y, r.width(), r.height()), pixmap, QPointF(sx, sy)); never executed (the execution status of this line is deduced): d->engine->drawTiledPixmap(QRectF(x, y, r.width(), r.height()), pixmap, QPointF(sx, sy)); | - |
6688 | } | 0 |
6689 | | - |
6690 | /*! | - |
6691 | \fn QPainter::drawTiledPixmap(const QRect &rectangle, const QPixmap &pixmap, | - |
6692 | const QPoint &position = QPoint()) | - |
6693 | \overload | - |
6694 | | - |
6695 | Draws a tiled \a pixmap, inside the given \a rectangle with its | - |
6696 | origin at the given \a position. | - |
6697 | */ | - |
6698 | | - |
6699 | /*! | - |
6700 | \fn void QPainter::drawTiledPixmap(int x, int y, int width, int height, const | - |
6701 | QPixmap &pixmap, int sx, int sy); | - |
6702 | \overload | - |
6703 | | - |
6704 | Draws a tiled \a pixmap in the specified rectangle. | - |
6705 | | - |
6706 | (\a{x}, \a{y}) specifies the top-left point in the paint device | - |
6707 | that is to be drawn onto; with the given \a width and \a | - |
6708 | height. (\a{sx}, \a{sy}) specifies the top-left point in the \a | - |
6709 | pixmap that is to be drawn; this defaults to (0, 0). | - |
6710 | */ | - |
6711 | | - |
6712 | #ifndef QT_NO_PICTURE | - |
6713 | | - |
6714 | /*! | - |
6715 | \fn void QPainter::drawPicture(const QPointF &point, const QPicture &picture) | - |
6716 | | - |
6717 | Replays the given \a picture at the given \a point. | - |
6718 | | - |
6719 | The QPicture class is a paint device that records and replays | - |
6720 | QPainter commands. A picture serializes the painter commands to an | - |
6721 | IO device in a platform-independent format. Everything that can be | - |
6722 | painted on a widget or pixmap can also be stored in a picture. | - |
6723 | | - |
6724 | This function does exactly the same as QPicture::play() when | - |
6725 | called with \a point = QPoint(0, 0). | - |
6726 | | - |
6727 | \table 100% | - |
6728 | \row | - |
6729 | \li | - |
6730 | \snippet code/src_gui_painting_qpainter.cpp 18 | - |
6731 | \endtable | - |
6732 | | - |
6733 | \sa QPicture::play() | - |
6734 | */ | - |
6735 | | - |
6736 | void QPainter::drawPicture(const QPointF &p, const QPicture &picture) | - |
6737 | { | - |
6738 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6739 | | - |
6740 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
6741 | return; | 0 |
6742 | | - |
6743 | if (!d->extended) partially evaluated: !d->extended no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
6744 | d->updateState(d->state); never executed: d->updateState(d->state); | 0 |
6745 | | - |
6746 | save(); executed (the execution status of this line is deduced): save(); | - |
6747 | translate(p); executed (the execution status of this line is deduced): translate(p); | - |
6748 | const_cast<QPicture *>(&picture)->play(this); executed (the execution status of this line is deduced): const_cast<QPicture *>(&picture)->play(this); | - |
6749 | restore(); executed (the execution status of this line is deduced): restore(); | - |
6750 | } executed: } Execution Count:1 | 1 |
6751 | | - |
6752 | /*! | - |
6753 | \fn void QPainter::drawPicture(const QPoint &point, const QPicture &picture) | - |
6754 | \overload | - |
6755 | | - |
6756 | Replays the given \a picture at the given \a point. | - |
6757 | */ | - |
6758 | | - |
6759 | /*! | - |
6760 | \fn void QPainter::drawPicture(int x, int y, const QPicture &picture) | - |
6761 | \overload | - |
6762 | | - |
6763 | Draws the given \a picture at point (\a x, \a y). | - |
6764 | */ | - |
6765 | | - |
6766 | #endif // QT_NO_PICTURE | - |
6767 | | - |
6768 | /*! | - |
6769 | \fn void QPainter::eraseRect(const QRectF &rectangle) | - |
6770 | | - |
6771 | Erases the area inside the given \a rectangle. Equivalent to | - |
6772 | calling | - |
6773 | \snippet code/src_gui_painting_qpainter.cpp 19 | - |
6774 | | - |
6775 | \sa fillRect() | - |
6776 | */ | - |
6777 | void QPainter::eraseRect(const QRectF &r) | - |
6778 | { | - |
6779 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6780 | | - |
6781 | fillRect(r, d->state->bgBrush); executed (the execution status of this line is deduced): fillRect(r, d->state->bgBrush); | - |
6782 | } executed: } Execution Count:55 | 55 |
6783 | | - |
6784 | static inline bool needsResolving(const QBrush &brush) | - |
6785 | { | - |
6786 | Qt::BrushStyle s = brush.style(); executed (the execution status of this line is deduced): Qt::BrushStyle s = brush.style(); | - |
6787 | return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern || executed: return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern || s == Qt::ConicalGradientPattern) && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode); Execution Count:20 | 20 |
6788 | s == Qt::ConicalGradientPattern) && executed: return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern || s == Qt::ConicalGradientPattern) && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode); Execution Count:20 | 20 |
6789 | brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode); executed: return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern || s == Qt::ConicalGradientPattern) && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode); Execution Count:20 | 20 |
6790 | } | - |
6791 | | - |
6792 | /*! | - |
6793 | \fn void QPainter::eraseRect(const QRect &rectangle) | - |
6794 | \overload | - |
6795 | | - |
6796 | Erases the area inside the given \a rectangle. | - |
6797 | */ | - |
6798 | | - |
6799 | /*! | - |
6800 | \fn void QPainter::eraseRect(int x, int y, int width, int height) | - |
6801 | \overload | - |
6802 | | - |
6803 | Erases the area inside the rectangle beginning at (\a x, \a y) | - |
6804 | with the given \a width and \a height. | - |
6805 | */ | - |
6806 | | - |
6807 | | - |
6808 | /*! | - |
6809 | \fn void QPainter::fillRect(int x, int y, int width, int height, Qt::BrushStyle style) | - |
6810 | \overload | - |
6811 | | - |
6812 | Fills the rectangle beginning at (\a{x}, \a{y}) with the given \a | - |
6813 | width and \a height, using the brush \a style specified. | - |
6814 | | - |
6815 | \since 4.5 | - |
6816 | */ | - |
6817 | | - |
6818 | /*! | - |
6819 | \fn void QPainter::fillRect(const QRect &rectangle, Qt::BrushStyle style) | - |
6820 | \overload | - |
6821 | | - |
6822 | Fills the given \a rectangle with the brush \a style specified. | - |
6823 | | - |
6824 | \since 4.5 | - |
6825 | */ | - |
6826 | | - |
6827 | /*! | - |
6828 | \fn void QPainter::fillRect(const QRectF &rectangle, Qt::BrushStyle style) | - |
6829 | \overload | - |
6830 | | - |
6831 | Fills the given \a rectangle with the brush \a style specified. | - |
6832 | | - |
6833 | \since 4.5 | - |
6834 | */ | - |
6835 | | - |
6836 | /*! | - |
6837 | \fn void QPainter::fillRect(const QRectF &rectangle, const QBrush &brush) | - |
6838 | | - |
6839 | Fills the given \a rectangle with the \a brush specified. | - |
6840 | | - |
6841 | Alternatively, you can specify a QColor instead of a QBrush; the | - |
6842 | QBrush constructor (taking a QColor argument) will automatically | - |
6843 | create a solid pattern brush. | - |
6844 | | - |
6845 | \sa drawRect() | - |
6846 | */ | - |
6847 | void QPainter::fillRect(const QRectF &r, const QBrush &brush) | - |
6848 | { | - |
6849 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6850 | | - |
6851 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:961 |
| 0-961 |
6852 | return; | 0 |
6853 | | - |
6854 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:961 | no Evaluation Count:0 |
| 0-961 |
6855 | const QGradient *g = brush.gradient(); executed (the execution status of this line is deduced): const QGradient *g = brush.gradient(); | - |
6856 | if (!g || g->coordinateMode() == QGradient::LogicalMode) { evaluated: !g yes Evaluation Count:459 | yes Evaluation Count:502 |
partially evaluated: g->coordinateMode() == QGradient::LogicalMode yes Evaluation Count:502 | no Evaluation Count:0 |
| 0-502 |
6857 | d->extended->fillRect(r, brush); executed (the execution status of this line is deduced): d->extended->fillRect(r, brush); | - |
6858 | return; executed: return; Execution Count:961 | 961 |
6859 | } | - |
6860 | } | 0 |
6861 | | - |
6862 | QPen oldPen = pen(); never executed (the execution status of this line is deduced): QPen oldPen = pen(); | - |
6863 | QBrush oldBrush = this->brush(); never executed (the execution status of this line is deduced): QBrush oldBrush = this->brush(); | - |
6864 | setPen(Qt::NoPen); never executed (the execution status of this line is deduced): setPen(Qt::NoPen); | - |
6865 | if (brush.style() == Qt::SolidPattern) { never evaluated: brush.style() == Qt::SolidPattern | 0 |
6866 | d->colorBrush.setStyle(Qt::SolidPattern); never executed (the execution status of this line is deduced): d->colorBrush.setStyle(Qt::SolidPattern); | - |
6867 | d->colorBrush.setColor(brush.color()); never executed (the execution status of this line is deduced): d->colorBrush.setColor(brush.color()); | - |
6868 | setBrush(d->colorBrush); never executed (the execution status of this line is deduced): setBrush(d->colorBrush); | - |
6869 | } else { | 0 |
6870 | setBrush(brush); never executed (the execution status of this line is deduced): setBrush(brush); | - |
6871 | } | 0 |
6872 | | - |
6873 | drawRect(r); never executed (the execution status of this line is deduced): drawRect(r); | - |
6874 | setBrush(oldBrush); never executed (the execution status of this line is deduced): setBrush(oldBrush); | - |
6875 | setPen(oldPen); never executed (the execution status of this line is deduced): setPen(oldPen); | - |
6876 | } | 0 |
6877 | | - |
6878 | /*! | - |
6879 | \fn void QPainter::fillRect(const QRect &rectangle, const QBrush &brush) | - |
6880 | \overload | - |
6881 | | - |
6882 | Fills the given \a rectangle with the specified \a brush. | - |
6883 | */ | - |
6884 | | - |
6885 | void QPainter::fillRect(const QRect &r, const QBrush &brush) | - |
6886 | { | - |
6887 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6888 | | - |
6889 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:58657 |
| 0-58657 |
6890 | return; | 0 |
6891 | | - |
6892 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:58658 | no Evaluation Count:0 |
| 0-58658 |
6893 | const QGradient *g = brush.gradient(); executed (the execution status of this line is deduced): const QGradient *g = brush.gradient(); | - |
6894 | if (!g || g->coordinateMode() == QGradient::LogicalMode) { evaluated: !g yes Evaluation Count:42471 | yes Evaluation Count:16187 |
evaluated: g->coordinateMode() == QGradient::LogicalMode yes Evaluation Count:16186 | yes Evaluation Count:2 |
| 2-42471 |
6895 | d->extended->fillRect(r, brush); executed (the execution status of this line is deduced): d->extended->fillRect(r, brush); | - |
6896 | return; executed: return; Execution Count:58642 | 58642 |
6897 | } | - |
6898 | } executed: } Execution Count:2 | 2 |
6899 | | - |
6900 | QPen oldPen = pen(); executed (the execution status of this line is deduced): QPen oldPen = pen(); | - |
6901 | QBrush oldBrush = this->brush(); executed (the execution status of this line is deduced): QBrush oldBrush = this->brush(); | - |
6902 | setPen(Qt::NoPen); executed (the execution status of this line is deduced): setPen(Qt::NoPen); | - |
6903 | if (brush.style() == Qt::SolidPattern) { partially evaluated: brush.style() == Qt::SolidPattern no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
6904 | d->colorBrush.setStyle(Qt::SolidPattern); never executed (the execution status of this line is deduced): d->colorBrush.setStyle(Qt::SolidPattern); | - |
6905 | d->colorBrush.setColor(brush.color()); never executed (the execution status of this line is deduced): d->colorBrush.setColor(brush.color()); | - |
6906 | setBrush(d->colorBrush); never executed (the execution status of this line is deduced): setBrush(d->colorBrush); | - |
6907 | } else { | 0 |
6908 | setBrush(brush); executed (the execution status of this line is deduced): setBrush(brush); | - |
6909 | } executed: } Execution Count:2 | 2 |
6910 | | - |
6911 | drawRect(r); executed (the execution status of this line is deduced): drawRect(r); | - |
6912 | setBrush(oldBrush); executed (the execution status of this line is deduced): setBrush(oldBrush); | - |
6913 | setPen(oldPen); executed (the execution status of this line is deduced): setPen(oldPen); | - |
6914 | } executed: } Execution Count:2 | 2 |
6915 | | - |
6916 | | - |
6917 | | - |
6918 | /*! | - |
6919 | \fn void QPainter::fillRect(const QRect &rectangle, const QColor &color) | - |
6920 | \overload | - |
6921 | | - |
6922 | Fills the given \a rectangle with the \a color specified. | - |
6923 | | - |
6924 | \since 4.5 | - |
6925 | */ | - |
6926 | void QPainter::fillRect(const QRect &r, const QColor &color) | - |
6927 | { | - |
6928 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6929 | | - |
6930 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:2934 |
| 0-2934 |
6931 | return; | 0 |
6932 | | - |
6933 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:2934 | no Evaluation Count:0 |
| 0-2934 |
6934 | d->extended->fillRect(r, color); executed (the execution status of this line is deduced): d->extended->fillRect(r, color); | - |
6935 | return; executed: return; Execution Count:2934 | 2934 |
6936 | } | - |
6937 | | - |
6938 | fillRect(r, QBrush(color)); never executed (the execution status of this line is deduced): fillRect(r, QBrush(color)); | - |
6939 | } | 0 |
6940 | | - |
6941 | | - |
6942 | /*! | - |
6943 | \fn void QPainter::fillRect(const QRectF &rectangle, const QColor &color) | - |
6944 | \overload | - |
6945 | | - |
6946 | Fills the given \a rectangle with the \a color specified. | - |
6947 | | - |
6948 | \since 4.5 | - |
6949 | */ | - |
6950 | void QPainter::fillRect(const QRectF &r, const QColor &color) | - |
6951 | { | - |
6952 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
6953 | | - |
6954 | if (!d->engine) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:89 |
| 0-89 |
6955 | return; | 0 |
6956 | | - |
6957 | if (d->extended) { partially evaluated: d->extended yes Evaluation Count:89 | no Evaluation Count:0 |
| 0-89 |
6958 | d->extended->fillRect(r, color); executed (the execution status of this line is deduced): d->extended->fillRect(r, color); | - |
6959 | return; executed: return; Execution Count:89 | 89 |
6960 | } | - |
6961 | | - |
6962 | fillRect(r, QBrush(color)); never executed (the execution status of this line is deduced): fillRect(r, QBrush(color)); | - |
6963 | } | 0 |
6964 | | - |
6965 | /*! | - |
6966 | \fn void QPainter::fillRect(int x, int y, int width, int height, const QBrush &brush) | - |
6967 | | - |
6968 | \overload | - |
6969 | | - |
6970 | Fills the rectangle beginning at (\a{x}, \a{y}) with the given \a | - |
6971 | width and \a height, using the given \a brush. | - |
6972 | */ | - |
6973 | | - |
6974 | /*! | - |
6975 | \fn void QPainter::fillRect(int x, int y, int width, int height, const QColor &color) | - |
6976 | | - |
6977 | \overload | - |
6978 | | - |
6979 | Fills the rectangle beginning at (\a{x}, \a{y}) with the given \a | - |
6980 | width and \a height, using the given \a color. | - |
6981 | | - |
6982 | \since 4.5 | - |
6983 | */ | - |
6984 | | - |
6985 | /*! | - |
6986 | \fn void QPainter::fillRect(int x, int y, int width, int height, Qt::GlobalColor color) | - |
6987 | | - |
6988 | \overload | - |
6989 | | - |
6990 | Fills the rectangle beginning at (\a{x}, \a{y}) with the given \a | - |
6991 | width and \a height, using the given \a color. | - |
6992 | | - |
6993 | \since 4.5 | - |
6994 | */ | - |
6995 | | - |
6996 | /*! | - |
6997 | \fn void QPainter::fillRect(const QRect &rectangle, Qt::GlobalColor color); | - |
6998 | | - |
6999 | \overload | - |
7000 | | - |
7001 | Fills the given \a rectangle with the specified \a color. | - |
7002 | | - |
7003 | \since 4.5 | - |
7004 | */ | - |
7005 | | - |
7006 | /*! | - |
7007 | \fn void QPainter::fillRect(const QRectF &rectangle, Qt::GlobalColor color); | - |
7008 | | - |
7009 | \overload | - |
7010 | | - |
7011 | Fills the given \a rectangle with the specified \a color. | - |
7012 | | - |
7013 | \since 4.5 | - |
7014 | */ | - |
7015 | | - |
7016 | /*! | - |
7017 | Sets the given render \a hint on the painter if \a on is true; | - |
7018 | otherwise clears the render hint. | - |
7019 | | - |
7020 | \sa setRenderHints(), renderHints(), {QPainter#Rendering | - |
7021 | Quality}{Rendering Quality} | - |
7022 | */ | - |
7023 | void QPainter::setRenderHint(RenderHint hint, bool on) | - |
7024 | { | - |
7025 | #ifdef QT_DEBUG_DRAW | - |
7026 | if (qt_show_painter_debug_output) | - |
7027 | printf("QPainter::setRenderHint: hint=%x, %s\n", hint, on ? "on" : "off"); | - |
7028 | #endif | - |
7029 | | - |
7030 | #ifndef QT_NO_DEBUG | - |
7031 | static const bool antialiasingDisabled = qgetenv("QT_NO_ANTIALIASING").toInt(); | - |
7032 | if (hint == QPainter::Antialiasing && antialiasingDisabled) | - |
7033 | return; | - |
7034 | #endif | - |
7035 | | - |
7036 | setRenderHints(hint, on); executed (the execution status of this line is deduced): setRenderHints(hint, on); | - |
7037 | } executed: } Execution Count:1354 | 1354 |
7038 | | - |
7039 | /*! | - |
7040 | \since 4.2 | - |
7041 | | - |
7042 | Sets the given render \a hints on the painter if \a on is true; | - |
7043 | otherwise clears the render hints. | - |
7044 | | - |
7045 | \sa setRenderHint(), renderHints(), {QPainter#Rendering | - |
7046 | Quality}{Rendering Quality} | - |
7047 | */ | - |
7048 | | - |
7049 | void QPainter::setRenderHints(RenderHints hints, bool on) | - |
7050 | { | - |
7051 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
7052 | | - |
7053 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:2 | yes Evaluation Count:5426 |
| 2-5426 |
7054 | qWarning("QPainter::setRenderHint: Painter must be active to set rendering hints"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7054, __PRETTY_FUNCTION__).warning("QPainter::setRenderHint: Painter must be active to set rendering hints"); | - |
7055 | return; executed: return; Execution Count:2 | 2 |
7056 | } | - |
7057 | | - |
7058 | if (on) evaluated: on yes Evaluation Count:3311 | yes Evaluation Count:2115 |
| 2115-3311 |
7059 | d->state->renderHints |= hints; executed: d->state->renderHints |= hints; Execution Count:3311 | 3311 |
7060 | else | - |
7061 | d->state->renderHints &= ~hints; executed: d->state->renderHints &= ~hints; Execution Count:2115 | 2115 |
7062 | | - |
7063 | if (d->extended) partially evaluated: d->extended yes Evaluation Count:5426 | no Evaluation Count:0 |
| 0-5426 |
7064 | d->extended->renderHintsChanged(); executed: d->extended->renderHintsChanged(); Execution Count:5426 | 5426 |
7065 | else | - |
7066 | d->state->dirtyFlags |= QPaintEngine::DirtyHints; never executed: d->state->dirtyFlags |= QPaintEngine::DirtyHints; | 0 |
7067 | } | - |
7068 | | - |
7069 | /*! | - |
7070 | Returns a flag that specifies the rendering hints that are set for | - |
7071 | this painter. | - |
7072 | | - |
7073 | \sa testRenderHint(), {QPainter#Rendering Quality}{Rendering Quality} | - |
7074 | */ | - |
7075 | QPainter::RenderHints QPainter::renderHints() const | - |
7076 | { | - |
7077 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
7078 | | - |
7079 | if (!d->engine) evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:28321 |
| 1-28321 |
7080 | return 0; executed: return 0; Execution Count:1 | 1 |
7081 | | - |
7082 | return d->state->renderHints; executed: return d->state->renderHints; Execution Count:28321 | 28321 |
7083 | } | - |
7084 | | - |
7085 | /*! | - |
7086 | \fn bool QPainter::testRenderHint(RenderHint hint) const | - |
7087 | \since 4.3 | - |
7088 | | - |
7089 | Returns true if \a hint is set; otherwise returns false. | - |
7090 | | - |
7091 | \sa renderHints(), setRenderHint() | - |
7092 | */ | - |
7093 | | - |
7094 | /*! | - |
7095 | Returns true if view transformation is enabled; otherwise returns | - |
7096 | false. | - |
7097 | | - |
7098 | \sa setViewTransformEnabled(), worldTransform() | - |
7099 | */ | - |
7100 | | - |
7101 | bool QPainter::viewTransformEnabled() const | - |
7102 | { | - |
7103 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
7104 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
7105 | qWarning("QPainter::viewTransformEnabled: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7105, __PRETTY_FUNCTION__).warning("QPainter::viewTransformEnabled: Painter not active"); | - |
7106 | return false; executed: return false; Execution Count:1 | 1 |
7107 | } | - |
7108 | return d->state->VxF; executed: return d->state->VxF; Execution Count:2 | 2 |
7109 | } | - |
7110 | | - |
7111 | /*! | - |
7112 | \fn void QPainter::setWindow(const QRect &rectangle) | - |
7113 | | - |
7114 | Sets the painter's window to the given \a rectangle, and enables | - |
7115 | view transformations. | - |
7116 | | - |
7117 | The window rectangle is part of the view transformation. The | - |
7118 | window specifies the logical coordinate system. Its sister, the | - |
7119 | viewport(), specifies the device coordinate system. | - |
7120 | | - |
7121 | The default window rectangle is the same as the device's | - |
7122 | rectangle. | - |
7123 | | - |
7124 | \sa window(), viewTransformEnabled(), {Coordinate | - |
7125 | System#Window-Viewport Conversion}{Window-Viewport Conversion} | - |
7126 | */ | - |
7127 | | - |
7128 | /*! | - |
7129 | \fn void QPainter::setWindow(int x, int y, int width, int height) | - |
7130 | \overload | - |
7131 | | - |
7132 | Sets the painter's window to the rectangle beginning at (\a x, \a | - |
7133 | y) and the given \a width and \a height. | - |
7134 | */ | - |
7135 | | - |
7136 | void QPainter::setWindow(const QRect &r) | - |
7137 | { | - |
7138 | #ifdef QT_DEBUG_DRAW | - |
7139 | if (qt_show_painter_debug_output) | - |
7140 | printf("QPainter::setWindow(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height()); | - |
7141 | #endif | - |
7142 | | - |
7143 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
7144 | | - |
7145 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:6 |
| 1-6 |
7146 | qWarning("QPainter::setWindow: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7146, __PRETTY_FUNCTION__).warning("QPainter::setWindow: Painter not active"); | - |
7147 | return; executed: return; Execution Count:1 | 1 |
7148 | } | - |
7149 | | - |
7150 | d->state->wx = r.x(); executed (the execution status of this line is deduced): d->state->wx = r.x(); | - |
7151 | d->state->wy = r.y(); executed (the execution status of this line is deduced): d->state->wy = r.y(); | - |
7152 | d->state->ww = r.width(); executed (the execution status of this line is deduced): d->state->ww = r.width(); | - |
7153 | d->state->wh = r.height(); executed (the execution status of this line is deduced): d->state->wh = r.height(); | - |
7154 | | - |
7155 | d->state->VxF = true; executed (the execution status of this line is deduced): d->state->VxF = true; | - |
7156 | d->updateMatrix(); executed (the execution status of this line is deduced): d->updateMatrix(); | - |
7157 | } executed: } Execution Count:6 | 6 |
7158 | | - |
7159 | /*! | - |
7160 | Returns the window rectangle. | - |
7161 | | - |
7162 | \sa setWindow(), setViewTransformEnabled() | - |
7163 | */ | - |
7164 | | - |
7165 | QRect QPainter::window() const | - |
7166 | { | - |
7167 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
7168 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:9 |
| 1-9 |
7169 | qWarning("QPainter::window: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7169, __PRETTY_FUNCTION__).warning("QPainter::window: Painter not active"); | - |
7170 | return QRect(); executed: return QRect(); Execution Count:1 | 1 |
7171 | } | - |
7172 | return QRect(d->state->wx, d->state->wy, d->state->ww, d->state->wh); executed: return QRect(d->state->wx, d->state->wy, d->state->ww, d->state->wh); Execution Count:9 | 9 |
7173 | } | - |
7174 | | - |
7175 | /*! | - |
7176 | \fn void QPainter::setViewport(const QRect &rectangle) | - |
7177 | | - |
7178 | Sets the painter's viewport rectangle to the given \a rectangle, | - |
7179 | and enables view transformations. | - |
7180 | | - |
7181 | The viewport rectangle is part of the view transformation. The | - |
7182 | viewport specifies the device coordinate system. Its sister, the | - |
7183 | window(), specifies the logical coordinate system. | - |
7184 | | - |
7185 | The default viewport rectangle is the same as the device's | - |
7186 | rectangle. | - |
7187 | | - |
7188 | \sa viewport(), viewTransformEnabled(), {Coordinate | - |
7189 | System#Window-Viewport Conversion}{Window-Viewport Conversion} | - |
7190 | */ | - |
7191 | | - |
7192 | /*! | - |
7193 | \fn void QPainter::setViewport(int x, int y, int width, int height) | - |
7194 | \overload | - |
7195 | | - |
7196 | Sets the painter's viewport rectangle to be the rectangle | - |
7197 | beginning at (\a x, \a y) with the given \a width and \a height. | - |
7198 | */ | - |
7199 | | - |
7200 | void QPainter::setViewport(const QRect &r) | - |
7201 | { | - |
7202 | #ifdef QT_DEBUG_DRAW | - |
7203 | if (qt_show_painter_debug_output) | - |
7204 | printf("QPainter::setViewport(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height()); | - |
7205 | #endif | - |
7206 | | - |
7207 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
7208 | | - |
7209 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
7210 | qWarning("QPainter::setViewport: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7210, __PRETTY_FUNCTION__).warning("QPainter::setViewport: Painter not active"); | - |
7211 | return; executed: return; Execution Count:1 | 1 |
7212 | } | - |
7213 | | - |
7214 | d->state->vx = r.x(); executed (the execution status of this line is deduced): d->state->vx = r.x(); | - |
7215 | d->state->vy = r.y(); executed (the execution status of this line is deduced): d->state->vy = r.y(); | - |
7216 | d->state->vw = r.width(); executed (the execution status of this line is deduced): d->state->vw = r.width(); | - |
7217 | d->state->vh = r.height(); executed (the execution status of this line is deduced): d->state->vh = r.height(); | - |
7218 | | - |
7219 | d->state->VxF = true; executed (the execution status of this line is deduced): d->state->VxF = true; | - |
7220 | d->updateMatrix(); executed (the execution status of this line is deduced): d->updateMatrix(); | - |
7221 | } executed: } Execution Count:5 | 5 |
7222 | | - |
7223 | /*! | - |
7224 | Returns the viewport rectangle. | - |
7225 | | - |
7226 | \sa setViewport(), setViewTransformEnabled() | - |
7227 | */ | - |
7228 | | - |
7229 | QRect QPainter::viewport() const | - |
7230 | { | - |
7231 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
7232 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:10 |
| 1-10 |
7233 | qWarning("QPainter::viewport: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7233, __PRETTY_FUNCTION__).warning("QPainter::viewport: Painter not active"); | - |
7234 | return QRect(); executed: return QRect(); Execution Count:1 | 1 |
7235 | } | - |
7236 | return QRect(d->state->vx, d->state->vy, d->state->vw, d->state->vh); executed: return QRect(d->state->vx, d->state->vy, d->state->vw, d->state->vh); Execution Count:10 | 10 |
7237 | } | - |
7238 | | - |
7239 | /*! | - |
7240 | Enables view transformations if \a enable is true, or disables | - |
7241 | view transformations if \a enable is false. | - |
7242 | | - |
7243 | \sa viewTransformEnabled(), {Coordinate System#Window-Viewport | - |
7244 | Conversion}{Window-Viewport Conversion} | - |
7245 | */ | - |
7246 | | - |
7247 | void QPainter::setViewTransformEnabled(bool enable) | - |
7248 | { | - |
7249 | #ifdef QT_DEBUG_DRAW | - |
7250 | if (qt_show_painter_debug_output) | - |
7251 | printf("QPainter::setViewTransformEnabled(), enable=%d\n", enable); | - |
7252 | #endif | - |
7253 | | - |
7254 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
7255 | | - |
7256 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:11 |
| 1-11 |
7257 | qWarning("QPainter::setViewTransformEnabled: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7257, __PRETTY_FUNCTION__).warning("QPainter::setViewTransformEnabled: Painter not active"); | - |
7258 | return; executed: return; Execution Count:1 | 1 |
7259 | } | - |
7260 | | - |
7261 | if (enable == d->state->VxF) evaluated: enable == d->state->VxF yes Evaluation Count:10 | yes Evaluation Count:1 |
| 1-10 |
7262 | return; executed: return; Execution Count:10 | 10 |
7263 | | - |
7264 | d->state->VxF = enable; executed (the execution status of this line is deduced): d->state->VxF = enable; | - |
7265 | d->updateMatrix(); executed (the execution status of this line is deduced): d->updateMatrix(); | - |
7266 | } executed: } Execution Count:1 | 1 |
7267 | | - |
7268 | /*! | - |
7269 | \threadsafe | - |
7270 | | - |
7271 | \obsolete | - |
7272 | | - |
7273 | Please use QWidget::render() instead. | - |
7274 | | - |
7275 | Redirects all paint commands for the given paint \a device, to the | - |
7276 | \a replacement device. The optional point \a offset defines an | - |
7277 | offset within the source device. | - |
7278 | | - |
7279 | The redirection will not be effective until the begin() function | - |
7280 | has been called; make sure to call end() for the given \a | - |
7281 | device's painter (if any) before redirecting. Call | - |
7282 | restoreRedirected() to restore the previous redirection. | - |
7283 | | - |
7284 | \warning Making use of redirections in the QPainter API implies | - |
7285 | that QPainter::begin() and QPaintDevice destructors need to hold | - |
7286 | a mutex for a short period. This can impact performance. Use of | - |
7287 | QWidget::render is strongly encouraged. | - |
7288 | | - |
7289 | \sa redirected(), restoreRedirected() | - |
7290 | */ | - |
7291 | void QPainter::setRedirected(const QPaintDevice *device, | - |
7292 | QPaintDevice *replacement, | - |
7293 | const QPoint &offset) | - |
7294 | { | - |
7295 | Q_ASSERT(device != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
7296 | Q_UNUSED(device) never executed (the execution status of this line is deduced): (void)device; | - |
7297 | Q_UNUSED(replacement) never executed (the execution status of this line is deduced): (void)replacement; | - |
7298 | Q_UNUSED(offset) never executed (the execution status of this line is deduced): (void)offset; | - |
7299 | qWarning("QPainter::setRedirected(): ignoring call to deprecated function, use QWidget::render() instead"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7299, __PRETTY_FUNCTION__).warning("QPainter::setRedirected(): ignoring call to deprecated function, use QWidget::render() instead"); | - |
7300 | } | 0 |
7301 | | - |
7302 | /*! | - |
7303 | \threadsafe | - |
7304 | | - |
7305 | \obsolete | - |
7306 | | - |
7307 | Using QWidget::render() obsoletes the use of this function. | - |
7308 | | - |
7309 | Restores the previous redirection for the given \a device after a | - |
7310 | call to setRedirected(). | - |
7311 | | - |
7312 | \warning Making use of redirections in the QPainter API implies | - |
7313 | that QPainter::begin() and QPaintDevice destructors need to hold | - |
7314 | a mutex for a short period. This can impact performance. Use of | - |
7315 | QWidget::render is strongly encouraged. | - |
7316 | | - |
7317 | \sa redirected() | - |
7318 | */ | - |
7319 | void QPainter::restoreRedirected(const QPaintDevice *device) | - |
7320 | { | - |
7321 | Q_UNUSED(device) never executed (the execution status of this line is deduced): (void)device; | - |
7322 | qWarning("QPainter::restoreRedirected(): ignoring call to deprecated function, use QWidget::render() instead"); never executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 7322, __PRETTY_FUNCTION__).warning("QPainter::restoreRedirected(): ignoring call to deprecated function, use QWidget::render() instead"); | - |
7323 | } | 0 |
7324 | | - |
7325 | /*! | - |
7326 | \threadsafe | - |
7327 | | - |
7328 | \obsolete | - |
7329 | | - |
7330 | Using QWidget::render() obsoletes the use of this function. | - |
7331 | | - |
7332 | Returns the replacement for given \a device. The optional out | - |
7333 | parameter \a offset returns the offset within the replaced device. | - |
7334 | | - |
7335 | \warning Making use of redirections in the QPainter API implies | - |
7336 | that QPainter::begin() and QPaintDevice destructors need to hold | - |
7337 | a mutex for a short period. This can impact performance. Use of | - |
7338 | QWidget::render is strongly encouraged. | - |
7339 | | - |
7340 | \sa setRedirected(), restoreRedirected() | - |
7341 | */ | - |
7342 | QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) | - |
7343 | { | - |
7344 | Q_UNUSED(device) executed (the execution status of this line is deduced): (void)device; | - |
7345 | Q_UNUSED(offset) executed (the execution status of this line is deduced): (void)offset; | - |
7346 | return 0; executed: return 0; Execution Count:90 | 90 |
7347 | } | - |
7348 | | - |
7349 | void qt_format_text(const QFont &fnt, const QRectF &_r, | - |
7350 | int tf, const QString& str, QRectF *brect, | - |
7351 | int tabstops, int *ta, int tabarraylen, | - |
7352 | QPainter *painter) | - |
7353 | { | - |
7354 | qt_format_text(fnt, _r, executed (the execution status of this line is deduced): qt_format_text(fnt, _r, | - |
7355 | tf, 0, str, brect, executed (the execution status of this line is deduced): tf, 0, str, brect, | - |
7356 | tabstops, ta, tabarraylen, executed (the execution status of this line is deduced): tabstops, ta, tabarraylen, | - |
7357 | painter); executed (the execution status of this line is deduced): painter); | - |
7358 | } executed: } Execution Count:31890 | 31890 |
7359 | void qt_format_text(const QFont &fnt, const QRectF &_r, | - |
7360 | int tf, const QTextOption *option, const QString& str, QRectF *brect, | - |
7361 | int tabstops, int *ta, int tabarraylen, | - |
7362 | QPainter *painter) | - |
7363 | { | - |
7364 | | - |
7365 | Q_ASSERT( !((tf & ~Qt::TextDontPrint)!=0 && option!=0) ); // we either have an option or flags executed (the execution status of this line is deduced): qt_noop(); | - |
7366 | | - |
7367 | if (option) { partially evaluated: option no Evaluation Count:0 | yes Evaluation Count:35631 |
| 0-35631 |
7368 | tf |= option->alignment(); never executed (the execution status of this line is deduced): tf |= option->alignment(); | - |
7369 | if (option->wrapMode() != QTextOption::NoWrap) never evaluated: option->wrapMode() != QTextOption::NoWrap | 0 |
7370 | tf |= Qt::TextWordWrap; never executed: tf |= Qt::TextWordWrap; | 0 |
7371 | | - |
7372 | if (option->flags() & QTextOption::IncludeTrailingSpaces) never evaluated: option->flags() & QTextOption::IncludeTrailingSpaces | 0 |
7373 | tf |= Qt::TextIncludeTrailingSpaces; never executed: tf |= Qt::TextIncludeTrailingSpaces; | 0 |
7374 | | - |
7375 | if (option->tabStop() >= 0 || !option->tabArray().isEmpty()) never evaluated: option->tabStop() >= 0 never evaluated: !option->tabArray().isEmpty() | 0 |
7376 | tf |= Qt::TextExpandTabs; never executed: tf |= Qt::TextExpandTabs; | 0 |
7377 | } | 0 |
7378 | | - |
7379 | // we need to copy r here to protect against the case (&r == brect). | - |
7380 | QRectF r(_r); executed (the execution status of this line is deduced): QRectF r(_r); | - |
7381 | | - |
7382 | bool dontclip = (tf & Qt::TextDontClip); executed (the execution status of this line is deduced): bool dontclip = (tf & Qt::TextDontClip); | - |
7383 | bool wordwrap = (tf & Qt::TextWordWrap) || (tf & Qt::TextWrapAnywhere); evaluated: (tf & Qt::TextWordWrap) yes Evaluation Count:511 | yes Evaluation Count:35120 |
partially evaluated: (tf & Qt::TextWrapAnywhere) no Evaluation Count:0 | yes Evaluation Count:35120 |
| 0-35120 |
7384 | bool singleline = (tf & Qt::TextSingleLine); executed (the execution status of this line is deduced): bool singleline = (tf & Qt::TextSingleLine); | - |
7385 | bool showmnemonic = (tf & Qt::TextShowMnemonic); executed (the execution status of this line is deduced): bool showmnemonic = (tf & Qt::TextShowMnemonic); | - |
7386 | bool hidemnmemonic = (tf & Qt::TextHideMnemonic); executed (the execution status of this line is deduced): bool hidemnmemonic = (tf & Qt::TextHideMnemonic); | - |
7387 | | - |
7388 | Qt::LayoutDirection layout_direction; executed (the execution status of this line is deduced): Qt::LayoutDirection layout_direction; | - |
7389 | if (tf & Qt::TextForceLeftToRight) evaluated: tf & Qt::TextForceLeftToRight yes Evaluation Count:454 | yes Evaluation Count:35177 |
| 454-35177 |
7390 | layout_direction = Qt::LeftToRight; executed: layout_direction = Qt::LeftToRight; Execution Count:454 | 454 |
7391 | else if (tf & Qt::TextForceRightToLeft) evaluated: tf & Qt::TextForceRightToLeft yes Evaluation Count:1 | yes Evaluation Count:35176 |
| 1-35176 |
7392 | layout_direction = Qt::RightToLeft; executed: layout_direction = Qt::RightToLeft; Execution Count:1 | 1 |
7393 | else if (option) partially evaluated: option no Evaluation Count:0 | yes Evaluation Count:35176 |
| 0-35176 |
7394 | layout_direction = option->textDirection(); never executed: layout_direction = option->textDirection(); | 0 |
7395 | else if (painter) evaluated: painter yes Evaluation Count:3286 | yes Evaluation Count:31890 |
| 3286-31890 |
7396 | layout_direction = painter->layoutDirection(); executed: layout_direction = painter->layoutDirection(); Execution Count:3286 | 3286 |
7397 | else | - |
7398 | layout_direction = Qt::LeftToRight; executed: layout_direction = Qt::LeftToRight; Execution Count:31890 | 31890 |
7399 | | - |
7400 | tf = QGuiApplicationPrivate::visualAlignment(layout_direction, QFlag(tf)); executed (the execution status of this line is deduced): tf = QGuiApplicationPrivate::visualAlignment(layout_direction, QFlag(tf)); | - |
7401 | | - |
7402 | bool isRightToLeft = layout_direction == Qt::RightToLeft; executed (the execution status of this line is deduced): bool isRightToLeft = layout_direction == Qt::RightToLeft; | - |
7403 | bool expandtabs = ((tf & Qt::TextExpandTabs) && evaluated: (tf & Qt::TextExpandTabs) yes Evaluation Count:3341 | yes Evaluation Count:32290 |
| 3341-32290 |
7404 | (((tf & Qt::AlignLeft) && !isRightToLeft) || evaluated: (tf & Qt::AlignLeft) yes Evaluation Count:3282 | yes Evaluation Count:59 |
partially evaluated: !isRightToLeft yes Evaluation Count:3282 | no Evaluation Count:0 |
| 0-3282 |
7405 | ((tf & Qt::AlignRight) && isRightToLeft))); evaluated: (tf & Qt::AlignRight) yes Evaluation Count:56 | yes Evaluation Count:3 |
evaluated: isRightToLeft yes Evaluation Count:1 | yes Evaluation Count:55 |
| 1-56 |
7406 | | - |
7407 | if (!painter) evaluated: !painter yes Evaluation Count:31890 | yes Evaluation Count:3741 |
| 3741-31890 |
7408 | tf |= Qt::TextDontPrint; executed: tf |= Qt::TextDontPrint; Execution Count:31890 | 31890 |
7409 | | - |
7410 | uint maxUnderlines = 0; executed (the execution status of this line is deduced): uint maxUnderlines = 0; | - |
7411 | int numUnderlines = 0; executed (the execution status of this line is deduced): int numUnderlines = 0; | - |
7412 | QVarLengthArray<int, 32> underlinePositions(1); executed (the execution status of this line is deduced): QVarLengthArray<int, 32> underlinePositions(1); | - |
7413 | | - |
7414 | QFontMetricsF fm(fnt); executed (the execution status of this line is deduced): QFontMetricsF fm(fnt); | - |
7415 | QString text = str; executed (the execution status of this line is deduced): QString text = str; | - |
7416 | int offset = 0; executed (the execution status of this line is deduced): int offset = 0; | - |
7417 | start_lengthVariant: code before this statement executed: start_lengthVariant: Execution Count:35631 | 35631 |
7418 | bool hasMoreLengthVariants = false; executed (the execution status of this line is deduced): bool hasMoreLengthVariants = false; | - |
7419 | // compatible behaviour to the old implementation. Replace | - |
7420 | // tabs by spaces | - |
7421 | int old_offset = offset; executed (the execution status of this line is deduced): int old_offset = offset; | - |
7422 | for (; offset < text.length(); offset++) { evaluated: offset < text.length() yes Evaluation Count:144043 | yes Evaluation Count:35631 |
| 35631-144043 |
7423 | QChar chr = text.at(offset); executed (the execution status of this line is deduced): QChar chr = text.at(offset); | - |
7424 | if (chr == QLatin1Char('\r') || (singleline && chr == QLatin1Char('\n'))) { partially evaluated: chr == QLatin1Char('\r') no Evaluation Count:0 | yes Evaluation Count:144043 |
evaluated: singleline yes Evaluation Count:12439 | yes Evaluation Count:131604 |
evaluated: chr == QLatin1Char('\n') yes Evaluation Count:6 | yes Evaluation Count:12433 |
| 0-144043 |
7425 | text[offset] = QLatin1Char(' '); executed (the execution status of this line is deduced): text[offset] = QLatin1Char(' '); | - |
7426 | } else if (chr == QLatin1Char('\n')) { executed: } Execution Count:6 evaluated: chr == QLatin1Char('\n') yes Evaluation Count:124 | yes Evaluation Count:143913 |
| 6-143913 |
7427 | text[offset] = QChar::LineSeparator; executed (the execution status of this line is deduced): text[offset] = QChar::LineSeparator; | - |
7428 | } else if (chr == QLatin1Char('&')) { executed: } Execution Count:124 evaluated: chr == QLatin1Char('&') yes Evaluation Count:2171 | yes Evaluation Count:141742 |
| 124-141742 |
7429 | ++maxUnderlines; executed (the execution status of this line is deduced): ++maxUnderlines; | - |
7430 | } else if (chr == QLatin1Char('\t')) { executed: } Execution Count:2171 partially evaluated: chr == QLatin1Char('\t') no Evaluation Count:0 | yes Evaluation Count:141742 |
| 0-141742 |
7431 | if (!expandtabs) { never evaluated: !expandtabs | 0 |
7432 | text[offset] = QLatin1Char(' '); never executed (the execution status of this line is deduced): text[offset] = QLatin1Char(' '); | - |
7433 | } else if (!tabarraylen && !tabstops) { never executed: } never evaluated: !tabarraylen never evaluated: !tabstops | 0 |
7434 | tabstops = qRound(fm.width(QLatin1Char('x'))*8); never executed (the execution status of this line is deduced): tabstops = qRound(fm.width(QLatin1Char('x'))*8); | - |
7435 | } | 0 |
7436 | } else if (chr == QChar(ushort(0x9c))) { partially evaluated: chr == QChar(ushort(0x9c)) no Evaluation Count:0 | yes Evaluation Count:141742 |
| 0-141742 |
7437 | // string with multiple length variants | - |
7438 | hasMoreLengthVariants = true; never executed (the execution status of this line is deduced): hasMoreLengthVariants = true; | - |
7439 | break; | 0 |
7440 | } | - |
7441 | } | - |
7442 | | - |
7443 | int length = offset - old_offset; executed (the execution status of this line is deduced): int length = offset - old_offset; | - |
7444 | if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) { partially evaluated: hidemnmemonic no Evaluation Count:0 | yes Evaluation Count:35631 |
evaluated: showmnemonic yes Evaluation Count:5961 | yes Evaluation Count:29670 |
evaluated: maxUnderlines > 0 yes Evaluation Count:2164 | yes Evaluation Count:3797 |
| 0-35631 |
7445 | underlinePositions.resize(maxUnderlines + 1); executed (the execution status of this line is deduced): underlinePositions.resize(maxUnderlines + 1); | - |
7446 | | - |
7447 | QChar *cout = text.data() + old_offset; executed (the execution status of this line is deduced): QChar *cout = text.data() + old_offset; | - |
7448 | QChar *cin = cout; executed (the execution status of this line is deduced): QChar *cin = cout; | - |
7449 | int l = length; executed (the execution status of this line is deduced): int l = length; | - |
7450 | while (l) { evaluated: l yes Evaluation Count:14376 | yes Evaluation Count:2164 |
| 2164-14376 |
7451 | if (*cin == QLatin1Char('&')) { evaluated: *cin == QLatin1Char('&') yes Evaluation Count:2168 | yes Evaluation Count:12208 |
| 2168-12208 |
7452 | ++cin; executed (the execution status of this line is deduced): ++cin; | - |
7453 | --length; executed (the execution status of this line is deduced): --length; | - |
7454 | --l; executed (the execution status of this line is deduced): --l; | - |
7455 | if (!l) partially evaluated: !l no Evaluation Count:0 | yes Evaluation Count:2168 |
| 0-2168 |
7456 | break; | 0 |
7457 | if (*cin != QLatin1Char('&') && !hidemnmemonic) partially evaluated: *cin != QLatin1Char('&') yes Evaluation Count:2168 | no Evaluation Count:0 |
partially evaluated: !hidemnmemonic yes Evaluation Count:2168 | no Evaluation Count:0 |
| 0-2168 |
7458 | underlinePositions[numUnderlines++] = cout - text.data() - old_offset; executed: underlinePositions[numUnderlines++] = cout - text.data() - old_offset; Execution Count:2168 | 2168 |
7459 | } executed: } Execution Count:2168 | 2168 |
7460 | *cout = *cin; executed (the execution status of this line is deduced): *cout = *cin; | - |
7461 | ++cout; executed (the execution status of this line is deduced): ++cout; | - |
7462 | ++cin; executed (the execution status of this line is deduced): ++cin; | - |
7463 | --l; executed (the execution status of this line is deduced): --l; | - |
7464 | } executed: } Execution Count:14376 | 14376 |
7465 | } executed: } Execution Count:2164 | 2164 |
7466 | | - |
7467 | // no need to do extra work for underlines if we don't paint | - |
7468 | if (tf & Qt::TextDontPrint) evaluated: tf & Qt::TextDontPrint yes Evaluation Count:31890 | yes Evaluation Count:3741 |
| 3741-31890 |
7469 | numUnderlines = 0; executed: numUnderlines = 0; Execution Count:31890 | 31890 |
7470 | | - |
7471 | underlinePositions[numUnderlines] = -1; executed (the execution status of this line is deduced): underlinePositions[numUnderlines] = -1; | - |
7472 | qreal height = 0; executed (the execution status of this line is deduced): qreal height = 0; | - |
7473 | qreal width = 0; executed (the execution status of this line is deduced): qreal width = 0; | - |
7474 | | - |
7475 | QString finalText = text.mid(old_offset, length); executed (the execution status of this line is deduced): QString finalText = text.mid(old_offset, length); | - |
7476 | QStackTextEngine engine(finalText, fnt); executed (the execution status of this line is deduced): QStackTextEngine engine(finalText, fnt); | - |
7477 | if (option) { partially evaluated: option no Evaluation Count:0 | yes Evaluation Count:35631 |
| 0-35631 |
7478 | engine.option = *option; never executed (the execution status of this line is deduced): engine.option = *option; | - |
7479 | } | 0 |
7480 | | - |
7481 | if (engine.option.tabStop() < 0 && tabstops > 0) partially evaluated: engine.option.tabStop() < 0 yes Evaluation Count:35631 | no Evaluation Count:0 |
partially evaluated: tabstops > 0 no Evaluation Count:0 | yes Evaluation Count:35631 |
| 0-35631 |
7482 | engine.option.setTabStop(tabstops); never executed: engine.option.setTabStop(tabstops); | 0 |
7483 | | - |
7484 | if (engine.option.tabs().isEmpty() && ta) { partially evaluated: engine.option.tabs().isEmpty() yes Evaluation Count:35631 | no Evaluation Count:0 |
partially evaluated: ta no Evaluation Count:0 | yes Evaluation Count:35631 |
| 0-35631 |
7485 | QList<qreal> tabs; never executed (the execution status of this line is deduced): QList<qreal> tabs; | - |
7486 | for (int i = 0; i < tabarraylen; i++) never evaluated: i < tabarraylen | 0 |
7487 | tabs.append(qreal(ta[i])); never executed: tabs.append(qreal(ta[i])); | 0 |
7488 | engine.option.setTabArray(tabs); never executed (the execution status of this line is deduced): engine.option.setTabArray(tabs); | - |
7489 | } | 0 |
7490 | | - |
7491 | engine.option.setTextDirection(layout_direction); executed (the execution status of this line is deduced): engine.option.setTextDirection(layout_direction); | - |
7492 | if (tf & Qt::AlignJustify) partially evaluated: tf & Qt::AlignJustify no Evaluation Count:0 | yes Evaluation Count:35631 |
| 0-35631 |
7493 | engine.option.setAlignment(Qt::AlignJustify); never executed: engine.option.setAlignment(Qt::AlignJustify); | 0 |
7494 | else | - |
7495 | engine.option.setAlignment(Qt::AlignLeft); // do not do alignment twice executed: engine.option.setAlignment(Qt::AlignLeft); Execution Count:35631 | 35631 |
7496 | | - |
7497 | if (!option && (tf & Qt::TextWrapAnywhere)) partially evaluated: !option yes Evaluation Count:35631 | no Evaluation Count:0 |
partially evaluated: (tf & Qt::TextWrapAnywhere) no Evaluation Count:0 | yes Evaluation Count:35631 |
| 0-35631 |
7498 | engine.option.setWrapMode(QTextOption::WrapAnywhere); never executed: engine.option.setWrapMode(QTextOption::WrapAnywhere); | 0 |
7499 | | - |
7500 | if (tf & Qt::TextJustificationForced) partially evaluated: tf & Qt::TextJustificationForced no Evaluation Count:0 | yes Evaluation Count:35631 |
| 0-35631 |
7501 | engine.forceJustification = true; never executed: engine.forceJustification = true; | 0 |
7502 | QTextLayout textLayout(&engine); executed (the execution status of this line is deduced): QTextLayout textLayout(&engine); | - |
7503 | textLayout.setCacheEnabled(true); executed (the execution status of this line is deduced): textLayout.setCacheEnabled(true); | - |
7504 | textLayout.engine()->underlinePositions = underlinePositions.data(); executed (the execution status of this line is deduced): textLayout.engine()->underlinePositions = underlinePositions.data(); | - |
7505 | | - |
7506 | if (finalText.isEmpty()) { evaluated: finalText.isEmpty() yes Evaluation Count:242 | yes Evaluation Count:35389 |
| 242-35389 |
7507 | height = fm.height(); executed (the execution status of this line is deduced): height = fm.height(); | - |
7508 | width = 0; executed (the execution status of this line is deduced): width = 0; | - |
7509 | tf |= Qt::TextDontPrint; executed (the execution status of this line is deduced): tf |= Qt::TextDontPrint; | - |
7510 | } else { executed: } Execution Count:242 | 242 |
7511 | qreal lineWidth = 0x01000000; executed (the execution status of this line is deduced): qreal lineWidth = 0x01000000; | - |
7512 | if (wordwrap || (tf & Qt::TextJustificationForced)) evaluated: wordwrap yes Evaluation Count:511 | yes Evaluation Count:34878 |
partially evaluated: (tf & Qt::TextJustificationForced) no Evaluation Count:0 | yes Evaluation Count:34878 |
| 0-34878 |
7513 | lineWidth = qMax<qreal>(0, r.width()); executed: lineWidth = qMax<qreal>(0, r.width()); Execution Count:511 | 511 |
7514 | if(!wordwrap) evaluated: !wordwrap yes Evaluation Count:34878 | yes Evaluation Count:511 |
| 511-34878 |
7515 | tf |= Qt::TextIncludeTrailingSpaces; executed: tf |= Qt::TextIncludeTrailingSpaces; Execution Count:34878 | 34878 |
7516 | textLayout.engine()->ignoreBidi = bool(tf & Qt::TextDontPrint); executed (the execution status of this line is deduced): textLayout.engine()->ignoreBidi = bool(tf & Qt::TextDontPrint); | - |
7517 | textLayout.beginLayout(); executed (the execution status of this line is deduced): textLayout.beginLayout(); | - |
7518 | | - |
7519 | qreal leading = fm.leading(); executed (the execution status of this line is deduced): qreal leading = fm.leading(); | - |
7520 | height = -leading; executed (the execution status of this line is deduced): height = -leading; | - |
7521 | | - |
7522 | while (1) { partially evaluated: 1 yes Evaluation Count:70715 | no Evaluation Count:0 |
| 0-70715 |
7523 | QTextLine l = textLayout.createLine(); executed (the execution status of this line is deduced): QTextLine l = textLayout.createLine(); | - |
7524 | if (!l.isValid()) evaluated: !l.isValid() yes Evaluation Count:34145 | yes Evaluation Count:36570 |
| 34145-36570 |
7525 | break; executed: break; Execution Count:34145 | 34145 |
7526 | | - |
7527 | l.setLineWidth(lineWidth); executed (the execution status of this line is deduced): l.setLineWidth(lineWidth); | - |
7528 | height += leading; executed (the execution status of this line is deduced): height += leading; | - |
7529 | | - |
7530 | // Make sure lines are positioned on whole pixels | - |
7531 | height = qCeil(height); executed (the execution status of this line is deduced): height = qCeil(height); | - |
7532 | l.setPosition(QPointF(0., height)); executed (the execution status of this line is deduced): l.setPosition(QPointF(0., height)); | - |
7533 | height += textLayout.engine()->lines[l.lineNumber()].height().toReal(); executed (the execution status of this line is deduced): height += textLayout.engine()->lines[l.lineNumber()].height().toReal(); | - |
7534 | width = qMax(width, l.naturalTextWidth()); executed (the execution status of this line is deduced): width = qMax(width, l.naturalTextWidth()); | - |
7535 | if (!dontclip && !brect && height >= r.height()) evaluated: !dontclip yes Evaluation Count:36415 | yes Evaluation Count:155 |
evaluated: !brect yes Evaluation Count:3662 | yes Evaluation Count:32753 |
evaluated: height >= r.height() yes Evaluation Count:1244 | yes Evaluation Count:2418 |
| 155-36415 |
7536 | break; executed: break; Execution Count:1244 | 1244 |
7537 | } executed: } Execution Count:35326 | 35326 |
7538 | textLayout.endLayout(); executed (the execution status of this line is deduced): textLayout.endLayout(); | - |
7539 | } executed: } Execution Count:35389 | 35389 |
7540 | | - |
7541 | qreal yoff = 0; executed (the execution status of this line is deduced): qreal yoff = 0; | - |
7542 | qreal xoff = 0; executed (the execution status of this line is deduced): qreal xoff = 0; | - |
7543 | if (tf & Qt::AlignBottom) partially evaluated: tf & Qt::AlignBottom no Evaluation Count:0 | yes Evaluation Count:35631 |
| 0-35631 |
7544 | yoff = r.height() - height; never executed: yoff = r.height() - height; | 0 |
7545 | else if (tf & Qt::AlignVCenter) evaluated: tf & Qt::AlignVCenter yes Evaluation Count:3496 | yes Evaluation Count:32135 |
| 3496-32135 |
7546 | yoff = (r.height() - height)/2; executed: yoff = (r.height() - height)/2; Execution Count:3496 | 3496 |
7547 | | - |
7548 | if (tf & Qt::AlignRight) evaluated: tf & Qt::AlignRight yes Evaluation Count:64 | yes Evaluation Count:35567 |
| 64-35567 |
7549 | xoff = r.width() - width; executed: xoff = r.width() - width; Execution Count:64 | 64 |
7550 | else if (tf & Qt::AlignHCenter) evaluated: tf & Qt::AlignHCenter yes Evaluation Count:1410 | yes Evaluation Count:34157 |
| 1410-34157 |
7551 | xoff = (r.width() - width)/2; executed: xoff = (r.width() - width)/2; Execution Count:1410 | 1410 |
7552 | | - |
7553 | QRectF bounds = QRectF(r.x() + xoff, r.y() + yoff, width, height); executed (the execution status of this line is deduced): QRectF bounds = QRectF(r.x() + xoff, r.y() + yoff, width, height); | - |
7554 | | - |
7555 | if (hasMoreLengthVariants && !(tf & Qt::TextLongestVariant) && !r.contains(bounds)) { partially evaluated: hasMoreLengthVariants no Evaluation Count:0 | yes Evaluation Count:35631 |
never evaluated: !(tf & Qt::TextLongestVariant) never evaluated: !r.contains(bounds) | 0-35631 |
7556 | offset++; never executed (the execution status of this line is deduced): offset++; | - |
7557 | goto start_lengthVariant; never executed: goto start_lengthVariant; | 0 |
7558 | } | - |
7559 | if (brect) evaluated: brect yes Evaluation Count:31890 | yes Evaluation Count:3741 |
| 3741-31890 |
7560 | *brect = bounds; executed: *brect = bounds; Execution Count:31890 | 31890 |
7561 | | - |
7562 | if (!(tf & Qt::TextDontPrint)) { evaluated: !(tf & Qt::TextDontPrint) yes Evaluation Count:3741 | yes Evaluation Count:31890 |
| 3741-31890 |
7563 | bool restore = false; executed (the execution status of this line is deduced): bool restore = false; | - |
7564 | if (!dontclip && !r.contains(bounds)) { evaluated: !dontclip yes Evaluation Count:3586 | yes Evaluation Count:155 |
evaluated: !r.contains(bounds) yes Evaluation Count:20 | yes Evaluation Count:3566 |
| 20-3586 |
7565 | restore = true; executed (the execution status of this line is deduced): restore = true; | - |
7566 | painter->save(); executed (the execution status of this line is deduced): painter->save(); | - |
7567 | painter->setClipRect(r, Qt::IntersectClip); executed (the execution status of this line is deduced): painter->setClipRect(r, Qt::IntersectClip); | - |
7568 | } executed: } Execution Count:20 | 20 |
7569 | | - |
7570 | for (int i = 0; i < textLayout.lineCount(); i++) { evaluated: i < textLayout.lineCount() yes Evaluation Count:3817 | yes Evaluation Count:3741 |
| 3741-3817 |
7571 | QTextLine line = textLayout.lineAt(i); executed (the execution status of this line is deduced): QTextLine line = textLayout.lineAt(i); | - |
7572 | QTextEngine *eng = textLayout.engine(); executed (the execution status of this line is deduced): QTextEngine *eng = textLayout.engine(); | - |
7573 | eng->enableDelayDecorations(); executed (the execution status of this line is deduced): eng->enableDelayDecorations(); | - |
7574 | | - |
7575 | qreal advance = line.horizontalAdvance(); executed (the execution status of this line is deduced): qreal advance = line.horizontalAdvance(); | - |
7576 | xoff = 0; executed (the execution status of this line is deduced): xoff = 0; | - |
7577 | if (tf & Qt::AlignRight) { evaluated: tf & Qt::AlignRight yes Evaluation Count:22 | yes Evaluation Count:3795 |
| 22-3795 |
7578 | xoff = r.width() - advance - executed (the execution status of this line is deduced): xoff = r.width() - advance - | - |
7579 | eng->leadingSpaceWidth(eng->lines[line.lineNumber()]).toReal(); executed (the execution status of this line is deduced): eng->leadingSpaceWidth(eng->lines[line.lineNumber()]).toReal(); | - |
7580 | } executed: } Execution Count:22 | 22 |
7581 | else if (tf & Qt::AlignHCenter) evaluated: tf & Qt::AlignHCenter yes Evaluation Count:1406 | yes Evaluation Count:2389 |
| 1406-2389 |
7582 | xoff = (r.width() - advance) / 2; executed: xoff = (r.width() - advance) / 2; Execution Count:1406 | 1406 |
7583 | | - |
7584 | line.draw(painter, QPointF(r.x() + xoff, r.y() + yoff)); executed (the execution status of this line is deduced): line.draw(painter, QPointF(r.x() + xoff, r.y() + yoff)); | - |
7585 | eng->drawDecorations(painter); executed (the execution status of this line is deduced): eng->drawDecorations(painter); | - |
7586 | } executed: } Execution Count:3817 | 3817 |
7587 | | - |
7588 | if (restore) { evaluated: restore yes Evaluation Count:20 | yes Evaluation Count:3721 |
| 20-3721 |
7589 | painter->restore(); executed (the execution status of this line is deduced): painter->restore(); | - |
7590 | } executed: } Execution Count:20 | 20 |
7591 | } executed: } Execution Count:3741 | 3741 |
7592 | } executed: } Execution Count:35631 | 35631 |
7593 | | - |
7594 | /*! | - |
7595 | Sets the layout direction used by the painter when drawing text, | - |
7596 | to the specified \a direction. | - |
7597 | | - |
7598 | The default is Qt::LayoutDirectionAuto, which will implicitly determine the | - |
7599 | direction from the text drawn. | - |
7600 | | - |
7601 | \sa QTextOption::setTextDirection(), layoutDirection(), drawText(), {QPainter#Settings}{Settings} | - |
7602 | */ | - |
7603 | void QPainter::setLayoutDirection(Qt::LayoutDirection direction) | - |
7604 | { | - |
7605 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
7606 | if (d->state) evaluated: d->state yes Evaluation Count:490 | yes Evaluation Count:1 |
| 1-490 |
7607 | d->state->layoutDirection = direction; executed: d->state->layoutDirection = direction; Execution Count:490 | 490 |
7608 | } executed: } Execution Count:491 | 491 |
7609 | | - |
7610 | /*! | - |
7611 | Returns the layout direction used by the painter when drawing text. | - |
7612 | | - |
7613 | \sa QTextOption::textDirection(), setLayoutDirection(), drawText(), {QPainter#Settings}{Settings} | - |
7614 | */ | - |
7615 | Qt::LayoutDirection QPainter::layoutDirection() const | - |
7616 | { | - |
7617 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
7618 | return d->state ? d->state->layoutDirection : Qt::LayoutDirectionAuto; executed: return d->state ? d->state->layoutDirection : Qt::LayoutDirectionAuto; Execution Count:6119 | 6119 |
7619 | } | - |
7620 | | - |
7621 | QPainterState::QPainterState(const QPainterState *s) | - |
7622 | : brushOrigin(s->brushOrigin), font(s->font), deviceFont(s->deviceFont), | - |
7623 | pen(s->pen), brush(s->brush), bgBrush(s->bgBrush), | - |
7624 | clipRegion(s->clipRegion), clipPath(s->clipPath), | - |
7625 | clipOperation(s->clipOperation), | - |
7626 | renderHints(s->renderHints), clipInfo(s->clipInfo), | - |
7627 | worldMatrix(s->worldMatrix), matrix(s->matrix), redirectionMatrix(s->redirectionMatrix), | - |
7628 | wx(s->wx), wy(s->wy), ww(s->ww), wh(s->wh), | - |
7629 | vx(s->vx), vy(s->vy), vw(s->vw), vh(s->vh), | - |
7630 | opacity(s->opacity), WxF(s->WxF), VxF(s->VxF), | - |
7631 | clipEnabled(s->clipEnabled), bgMode(s->bgMode), painter(s->painter), | - |
7632 | layoutDirection(s->layoutDirection), | - |
7633 | composition_mode(s->composition_mode), | - |
7634 | emulationSpecifier(s->emulationSpecifier), changeFlags(0) | - |
7635 | { | - |
7636 | dirtyFlags = s->dirtyFlags; executed (the execution status of this line is deduced): dirtyFlags = s->dirtyFlags; | - |
7637 | } executed: } Execution Count:9 | 9 |
7638 | | - |
7639 | QPainterState::QPainterState() | - |
7640 | : brushOrigin(0, 0), bgBrush(Qt::white), clipOperation(Qt::NoClip), | - |
7641 | renderHints(0), | - |
7642 | wx(0), wy(0), ww(0), wh(0), vx(0), vy(0), vw(0), vh(0), | - |
7643 | opacity(1), WxF(false), VxF(false), clipEnabled(true), | - |
7644 | bgMode(Qt::TransparentMode), painter(0), | - |
7645 | layoutDirection(QGuiApplication::layoutDirection()), | - |
7646 | composition_mode(QPainter::CompositionMode_SourceOver), | - |
7647 | emulationSpecifier(0), changeFlags(0) | - |
7648 | { | - |
7649 | dirtyFlags = 0; executed (the execution status of this line is deduced): dirtyFlags = 0; | - |
7650 | } executed: } Execution Count:28775 | 28775 |
7651 | | - |
7652 | QPainterState::~QPainterState() | - |
7653 | { | - |
7654 | } | - |
7655 | | - |
7656 | void QPainterState::init(QPainter *p) { | - |
7657 | bgBrush = Qt::white; never executed (the execution status of this line is deduced): bgBrush = Qt::white; | - |
7658 | bgMode = Qt::TransparentMode; never executed (the execution status of this line is deduced): bgMode = Qt::TransparentMode; | - |
7659 | WxF = false; never executed (the execution status of this line is deduced): WxF = false; | - |
7660 | VxF = false; never executed (the execution status of this line is deduced): VxF = false; | - |
7661 | clipEnabled = true; never executed (the execution status of this line is deduced): clipEnabled = true; | - |
7662 | wx = wy = ww = wh = 0; never executed (the execution status of this line is deduced): wx = wy = ww = wh = 0; | - |
7663 | vx = vy = vw = vh = 0; never executed (the execution status of this line is deduced): vx = vy = vw = vh = 0; | - |
7664 | painter = p; never executed (the execution status of this line is deduced): painter = p; | - |
7665 | pen = QPen(); never executed (the execution status of this line is deduced): pen = QPen(); | - |
7666 | brushOrigin = QPointF(0, 0); never executed (the execution status of this line is deduced): brushOrigin = QPointF(0, 0); | - |
7667 | brush = QBrush(); never executed (the execution status of this line is deduced): brush = QBrush(); | - |
7668 | font = deviceFont = QFont(); never executed (the execution status of this line is deduced): font = deviceFont = QFont(); | - |
7669 | clipRegion = QRegion(); never executed (the execution status of this line is deduced): clipRegion = QRegion(); | - |
7670 | clipPath = QPainterPath(); never executed (the execution status of this line is deduced): clipPath = QPainterPath(); | - |
7671 | clipOperation = Qt::NoClip; never executed (the execution status of this line is deduced): clipOperation = Qt::NoClip; | - |
7672 | clipInfo.clear(); never executed (the execution status of this line is deduced): clipInfo.clear(); | - |
7673 | worldMatrix.reset(); never executed (the execution status of this line is deduced): worldMatrix.reset(); | - |
7674 | matrix.reset(); never executed (the execution status of this line is deduced): matrix.reset(); | - |
7675 | layoutDirection = QGuiApplication::layoutDirection(); never executed (the execution status of this line is deduced): layoutDirection = QGuiApplication::layoutDirection(); | - |
7676 | composition_mode = QPainter::CompositionMode_SourceOver; never executed (the execution status of this line is deduced): composition_mode = QPainter::CompositionMode_SourceOver; | - |
7677 | emulationSpecifier = 0; never executed (the execution status of this line is deduced): emulationSpecifier = 0; | - |
7678 | dirtyFlags = 0; never executed (the execution status of this line is deduced): dirtyFlags = 0; | - |
7679 | changeFlags = 0; never executed (the execution status of this line is deduced): changeFlags = 0; | - |
7680 | renderHints = 0; never executed (the execution status of this line is deduced): renderHints = 0; | - |
7681 | opacity = 1; never executed (the execution status of this line is deduced): opacity = 1; | - |
7682 | } | 0 |
7683 | | - |
7684 | /*! | - |
7685 | \fn void QPainter::drawImage(const QRectF &target, const QImage &image, const QRectF &source, | - |
7686 | Qt::ImageConversionFlags flags) | - |
7687 | | - |
7688 | Draws the rectangular portion \a source of the given \a image | - |
7689 | into the \a target rectangle in the paint device. | - |
7690 | | - |
7691 | \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree. | - |
7692 | | - |
7693 | If the image needs to be modified to fit in a lower-resolution | - |
7694 | result (e.g. converting from 32-bit to 8-bit), use the \a flags to | - |
7695 | specify how you would prefer this to happen. | - |
7696 | | - |
7697 | \table 100% | - |
7698 | \row | - |
7699 | \li | - |
7700 | \snippet code/src_gui_painting_qpainter.cpp 20 | - |
7701 | \endtable | - |
7702 | | - |
7703 | \sa drawPixmap() | - |
7704 | */ | - |
7705 | | - |
7706 | /*! | - |
7707 | \fn void QPainter::drawImage(const QRect &target, const QImage &image, const QRect &source, | - |
7708 | Qt::ImageConversionFlags flags) | - |
7709 | \overload | - |
7710 | | - |
7711 | Draws the rectangular portion \a source of the given \a image | - |
7712 | into the \a target rectangle in the paint device. | - |
7713 | | - |
7714 | \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree. | - |
7715 | */ | - |
7716 | | - |
7717 | /*! | - |
7718 | \fn void QPainter::drawImage(const QPointF &point, const QImage &image) | - |
7719 | | - |
7720 | \overload | - |
7721 | | - |
7722 | Draws the given \a image at the given \a point. | - |
7723 | */ | - |
7724 | | - |
7725 | /*! | - |
7726 | \fn void QPainter::drawImage(const QPoint &point, const QImage &image) | - |
7727 | | - |
7728 | \overload | - |
7729 | | - |
7730 | Draws the given \a image at the given \a point. | - |
7731 | */ | - |
7732 | | - |
7733 | /*! | - |
7734 | \fn void QPainter::drawImage(const QPointF &point, const QImage &image, const QRectF &source, | - |
7735 | Qt::ImageConversionFlags flags = 0) | - |
7736 | | - |
7737 | \overload | - |
7738 | | - |
7739 | Draws the rectangular portion \a source of the given \a image with | - |
7740 | its origin at the given \a point. | - |
7741 | */ | - |
7742 | | - |
7743 | /*! | - |
7744 | \fn void QPainter::drawImage(const QPoint &point, const QImage &image, const QRect &source, | - |
7745 | Qt::ImageConversionFlags flags = 0) | - |
7746 | \overload | - |
7747 | | - |
7748 | Draws the rectangular portion \a source of the given \a image with | - |
7749 | its origin at the given \a point. | - |
7750 | */ | - |
7751 | | - |
7752 | /*! | - |
7753 | \fn void QPainter::drawImage(const QRectF &rectangle, const QImage &image) | - |
7754 | | - |
7755 | \overload | - |
7756 | | - |
7757 | Draws the given \a image into the given \a rectangle. | - |
7758 | | - |
7759 | \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree. | - |
7760 | */ | - |
7761 | | - |
7762 | /*! | - |
7763 | \fn void QPainter::drawImage(const QRect &rectangle, const QImage &image) | - |
7764 | | - |
7765 | \overload | - |
7766 | | - |
7767 | Draws the given \a image into the given \a rectangle. | - |
7768 | | - |
7769 | \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree. | - |
7770 | */ | - |
7771 | | - |
7772 | /*! | - |
7773 | \fn void QPainter::drawImage(int x, int y, const QImage &image, | - |
7774 | int sx, int sy, int sw, int sh, | - |
7775 | Qt::ImageConversionFlags flags) | - |
7776 | \overload | - |
7777 | | - |
7778 | Draws an image at (\a{x}, \a{y}) by copying a part of \a image into | - |
7779 | the paint device. | - |
7780 | | - |
7781 | (\a{x}, \a{y}) specifies the top-left point in the paint device that is | - |
7782 | to be drawn onto. (\a{sx}, \a{sy}) specifies the top-left point in \a | - |
7783 | image that is to be drawn. The default is (0, 0). | - |
7784 | | - |
7785 | (\a{sw}, \a{sh}) specifies the size of the image that is to be drawn. | - |
7786 | The default, (0, 0) (and negative) means all the way to the | - |
7787 | bottom-right of the image. | - |
7788 | */ | - |
7789 | | - |
7790 | /*! | - |
7791 | \class QPaintEngineState | - |
7792 | \since 4.1 | - |
7793 | \inmodule QtGui | - |
7794 | | - |
7795 | \brief The QPaintEngineState class provides information about the | - |
7796 | active paint engine's current state. | - |
7797 | \reentrant | - |
7798 | | - |
7799 | QPaintEngineState records which properties that have changed since | - |
7800 | the last time the paint engine was updated, as well as their | - |
7801 | current value. | - |
7802 | | - |
7803 | Which properties that have changed can at any time be retrieved | - |
7804 | using the state() function. This function returns an instance of | - |
7805 | the QPaintEngine::DirtyFlags type which stores an OR combination | - |
7806 | of QPaintEngine::DirtyFlag values. The QPaintEngine::DirtyFlag | - |
7807 | enum defines whether a property has changed since the last update | - |
7808 | or not. | - |
7809 | | - |
7810 | If a property is marked with a dirty flag, its current value can | - |
7811 | be retrieved using the corresponding get function: | - |
7812 | | - |
7813 | \target GetFunction | - |
7814 | | - |
7815 | \table | - |
7816 | \header \li Property Flag \li Current Property Value | - |
7817 | \row \li QPaintEngine::DirtyBackground \li backgroundBrush() | - |
7818 | \row \li QPaintEngine::DirtyBackgroundMode \li backgroundMode() | - |
7819 | \row \li QPaintEngine::DirtyBrush \li brush() | - |
7820 | \row \li QPaintEngine::DirtyBrushOrigin \li brushOrigin() | - |
7821 | \row \li QPaintEngine::DirtyClipRegion \e or QPaintEngine::DirtyClipPath | - |
7822 | \li clipOperation() | - |
7823 | \row \li QPaintEngine::DirtyClipPath \li clipPath() | - |
7824 | \row \li QPaintEngine::DirtyClipRegion \li clipRegion() | - |
7825 | \row \li QPaintEngine::DirtyCompositionMode \li compositionMode() | - |
7826 | \row \li QPaintEngine::DirtyFont \li font() | - |
7827 | \row \li QPaintEngine::DirtyTransform \li transform() | - |
7828 | \row \li QPaintEngine::DirtyClipEnabled \li isClipEnabled() | - |
7829 | \row \li QPaintEngine::DirtyPen \li pen() | - |
7830 | \row \li QPaintEngine::DirtyHints \li renderHints() | - |
7831 | \endtable | - |
7832 | | - |
7833 | The QPaintEngineState class also provide the painter() function | - |
7834 | which returns a pointer to the painter that is currently updating | - |
7835 | the paint engine. | - |
7836 | | - |
7837 | An instance of this class, representing the current state of the | - |
7838 | active paint engine, is passed as argument to the | - |
7839 | QPaintEngine::updateState() function. The only situation in which | - |
7840 | you will have to use this class directly is when implementing your | - |
7841 | own paint engine. | - |
7842 | | - |
7843 | \sa QPaintEngine | - |
7844 | */ | - |
7845 | | - |
7846 | | - |
7847 | /*! | - |
7848 | \fn QPaintEngine::DirtyFlags QPaintEngineState::state() const | - |
7849 | | - |
7850 | Returns a combination of flags identifying the set of properties | - |
7851 | that need to be updated when updating the paint engine's state | - |
7852 | (i.e. during a call to the QPaintEngine::updateState() function). | - |
7853 | | - |
7854 | \sa QPaintEngine::updateState() | - |
7855 | */ | - |
7856 | | - |
7857 | | - |
7858 | /*! | - |
7859 | Returns the pen in the current paint engine state. | - |
7860 | | - |
7861 | This variable should only be used when the state() returns a | - |
7862 | combination which includes the QPaintEngine::DirtyPen flag. | - |
7863 | | - |
7864 | \sa state(), QPaintEngine::updateState() | - |
7865 | */ | - |
7866 | | - |
7867 | QPen QPaintEngineState::pen() const | - |
7868 | { | - |
7869 | return static_cast<const QPainterState *>(this)->pen; executed: return static_cast<const QPainterState *>(this)->pen; Execution Count:18 | 18 |
7870 | } | - |
7871 | | - |
7872 | /*! | - |
7873 | Returns the brush in the current paint engine state. | - |
7874 | | - |
7875 | This variable should only be used when the state() returns a | - |
7876 | combination which includes the QPaintEngine::DirtyBrush flag. | - |
7877 | | - |
7878 | \sa state(), QPaintEngine::updateState() | - |
7879 | */ | - |
7880 | | - |
7881 | QBrush QPaintEngineState::brush() const | - |
7882 | { | - |
7883 | return static_cast<const QPainterState *>(this)->brush; executed: return static_cast<const QPainterState *>(this)->brush; Execution Count:16 | 16 |
7884 | } | - |
7885 | | - |
7886 | /*! | - |
7887 | Returns the brush origin in the current paint engine state. | - |
7888 | | - |
7889 | This variable should only be used when the state() returns a | - |
7890 | combination which includes the QPaintEngine::DirtyBrushOrigin flag. | - |
7891 | | - |
7892 | \sa state(), QPaintEngine::updateState() | - |
7893 | */ | - |
7894 | | - |
7895 | QPointF QPaintEngineState::brushOrigin() const | - |
7896 | { | - |
7897 | return static_cast<const QPainterState *>(this)->brushOrigin; never executed: return static_cast<const QPainterState *>(this)->brushOrigin; | 0 |
7898 | } | - |
7899 | | - |
7900 | /*! | - |
7901 | Returns the background brush in the current paint engine state. | - |
7902 | | - |
7903 | This variable should only be used when the state() returns a | - |
7904 | combination which includes the QPaintEngine::DirtyBackground flag. | - |
7905 | | - |
7906 | \sa state(), QPaintEngine::updateState() | - |
7907 | */ | - |
7908 | | - |
7909 | QBrush QPaintEngineState::backgroundBrush() const | - |
7910 | { | - |
7911 | return static_cast<const QPainterState *>(this)->bgBrush; never executed: return static_cast<const QPainterState *>(this)->bgBrush; | 0 |
7912 | } | - |
7913 | | - |
7914 | /*! | - |
7915 | Returns the background mode in the current paint engine | - |
7916 | state. | - |
7917 | | - |
7918 | This variable should only be used when the state() returns a | - |
7919 | combination which includes the QPaintEngine::DirtyBackgroundMode flag. | - |
7920 | | - |
7921 | \sa state(), QPaintEngine::updateState() | - |
7922 | */ | - |
7923 | | - |
7924 | Qt::BGMode QPaintEngineState::backgroundMode() const | - |
7925 | { | - |
7926 | return static_cast<const QPainterState *>(this)->bgMode; never executed: return static_cast<const QPainterState *>(this)->bgMode; | 0 |
7927 | } | - |
7928 | | - |
7929 | /*! | - |
7930 | Returns the font in the current paint engine | - |
7931 | state. | - |
7932 | | - |
7933 | This variable should only be used when the state() returns a | - |
7934 | combination which includes the QPaintEngine::DirtyFont flag. | - |
7935 | | - |
7936 | \sa state(), QPaintEngine::updateState() | - |
7937 | */ | - |
7938 | | - |
7939 | QFont QPaintEngineState::font() const | - |
7940 | { | - |
7941 | return static_cast<const QPainterState *>(this)->font; never executed: return static_cast<const QPainterState *>(this)->font; | 0 |
7942 | } | - |
7943 | | - |
7944 | /*! | - |
7945 | \since 4.2 | - |
7946 | \obsolete | - |
7947 | | - |
7948 | Returns the matrix in the current paint engine | - |
7949 | state. | - |
7950 | | - |
7951 | \note It is advisable to use transform() instead of this function to | - |
7952 | preserve the properties of perspective transformations. | - |
7953 | | - |
7954 | This variable should only be used when the state() returns a | - |
7955 | combination which includes the QPaintEngine::DirtyTransform flag. | - |
7956 | | - |
7957 | \sa state(), QPaintEngine::updateState() | - |
7958 | */ | - |
7959 | | - |
7960 | QMatrix QPaintEngineState::matrix() const | - |
7961 | { | - |
7962 | const QPainterState *st = static_cast<const QPainterState *>(this); never executed (the execution status of this line is deduced): const QPainterState *st = static_cast<const QPainterState *>(this); | - |
7963 | | - |
7964 | return st->matrix.toAffine(); never executed: return st->matrix.toAffine(); | 0 |
7965 | } | - |
7966 | | - |
7967 | /*! | - |
7968 | \since 4.3 | - |
7969 | | - |
7970 | Returns the matrix in the current paint engine state. | - |
7971 | | - |
7972 | This variable should only be used when the state() returns a | - |
7973 | combination which includes the QPaintEngine::DirtyTransform flag. | - |
7974 | | - |
7975 | \sa state(), QPaintEngine::updateState() | - |
7976 | */ | - |
7977 | | - |
7978 | | - |
7979 | QTransform QPaintEngineState::transform() const | - |
7980 | { | - |
7981 | const QPainterState *st = static_cast<const QPainterState *>(this); executed (the execution status of this line is deduced): const QPainterState *st = static_cast<const QPainterState *>(this); | - |
7982 | | - |
7983 | return st->matrix; executed: return st->matrix; Execution Count:35 | 35 |
7984 | } | - |
7985 | | - |
7986 | | - |
7987 | /*! | - |
7988 | Returns the clip operation in the current paint engine | - |
7989 | state. | - |
7990 | | - |
7991 | This variable should only be used when the state() returns a | - |
7992 | combination which includes either the QPaintEngine::DirtyClipPath | - |
7993 | or the QPaintEngine::DirtyClipRegion flag. | - |
7994 | | - |
7995 | \sa state(), QPaintEngine::updateState() | - |
7996 | */ | - |
7997 | | - |
7998 | Qt::ClipOperation QPaintEngineState::clipOperation() const | - |
7999 | { | - |
8000 | return static_cast<const QPainterState *>(this)->clipOperation; never executed: return static_cast<const QPainterState *>(this)->clipOperation; | 0 |
8001 | } | - |
8002 | | - |
8003 | /*! | - |
8004 | \since 4.3 | - |
8005 | | - |
8006 | Returns whether the coordinate of the fill have been specified | - |
8007 | as bounded by the current rendering operation and have to be | - |
8008 | resolved (about the currently rendered primitive). | - |
8009 | */ | - |
8010 | bool QPaintEngineState::brushNeedsResolving() const | - |
8011 | { | - |
8012 | const QBrush &brush = static_cast<const QPainterState *>(this)->brush; executed (the execution status of this line is deduced): const QBrush &brush = static_cast<const QPainterState *>(this)->brush; | - |
8013 | return needsResolving(brush); executed: return needsResolving(brush); Execution Count:10 | 10 |
8014 | } | - |
8015 | | - |
8016 | | - |
8017 | /*! | - |
8018 | \since 4.3 | - |
8019 | | - |
8020 | Returns whether the coordinate of the stroke have been specified | - |
8021 | as bounded by the current rendering operation and have to be | - |
8022 | resolved (about the currently rendered primitive). | - |
8023 | */ | - |
8024 | bool QPaintEngineState::penNeedsResolving() const | - |
8025 | { | - |
8026 | const QPen &pen = static_cast<const QPainterState *>(this)->pen; executed (the execution status of this line is deduced): const QPen &pen = static_cast<const QPainterState *>(this)->pen; | - |
8027 | return needsResolving(pen.brush()); executed: return needsResolving(pen.brush()); Execution Count:10 | 10 |
8028 | } | - |
8029 | | - |
8030 | /*! | - |
8031 | Returns the clip region in the current paint engine state. | - |
8032 | | - |
8033 | This variable should only be used when the state() returns a | - |
8034 | combination which includes the QPaintEngine::DirtyClipRegion flag. | - |
8035 | | - |
8036 | \sa state(), QPaintEngine::updateState() | - |
8037 | */ | - |
8038 | | - |
8039 | QRegion QPaintEngineState::clipRegion() const | - |
8040 | { | - |
8041 | return static_cast<const QPainterState *>(this)->clipRegion; never executed: return static_cast<const QPainterState *>(this)->clipRegion; | 0 |
8042 | } | - |
8043 | | - |
8044 | /*! | - |
8045 | Returns the clip path in the current paint engine state. | - |
8046 | | - |
8047 | This variable should only be used when the state() returns a | - |
8048 | combination which includes the QPaintEngine::DirtyClipPath flag. | - |
8049 | | - |
8050 | \sa state(), QPaintEngine::updateState() | - |
8051 | */ | - |
8052 | | - |
8053 | QPainterPath QPaintEngineState::clipPath() const | - |
8054 | { | - |
8055 | return static_cast<const QPainterState *>(this)->clipPath; never executed: return static_cast<const QPainterState *>(this)->clipPath; | 0 |
8056 | } | - |
8057 | | - |
8058 | /*! | - |
8059 | Returns whether clipping is enabled or not in the current paint | - |
8060 | engine state. | - |
8061 | | - |
8062 | This variable should only be used when the state() returns a | - |
8063 | combination which includes the QPaintEngine::DirtyClipEnabled | - |
8064 | flag. | - |
8065 | | - |
8066 | \sa state(), QPaintEngine::updateState() | - |
8067 | */ | - |
8068 | | - |
8069 | bool QPaintEngineState::isClipEnabled() const | - |
8070 | { | - |
8071 | return static_cast<const QPainterState *>(this)->clipEnabled; never executed: return static_cast<const QPainterState *>(this)->clipEnabled; | 0 |
8072 | } | - |
8073 | | - |
8074 | /*! | - |
8075 | Returns the render hints in the current paint engine state. | - |
8076 | | - |
8077 | This variable should only be used when the state() returns a | - |
8078 | combination which includes the QPaintEngine::DirtyHints | - |
8079 | flag. | - |
8080 | | - |
8081 | \sa state(), QPaintEngine::updateState() | - |
8082 | */ | - |
8083 | | - |
8084 | QPainter::RenderHints QPaintEngineState::renderHints() const | - |
8085 | { | - |
8086 | return static_cast<const QPainterState *>(this)->renderHints; executed: return static_cast<const QPainterState *>(this)->renderHints; Execution Count:2 | 2 |
8087 | } | - |
8088 | | - |
8089 | /*! | - |
8090 | Returns the composition mode in the current paint engine state. | - |
8091 | | - |
8092 | This variable should only be used when the state() returns a | - |
8093 | combination which includes the QPaintEngine::DirtyCompositionMode | - |
8094 | flag. | - |
8095 | | - |
8096 | \sa state(), QPaintEngine::updateState() | - |
8097 | */ | - |
8098 | | - |
8099 | QPainter::CompositionMode QPaintEngineState::compositionMode() const | - |
8100 | { | - |
8101 | return static_cast<const QPainterState *>(this)->composition_mode; executed: return static_cast<const QPainterState *>(this)->composition_mode; Execution Count:471 | 471 |
8102 | } | - |
8103 | | - |
8104 | | - |
8105 | /*! | - |
8106 | Returns a pointer to the painter currently updating the paint | - |
8107 | engine. | - |
8108 | */ | - |
8109 | | - |
8110 | QPainter *QPaintEngineState::painter() const | - |
8111 | { | - |
8112 | return static_cast<const QPainterState *>(this)->painter; executed: return static_cast<const QPainterState *>(this)->painter; Execution Count:23092 | 23092 |
8113 | } | - |
8114 | | - |
8115 | | - |
8116 | /*! | - |
8117 | \since 4.2 | - |
8118 | | - |
8119 | Returns the opacity in the current paint engine state. | - |
8120 | */ | - |
8121 | | - |
8122 | qreal QPaintEngineState::opacity() const | - |
8123 | { | - |
8124 | return static_cast<const QPainterState *>(this)->opacity; never executed: return static_cast<const QPainterState *>(this)->opacity; | 0 |
8125 | } | - |
8126 | | - |
8127 | /*! | - |
8128 | \since 4.3 | - |
8129 | | - |
8130 | Sets the world transformation matrix. | - |
8131 | If \a combine is true, the specified \a transform is combined with | - |
8132 | the current matrix; otherwise it replaces the current matrix. | - |
8133 | | - |
8134 | \sa transform(), setWorldTransform() | - |
8135 | */ | - |
8136 | | - |
8137 | void QPainter::setTransform(const QTransform &transform, bool combine ) | - |
8138 | { | - |
8139 | setWorldTransform(transform, combine); executed (the execution status of this line is deduced): setWorldTransform(transform, combine); | - |
8140 | } executed: } Execution Count:47 | 47 |
8141 | | - |
8142 | /*! | - |
8143 | Returns the world transformation matrix. | - |
8144 | | - |
8145 | \sa worldTransform() | - |
8146 | */ | - |
8147 | | - |
8148 | const QTransform & QPainter::transform() const | - |
8149 | { | - |
8150 | return worldTransform(); executed: return worldTransform(); Execution Count:416 | 416 |
8151 | } | - |
8152 | | - |
8153 | | - |
8154 | /*! | - |
8155 | Returns the matrix that transforms from logical coordinates to | - |
8156 | device coordinates of the platform dependent paint device. | - |
8157 | | - |
8158 | This function is \e only needed when using platform painting | - |
8159 | commands on the platform dependent handle (Qt::HANDLE), and the | - |
8160 | platform does not do transformations nativly. | - |
8161 | | - |
8162 | The QPaintEngine::PaintEngineFeature enum can be queried to | - |
8163 | determine whether the platform performs the transformations or | - |
8164 | not. | - |
8165 | | - |
8166 | \sa worldTransform(), QPaintEngine::hasFeature(), | - |
8167 | */ | - |
8168 | | - |
8169 | const QTransform & QPainter::deviceTransform() const | - |
8170 | { | - |
8171 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
8172 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:1 | yes Evaluation Count:39 |
| 1-39 |
8173 | qWarning("QPainter::deviceTransform: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 8173, __PRETTY_FUNCTION__).warning("QPainter::deviceTransform: Painter not active"); | - |
8174 | return d->fakeState()->transform; executed: return d->fakeState()->transform; Execution Count:1 | 1 |
8175 | } | - |
8176 | return d->state->matrix; executed: return d->state->matrix; Execution Count:39 | 39 |
8177 | } | - |
8178 | | - |
8179 | | - |
8180 | /*! | - |
8181 | Resets any transformations that were made using translate(), | - |
8182 | scale(), shear(), rotate(), setWorldTransform(), setViewport() | - |
8183 | and setWindow(). | - |
8184 | | - |
8185 | \sa {Coordinate Transformations} | - |
8186 | */ | - |
8187 | | - |
8188 | void QPainter::resetTransform() | - |
8189 | { | - |
8190 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
8191 | #ifdef QT_DEBUG_DRAW | - |
8192 | if (qt_show_painter_debug_output) | - |
8193 | printf("QPainter::resetMatrix()\n"); | - |
8194 | #endif | - |
8195 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-9 |
8196 | qWarning("QPainter::resetMatrix: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 8196, __PRETTY_FUNCTION__).warning("QPainter::resetMatrix: Painter not active"); | - |
8197 | return; executed: return; Execution Count:2 | 2 |
8198 | } | - |
8199 | | - |
8200 | d->state->wx = d->state->wy = d->state->vx = d->state->vy = 0; // default view origins executed (the execution status of this line is deduced): d->state->wx = d->state->wy = d->state->vx = d->state->vy = 0; | - |
8201 | d->state->ww = d->state->vw = d->device->metric(QPaintDevice::PdmWidth); executed (the execution status of this line is deduced): d->state->ww = d->state->vw = d->device->metric(QPaintDevice::PdmWidth); | - |
8202 | d->state->wh = d->state->vh = d->device->metric(QPaintDevice::PdmHeight); executed (the execution status of this line is deduced): d->state->wh = d->state->vh = d->device->metric(QPaintDevice::PdmHeight); | - |
8203 | d->state->worldMatrix = QTransform(); executed (the execution status of this line is deduced): d->state->worldMatrix = QTransform(); | - |
8204 | setMatrixEnabled(false); executed (the execution status of this line is deduced): setMatrixEnabled(false); | - |
8205 | setViewTransformEnabled(false); executed (the execution status of this line is deduced): setViewTransformEnabled(false); | - |
8206 | if (d->extended) partially evaluated: d->extended yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
8207 | d->extended->transformChanged(); executed: d->extended->transformChanged(); Execution Count:9 | 9 |
8208 | else | - |
8209 | d->state->dirtyFlags |= QPaintEngine::DirtyTransform; never executed: d->state->dirtyFlags |= QPaintEngine::DirtyTransform; | 0 |
8210 | } | - |
8211 | | - |
8212 | /*! | - |
8213 | Sets the world transformation matrix. | - |
8214 | If \a combine is true, the specified \a matrix is combined with the current matrix; | - |
8215 | otherwise it replaces the current matrix. | - |
8216 | | - |
8217 | \sa transform(), setTransform() | - |
8218 | */ | - |
8219 | | - |
8220 | void QPainter::setWorldTransform(const QTransform &matrix, bool combine ) | - |
8221 | { | - |
8222 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
8223 | | - |
8224 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:3 | yes Evaluation Count:6829 |
| 3-6829 |
8225 | qWarning("QPainter::setWorldTransform: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 8225, __PRETTY_FUNCTION__).warning("QPainter::setWorldTransform: Painter not active"); | - |
8226 | return; executed: return; Execution Count:3 | 3 |
8227 | } | - |
8228 | | - |
8229 | if (combine) evaluated: combine yes Evaluation Count:20 | yes Evaluation Count:6809 |
| 20-6809 |
8230 | d->state->worldMatrix = matrix * d->state->worldMatrix; // combines executed: d->state->worldMatrix = matrix * d->state->worldMatrix; Execution Count:20 | 20 |
8231 | else | - |
8232 | d->state->worldMatrix = matrix; // set new matrix executed: d->state->worldMatrix = matrix; Execution Count:6809 | 6809 |
8233 | | - |
8234 | d->state->WxF = true; executed (the execution status of this line is deduced): d->state->WxF = true; | - |
8235 | d->updateMatrix(); executed (the execution status of this line is deduced): d->updateMatrix(); | - |
8236 | } executed: } Execution Count:6829 | 6829 |
8237 | | - |
8238 | /*! | - |
8239 | Returns the world transformation matrix. | - |
8240 | */ | - |
8241 | | - |
8242 | const QTransform & QPainter::worldTransform() const | - |
8243 | { | - |
8244 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
8245 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:2 | yes Evaluation Count:2716 |
| 2-2716 |
8246 | qWarning("QPainter::worldTransform: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 8246, __PRETTY_FUNCTION__).warning("QPainter::worldTransform: Painter not active"); | - |
8247 | return d->fakeState()->transform; executed: return d->fakeState()->transform; Execution Count:2 | 2 |
8248 | } | - |
8249 | return d->state->worldMatrix; executed: return d->state->worldMatrix; Execution Count:2716 | 2716 |
8250 | } | - |
8251 | | - |
8252 | /*! | - |
8253 | Returns the transformation matrix combining the current | - |
8254 | window/viewport and world transformation. | - |
8255 | | - |
8256 | \sa setWorldTransform(), setWindow(), setViewport() | - |
8257 | */ | - |
8258 | | - |
8259 | QTransform QPainter::combinedTransform() const | - |
8260 | { | - |
8261 | Q_D(const QPainter); executed (the execution status of this line is deduced): const QPainterPrivate * const d = d_func(); | - |
8262 | if (!d->engine) { evaluated: !d->engine yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
8263 | qWarning("QPainter::combinedTransform: Painter not active"); executed (the execution status of this line is deduced): QMessageLogger("painting/qpainter.cpp", 8263, __PRETTY_FUNCTION__).warning("QPainter::combinedTransform: Painter not active"); | - |
8264 | return QTransform(); executed: return QTransform(); Execution Count:2 | 2 |
8265 | } | - |
8266 | return d->state->worldMatrix * d->viewTransform() * d->hidpiScaleTransform(); executed: return d->state->worldMatrix * d->viewTransform() * d->hidpiScaleTransform(); Execution Count:3 | 3 |
8267 | } | - |
8268 | | - |
8269 | /*! | - |
8270 | \since 4.7 | - |
8271 | | - |
8272 | This function is used to draw \a pixmap, or a sub-rectangle of \a pixmap, | - |
8273 | at multiple positions with different scale, rotation and opacity. \a | - |
8274 | fragments is an array of \a fragmentCount elements specifying the | - |
8275 | parameters used to draw each pixmap fragment. The \a hints | - |
8276 | parameter can be used to pass in drawing hints. | - |
8277 | | - |
8278 | This function is potentially faster than multiple calls to drawPixmap(), | - |
8279 | since the backend can optimize state changes. | - |
8280 | | - |
8281 | \sa QPainter::PixmapFragment, QPainter::PixmapFragmentHint | - |
8282 | */ | - |
8283 | | - |
8284 | void QPainter::drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount, | - |
8285 | const QPixmap &pixmap, PixmapFragmentHints hints) | - |
8286 | { | - |
8287 | Q_D(QPainter); executed (the execution status of this line is deduced): QPainterPrivate * const d = d_func(); | - |
8288 | | - |
8289 | if (!d->engine || pixmap.isNull()) partially evaluated: !d->engine no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: pixmap.isNull() no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
8290 | return; | 0 |
8291 | | - |
8292 | #ifndef QT_NO_DEBUG | - |
8293 | for (int i = 0; i < fragmentCount; ++i) { | - |
8294 | QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, | - |
8295 | fragments[i].width, fragments[i].height); | - |
8296 | if (!(QRectF(pixmap.rect()).contains(sourceRect))) | - |
8297 | qWarning("QPainter::drawPixmapFragments - the source rect is not contained by the pixmap's rectangle"); | - |
8298 | } | - |
8299 | #endif | - |
8300 | | - |
8301 | if (d->engine->isExtended()) { partially evaluated: d->engine->isExtended() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
8302 | d->extended->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); executed (the execution status of this line is deduced): d->extended->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); | - |
8303 | } else { executed: } Execution Count:3 | 3 |
8304 | qreal oldOpacity = opacity(); never executed (the execution status of this line is deduced): qreal oldOpacity = opacity(); | - |
8305 | QTransform oldTransform = transform(); never executed (the execution status of this line is deduced): QTransform oldTransform = transform(); | - |
8306 | | - |
8307 | for (int i = 0; i < fragmentCount; ++i) { never evaluated: i < fragmentCount | 0 |
8308 | QTransform transform = oldTransform; never executed (the execution status of this line is deduced): QTransform transform = oldTransform; | - |
8309 | qreal xOffset = 0; never executed (the execution status of this line is deduced): qreal xOffset = 0; | - |
8310 | qreal yOffset = 0; never executed (the execution status of this line is deduced): qreal yOffset = 0; | - |
8311 | if (fragments[i].rotation == 0) { never evaluated: fragments[i].rotation == 0 | 0 |
8312 | xOffset = fragments[i].x; never executed (the execution status of this line is deduced): xOffset = fragments[i].x; | - |
8313 | yOffset = fragments[i].y; never executed (the execution status of this line is deduced): yOffset = fragments[i].y; | - |
8314 | } else { | 0 |
8315 | transform.translate(fragments[i].x, fragments[i].y); never executed (the execution status of this line is deduced): transform.translate(fragments[i].x, fragments[i].y); | - |
8316 | transform.rotate(fragments[i].rotation); never executed (the execution status of this line is deduced): transform.rotate(fragments[i].rotation); | - |
8317 | } | 0 |
8318 | setOpacity(oldOpacity * fragments[i].opacity); never executed (the execution status of this line is deduced): setOpacity(oldOpacity * fragments[i].opacity); | - |
8319 | setTransform(transform); never executed (the execution status of this line is deduced): setTransform(transform); | - |
8320 | | - |
8321 | qreal w = fragments[i].scaleX * fragments[i].width; never executed (the execution status of this line is deduced): qreal w = fragments[i].scaleX * fragments[i].width; | - |
8322 | qreal h = fragments[i].scaleY * fragments[i].height; never executed (the execution status of this line is deduced): qreal h = fragments[i].scaleY * fragments[i].height; | - |
8323 | QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, never executed (the execution status of this line is deduced): QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, | - |
8324 | fragments[i].width, fragments[i].height); never executed (the execution status of this line is deduced): fragments[i].width, fragments[i].height); | - |
8325 | drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, sourceRect); never executed (the execution status of this line is deduced): drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, sourceRect); | - |
8326 | } | 0 |
8327 | | - |
8328 | setOpacity(oldOpacity); never executed (the execution status of this line is deduced): setOpacity(oldOpacity); | - |
8329 | setTransform(oldTransform); never executed (the execution status of this line is deduced): setTransform(oldTransform); | - |
8330 | } | 0 |
8331 | } | - |
8332 | | - |
8333 | /*! | - |
8334 | \since 4.7 | - |
8335 | \class QPainter::PixmapFragment | - |
8336 | \inmodule QtGui | - |
8337 | | - |
8338 | \brief This class is used in conjunction with the | - |
8339 | QPainter::drawPixmapFragments() function to specify how a pixmap, or | - |
8340 | sub-rect of a pixmap, is drawn. | - |
8341 | | - |
8342 | The \a sourceLeft, \a sourceTop, \a width and \a height variables are used | - |
8343 | as a source rectangle within the pixmap passed into the | - |
8344 | QPainter::drawPixmapFragments() function. The variables \a x, \a y, \a | - |
8345 | width and \a height are used to calculate the target rectangle that is | - |
8346 | drawn. \a x and \a y denotes the center of the target rectangle. The \a | - |
8347 | width and \a height in the target rectangle is scaled by the \a scaleX and | - |
8348 | \a scaleY values. The resulting target rectangle is then rotated \a | - |
8349 | rotation degrees around the \a x, \a y center point. | - |
8350 | | - |
8351 | \sa QPainter::drawPixmapFragments() | - |
8352 | */ | - |
8353 | | - |
8354 | /*! | - |
8355 | \since 4.7 | - |
8356 | | - |
8357 | This is a convenience function that returns a QPainter::PixmapFragment that is | - |
8358 | initialized with the \a pos, \a sourceRect, \a scaleX, \a scaleY, \a | - |
8359 | rotation, \a opacity parameters. | - |
8360 | */ | - |
8361 | | - |
8362 | QPainter::PixmapFragment QPainter::PixmapFragment::create(const QPointF &pos, const QRectF &sourceRect, | - |
8363 | qreal scaleX, qreal scaleY, qreal rotation, | - |
8364 | qreal opacity) | - |
8365 | { | - |
8366 | PixmapFragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(), executed (the execution status of this line is deduced): PixmapFragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(), | - |
8367 | sourceRect.height(), scaleX, scaleY, rotation, opacity}; executed (the execution status of this line is deduced): sourceRect.height(), scaleX, scaleY, rotation, opacity}; | - |
8368 | return fragment; executed: return fragment; Execution Count:1 | 1 |
8369 | } | - |
8370 | | - |
8371 | /*! | - |
8372 | \variable QPainter::PixmapFragment::x | - |
8373 | \brief the x coordinate of center point in the target rectangle. | - |
8374 | */ | - |
8375 | | - |
8376 | /*! | - |
8377 | \variable QPainter::PixmapFragment::y | - |
8378 | \brief the y coordinate of the center point in the target rectangle. | - |
8379 | */ | - |
8380 | | - |
8381 | /*! | - |
8382 | \variable QPainter::PixmapFragment::sourceLeft | - |
8383 | \brief the left coordinate of the source rectangle. | - |
8384 | */ | - |
8385 | | - |
8386 | /*! | - |
8387 | \variable QPainter::PixmapFragment::sourceTop | - |
8388 | \brief the top coordinate of the source rectangle. | - |
8389 | */ | - |
8390 | | - |
8391 | /*! | - |
8392 | \variable QPainter::PixmapFragment::width | - |
8393 | | - |
8394 | \brief the width of the source rectangle and is used to calculate the width | - |
8395 | of the target rectangle. | - |
8396 | */ | - |
8397 | | - |
8398 | /*! | - |
8399 | \variable QPainter::PixmapFragment::height | - |
8400 | | - |
8401 | \brief the height of the source rectangle and is used to calculate the | - |
8402 | height of the target rectangle. | - |
8403 | */ | - |
8404 | | - |
8405 | /*! | - |
8406 | \variable QPainter::PixmapFragment::scaleX | - |
8407 | \brief the horizontal scale of the target rectangle. | - |
8408 | */ | - |
8409 | | - |
8410 | /*! | - |
8411 | \variable QPainter::PixmapFragment::scaleY | - |
8412 | \brief the vertical scale of the target rectangle. | - |
8413 | */ | - |
8414 | | - |
8415 | /*! | - |
8416 | \variable QPainter::PixmapFragment::rotation | - |
8417 | | - |
8418 | \brief the rotation of the target rectangle in degrees. The target | - |
8419 | rectangle is rotated after it has been scaled. | - |
8420 | */ | - |
8421 | | - |
8422 | /*! | - |
8423 | \variable QPainter::PixmapFragment::opacity | - |
8424 | | - |
8425 | \brief the opacity of the target rectangle, where 0.0 is fully transparent | - |
8426 | and 1.0 is fully opaque. | - |
8427 | */ | - |
8428 | | - |
8429 | /*! | - |
8430 | \since 4.7 | - |
8431 | | - |
8432 | \enum QPainter::PixmapFragmentHint | - |
8433 | | - |
8434 | \value OpaqueHint Indicates that the pixmap fragments to be drawn are | - |
8435 | opaque. Opaque fragments are potentially faster to draw. | - |
8436 | | - |
8437 | \sa QPainter::drawPixmapFragments(), QPainter::PixmapFragment | - |
8438 | */ | - |
8439 | | - |
8440 | void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation) | - |
8441 | { | - |
8442 | p->draw_helper(path, operation); never executed (the execution status of this line is deduced): p->draw_helper(path, operation); | - |
8443 | } | 0 |
8444 | | - |
8445 | QT_END_NAMESPACE | - |
8446 | | - |
| | |