qpainter.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qpainter.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40// QtCore-
41#include <qdebug.h>-
42#include <qmath.h>-
43#include <qmutex.h>-
44-
45// QtGui-
46#include "qbitmap.h"-
47#include "qimage.h"-
48#include "qpaintdevice.h"-
49#include "qpaintengine.h"-
50#include "qpainter.h"-
51#include "qpainter_p.h"-
52#include "qpainterpath.h"-
53#include "qpicture.h"-
54#include "qpixmapcache.h"-
55#include "qpolygon.h"-
56#include "qtextlayout.h"-
57#include "qthread.h"-
58#include "qvarlengtharray.h"-
59#include "qstatictext.h"-
60#include "qglyphrun.h"-
61-
62#include <qpa/qplatformtheme.h>-
63#include <qpa/qplatformintegration.h>-
64-
65#include <private/qfontengine_p.h>-
66#include <private/qpaintengine_p.h>-
67#include <private/qemulationpaintengine_p.h>-
68#include <private/qpainterpath_p.h>-
69#include <private/qtextengine_p.h>-
70#include <private/qpaintengine_raster_p.h>-
71#include <private/qmath_p.h>-
72#include <private/qstatictext_p.h>-
73#include <private/qglyphrun_p.h>-
74#include <private/qhexstring_p.h>-
75#include <private/qguiapplication_p.h>-
76#include <private/qrawfont_p.h>-
77-
78QT_BEGIN_NAMESPACE-
79-
80#define QGradient_StretchToDevice 0x10000000-
81#define QPaintEngine_OpaqueBackground 0x40000000-
82-
83// #define QT_DEBUG_DRAW-
84#ifdef QT_DEBUG_DRAW-
85bool qt_show_painter_debug_output = true;-
86#endif-
87-
88extern QPixmap qt_pixmapForBrush(int style, bool invert);-
89-
90void qt_format_text(const QFont &font,-
91 const QRectF &_r, int tf, const QTextOption *option, const QString& str, QRectF *brect,-
92 int tabstops, int* tabarray, int tabarraylen,-
93 QPainter *painter);-
94static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextEngine *textEngine,-
95 QTextCharFormat::UnderlineStyle underlineStyle,-
96 QTextItem::RenderFlags flags, qreal width,-
97 const QTextCharFormat &charFormat);-
98// Helper function to calculate left most position, width and flags for decoration drawing-
99Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray,-
100 const QFixedPoint *positions, int glyphCount,-
101 QFontEngine *fontEngine, const QFont &font,-
102 const QTextCharFormat &charFormat);-
103-
104static inline QGradient::CoordinateMode coordinateMode(const QBrush &brush)-
105{-
106 switch (brush.style()) {-
107 case Qt::LinearGradientPattern:
never executed: case Qt::LinearGradientPattern:
0
108 case Qt::RadialGradientPattern:
never executed: case Qt::RadialGradientPattern:
0
109 case Qt::ConicalGradientPattern:
never executed: case Qt::ConicalGradientPattern:
0
110 return brush.gradient()->coordinateMode();
never executed: return brush.gradient()->coordinateMode();
0
111 default:
never executed: default:
0
112 ;-
113 }
never executed: end of block
0
114 return QGradient::LogicalMode;
never executed: return QGradient::LogicalMode;
0
115}-
116-
117extern bool qHasPixmapTexture(const QBrush &);-
118-
119static inline bool is_brush_transparent(const QBrush &brush) {-
120 Qt::BrushStyle s = brush.style();-
121 if (s != Qt::TexturePattern)
s != Qt::TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
122 return s >= Qt::Dense1Pattern && s <= Qt::DiagCrossPattern;
never executed: return s >= Qt::Dense1Pattern && s <= Qt::DiagCrossPattern;
0
123 if (qHasPixmapTexture(brush))
qHasPixmapTexture(brush)Description
TRUEnever evaluated
FALSEnever evaluated
0
124 return brush.texture().isQBitmap() || brush.texture().hasAlphaChannel();
never executed: return brush.texture().isQBitmap() || brush.texture().hasAlphaChannel();
0
125 else {-
126 const QImage texture = brush.textureImage();-
127 return texture.hasAlphaChannel() || (texture.depth() == 1 && texture.colorCount() == 0);
never executed: return texture.hasAlphaChannel() || (texture.depth() == 1 && texture.colorCount() == 0);
0
128 }-
129}-
130-
131static inline bool is_pen_transparent(const QPen &pen) {-
132 return pen.style() > Qt::SolidLine || is_brush_transparent(pen.brush());
never executed: return pen.style() > Qt::SolidLine || is_brush_transparent(pen.brush());
0
133}-
134-
135/* Discards the emulation flags that are not relevant for line drawing-
136 and returns the result-
137*/-
138static inline uint line_emulation(uint emulation)-
139{-
140 return emulation & (QPaintEngine::PrimitiveTransform
never executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000);
0
141 | QPaintEngine::AlphaBlend
never executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000);
0
142 | QPaintEngine::Antialiasing
never executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000);
0
143 | QPaintEngine::BrushStroke
never executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000);
0
144 | QPaintEngine::ConstantOpacity
never executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000);
0
145 | QGradient_StretchToDevice
never executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000);
0
146 | QPaintEngine::ObjectBoundingModeGradients
never executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000);
0
147 | QPaintEngine_OpaqueBackground);
never executed: return emulation & (QPaintEngine::PrimitiveTransform | QPaintEngine::AlphaBlend | QPaintEngine::Antialiasing | QPaintEngine::BrushStroke | QPaintEngine::ConstantOpacity | 0x10000000 | QPaintEngine::ObjectBoundingModeGradients | 0x40000000);
0
148}-
149-
150#ifndef QT_NO_DEBUG-
151static bool qt_painter_thread_test(int devType, int engineType, const char *what)-
152{-
153 const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();-
154 switch (devType) {-
155 case QInternal::Image:
never executed: case QInternal::Image:
0
156 case QInternal::Printer:
never executed: case QInternal::Printer:
0
157 case QInternal::Picture:
never executed: case QInternal::Picture:
0
158 // can be drawn onto these devices safely from any thread-
159 break;
never executed: break;
0
160 default:
never executed: default:
0
161 if (QThread::currentThread() != qApp->thread()
QThread::curre...()))->thread()Description
TRUEnever evaluated
FALSEnever evaluated
0
162 // pixmaps cannot be targets unless threaded pixmaps are supported-
163 && (devType != QInternal::Pixmap || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedPixmaps))
devType != QInternal::PixmapDescription
TRUEnever evaluated
FALSEnever evaluated
!platformInteg...readedPixmaps)Description
TRUEnever evaluated
FALSEnever evaluated
0
164 // framebuffer objects and such cannot be targets unless threaded GL is supported-
165 && (devType != QInternal::OpenGL || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedOpenGL))
devType != QInternal::OpenGLDescription
TRUEnever evaluated
FALSEnever evaluated
!platformInteg...hreadedOpenGL)Description
TRUEnever evaluated
FALSEnever evaluated
0
166 // widgets cannot be targets except for QGLWidget-
167 && (devType != QInternal::Widget || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedOpenGL)
devType != QInternal::WidgetDescription
TRUEnever evaluated
FALSEnever evaluated
!platformInteg...hreadedOpenGL)Description
TRUEnever evaluated
FALSEnever evaluated
0
168 || (engineType != QPaintEngine::OpenGL && engineType != QPaintEngine::OpenGL2))) {
engineType != ...Engine::OpenGLDescription
TRUEnever evaluated
FALSEnever evaluated
engineType != ...ngine::OpenGL2Description
TRUEnever evaluated
FALSEnever evaluated
0
169 qWarning("QPainter: It is not safe to use %s outside the GUI thread", what);-
170 return false;
never executed: return false;
0
171 }-
172 break;
never executed: break;
0
173 }-
174 return true;
never executed: return true;
0
175}-
176#endif-
177-
178void QPainterPrivate::checkEmulation()-
179{-
180 Q_ASSERT(extended);-
181 bool doEmulation = false;-
182 if (state->bgMode == Qt::OpaqueMode)
state->bgMode ...Qt::OpaqueModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
183 doEmulation = true;
never executed: doEmulation = true;
0
184-
185 const QGradient *bg = state->brush.gradient();-
186 if (bg && bg->coordinateMode() > QGradient::LogicalMode)
bgDescription
TRUEnever evaluated
FALSEnever evaluated
bg->coordinate...t::LogicalModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
187 doEmulation = true;
never executed: doEmulation = true;
0
188-
189 const QGradient *pg = qpen_brush(state->pen).gradient();-
190 if (pg && pg->coordinateMode() > QGradient::LogicalMode)
pgDescription
TRUEnever evaluated
FALSEnever evaluated
pg->coordinate...t::LogicalModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
191 doEmulation = true;
never executed: doEmulation = true;
0
192-
193 if (doEmulation && extended->flags() & QPaintEngineEx::DoNotEmulate)
doEmulationDescription
TRUEnever evaluated
FALSEnever evaluated
extended->flag...::DoNotEmulateDescription
TRUEnever evaluated
FALSEnever evaluated
0
194 return;
never executed: return;
0
195-
196 if (doEmulation) {
doEmulationDescription
TRUEnever evaluated
FALSEnever evaluated
0
197 if (extended != emulationEngine) {
extended != emulationEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
198 if (!emulationEngine)
!emulationEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
199 emulationEngine = new QEmulationPaintEngine(extended);
never executed: emulationEngine = new QEmulationPaintEngine(extended);
0
200 extended = emulationEngine;-
201 extended->setState(state);-
202 }
never executed: end of block
0
203 } else if (emulationEngine == extended) {
never executed: end of block
emulationEngine == extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
204 extended = emulationEngine->real_engine;-
205 }
never executed: end of block
0
206}
never executed: end of block
0
207-
208-
209QPainterPrivate::~QPainterPrivate()-
210{-
211 delete emulationEngine;-
212 qDeleteAll(states);-
213 delete dummyState;-
214}
never executed: end of block
0
215-
216-
217QTransform QPainterPrivate::viewTransform() const-
218{-
219 if (state->VxF) {
state->VxFDescription
TRUEnever evaluated
FALSEnever evaluated
0
220 qreal scaleW = qreal(state->vw)/qreal(state->ww);-
221 qreal scaleH = qreal(state->vh)/qreal(state->wh);-
222 return QTransform(scaleW, 0, 0, scaleH,
never executed: return QTransform(scaleW, 0, 0, scaleH, state->vx - state->wx*scaleW, state->vy - state->wy*scaleH);
0
223 state->vx - state->wx*scaleW, state->vy - state->wy*scaleH);
never executed: return QTransform(scaleW, 0, 0, scaleH, state->vx - state->wx*scaleW, state->vy - state->wy*scaleH);
0
224 }-
225 return QTransform();
never executed: return QTransform();
0
226}-
227-
228qreal QPainterPrivate::effectiveDevicePixelRatio() const-
229{-
230 // Special cases for devices that does not support PdmDevicePixelRatio go here:-
231 if (device->devType() == QInternal::Printer)
device->devTyp...ernal::PrinterDescription
TRUEnever evaluated
FALSEnever evaluated
0
232 return qreal(1);
never executed: return qreal(1);
0
233-
234 return qMax(qreal(1), device->devicePixelRatioF());
never executed: return qMax(qreal(1), device->devicePixelRatioF());
0
235}-
236-
237QTransform QPainterPrivate::hidpiScaleTransform() const-
238{-
239 const qreal devicePixelRatio = effectiveDevicePixelRatio();-
240 return QTransform::fromScale(devicePixelRatio, devicePixelRatio);
never executed: return QTransform::fromScale(devicePixelRatio, devicePixelRatio);
0
241}-
242-
243/*-
244 \internal-
245 Returns \c true if using a shared painter; otherwise false.-
246*/-
247bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)-
248{-
249 Q_ASSERT(q);-
250 Q_ASSERT(pdev);-
251-
252 QPainter *sp = pdev->sharedPainter();-
253 if (!sp)
!spDescription
TRUEnever evaluated
FALSEnever evaluated
0
254 return false;
never executed: return false;
0
255-
256 // Save the current state of the shared painter and assign-
257 // the current d_ptr to the shared painter's d_ptr.-
258 sp->save();-
259 if (!sp->d_ptr->d_ptrs) {
!sp->d_ptr->d_ptrsDescription
TRUEnever evaluated
FALSEnever evaluated
0
260 // Allocate space for 4 d-pointers (enough for up to 4 sub-sequent-
261 // redirections within the same paintEvent(), which should be enough-
262 // in 99% of all cases). E.g: A renders B which renders C which renders D.-
263 sp->d_ptr->d_ptrs_size = 4;-
264 sp->d_ptr->d_ptrs = (QPainterPrivate **)malloc(4 * sizeof(QPainterPrivate *));-
265 Q_CHECK_PTR(sp->d_ptr->d_ptrs);
never executed: qt_check_pointer(__FILE__,265);
!(sp->d_ptr->d_ptrs)Description
TRUEnever evaluated
FALSEnever evaluated
0
266 } else if (sp->d_ptr->refcount - 1 == sp->d_ptr->d_ptrs_size) {
never executed: end of block
sp->d_ptr->ref...r->d_ptrs_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
267 // However, to support corner cases we grow the array dynamically if needed.-
268 sp->d_ptr->d_ptrs_size <<= 1;-
269 const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *);-
270 sp->d_ptr->d_ptrs = q_check_ptr((QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize));-
271 }
never executed: end of block
0
272 sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data();-
273 q->d_ptr.take();-
274 q->d_ptr.reset(sp->d_ptr.data());-
275-
276 Q_ASSERT(q->d_ptr->state);-
277-
278 // Now initialize the painter with correct widget properties.-
279 q->initFrom(pdev);-
280 QPoint offset;-
281 pdev->redirected(&offset);-
282 offset += q->d_ptr->engine->coordinateOffset();-
283-
284 // Update system rect.-
285 q->d_ptr->state->ww = q->d_ptr->state->vw = pdev->width();-
286 q->d_ptr->state->wh = q->d_ptr->state->vh = pdev->height();-
287-
288 // Update matrix.-
289 if (q->d_ptr->state->WxF) {
q->d_ptr->state->WxFDescription
TRUEnever evaluated
FALSEnever evaluated
0
290 q->d_ptr->state->redirectionMatrix = q->d_ptr->state->matrix;-
291 q->d_ptr->state->redirectionMatrix *= q->d_ptr->hidpiScaleTransform().inverted();-
292 q->d_ptr->state->redirectionMatrix.translate(-offset.x(), -offset.y());-
293 q->d_ptr->state->worldMatrix = QTransform();-
294 q->d_ptr->state->WxF = false;-
295 } else {
never executed: end of block
0
296 q->d_ptr->state->redirectionMatrix = QTransform::fromTranslate(-offset.x(), -offset.y());-
297 }
never executed: end of block
0
298 q->d_ptr->updateMatrix();-
299-
300 QPaintEnginePrivate *enginePrivate = q->d_ptr->engine->d_func();-
301 if (enginePrivate->currentClipDevice == pdev) {
enginePrivate-...Device == pdevDescription
TRUEnever evaluated
FALSEnever evaluated
0
302 enginePrivate->systemStateChanged();-
303 return true;
never executed: return true;
0
304 }-
305-
306 // Update system transform and clip.-
307 enginePrivate->currentClipDevice = pdev;-
308 enginePrivate->setSystemTransform(q->d_ptr->state->matrix);-
309 return true;
never executed: return true;
0
310}-
311-
312void QPainterPrivate::detachPainterPrivate(QPainter *q)-
313{-
314 Q_ASSERT(refcount > 1);-
315 Q_ASSERT(q);-
316-
317 QPainterPrivate *original = d_ptrs[--refcount - 1];-
318 if (inDestructor) {
inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
319 inDestructor = false;-
320 if (original)
originalDescription
TRUEnever evaluated
FALSEnever evaluated
0
321 original->inDestructor = true;
never executed: original->inDestructor = true;
0
322 } else if (!original) {
never executed: end of block
!originalDescription
TRUEnever evaluated
FALSEnever evaluated
0
323 original = new QPainterPrivate(q);-
324 }
never executed: end of block
0
325-
326 d_ptrs[refcount - 1] = 0;-
327 q->restore();-
328 q->d_ptr.take();-
329 q->d_ptr.reset(original);-
330-
331 if (emulationEngine) {
emulationEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
332 extended = emulationEngine->real_engine;-
333 delete emulationEngine;-
334 emulationEngine = 0;-
335 }
never executed: end of block
0
336}
never executed: end of block
0
337-
338-
339void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperation op)-
340{-
341#ifdef QT_DEBUG_DRAW-
342 if (qt_show_painter_debug_output) {-
343 printf("QPainter::drawHelper\n");-
344 }-
345#endif-
346-
347 if (originalPath.isEmpty())
originalPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
348 return;
never executed: return;
0
349-
350 QPaintEngine::PaintEngineFeatures gradientStretch =-
351 QPaintEngine::PaintEngineFeatures(QGradient_StretchToDevice-
352 | QPaintEngine::ObjectBoundingModeGradients);-
353-
354 const bool mustEmulateObjectBoundingModeGradients = extended
extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
355 || ((state->emulationSpecifier & QPaintEngine::ObjectBoundingModeGradients)
(state->emulat...ModeGradients)Description
TRUEnever evaluated
FALSEnever evaluated
0
356 && !engine->hasFeature(QPaintEngine::PatternTransform));
!engine->hasFe...ternTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
357-
358 if (!(state->emulationSpecifier & ~gradientStretch)
!(state->emula...adientStretch)Description
TRUEnever evaluated
FALSEnever evaluated
0
359 && !mustEmulateObjectBoundingModeGradients) {
!mustEmulateOb...gModeGradientsDescription
TRUEnever evaluated
FALSEnever evaluated
0
360 drawStretchedGradient(originalPath, op);-
361 return;
never executed: return;
0
362 } else if (state->emulationSpecifier & QPaintEngine_OpaqueBackground) {
state->emulati...r & 0x40000000Description
TRUEnever evaluated
FALSEnever evaluated
0
363 drawOpaqueBackground(originalPath, op);-
364 return;
never executed: return;
0
365 }-
366-
367 Q_Q(QPainter);-
368-
369 qreal strokeOffsetX = 0, strokeOffsetY = 0;-
370-
371 QPainterPath path = originalPath * state->matrix;-
372 QRectF pathBounds = path.boundingRect();-
373 QRectF strokeBounds;-
374 bool doStroke = (op & StrokeDraw) && (state->pen.style() != Qt::NoPen);
(op & StrokeDraw)Description
TRUEnever evaluated
FALSEnever evaluated
(state->pen.st... != Qt::NoPen)Description
TRUEnever evaluated
FALSEnever evaluated
0
375 if (doStroke) {
doStrokeDescription
TRUEnever evaluated
FALSEnever evaluated
0
376 qreal penWidth = state->pen.widthF();-
377 if (penWidth == 0) {
penWidth == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
378 strokeOffsetX = 1;-
379 strokeOffsetY = 1;-
380 } else {
never executed: end of block
0
381 // In case of complex xform-
382 if (state->matrix.type() > QTransform::TxScale) {
state->matrix....sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
383 QPainterPathStroker stroker;-
384 stroker.setWidth(penWidth);-
385 stroker.setJoinStyle(state->pen.joinStyle());-
386 stroker.setCapStyle(state->pen.capStyle());-
387 QPainterPath stroke = stroker.createStroke(originalPath);-
388 strokeBounds = (stroke * state->matrix).boundingRect();-
389 } else {
never executed: end of block
0
390 strokeOffsetX = qAbs(penWidth * state->matrix.m11() / 2.0);-
391 strokeOffsetY = qAbs(penWidth * state->matrix.m22() / 2.0);-
392 }
never executed: end of block
0
393 }-
394 }-
395-
396 QRect absPathRect;-
397 if (!strokeBounds.isEmpty()) {
!strokeBounds.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
398 absPathRect = strokeBounds.intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect();-
399 } else {
never executed: end of block
0
400 absPathRect = pathBounds.adjusted(-strokeOffsetX, -strokeOffsetY, strokeOffsetX, strokeOffsetY)-
401 .intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect();-
402 }
never executed: end of block
0
403-
404 if (q->hasClipping()) {
q->hasClipping()Description
TRUEnever evaluated
FALSEnever evaluated
0
405 bool hasPerspectiveTransform = false;-
406 for (const QPainterClipInfo &info : qAsConst(state->clipInfo)) {-
407 if (info.matrix.type() == QTransform::TxProject) {
info.matrix.ty...orm::TxProjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
408 hasPerspectiveTransform = true;-
409 break;
never executed: break;
0
410 }-
411 }
never executed: end of block
0
412 // avoid mapping QRegions with perspective transforms-
413 if (!hasPerspectiveTransform) {
!hasPerspectiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
414 // The trick with txinv and invMatrix is done in order to-
415 // avoid transforming the clip to logical coordinates, and-
416 // then back to device coordinates. This is a problem with-
417 // QRegion/QRect based clips, since they use integer-
418 // coordinates and converting to/from logical coordinates will-
419 // lose precision.-
420 bool old_txinv = txinv;-
421 QTransform old_invMatrix = invMatrix;-
422 txinv = true;-
423 invMatrix = QTransform();-
424 QPainterPath clipPath = q->clipPath();-
425 QRectF r = clipPath.boundingRect().intersected(absPathRect);-
426 absPathRect = r.toAlignedRect();-
427 txinv = old_txinv;-
428 invMatrix = old_invMatrix;-
429 }
never executed: end of block
0
430 }
never executed: end of block
0
431-
432// qDebug("\nQPainterPrivate::draw_helper(), x=%d, y=%d, w=%d, h=%d",-
433// devMinX, devMinY, device->width(), device->height());-
434// qDebug() << " - matrix" << state->matrix;-
435// qDebug() << " - originalPath.bounds" << originalPath.boundingRect();-
436// qDebug() << " - path.bounds" << path.boundingRect();-
437-
438 if (absPathRect.width() <= 0 || absPathRect.height() <= 0)
absPathRect.width() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
absPathRect.height() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
439 return;
never executed: return;
0
440-
441 QImage image(absPathRect.width(), absPathRect.height(), QImage::Format_ARGB32_Premultiplied);-
442 image.fill(0);-
443-
444 QPainter p(&image);-
445-
446 p.d_ptr->helper_device = helper_device;-
447-
448 p.setOpacity(state->opacity);-
449 p.translate(-absPathRect.x(), -absPathRect.y());-
450 p.setTransform(state->matrix, true);-
451 p.setPen(doStroke ? state->pen : QPen(Qt::NoPen));-
452 p.setBrush((op & FillDraw) ? state->brush : QBrush(Qt::NoBrush));-
453 p.setBackground(state->bgBrush);-
454 p.setBackgroundMode(state->bgMode);-
455 p.setBrushOrigin(state->brushOrigin);-
456-
457 p.setRenderHint(QPainter::Antialiasing, state->renderHints & QPainter::Antialiasing);-
458 p.setRenderHint(QPainter::SmoothPixmapTransform,-
459 state->renderHints & QPainter::SmoothPixmapTransform);-
460-
461 p.drawPath(originalPath);-
462-
463#ifndef QT_NO_DEBUG-
464 static bool do_fallback_overlay = !qEnvironmentVariableIsEmpty("QT_PAINT_FALLBACK_OVERLAY");-
465 if (do_fallback_overlay) {
do_fallback_overlayDescription
TRUEnever evaluated
FALSEnever evaluated
0
466 QImage block(8, 8, QImage::Format_ARGB32_Premultiplied);-
467 QPainter pt(&block);-
468 pt.fillRect(0, 0, 8, 8, QColor(196, 0, 196));-
469 pt.drawLine(0, 0, 8, 8);-
470 pt.end();-
471 p.resetTransform();-
472 p.setCompositionMode(QPainter::CompositionMode_SourceAtop);-
473 p.setOpacity(0.5);-
474 p.fillRect(0, 0, image.width(), image.height(), QBrush(block));-
475 }
never executed: end of block
0
476#endif-
477-
478 p.end();-
479-
480 q->save();-
481 state->matrix = QTransform();-
482 if (extended) {
extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
483 extended->transformChanged();-
484 } else {
never executed: end of block
0
485 state->dirtyFlags |= QPaintEngine::DirtyTransform;-
486 updateState(state);-
487 }
never executed: end of block
0
488 engine->drawImage(absPathRect,-
489 image,-
490 QRectF(0, 0, absPathRect.width(), absPathRect.height()),-
491 Qt::OrderedDither | Qt::OrderedAlphaDither);-
492 q->restore();-
493}
never executed: end of block
0
494-
495void QPainterPrivate::drawOpaqueBackground(const QPainterPath &path, DrawOperation op)-
496{-
497 Q_Q(QPainter);-
498-
499 q->setBackgroundMode(Qt::TransparentMode);-
500-
501 if (op & FillDraw && state->brush.style() != Qt::NoBrush) {
op & FillDrawDescription
TRUEnever evaluated
FALSEnever evaluated
state->brush.s...!= Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
502 q->fillPath(path, state->bgBrush.color());-
503 q->fillPath(path, state->brush);-
504 }
never executed: end of block
0
505-
506 if (op & StrokeDraw && state->pen.style() != Qt::NoPen) {
op & StrokeDrawDescription
TRUEnever evaluated
FALSEnever evaluated
state->pen.sty...) != Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
507 q->strokePath(path, QPen(state->bgBrush.color(), state->pen.width()));-
508 q->strokePath(path, state->pen);-
509 }
never executed: end of block
0
510-
511 q->setBackgroundMode(Qt::OpaqueMode);-
512}
never executed: end of block
0
513-
514static inline QBrush stretchGradientToUserSpace(const QBrush &brush, const QRectF &boundingRect)-
515{-
516 Q_ASSERT(brush.style() >= Qt::LinearGradientPattern-
517 && brush.style() <= Qt::ConicalGradientPattern);-
518-
519 QTransform gradientToUser(boundingRect.width(), 0, 0, boundingRect.height(),-
520 boundingRect.x(), boundingRect.y());-
521-
522 QGradient g = *brush.gradient();-
523 g.setCoordinateMode(QGradient::LogicalMode);-
524-
525 QBrush b(g);-
526 b.setTransform(gradientToUser * b.transform());-
527 return b;
never executed: return b;
0
528}-
529-
530void QPainterPrivate::drawStretchedGradient(const QPainterPath &path, DrawOperation op)-
531{-
532 Q_Q(QPainter);-
533-
534 const qreal sw = helper_device->width();-
535 const qreal sh = helper_device->height();-
536-
537 bool changedPen = false;-
538 bool changedBrush = false;-
539 bool needsFill = false;-
540-
541 const QPen pen = state->pen;-
542 const QBrush brush = state->brush;-
543-
544 const QGradient::CoordinateMode penMode = coordinateMode(pen.brush());-
545 const QGradient::CoordinateMode brushMode = coordinateMode(brush);-
546-
547 QRectF boundingRect;-
548-
549 // Draw the xformed fill if the brush is a stretch gradient.-
550 if ((op & FillDraw) && brush.style() != Qt::NoBrush) {
(op & FillDraw)Description
TRUEnever evaluated
FALSEnever evaluated
brush.style() != Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
551 if (brushMode == QGradient::StretchToDeviceMode) {
brushMode == Q...chToDeviceModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
552 q->setPen(Qt::NoPen);-
553 changedPen = pen.style() != Qt::NoPen;-
554 q->scale(sw, sh);-
555 updateState(state);-
556-
557 const qreal isw = 1.0 / sw;-
558 const qreal ish = 1.0 / sh;-
559 QTransform inv(isw, 0, 0, ish, 0, 0);-
560 engine->drawPath(path * inv);-
561 q->scale(isw, ish);-
562 } else {
never executed: end of block
0
563 needsFill = true;-
564-
565 if (brushMode == QGradient::ObjectBoundingMode) {
brushMode == Q...ctBoundingModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
566 Q_ASSERT(engine->hasFeature(QPaintEngine::PatternTransform));-
567 boundingRect = path.boundingRect();-
568 q->setBrush(stretchGradientToUserSpace(brush, boundingRect));-
569 changedBrush = true;-
570 }
never executed: end of block
0
571 }
never executed: end of block
0
572 }-
573-
574 if ((op & StrokeDraw) && pen.style() != Qt::NoPen) {
(op & StrokeDraw)Description
TRUEnever evaluated
FALSEnever evaluated
pen.style() != Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
575 // Draw the xformed outline if the pen is a stretch gradient.-
576 if (penMode == QGradient::StretchToDeviceMode) {
penMode == QGr...chToDeviceModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
577 q->setPen(Qt::NoPen);-
578 changedPen = true;-
579-
580 if (needsFill) {
needsFillDescription
TRUEnever evaluated
FALSEnever evaluated
0
581 updateState(state);-
582 engine->drawPath(path);-
583 }
never executed: end of block
0
584-
585 q->scale(sw, sh);-
586 q->setBrush(pen.brush());-
587 changedBrush = true;-
588 updateState(state);-
589-
590 QPainterPathStroker stroker;-
591 stroker.setDashPattern(pen.style());-
592 stroker.setWidth(pen.widthF());-
593 stroker.setJoinStyle(pen.joinStyle());-
594 stroker.setCapStyle(pen.capStyle());-
595 stroker.setMiterLimit(pen.miterLimit());-
596 QPainterPath stroke = stroker.createStroke(path);-
597-
598 const qreal isw = 1.0 / sw;-
599 const qreal ish = 1.0 / sh;-
600 QTransform inv(isw, 0, 0, ish, 0, 0);-
601 engine->drawPath(stroke * inv);-
602 q->scale(isw, ish);-
603 } else {
never executed: end of block
0
604 if (!needsFill && brush.style() != Qt::NoBrush) {
!needsFillDescription
TRUEnever evaluated
FALSEnever evaluated
brush.style() != Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
605 q->setBrush(Qt::NoBrush);-
606 changedBrush = true;-
607 }
never executed: end of block
0
608-
609 if (penMode == QGradient::ObjectBoundingMode) {
penMode == QGr...ctBoundingModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
610 Q_ASSERT(engine->hasFeature(QPaintEngine::PatternTransform));-
611-
612 // avoid computing the bounding rect twice-
613 if (!needsFill || brushMode != QGradient::ObjectBoundingMode)
!needsFillDescription
TRUEnever evaluated
FALSEnever evaluated
brushMode != Q...ctBoundingModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
614 boundingRect = path.boundingRect();
never executed: boundingRect = path.boundingRect();
0
615-
616 QPen p = pen;-
617 p.setBrush(stretchGradientToUserSpace(pen.brush(), boundingRect));-
618 q->setPen(p);-
619 changedPen = true;-
620 } else if (changedPen) {
never executed: end of block
changedPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
621 q->setPen(pen);-
622 changedPen = false;-
623 }
never executed: end of block
0
624-
625 updateState(state);-
626 engine->drawPath(path);-
627 }
never executed: end of block
0
628 } else if (needsFill) {
needsFillDescription
TRUEnever evaluated
FALSEnever evaluated
0
629 if (pen.style() != Qt::NoPen) {
pen.style() != Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
630 q->setPen(Qt::NoPen);-
631 changedPen = true;-
632 }
never executed: end of block
0
633-
634 updateState(state);-
635 engine->drawPath(path);-
636 }
never executed: end of block
0
637-
638 if (changedPen)
changedPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
639 q->setPen(pen);
never executed: q->setPen(pen);
0
640 if (changedBrush)
changedBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
641 q->setBrush(brush);
never executed: q->setBrush(brush);
0
642}
never executed: end of block
0
643-
644-
645void QPainterPrivate::updateMatrix()-
646{-
647 state->matrix = state->WxF ? state->worldMatrix : QTransform();
state->WxFDescription
TRUEnever evaluated
FALSEnever evaluated
0
648 if (state->VxF)
state->VxFDescription
TRUEnever evaluated
FALSEnever evaluated
0
649 state->matrix *= viewTransform();
never executed: state->matrix *= viewTransform();
0
650-
651 txinv = false; // no inverted matrix-
652 state->matrix *= state->redirectionMatrix;-
653 if (extended)
extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
654 extended->transformChanged();
never executed: extended->transformChanged();
0
655 else-
656 state->dirtyFlags |= QPaintEngine::DirtyTransform;
never executed: state->dirtyFlags |= QPaintEngine::DirtyTransform;
0
657-
658 state->matrix *= hidpiScaleTransform();-
659-
660// printf("VxF=%d, WxF=%d\n", state->VxF, state->WxF);-
661// qDebug() << " --- using matrix" << state->matrix << redirection_offset;-
662}
never executed: end of block
0
663-
664/*! \internal */-
665void QPainterPrivate::updateInvMatrix()-
666{-
667 Q_ASSERT(txinv == false);-
668 txinv = true; // creating inverted matrix-
669 invMatrix = state->matrix.inverted();-
670}
never executed: end of block
0
671-
672extern bool qt_isExtendedRadialGradient(const QBrush &brush);-
673-
674void QPainterPrivate::updateEmulationSpecifier(QPainterState *s)-
675{-
676 bool alpha = false;-
677 bool linearGradient = false;-
678 bool radialGradient = false;-
679 bool extendedRadialGradient = false;-
680 bool conicalGradient = false;-
681 bool patternBrush = false;-
682 bool xform = false;-
683 bool complexXform = false;-
684-
685 bool skip = true;-
686-
687 // Pen and brush properties (we have to check both if one changes because the-
688 // one that's unchanged can still be in a state which requires emulation)-
689 if (s->state() & (QPaintEngine::DirtyPen | QPaintEngine::DirtyBrush | QPaintEngine::DirtyHints)) {
s->state() & (...e::DirtyHints)Description
TRUEnever evaluated
FALSEnever evaluated
0
690 // Check Brush stroke emulation-
691 if (!s->pen.isSolid() && !engine->hasFeature(QPaintEngine::BrushStroke))
!s->pen.isSolid()Description
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...::BrushStroke)Description
TRUEnever evaluated
FALSEnever evaluated
0
692 s->emulationSpecifier |= QPaintEngine::BrushStroke;
never executed: s->emulationSpecifier |= QPaintEngine::BrushStroke;
0
693 else-
694 s->emulationSpecifier &= ~QPaintEngine::BrushStroke;
never executed: s->emulationSpecifier &= ~QPaintEngine::BrushStroke;
0
695-
696 skip = false;-
697-
698 QBrush penBrush = (qpen_style(s->pen) == Qt::NoPen) ? QBrush(Qt::NoBrush) : qpen_brush(s->pen);
(qpen_style(s-... == Qt::NoPen)Description
TRUEnever evaluated
FALSEnever evaluated
0
699 Qt::BrushStyle brushStyle = qbrush_style(s->brush);-
700 Qt::BrushStyle penBrushStyle = qbrush_style(penBrush);-
701 alpha = (penBrushStyle != Qt::NoBrush
penBrushStyle != Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
702 && (penBrushStyle < Qt::LinearGradientPattern && penBrush.color().alpha() != 255)
penBrushStyle ...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
penBrush.color...alpha() != 255Description
TRUEnever evaluated
FALSEnever evaluated
0
703 && !penBrush.isOpaque())
!penBrush.isOpaque()Description
TRUEnever evaluated
FALSEnever evaluated
0
704 || (brushStyle != Qt::NoBrush
brushStyle != Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
705 && (brushStyle < Qt::LinearGradientPattern && s->brush.color().alpha() != 255)
brushStyle < Q...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
s->brush.color...alpha() != 255Description
TRUEnever evaluated
FALSEnever evaluated
0
706 && !s->brush.isOpaque());
!s->brush.isOpaque()Description
TRUEnever evaluated
FALSEnever evaluated
0
707 linearGradient = ((penBrushStyle == Qt::LinearGradientPattern) ||
(penBrushStyle...adientPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
708 (brushStyle == Qt::LinearGradientPattern));
(brushStyle ==...adientPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
709 radialGradient = ((penBrushStyle == Qt::RadialGradientPattern) ||
(penBrushStyle...adientPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
710 (brushStyle == Qt::RadialGradientPattern));
(brushStyle ==...adientPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
711 extendedRadialGradient = radialGradient && (qt_isExtendedRadialGradient(penBrush) || qt_isExtendedRadialGradient(s->brush));
radialGradientDescription
TRUEnever evaluated
FALSEnever evaluated
qt_isExtendedR...ient(penBrush)Description
TRUEnever evaluated
FALSEnever evaluated
qt_isExtendedR...ient(s->brush)Description
TRUEnever evaluated
FALSEnever evaluated
0
712 conicalGradient = ((penBrushStyle == Qt::ConicalGradientPattern) ||
(penBrushStyle...adientPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
713 (brushStyle == Qt::ConicalGradientPattern));
(brushStyle ==...adientPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
714 patternBrush = (((penBrushStyle > Qt::SolidPattern
penBrushStyle ...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
715 && penBrushStyle < Qt::LinearGradientPattern)
penBrushStyle ...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
716 || penBrushStyle == Qt::TexturePattern) ||
penBrushStyle ...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
717 ((brushStyle > Qt::SolidPattern
brushStyle > Qt::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
718 && brushStyle < Qt::LinearGradientPattern)
brushStyle < Q...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
719 || brushStyle == Qt::TexturePattern));
brushStyle == ...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
720-
721 bool penTextureAlpha = false;-
722 if (penBrush.style() == Qt::TexturePattern)
penBrush.style...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
723 penTextureAlpha = qHasPixmapTexture(penBrush)
never executed: penTextureAlpha = qHasPixmapTexture(penBrush) ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() : penBrush.textureImage().hasAlphaChannel();
qHasPixmapTexture(penBrush)Description
TRUEnever evaluated
FALSEnever evaluated
0
724 ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha()
never executed: penTextureAlpha = qHasPixmapTexture(penBrush) ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() : penBrush.textureImage().hasAlphaChannel();
(penBrush.text...).depth() > 1)Description
TRUEnever evaluated
FALSEnever evaluated
penBrush.texture().hasAlpha()Description
TRUEnever evaluated
FALSEnever evaluated
0
725 : penBrush.textureImage().hasAlphaChannel();
never executed: penTextureAlpha = qHasPixmapTexture(penBrush) ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() : penBrush.textureImage().hasAlphaChannel();
0
726 bool brushTextureAlpha = false;-
727 if (s->brush.style() == Qt::TexturePattern) {
s->brush.style...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
728 brushTextureAlpha = qHasPixmapTexture(s->brush)
qHasPixmapTexture(s->brush)Description
TRUEnever evaluated
FALSEnever evaluated
0
729 ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha()
(s->brush.text...).depth() > 1)Description
TRUEnever evaluated
FALSEnever evaluated
s->brush.texture().hasAlpha()Description
TRUEnever evaluated
FALSEnever evaluated
0
730 : s->brush.textureImage().hasAlphaChannel();-
731 }
never executed: end of block
0
732 if (((penBrush.style() == Qt::TexturePattern && penTextureAlpha)
penBrush.style...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
penTextureAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
733 || (s->brush.style() == Qt::TexturePattern && brushTextureAlpha))
s->brush.style...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
brushTextureAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
734 && !engine->hasFeature(QPaintEngine::MaskedBrush))
!engine->hasFe...::MaskedBrush)Description
TRUEnever evaluated
FALSEnever evaluated
0
735 s->emulationSpecifier |= QPaintEngine::MaskedBrush;
never executed: s->emulationSpecifier |= QPaintEngine::MaskedBrush;
0
736 else-
737 s->emulationSpecifier &= ~QPaintEngine::MaskedBrush;
never executed: s->emulationSpecifier &= ~QPaintEngine::MaskedBrush;
0
738 }-
739-
740 if (s->state() & (QPaintEngine::DirtyHints
s->state() & (...ackgroundMode)Description
TRUEnever evaluated
FALSEnever evaluated
0
741 | QPaintEngine::DirtyOpacity
s->state() & (...ackgroundMode)Description
TRUEnever evaluated
FALSEnever evaluated
0
742 | QPaintEngine::DirtyBackgroundMode)) {
s->state() & (...ackgroundMode)Description
TRUEnever evaluated
FALSEnever evaluated
0
743 skip = false;-
744 }
never executed: end of block
0
745-
746 if (skip)
skipDescription
TRUEnever evaluated
FALSEnever evaluated
0
747 return;
never executed: return;
0
748-
749#if 0-
750 qDebug("QPainterPrivate::updateEmulationSpecifier, state=%p\n"-
751 " - alpha: %d\n"-
752 " - linearGradient: %d\n"-
753 " - radialGradient: %d\n"-
754 " - conicalGradient: %d\n"-
755 " - patternBrush: %d\n"-
756 " - hints: %x\n"-
757 " - xform: %d\n",-
758 s,-
759 alpha,-
760 linearGradient,-
761 radialGradient,-
762 conicalGradient,-
763 patternBrush,-
764 uint(s->renderHints),-
765 xform);-
766#endif-
767-
768 // XForm properties-
769 if (s->state() & QPaintEngine::DirtyTransform) {
s->state() & Q...DirtyTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
770 xform = !s->matrix.isIdentity();-
771 complexXform = !s->matrix.isAffine();-
772 } else if (s->matrix.type() >= QTransform::TxTranslate) {
never executed: end of block
s->matrix.type...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
773 xform = true;-
774 complexXform = !s->matrix.isAffine();-
775 }
never executed: end of block
0
776-
777 const bool brushXform = (s->brush.transform().type() != QTransform::TxNone);-
778 const bool penXform = (s->pen.brush().transform().type() != QTransform::TxNone);-
779-
780 const bool patternXform = patternBrush && (xform || brushXform || penXform);
patternBrushDescription
TRUEnever evaluated
FALSEnever evaluated
xformDescription
TRUEnever evaluated
FALSEnever evaluated
brushXformDescription
TRUEnever evaluated
FALSEnever evaluated
penXformDescription
TRUEnever evaluated
FALSEnever evaluated
0
781-
782 // Check alphablending-
783 if (alpha && !engine->hasFeature(QPaintEngine::AlphaBlend))
alphaDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...e::AlphaBlend)Description
TRUEnever evaluated
FALSEnever evaluated
0
784 s->emulationSpecifier |= QPaintEngine::AlphaBlend;
never executed: s->emulationSpecifier |= QPaintEngine::AlphaBlend;
0
785 else-
786 s->emulationSpecifier &= ~QPaintEngine::AlphaBlend;
never executed: s->emulationSpecifier &= ~QPaintEngine::AlphaBlend;
0
787-
788 // Linear gradient emulation-
789 if (linearGradient && !engine->hasFeature(QPaintEngine::LinearGradientFill))
linearGradientDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...rGradientFill)Description
TRUEnever evaluated
FALSEnever evaluated
0
790 s->emulationSpecifier |= QPaintEngine::LinearGradientFill;
never executed: s->emulationSpecifier |= QPaintEngine::LinearGradientFill;
0
791 else-
792 s->emulationSpecifier &= ~QPaintEngine::LinearGradientFill;
never executed: s->emulationSpecifier &= ~QPaintEngine::LinearGradientFill;
0
793-
794 // Radial gradient emulation-
795 if (extendedRadialGradient || (radialGradient && !engine->hasFeature(QPaintEngine::RadialGradientFill)))
extendedRadialGradientDescription
TRUEnever evaluated
FALSEnever evaluated
radialGradientDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...lGradientFill)Description
TRUEnever evaluated
FALSEnever evaluated
0
796 s->emulationSpecifier |= QPaintEngine::RadialGradientFill;
never executed: s->emulationSpecifier |= QPaintEngine::RadialGradientFill;
0
797 else-
798 s->emulationSpecifier &= ~QPaintEngine::RadialGradientFill;
never executed: s->emulationSpecifier &= ~QPaintEngine::RadialGradientFill;
0
799-
800 // Conical gradient emulation-
801 if (conicalGradient && !engine->hasFeature(QPaintEngine::ConicalGradientFill))
conicalGradientDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...lGradientFill)Description
TRUEnever evaluated
FALSEnever evaluated
0
802 s->emulationSpecifier |= QPaintEngine::ConicalGradientFill;
never executed: s->emulationSpecifier |= QPaintEngine::ConicalGradientFill;
0
803 else-
804 s->emulationSpecifier &= ~QPaintEngine::ConicalGradientFill;
never executed: s->emulationSpecifier &= ~QPaintEngine::ConicalGradientFill;
0
805-
806 // Pattern brushes-
807 if (patternBrush && !engine->hasFeature(QPaintEngine::PatternBrush))
patternBrushDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...:PatternBrush)Description
TRUEnever evaluated
FALSEnever evaluated
0
808 s->emulationSpecifier |= QPaintEngine::PatternBrush;
never executed: s->emulationSpecifier |= QPaintEngine::PatternBrush;
0
809 else-
810 s->emulationSpecifier &= ~QPaintEngine::PatternBrush;
never executed: s->emulationSpecifier &= ~QPaintEngine::PatternBrush;
0
811-
812 // Pattern XForms-
813 if (patternXform && !engine->hasFeature(QPaintEngine::PatternTransform))
patternXformDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...ternTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
814 s->emulationSpecifier |= QPaintEngine::PatternTransform;
never executed: s->emulationSpecifier |= QPaintEngine::PatternTransform;
0
815 else-
816 s->emulationSpecifier &= ~QPaintEngine::PatternTransform;
never executed: s->emulationSpecifier &= ~QPaintEngine::PatternTransform;
0
817-
818 // Primitive XForms-
819 if (xform && !engine->hasFeature(QPaintEngine::PrimitiveTransform))
xformDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...tiveTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
820 s->emulationSpecifier |= QPaintEngine::PrimitiveTransform;
never executed: s->emulationSpecifier |= QPaintEngine::PrimitiveTransform;
0
821 else-
822 s->emulationSpecifier &= ~QPaintEngine::PrimitiveTransform;
never executed: s->emulationSpecifier &= ~QPaintEngine::PrimitiveTransform;
0
823-
824 // Perspective XForms-
825 if (complexXform && !engine->hasFeature(QPaintEngine::PerspectiveTransform))
complexXformDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...tiveTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
826 s->emulationSpecifier |= QPaintEngine::PerspectiveTransform;
never executed: s->emulationSpecifier |= QPaintEngine::PerspectiveTransform;
0
827 else-
828 s->emulationSpecifier &= ~QPaintEngine::PerspectiveTransform;
never executed: s->emulationSpecifier &= ~QPaintEngine::PerspectiveTransform;
0
829-
830 // Constant opacity-
831 if (state->opacity != 1 && !engine->hasFeature(QPaintEngine::ConstantOpacity))
state->opacity != 1Description
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...nstantOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
832 s->emulationSpecifier |= QPaintEngine::ConstantOpacity;
never executed: s->emulationSpecifier |= QPaintEngine::ConstantOpacity;
0
833 else-
834 s->emulationSpecifier &= ~QPaintEngine::ConstantOpacity;
never executed: s->emulationSpecifier &= ~QPaintEngine::ConstantOpacity;
0
835-
836 bool gradientStretch = false;-
837 bool objectBoundingMode = false;-
838 if (linearGradient || conicalGradient || radialGradient) {
linearGradientDescription
TRUEnever evaluated
FALSEnever evaluated
conicalGradientDescription
TRUEnever evaluated
FALSEnever evaluated
radialGradientDescription
TRUEnever evaluated
FALSEnever evaluated
0
839 QGradient::CoordinateMode brushMode = coordinateMode(s->brush);-
840 QGradient::CoordinateMode penMode = coordinateMode(s->pen.brush());-
841-
842 gradientStretch |= (brushMode == QGradient::StretchToDeviceMode);-
843 gradientStretch |= (penMode == QGradient::StretchToDeviceMode);-
844-
845 objectBoundingMode |= (brushMode == QGradient::ObjectBoundingMode);-
846 objectBoundingMode |= (penMode == QGradient::ObjectBoundingMode);-
847 }
never executed: end of block
0
848 if (gradientStretch)
gradientStretchDescription
TRUEnever evaluated
FALSEnever evaluated
0
849 s->emulationSpecifier |= QGradient_StretchToDevice;
never executed: s->emulationSpecifier |= 0x10000000;
0
850 else-
851 s->emulationSpecifier &= ~QGradient_StretchToDevice;
never executed: s->emulationSpecifier &= ~0x10000000;
0
852-
853 if (objectBoundingMode && !engine->hasFeature(QPaintEngine::ObjectBoundingModeGradients))
objectBoundingModeDescription
TRUEnever evaluated
FALSEnever evaluated
!engine->hasFe...ModeGradients)Description
TRUEnever evaluated
FALSEnever evaluated
0
854 s->emulationSpecifier |= QPaintEngine::ObjectBoundingModeGradients;
never executed: s->emulationSpecifier |= QPaintEngine::ObjectBoundingModeGradients;
0
855 else-
856 s->emulationSpecifier &= ~QPaintEngine::ObjectBoundingModeGradients;
never executed: s->emulationSpecifier &= ~QPaintEngine::ObjectBoundingModeGradients;
0
857-
858 // Opaque backgrounds...-
859 if (s->bgMode == Qt::OpaqueMode &&
s->bgMode == Qt::OpaqueModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
860 (is_pen_transparent(s->pen) || is_brush_transparent(s->brush)))
is_pen_transparent(s->pen)Description
TRUEnever evaluated
FALSEnever evaluated
is_brush_transparent(s->brush)Description
TRUEnever evaluated
FALSEnever evaluated
0
861 s->emulationSpecifier |= QPaintEngine_OpaqueBackground;
never executed: s->emulationSpecifier |= 0x40000000;
0
862 else-
863 s->emulationSpecifier &= ~QPaintEngine_OpaqueBackground;
never executed: s->emulationSpecifier &= ~0x40000000;
0
864-
865#if 0-
866 //won't be correct either way because the device can already have-
867 // something rendered to it in which case subsequent emulation-
868 // on a fully transparent qimage and then blitting the results-
869 // won't produce correct results-
870 // Blend modes-
871 if (state->composition_mode > QPainter::CompositionMode_Xor &&-
872 !engine->hasFeature(QPaintEngine::BlendModes))-
873 s->emulationSpecifier |= QPaintEngine::BlendModes;-
874 else-
875 s->emulationSpecifier &= ~QPaintEngine::BlendModes;-
876#endif-
877}-
878-
879void QPainterPrivate::updateStateImpl(QPainterState *newState)-
880{-
881 // ### we might have to call QPainter::begin() here...-
882 if (!engine->state) {
!engine->stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
883 engine->state = newState;-
884 engine->setDirty(QPaintEngine::AllDirty);-
885 }
never executed: end of block
0
886-
887 if (engine->state->painter() != newState->painter)
engine->state-...State->painterDescription
TRUEnever evaluated
FALSEnever evaluated
0
888 // ### this could break with clip regions vs paths.-
889 engine->setDirty(QPaintEngine::AllDirty);
never executed: engine->setDirty(QPaintEngine::AllDirty);
0
890-
891 // Upon restore, revert all changes since last save-
892 else if (engine->state != newState)
engine->state != newStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
893 newState->dirtyFlags |= QPaintEngine::DirtyFlags(static_cast<QPainterState *>(engine->state)->changeFlags);
never executed: newState->dirtyFlags |= QPaintEngine::DirtyFlags(static_cast<QPainterState *>(engine->state)->changeFlags);
0
894-
895 // We need to store all changes made so that restore can deal with them-
896 else-
897 newState->changeFlags |= newState->dirtyFlags;
never executed: newState->changeFlags |= newState->dirtyFlags;
0
898-
899 updateEmulationSpecifier(newState);-
900-
901 // Unset potential dirty background mode-
902 newState->dirtyFlags &= ~(QPaintEngine::DirtyBackgroundMode-
903 | QPaintEngine::DirtyBackground);-
904-
905 engine->state = newState;-
906 engine->updateState(*newState);-
907 engine->clearDirty(QPaintEngine::AllDirty);-
908-
909}
never executed: end of block
0
910-
911void QPainterPrivate::updateState(QPainterState *newState)-
912{-
913-
914 if (!newState) {
!newStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
915 engine->state = newState;-
916 } else if (newState->state() || engine->state!=newState) {
never executed: end of block
newState->state()Description
TRUEnever evaluated
FALSEnever evaluated
engine->state!=newStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
917 updateStateImpl(newState);-
918 }
never executed: end of block
0
919}
never executed: end of block
0
920-
921-
922/*!-
923 \class QPainter-
924 \brief The QPainter class performs low-level painting on widgets and-
925 other paint devices.-
926-
927 \inmodule QtGui-
928 \ingroup painting-
929-
930 \reentrant-
931-
932 QPainter provides highly optimized functions to do most of the-
933 drawing GUI programs require. It can draw everything from simple-
934 lines to complex shapes like pies and chords. It can also draw-
935 aligned text and pixmaps. Normally, it draws in a "natural"-
936 coordinate system, but it can also do view and world-
937 transformation. QPainter can operate on any object that inherits-
938 the QPaintDevice class.-
939-
940 The common use of QPainter is inside a widget's paint event:-
941 Construct and customize (e.g. set the pen or the brush) the-
942 painter. Then draw. Remember to destroy the QPainter object after-
943 drawing. For example:-
944-
945 \snippet code/src_gui_painting_qpainter.cpp 0-
946-
947 The core functionality of QPainter is drawing, but the class also-
948 provide several functions that allows you to customize QPainter's-
949 settings and its rendering quality, and others that enable-
950 clipping. In addition you can control how different shapes are-
951 merged together by specifying the painter's composition mode.-
952-
953 The isActive() function indicates whether the painter is active. A-
954 painter is activated by the begin() function and the constructor-
955 that takes a QPaintDevice argument. The end() function, and the-
956 destructor, deactivates it.-
957-
958 Together with the QPaintDevice and QPaintEngine classes, QPainter-
959 form the basis for Qt's paint system. QPainter is the class used-
960 to perform drawing operations. QPaintDevice represents a device-
961 that can be painted on using a QPainter. QPaintEngine provides the-
962 interface that the painter uses to draw onto different types of-
963 devices. If the painter is active, device() returns the paint-
964 device on which the painter paints, and paintEngine() returns the-
965 paint engine that the painter is currently operating on. For more-
966 information, see the \l {Paint System}.-
967-
968 Sometimes it is desirable to make someone else paint on an unusual-
969 QPaintDevice. QPainter supports a static function to do this,-
970 setRedirected().-
971-
972 \warning When the paintdevice is a widget, QPainter can only be-
973 used inside a paintEvent() function or in a function called by-
974 paintEvent().-
975-
976 \tableofcontents-
977-
978 \section1 Settings-
979-
980 There are several settings that you can customize to make QPainter-
981 draw according to your preferences:-
982-
983 \list-
984-
985 \li font() is the font used for drawing text. If the painter-
986 isActive(), you can retrieve information about the currently set-
987 font, and its metrics, using the fontInfo() and fontMetrics()-
988 functions respectively.-
989-
990 \li brush() defines the color or pattern that is used for filling-
991 shapes.-
992-
993 \li pen() defines the color or stipple that is used for drawing-
994 lines or boundaries.-
995-
996 \li backgroundMode() defines whether there is a background() or-
997 not, i.e it is either Qt::OpaqueMode or Qt::TransparentMode.-
998-
999 \li background() only applies when backgroundMode() is \l-
1000 Qt::OpaqueMode and pen() is a stipple. In that case, it-
1001 describes the color of the background pixels in the stipple.-
1002-
1003 \li brushOrigin() defines the origin of the tiled brushes, normally-
1004 the origin of widget's background.-
1005-
1006 \li viewport(), window(), worldTransform() make up the painter's coordinate-
1007 transformation system. For more information, see the \l-
1008 {Coordinate Transformations} section and the \l {Coordinate-
1009 System} documentation.-
1010-
1011 \li hasClipping() tells whether the painter clips at all. (The paint-
1012 device clips, too.) If the painter clips, it clips to clipRegion().-
1013-
1014 \li layoutDirection() defines the layout direction used by the-
1015 painter when drawing text.-
1016-
1017 \li worldMatrixEnabled() tells whether world transformation is enabled.-
1018-
1019 \li viewTransformEnabled() tells whether view transformation is-
1020 enabled.-
1021-
1022 \endlist-
1023-
1024 Note that some of these settings mirror settings in some paint-
1025 devices, e.g. QWidget::font(). The QPainter::begin() function (or-
1026 equivalently the QPainter constructor) copies these attributes-
1027 from the paint device.-
1028-
1029 You can at any time save the QPainter's state by calling the-
1030 save() function which saves all the available settings on an-
1031 internal stack. The restore() function pops them back.-
1032-
1033 \section1 Drawing-
1034-
1035 QPainter provides functions to draw most primitives: drawPoint(),-
1036 drawPoints(), drawLine(), drawRect(), drawRoundedRect(),-
1037 drawEllipse(), drawArc(), drawPie(), drawChord(), drawPolyline(),-
1038 drawPolygon(), drawConvexPolygon() and drawCubicBezier(). The two-
1039 convenience functions, drawRects() and drawLines(), draw the given-
1040 number of rectangles or lines in the given array of \l-
1041 {QRect}{QRects} or \l {QLine}{QLines} using the current pen and-
1042 brush.-
1043-
1044 The QPainter class also provides the fillRect() function which-
1045 fills the given QRect, with the given QBrush, and the eraseRect()-
1046 function that erases the area inside the given rectangle.-
1047-
1048 All of these functions have both integer and floating point-
1049 versions.-
1050-
1051 \table 100%-
1052 \row-
1053 \li \inlineimage qpainter-basicdrawing.png-
1054 \li-
1055 \b {Basic Drawing Example}-
1056-
1057 The \l {painting/basicdrawing}{Basic Drawing} example shows how to-
1058 display basic graphics primitives in a variety of styles using the-
1059 QPainter class.-
1060-
1061 \endtable-
1062-
1063 If you need to draw a complex shape, especially if you need to do-
1064 so repeatedly, consider creating a QPainterPath and drawing it-
1065 using drawPath().-
1066-
1067 \table 100%-
1068 \row-
1069 \li-
1070 \b {Painter Paths example}-
1071-
1072 The QPainterPath class provides a container for painting-
1073 operations, enabling graphical shapes to be constructed and-
1074 reused.-
1075-
1076 The \l {painting/painterpaths}{Painter Paths} example shows how-
1077 painter paths can be used to build complex shapes for rendering.-
1078-
1079 \li \inlineimage qpainter-painterpaths.png-
1080 \endtable-
1081-
1082 QPainter also provides the fillPath() function which fills the-
1083 given QPainterPath with the given QBrush, and the strokePath()-
1084 function that draws the outline of the given path (i.e. strokes-
1085 the path).-
1086-
1087 See also the \l {painting/deform}{Vector Deformation} example which-
1088 shows how to use advanced vector techniques to draw text using a-
1089 QPainterPath, the \l {painting/gradients}{Gradients} example which shows-
1090 the different types of gradients that are available in Qt, and the \l-
1091 {painting/pathstroke}{Path Stroking} example which shows Qt's built-in-
1092 dash patterns and shows how custom patterns can be used to extend-
1093 the range of available patterns.-
1094-
1095 \table-
1096 \header-
1097 \li \l {painting/deform}{Vector Deformation}-
1098 \li \l {painting/gradients}{Gradients}-
1099 \li \l {painting/pathstroke}{Path Stroking}-
1100 \row-
1101 \li \inlineimage qpainter-vectordeformation.png-
1102 \li \inlineimage qpainter-gradients.png-
1103 \li \inlineimage qpainter-pathstroking.png-
1104 \endtable-
1105-
1106 Text drawing is done using drawText(). When you need-
1107 fine-grained positioning, boundingRect() tells you where a given-
1108 drawText() command will draw.-
1109-
1110 \section1 Drawing Pixmaps and Images-
1111-
1112 There are functions to draw pixmaps/images, namely drawPixmap(),-
1113 drawImage() and drawTiledPixmap(). Both drawPixmap() and drawImage()-
1114 produce the same result, except that drawPixmap() is faster-
1115 on-screen while drawImage() may be faster on a QPrinter or other-
1116 devices.-
1117-
1118 There is a drawPicture() function that draws the contents of an-
1119 entire QPicture. The drawPicture() function is the only function-
1120 that disregards all the painter's settings as QPicture has its own-
1121 settings.-
1122-
1123 \section2 Drawing High Resolution Versions of Pixmaps and Images-
1124-
1125 High resolution versions of pixmaps have a \e{device pixel ratio} value larger-
1126 than 1 (see QImageReader, QPixmap::devicePixelRatio()). Should it match the value-
1127 of the underlying QPaintDevice, it is drawn directly onto the device with no-
1128 additional transformation applied.-
1129-
1130 This is for example the case when drawing a QPixmap of 64x64 pixels size with-
1131 a device pixel ratio of 2 onto a high DPI screen which also has-
1132 a device pixel ratio of 2. Note that the pixmap is then effectively 32x32-
1133 pixels in \e{user space}. Code paths in Qt that calculate layout geometry-
1134 based on the pixmap size will use this size. The net effect of this is that-
1135 the pixmap is displayed as high DPI pixmap rather than a large pixmap.-
1136-
1137 \section1 Rendering Quality-
1138-
1139 To get the optimal rendering result using QPainter, you should use-
1140 the platform independent QImage as paint device; i.e. using QImage-
1141 will ensure that the result has an identical pixel representation-
1142 on any platform.-
1143-
1144 The QPainter class also provides a means of controlling the-
1145 rendering quality through its RenderHint enum and the support for-
1146 floating point precision: All the functions for drawing primitives-
1147 has a floating point version. These are often used in combination-
1148 with the \l {RenderHint}{QPainter::Antialiasing} render hint.-
1149-
1150 \table 100%-
1151 \row-
1152 \li \inlineimage qpainter-concentriccircles.png-
1153 \li-
1154 \b {Concentric Circles Example}-
1155-
1156 The \l {painting/concentriccircles}{Concentric Circles} example-
1157 shows the improved rendering quality that can be obtained using-
1158 floating point precision and anti-aliasing when drawing custom-
1159 widgets.-
1160-
1161 The application's main window displays several widgets which are-
1162 drawn using the various combinations of precision and-
1163 anti-aliasing.-
1164-
1165 \endtable-
1166-
1167 The RenderHint enum specifies flags to QPainter that may or may-
1168 not be respected by any given engine. \l-
1169 {RenderHint}{QPainter::Antialiasing} indicates that the engine-
1170 should antialias edges of primitives if possible, \l-
1171 {RenderHint}{QPainter::TextAntialiasing} indicates that the engine-
1172 should antialias text if possible, and the \l-
1173 {RenderHint}{QPainter::SmoothPixmapTransform} indicates that the-
1174 engine should use a smooth pixmap transformation algorithm.-
1175-
1176 The renderHints() function returns a flag that specifies the-
1177 rendering hints that are set for this painter. Use the-
1178 setRenderHint() function to set or clear the currently set-
1179 RenderHints.-
1180-
1181 \section1 Coordinate Transformations-
1182-
1183 Normally, the QPainter operates on the device's own coordinate-
1184 system (usually pixels), but QPainter has good support for-
1185 coordinate transformations.-
1186-
1187 \table-
1188 \header-
1189 \li nop \li rotate() \li scale() \li translate()-
1190 \row-
1191 \li \inlineimage qpainter-clock.png-
1192 \li \inlineimage qpainter-rotation.png-
1193 \li \inlineimage qpainter-scale.png-
1194 \li \inlineimage qpainter-translation.png-
1195 \endtable-
1196-
1197 The most commonly used transformations are scaling, rotation,-
1198 translation and shearing. Use the scale() function to scale the-
1199 coordinate system by a given offset, the rotate() function to-
1200 rotate it clockwise and translate() to translate it (i.e. adding a-
1201 given offset to the points). You can also twist the coordinate-
1202 system around the origin using the shear() function. See the \l-
1203 {painting/affine}{Affine Transformations} example for a visualization of-
1204 a sheared coordinate system.-
1205-
1206 See also the \l {painting/transformations}{Transformations}-
1207 example which shows how transformations influence the way that-
1208 QPainter renders graphics primitives. In particular it shows how-
1209 the order of transformations affects the result.-
1210-
1211 \table 100%-
1212 \row-
1213 \li-
1214 \b {Affine Transformations Example}-
1215-
1216 The \l {painting/affine}{Affine Transformations} example shows Qt's-
1217 ability to perform affine transformations on painting-
1218 operations. The demo also allows the user to experiment with the-
1219 transformation operations and see the results immediately.-
1220-
1221 \li \inlineimage qpainter-affinetransformations.png-
1222 \endtable-
1223-
1224 All the tranformation operations operate on the transformation-
1225 worldTransform(). A matrix transforms a point in the plane to another-
1226 point. For more information about the transformation matrix, see-
1227 the \l {Coordinate System} and QTransform documentation.-
1228-
1229 The setWorldTransform() function can replace or add to the currently-
1230 set worldTransform(). The resetTransform() function resets any-
1231 transformations that were made using translate(), scale(),-
1232 shear(), rotate(), setWorldTransform(), setViewport() and setWindow()-
1233 functions. The deviceTransform() returns the matrix that transforms-
1234 from logical coordinates to device coordinates of the platform-
1235 dependent paint device. The latter function is only needed when-
1236 using platform painting commands on the platform dependent handle,-
1237 and the platform does not do transformations nativly.-
1238-
1239 When drawing with QPainter, we specify points using logical-
1240 coordinates which then are converted into the physical coordinates-
1241 of the paint device. The mapping of the logical coordinates to the-
1242 physical coordinates are handled by QPainter's combinedTransform(), a-
1243 combination of viewport() and window() and worldTransform(). The-
1244 viewport() represents the physical coordinates specifying an-
1245 arbitrary rectangle, the window() describes the same rectangle in-
1246 logical coordinates, and the worldTransform() is identical with the-
1247 transformation matrix.-
1248-
1249 See also \l {Coordinate System}-
1250-
1251 \section1 Clipping-
1252-
1253 QPainter can clip any drawing operation to a rectangle, a region,-
1254 or a vector path. The current clip is available using the-
1255 functions clipRegion() and clipPath(). Whether paths or regions are-
1256 preferred (faster) depends on the underlying paintEngine(). For-
1257 example, the QImage paint engine prefers paths while the X11 paint-
1258 engine prefers regions. Setting a clip is done in the painters-
1259 logical coordinates.-
1260-
1261 After QPainter's clipping, the paint device may also clip. For-
1262 example, most widgets clip away the pixels used by child widgets,-
1263 and most printers clip away an area near the edges of the paper.-
1264 This additional clipping is not reflected by the return value of-
1265 clipRegion() or hasClipping().-
1266-
1267 \section1 Composition Modes-
1268 \target Composition Modes-
1269-
1270 QPainter provides the CompositionMode enum which defines the-
1271 Porter-Duff rules for digital image compositing; it describes a-
1272 model for combining the pixels in one image, the source, with the-
1273 pixels in another image, the destination.-
1274-
1275 The two most common forms of composition are \l-
1276 {QPainter::CompositionMode}{Source} and \l-
1277 {QPainter::CompositionMode}{SourceOver}. \l-
1278 {QPainter::CompositionMode}{Source} is used to draw opaque objects-
1279 onto a paint device. In this mode, each pixel in the source-
1280 replaces the corresponding pixel in the destination. In \l-
1281 {QPainter::CompositionMode}{SourceOver} composition mode, the-
1282 source object is transparent and is drawn on top of the-
1283 destination.-
1284-
1285 Note that composition transformation operates pixelwise. For that-
1286 reason, there is a difference between using the graphic primitive-
1287 itself and its bounding rectangle: The bounding rect contains-
1288 pixels with alpha == 0 (i.e the pixels surrounding the-
1289 primitive). These pixels will overwrite the other image's pixels,-
1290 affectively clearing those, while the primitive only overwrites-
1291 its own area.-
1292-
1293 \table 100%-
1294 \row-
1295 \li \inlineimage qpainter-compositiondemo.png-
1296-
1297 \li-
1298 \b {Composition Modes Example}-
1299-
1300 The \l {painting/composition}{Composition Modes} example, available in-
1301 Qt's examples directory, allows you to experiment with the various-
1302 composition modes and see the results immediately.-
1303-
1304 \endtable-
1305-
1306 \section1 Limitations-
1307 \target Limitations-
1308-
1309 If you are using coordinates with Qt's raster-based paint engine, it is-
1310 important to note that, while coordinates greater than +/- 2\sup 15 can-
1311 be used, any painting performed with coordinates outside this range is not-
1312 guaranteed to be shown; the drawing may be clipped. This is due to the-
1313 use of \c{short int} in the implementation.-
1314-
1315 The outlines generated by Qt's stroker are only an approximation when dealing-
1316 with curved shapes. It is in most cases impossible to represent the outline of-
1317 a bezier curve segment using another bezier curve segment, and so Qt approximates-
1318 the curve outlines by using several smaller curves. For performance reasons there-
1319 is a limit to how many curves Qt uses for these outlines, and thus when using-
1320 large pen widths or scales the outline error increases. To generate outlines with-
1321 smaller errors it is possible to use the QPainterPathStroker class, which has the-
1322 setCurveThreshold member function which let's the user specify the error tolerance.-
1323 Another workaround is to convert the paths to polygons first and then draw the-
1324 polygons instead.-
1325-
1326 \section1 Performance-
1327-
1328 QPainter is a rich framework that allows developers to do a great-
1329 variety of graphical operations, such as gradients, composition-
1330 modes and vector graphics. And QPainter can do this across a-
1331 variety of different hardware and software stacks. Naturally the-
1332 underlying combination of hardware and software has some-
1333 implications for performance, and ensuring that every single-
1334 operation is fast in combination with all the various combinations-
1335 of composition modes, brushes, clipping, transformation, etc, is-
1336 close to an impossible task because of the number of-
1337 permutations. As a compromise we have selected a subset of the-
1338 QPainter API and backends, where performance is guaranteed to be as-
1339 good as we can sensibly get it for the given combination of-
1340 hardware and software.-
1341-
1342 The backends we focus on as high-performance engines are:-
1343-
1344 \list-
1345-
1346 \li Raster - This backend implements all rendering in pure software-
1347 and is always used to render into QImages. For optimal performance-
1348 only use the format types QImage::Format_ARGB32_Premultiplied,-
1349 QImage::Format_RGB32 or QImage::Format_RGB16. Any other format,-
1350 including QImage::Format_ARGB32, has significantly worse-
1351 performance. This engine is used by default for QWidget and QPixmap.-
1352-
1353 \li OpenGL 2.0 (ES) - This backend is the primary backend for-
1354 hardware accelerated graphics. It can be run on desktop machines-
1355 and embedded devices supporting the OpenGL 2.0 or OpenGL/ES 2.0-
1356 specification. This includes most graphics chips produced in the-
1357 last couple of years. The engine can be enabled by using QPainter-
1358 onto a QOpenGLWidget.-
1359-
1360 \endlist-
1361-
1362 These operations are:-
1363-
1364 \list-
1365-
1366 \li Simple transformations, meaning translation and scaling, pluss-
1367 0, 90, 180, 270 degree rotations.-
1368-
1369 \li \c drawPixmap() in combination with simple transformations and-
1370 opacity with non-smooth transformation mode-
1371 (\c QPainter::SmoothPixmapTransform not enabled as a render hint).-
1372-
1373 \li Rectangle fills with solid color, two-color linear gradients-
1374 and simple transforms.-
1375-
1376 \li Rectangular clipping with simple transformations and intersect-
1377 clip.-
1378-
1379 \li Composition Modes \c QPainter::CompositionMode_Source and-
1380 QPainter::CompositionMode_SourceOver-
1381-
1382 \li Rounded rectangle filling using solid color and two-color-
1383 linear gradients fills.-
1384-
1385 \li 3x3 patched pixmaps, via qDrawBorderPixmap.-
1386-
1387 \endlist-
1388-
1389 This list gives an indication of which features to safely use in-
1390 an application where performance is critical. For certain setups,-
1391 other operations may be fast too, but before making extensive use-
1392 of them, it is recommended to benchmark and verify them on the-
1393 system where the software will run in the end. There are also-
1394 cases where expensive operations are ok to use, for instance when-
1395 the result is cached in a QPixmap.-
1396-
1397 \sa QPaintDevice, QPaintEngine, {Qt SVG}, {Basic Drawing Example},-
1398 {Drawing Utility Functions}-
1399*/-
1400-
1401/*!-
1402 \enum QPainter::RenderHint-
1403-
1404 Renderhints are used to specify flags to QPainter that may or-
1405 may not be respected by any given engine.-
1406-
1407 \value Antialiasing Indicates that the engine should antialias-
1408 edges of primitives if possible.-
1409-
1410 \value TextAntialiasing Indicates that the engine should antialias-
1411 text if possible. To forcibly disable antialiasing for text, do not-
1412 use this hint. Instead, set QFont::NoAntialias on your font's style-
1413 strategy.-
1414-
1415 \value SmoothPixmapTransform Indicates that the engine should use-
1416 a smooth pixmap transformation algorithm (such as bilinear) rather-
1417 than nearest neighbor.-
1418-
1419 \value HighQualityAntialiasing This value is obsolete and will be ignored,-
1420 use the Antialiasing render hint instead.-
1421-
1422 \value NonCosmeticDefaultPen This value is obsolete, the default for QPen-
1423 is now non-cosmetic.-
1424-
1425 \value Qt4CompatiblePainting Compatibility hint telling the engine to use the-
1426 same X11 based fill rules as in Qt 4, where aliased rendering is offset-
1427 by slightly less than half a pixel. Also will treat default constructed pens-
1428 as cosmetic. Potentially useful when porting a Qt 4 application to Qt 5.-
1429-
1430 \sa renderHints(), setRenderHint(), {QPainter#Rendering-
1431 Quality}{Rendering Quality}, {Concentric Circles Example}-
1432-
1433*/-
1434-
1435/*!-
1436 Constructs a painter.-
1437-
1438 \sa begin(), end()-
1439*/-
1440-
1441QPainter::QPainter()-
1442 : d_ptr(new QPainterPrivate(this))-
1443{-
1444}
never executed: end of block
0
1445-
1446/*!-
1447 \fn QPainter::QPainter(QPaintDevice *device)-
1448-
1449 Constructs a painter that begins painting the paint \a device-
1450 immediately.-
1451-
1452 This constructor is convenient for short-lived painters, e.g. in a-
1453 QWidget::paintEvent() and should be used only once. The-
1454 constructor calls begin() for you and the QPainter destructor-
1455 automatically calls end().-
1456-
1457 Here's an example using begin() and end():-
1458 \snippet code/src_gui_painting_qpainter.cpp 1-
1459-
1460 The same example using this constructor:-
1461 \snippet code/src_gui_painting_qpainter.cpp 2-
1462-
1463 Since the constructor cannot provide feedback when the initialization-
1464 of the painter failed you should rather use begin() and end() to paint-
1465 on external devices, e.g. printers.-
1466-
1467 \sa begin(), end()-
1468*/-
1469-
1470QPainter::QPainter(QPaintDevice *pd)-
1471 : d_ptr(0)-
1472{-
1473 Q_ASSERT(pd != 0);-
1474 if (!QPainterPrivate::attachPainterPrivate(this, pd)) {
!QPainterPriva...vate(this, pd)Description
TRUEnever evaluated
FALSEnever evaluated
0
1475 d_ptr.reset(new QPainterPrivate(this));-
1476 begin(pd);-
1477 }
never executed: end of block
0
1478 Q_ASSERT(d_ptr);-
1479}
never executed: end of block
0
1480-
1481/*!-
1482 Destroys the painter.-
1483*/-
1484QPainter::~QPainter()-
1485{-
1486 d_ptr->inDestructor = true;-
1487 QT_TRY {-
1488 if (isActive())
isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1489 end();
never executed: end();
0
1490 else if (d_ptr->refcount > 1)
d_ptr->refcount > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1491 d_ptr->detachPainterPrivate(this);
never executed: d_ptr->detachPainterPrivate(this);
0
1492 } QT_CATCH(...) {
never executed: end of block
dead code: { }
-
1493 // don't throw anything in the destructor.
dead code: { }
-
1494 }
dead code: { }
-
1495 if (d_ptr) {
d_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
1496 // Make sure we haven't messed things up.-
1497 Q_ASSERT(d_ptr->inDestructor);-
1498 d_ptr->inDestructor = false;-
1499 Q_ASSERT(d_ptr->refcount == 1);-
1500 if (d_ptr->d_ptrs)
d_ptr->d_ptrsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1501 free(d_ptr->d_ptrs);
never executed: free(d_ptr->d_ptrs);
0
1502 }
never executed: end of block
0
1503}
never executed: end of block
0
1504-
1505/*!-
1506 Returns the paint device on which this painter is currently-
1507 painting, or 0 if the painter is not active.-
1508-
1509 \sa isActive()-
1510*/-
1511-
1512QPaintDevice *QPainter::device() const-
1513{-
1514 Q_D(const QPainter);-
1515 if (isActive() && d->engine->d_func()->currentClipDevice)
isActive()Description
TRUEnever evaluated
FALSEnever evaluated
d->engine->d_f...rentClipDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1516 return d->engine->d_func()->currentClipDevice;
never executed: return d->engine->d_func()->currentClipDevice;
0
1517 return d->original_device;
never executed: return d->original_device;
0
1518}-
1519-
1520/*!-
1521 Returns \c true if begin() has been called and end() has not yet been-
1522 called; otherwise returns \c false.-
1523-
1524 \sa begin(), QPaintDevice::paintingActive()-
1525*/-
1526-
1527bool QPainter::isActive() const-
1528{-
1529 Q_D(const QPainter);-
1530 return d->engine;
never executed: return d->engine;
0
1531}-
1532-
1533/*!-
1534 Initializes the painters pen, background and font to the same as-
1535 the given \a device.-
1536-
1537 \obsolete-
1538-
1539 \sa begin(), {QPainter#Settings}{Settings}-
1540*/-
1541void QPainter::initFrom(const QPaintDevice *device)-
1542{-
1543 Q_ASSERT_X(device, "QPainter::initFrom(const QPaintDevice *device)", "QPaintDevice cannot be 0");-
1544 Q_D(QPainter);-
1545 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1546 qWarning("QPainter::initFrom: Painter not active, aborted");-
1547 return;
never executed: return;
0
1548 }-
1549-
1550 device->initPainter(this);-
1551-
1552 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1553 d->extended->penChanged();-
1554 } else if (d->engine) {
never executed: end of block
d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1555 d->engine->setDirty(QPaintEngine::DirtyPen);-
1556 d->engine->setDirty(QPaintEngine::DirtyBrush);-
1557 d->engine->setDirty(QPaintEngine::DirtyFont);-
1558 }
never executed: end of block
0
1559}
never executed: end of block
0
1560-
1561-
1562/*!-
1563 Saves the current painter state (pushes the state onto a stack). A-
1564 save() must be followed by a corresponding restore(); the end()-
1565 function unwinds the stack.-
1566-
1567 \sa restore()-
1568*/-
1569-
1570void QPainter::save()-
1571{-
1572#ifdef QT_DEBUG_DRAW-
1573 if (qt_show_painter_debug_output)-
1574 printf("QPainter::save()\n");-
1575#endif-
1576 Q_D(QPainter);-
1577 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1578 qWarning("QPainter::save: Painter not active");-
1579 return;
never executed: return;
0
1580 }-
1581-
1582 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1583 d->state = d->extended->createState(d->states.back());-
1584 d->extended->setState(d->state);-
1585 } else {
never executed: end of block
0
1586 d->updateState(d->state);-
1587 d->state = new QPainterState(d->states.back());-
1588 d->engine->state = d->state;-
1589 }
never executed: end of block
0
1590 d->states.push_back(d->state);-
1591}
never executed: end of block
0
1592-
1593/*!-
1594 Restores the current painter state (pops a saved state off the-
1595 stack).-
1596-
1597 \sa save()-
1598*/-
1599-
1600void QPainter::restore()-
1601{-
1602#ifdef QT_DEBUG_DRAW-
1603 if (qt_show_painter_debug_output)-
1604 printf("QPainter::restore()\n");-
1605#endif-
1606 Q_D(QPainter);-
1607 if (d->states.size()<=1) {
d->states.size()<=1Description
TRUEnever evaluated
FALSEnever evaluated
0
1608 qWarning("QPainter::restore: Unbalanced save/restore");-
1609 return;
never executed: return;
0
1610 } else if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1611 qWarning("QPainter::restore: Painter not active");-
1612 return;
never executed: return;
0
1613 }-
1614-
1615 QPainterState *tmp = d->state;-
1616 d->states.pop_back();-
1617 d->state = d->states.back();-
1618 d->txinv = false;-
1619-
1620 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1621 d->checkEmulation();-
1622 d->extended->setState(d->state);-
1623 delete tmp;-
1624 return;
never executed: return;
0
1625 }-
1626-
1627 // trigger clip update if the clip path/region has changed since-
1628 // last save-
1629 if (!d->state->clipInfo.isEmpty()
!d->state->clipInfo.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1630 && (tmp->changeFlags & (QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipPath))) {
(tmp->changeFl...irtyClipPath))Description
TRUEnever evaluated
FALSEnever evaluated
0
1631 // reuse the tmp state to avoid any extra allocs...-
1632 tmp->dirtyFlags = QPaintEngine::DirtyClipPath;-
1633 tmp->clipOperation = Qt::NoClip;-
1634 tmp->clipPath = QPainterPath();-
1635 d->engine->updateState(*tmp);-
1636 // replay the list of clip states,-
1637 for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {-
1638 tmp->matrix = info.matrix;-
1639 tmp->matrix *= d->state->redirectionMatrix;-
1640 tmp->clipOperation = info.operation;-
1641 if (info.clipType == QPainterClipInfo::RectClip) {
info.clipType ...Info::RectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
1642 tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform;-
1643 tmp->clipRegion = info.rect;-
1644 } else if (info.clipType == QPainterClipInfo::RegionClip) {
never executed: end of block
info.clipType ...fo::RegionClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
1645 tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform;-
1646 tmp->clipRegion = info.region;-
1647 } else { // clipType == QPainterClipInfo::PathClip
never executed: end of block
0
1648 tmp->dirtyFlags = QPaintEngine::DirtyClipPath | QPaintEngine::DirtyTransform;-
1649 tmp->clipPath = info.path;-
1650 }
never executed: end of block
0
1651 d->engine->updateState(*tmp);-
1652 }
never executed: end of block
0
1653-
1654-
1655 //Since we've updated the clip region anyway, pretend that the clip path hasn't changed:-
1656 d->state->dirtyFlags &= ~(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion);-
1657 tmp->changeFlags &= ~uint(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion);-
1658 tmp->changeFlags |= QPaintEngine::DirtyTransform;-
1659 }
never executed: end of block
0
1660-
1661 d->updateState(d->state);-
1662 delete tmp;-
1663}
never executed: end of block
0
1664-
1665-
1666/*!-
1667-
1668 \fn bool QPainter::begin(QPaintDevice *device)-
1669-
1670 Begins painting the paint \a device and returns \c true if-
1671 successful; otherwise returns \c false.-
1672-
1673 Notice that all painter settings (setPen(), setBrush() etc.) are reset-
1674 to default values when begin() is called.-
1675-
1676 The errors that can occur are serious problems, such as these:-
1677-
1678 \snippet code/src_gui_painting_qpainter.cpp 3-
1679-
1680 Note that most of the time, you can use one of the constructors-
1681 instead of begin(), and that end() is automatically done at-
1682 destruction.-
1683-
1684 \warning A paint device can only be painted by one painter at a-
1685 time.-
1686-
1687 \warning Painting on a QImage with the format-
1688 QImage::Format_Indexed8 is not supported.-
1689-
1690 \sa end(), QPainter()-
1691*/-
1692-
1693static inline void qt_cleanup_painter_state(QPainterPrivate *d)-
1694{-
1695 d->states.clear();-
1696 delete d->state;-
1697 d->state = 0;-
1698 d->engine = 0;-
1699 d->device = 0;-
1700}
never executed: end of block
0
1701-
1702bool QPainter::begin(QPaintDevice *pd)-
1703{-
1704 Q_ASSERT(pd);-
1705-
1706 if (pd->painters > 0) {
pd->painters > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1707 qWarning("QPainter::begin: A paint device can only be painted by one painter at a time.");-
1708 return false;
never executed: return false;
0
1709 }-
1710-
1711 if (d_ptr->engine) {
d_ptr->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1712 qWarning("QPainter::begin: Painter already active");-
1713 return false;
never executed: return false;
0
1714 }-
1715-
1716 if (QPainterPrivate::attachPainterPrivate(this, pd))
QPainterPrivat...vate(this, pd)Description
TRUEnever evaluated
FALSEnever evaluated
0
1717 return true;
never executed: return true;
0
1718-
1719 Q_D(QPainter);-
1720-
1721 d->helper_device = pd;-
1722 d->original_device = pd;-
1723-
1724 QPoint redirectionOffset;-
1725 QPaintDevice *rpd = pd->redirected(&redirectionOffset);-
1726 if (rpd)
rpdDescription
TRUEnever evaluated
FALSEnever evaluated
0
1727 pd = rpd;
never executed: pd = rpd;
0
1728-
1729#ifdef QT_DEBUG_DRAW-
1730 if (qt_show_painter_debug_output)-
1731 printf("QPainter::begin(), device=%p, type=%d\n", pd, pd->devType());-
1732#endif-
1733-
1734 if (pd->devType() == QInternal::Pixmap)
pd->devType() ...ternal::PixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
1735 static_cast<QPixmap *>(pd)->detach();
never executed: static_cast<QPixmap *>(pd)->detach();
0
1736 else if (pd->devType() == QInternal::Image)
pd->devType() ...nternal::ImageDescription
TRUEnever evaluated
FALSEnever evaluated
0
1737 static_cast<QImage *>(pd)->detach();
never executed: static_cast<QImage *>(pd)->detach();
0
1738-
1739 d->engine = pd->paintEngine();-
1740-
1741 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1742 qWarning("QPainter::begin: Paint device returned engine == 0, type: %d", pd->devType());-
1743 return false;
never executed: return false;
0
1744 }-
1745-
1746 d->device = pd;-
1747-
1748 d->extended = d->engine->isExtended() ? static_cast<QPaintEngineEx *>(d->engine) : 0;
d->engine->isExtended()Description
TRUEnever evaluated
FALSEnever evaluated
0
1749 if (d->emulationEngine)
d->emulationEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1750 d->emulationEngine->real_engine = d->extended;
never executed: d->emulationEngine->real_engine = d->extended;
0
1751-
1752 // Setup new state...-
1753 Q_ASSERT(!d->state);-
1754 d->state = d->extended ? d->extended->createState(0) : new QPainterState;
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1755 d->state->painter = this;-
1756 d->states.push_back(d->state);-
1757-
1758 d->state->redirectionMatrix.translate(-redirectionOffset.x(), -redirectionOffset.y());-
1759 d->state->brushOrigin = QPointF();-
1760-
1761 // Slip a painter state into the engine before we do any other operations-
1762 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1763 d->extended->setState(d->state);
never executed: d->extended->setState(d->state);
0
1764 else-
1765 d->engine->state = d->state;
never executed: d->engine->state = d->state;
0
1766-
1767 switch (pd->devType()) {-
1768 case QInternal::Pixmap:
never executed: case QInternal::Pixmap:
0
1769 {-
1770 QPixmap *pm = static_cast<QPixmap *>(pd);-
1771 Q_ASSERT(pm);-
1772 if (pm->isNull()) {
pm->isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1773 qWarning("QPainter::begin: Cannot paint on a null pixmap");-
1774 qt_cleanup_painter_state(d);-
1775 return false;
never executed: return false;
0
1776 }-
1777-
1778 if (pm->depth() == 1) {
pm->depth() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1779 d->state->pen = QPen(Qt::color1);-
1780 d->state->brush = QBrush(Qt::color0);-
1781 }
never executed: end of block
0
1782 break;
never executed: break;
0
1783 }-
1784 case QInternal::Image:
never executed: case QInternal::Image:
0
1785 {-
1786 QImage *img = static_cast<QImage *>(pd);-
1787 Q_ASSERT(img);-
1788 if (img->isNull()) {
img->isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1789 qWarning("QPainter::begin: Cannot paint on a null image");-
1790 qt_cleanup_painter_state(d);-
1791 return false;
never executed: return false;
0
1792 } else if (img->format() == QImage::Format_Indexed8) {
img->format() ...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
0
1793 // Painting on indexed8 images is not supported.-
1794 qWarning("QPainter::begin: Cannot paint on an image with the QImage::Format_Indexed8 format");-
1795 qt_cleanup_painter_state(d);-
1796 return false;
never executed: return false;
0
1797 }-
1798 if (img->depth() == 1) {
img->depth() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1799 d->state->pen = QPen(Qt::color1);-
1800 d->state->brush = QBrush(Qt::color0);-
1801 }
never executed: end of block
0
1802 break;
never executed: break;
0
1803 }-
1804 default:
never executed: default:
0
1805 break;
never executed: break;
0
1806 }-
1807 if (d->state->ww == 0) // For compat with 3.x painter defaults
d->state->ww == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1808 d->state->ww = d->state->wh = d->state->vw = d->state->vh = 1024;
never executed: d->state->ww = d->state->wh = d->state->vw = d->state->vh = 1024;
0
1809-
1810 d->engine->setPaintDevice(pd);-
1811-
1812 bool begun = d->engine->begin(pd);-
1813 if (!begun) {
!begunDescription
TRUEnever evaluated
FALSEnever evaluated
0
1814 qWarning("QPainter::begin(): Returned false");-
1815 if (d->engine->isActive()) {
d->engine->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1816 end();-
1817 } else {
never executed: end of block
0
1818 qt_cleanup_painter_state(d);-
1819 }
never executed: end of block
0
1820 return false;
never executed: return false;
0
1821 } else {-
1822 d->engine->setActive(begun);-
1823 }
never executed: end of block
0
1824-
1825 // Copy painter properties from original paint device,-
1826 // required for QPixmap::grabWidget()-
1827 if (d->original_device->devType() == QInternal::Widget) {
d->original_de...ternal::WidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1828 initFrom(d->original_device);-
1829 } else {
never executed: end of block
0
1830 d->state->layoutDirection = Qt::LayoutDirectionAuto;-
1831 // make sure we have a font compatible with the paintdevice-
1832 d->state->deviceFont = d->state->font = QFont(d->state->deviceFont, device());-
1833 }
never executed: end of block
0
1834-
1835 QRect systemRect = d->engine->systemRect();-
1836 if (!systemRect.isEmpty()) {
!systemRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1837 d->state->ww = d->state->vw = systemRect.width();-
1838 d->state->wh = d->state->vh = systemRect.height();-
1839 } else {
never executed: end of block
0
1840 d->state->ww = d->state->vw = pd->metric(QPaintDevice::PdmWidth);-
1841 d->state->wh = d->state->vh = pd->metric(QPaintDevice::PdmHeight);-
1842 }
never executed: end of block
0
1843-
1844 const QPoint coordinateOffset = d->engine->coordinateOffset();-
1845 d->state->redirectionMatrix.translate(-coordinateOffset.x(), -coordinateOffset.y());-
1846-
1847 Q_ASSERT(d->engine->isActive());-
1848-
1849 if (!d->state->redirectionMatrix.isIdentity() || d->effectiveDevicePixelRatio() > 1)
!d->state->red...x.isIdentity()Description
TRUEnever evaluated
FALSEnever evaluated
d->effectiveDe...xelRatio() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1850 d->updateMatrix();
never executed: d->updateMatrix();
0
1851-
1852 Q_ASSERT(d->engine->isActive());-
1853 d->state->renderHints = QPainter::TextAntialiasing;-
1854 ++d->device->painters;-
1855-
1856 d->state->emulationSpecifier = 0;-
1857-
1858 return true;
never executed: return true;
0
1859}-
1860-
1861/*!-
1862 Ends painting. Any resources used while painting are released. You-
1863 don't normally need to call this since it is called by the-
1864 destructor.-
1865-
1866 Returns \c true if the painter is no longer active; otherwise returns \c false.-
1867-
1868 \sa begin(), isActive()-
1869*/-
1870-
1871bool QPainter::end()-
1872{-
1873#ifdef QT_DEBUG_DRAW-
1874 if (qt_show_painter_debug_output)-
1875 printf("QPainter::end()\n");-
1876#endif-
1877 Q_D(QPainter);-
1878-
1879 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1880 qWarning("QPainter::end: Painter not active, aborted");-
1881 qt_cleanup_painter_state(d);-
1882 return false;
never executed: return false;
0
1883 }-
1884-
1885 if (d->refcount > 1) {
d->refcount > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1886 d->detachPainterPrivate(this);-
1887 return true;
never executed: return true;
0
1888 }-
1889-
1890 bool ended = true;-
1891-
1892 if (d->engine->isActive()) {
d->engine->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1893 ended = d->engine->end();-
1894 d->updateState(0);-
1895-
1896 --d->device->painters;-
1897 if (d->device->painters == 0) {
d->device->painters == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1898 d->engine->setPaintDevice(0);-
1899 d->engine->setActive(false);-
1900 }
never executed: end of block
0
1901 }
never executed: end of block
0
1902-
1903 if (d->states.size() > 1) {
d->states.size() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1904 qWarning("QPainter::end: Painter ended with %d saved states",-
1905 d->states.size());-
1906 }
never executed: end of block
0
1907-
1908 if (d->engine->autoDestruct()) {
d->engine->autoDestruct()Description
TRUEnever evaluated
FALSEnever evaluated
0
1909 delete d->engine;-
1910 }
never executed: end of block
0
1911-
1912 if (d->emulationEngine) {
d->emulationEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1913 delete d->emulationEngine;-
1914 d->emulationEngine = 0;-
1915 }
never executed: end of block
0
1916-
1917 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1918 d->extended = 0;-
1919 }
never executed: end of block
0
1920-
1921 qt_cleanup_painter_state(d);-
1922-
1923 return ended;
never executed: return ended;
0
1924}-
1925-
1926-
1927/*!-
1928 Returns the paint engine that the painter is currently operating-
1929 on if the painter is active; otherwise 0.-
1930-
1931 \sa isActive()-
1932*/-
1933QPaintEngine *QPainter::paintEngine() const-
1934{-
1935 Q_D(const QPainter);-
1936 return d->engine;
never executed: return d->engine;
0
1937}-
1938-
1939/*!-
1940 \since 4.6-
1941-
1942 Flushes the painting pipeline and prepares for the user issuing commands-
1943 directly to the underlying graphics context. Must be followed by a call to-
1944 endNativePainting().-
1945-
1946 Note that only the states the underlying paint engine changes will be reset-
1947 to their respective default states. The states we reset may change from-
1948 release to release. The following states are currently reset in the OpenGL-
1949 2 engine:-
1950-
1951 \list-
1952 \li blending is disabled-
1953 \li the depth, stencil and scissor tests are disabled-
1954 \li the active texture unit is reset to 0-
1955 \li the depth mask, depth function and the clear depth are reset to their-
1956 default values-
1957 \li the stencil mask, stencil operation and stencil function are reset to-
1958 their default values-
1959 \li the current color is reset to solid white-
1960 \endlist-
1961-
1962 If, for example, the OpenGL polygon mode is changed by the user inside a-
1963 beginNativePaint()/endNativePainting() block, it will not be reset to the-
1964 default state by endNativePainting(). Here is an example that shows-
1965 intermixing of painter commands and raw OpenGL commands:-
1966-
1967 \snippet code/src_gui_painting_qpainter.cpp 21-
1968-
1969 \sa endNativePainting()-
1970*/-
1971void QPainter::beginNativePainting()-
1972{-
1973 Q_D(QPainter);-
1974 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1975 qWarning("QPainter::beginNativePainting: Painter not active");-
1976 return;
never executed: return;
0
1977 }-
1978-
1979 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1980 d->extended->beginNativePainting();
never executed: d->extended->beginNativePainting();
0
1981}
never executed: end of block
0
1982-
1983/*!-
1984 \since 4.6-
1985-
1986 Restores the painter after manually issuing native painting commands. Lets-
1987 the painter restore any native state that it relies on before calling any-
1988 other painter commands.-
1989-
1990 \sa beginNativePainting()-
1991*/-
1992void QPainter::endNativePainting()-
1993{-
1994 Q_D(const QPainter);-
1995 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1996 qWarning("QPainter::beginNativePainting: Painter not active");-
1997 return;
never executed: return;
0
1998 }-
1999-
2000 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2001 d->extended->endNativePainting();
never executed: d->extended->endNativePainting();
0
2002 else-
2003 d->engine->syncState();
never executed: d->engine->syncState();
0
2004}-
2005-
2006/*!-
2007 Returns the font metrics for the painter if the painter is-
2008 active. Otherwise, the return value is undefined.-
2009-
2010 \sa font(), isActive(), {QPainter#Settings}{Settings}-
2011*/-
2012-
2013QFontMetrics QPainter::fontMetrics() const-
2014{-
2015 Q_D(const QPainter);-
2016 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2017 qWarning("QPainter::fontMetrics: Painter not active");-
2018 return QFontMetrics(QFont());
never executed: return QFontMetrics(QFont());
0
2019 }-
2020 return QFontMetrics(d->state->font);
never executed: return QFontMetrics(d->state->font);
0
2021}-
2022-
2023-
2024/*!-
2025 Returns the font info for the painter if the painter is-
2026 active. Otherwise, the return value is undefined.-
2027-
2028 \sa font(), isActive(), {QPainter#Settings}{Settings}-
2029*/-
2030-
2031QFontInfo QPainter::fontInfo() const-
2032{-
2033 Q_D(const QPainter);-
2034 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2035 qWarning("QPainter::fontInfo: Painter not active");-
2036 return QFontInfo(QFont());
never executed: return QFontInfo(QFont());
0
2037 }-
2038 return QFontInfo(d->state->font);
never executed: return QFontInfo(d->state->font);
0
2039}-
2040-
2041/*!-
2042 \since 4.2-
2043-
2044 Returns the opacity of the painter. The default value is-
2045 1.-
2046*/-
2047-
2048qreal QPainter::opacity() const-
2049{-
2050 Q_D(const QPainter);-
2051 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2052 qWarning("QPainter::opacity: Painter not active");-
2053 return 1.0;
never executed: return 1.0;
0
2054 }-
2055 return d->state->opacity;
never executed: return d->state->opacity;
0
2056}-
2057-
2058/*!-
2059 \since 4.2-
2060-
2061 Sets the opacity of the painter to \a opacity. The value should-
2062 be in the range 0.0 to 1.0, where 0.0 is fully transparent and-
2063 1.0 is fully opaque.-
2064-
2065 Opacity set on the painter will apply to all drawing operations-
2066 individually.-
2067*/-
2068-
2069void QPainter::setOpacity(qreal opacity)-
2070{-
2071 Q_D(QPainter);-
2072-
2073 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2074 qWarning("QPainter::setOpacity: Painter not active");-
2075 return;
never executed: return;
0
2076 }-
2077-
2078 opacity = qMin(qreal(1), qMax(qreal(0), opacity));-
2079-
2080 if (opacity == d->state->opacity)
opacity == d->state->opacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
2081 return;
never executed: return;
0
2082-
2083 d->state->opacity = opacity;-
2084-
2085 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2086 d->extended->opacityChanged();
never executed: d->extended->opacityChanged();
0
2087 else-
2088 d->state->dirtyFlags |= QPaintEngine::DirtyOpacity;
never executed: d->state->dirtyFlags |= QPaintEngine::DirtyOpacity;
0
2089}-
2090-
2091-
2092/*!-
2093 Returns the currently set brush origin.-
2094-
2095 \sa setBrushOrigin(), {QPainter#Settings}{Settings}-
2096*/-
2097-
2098QPoint QPainter::brushOrigin() const-
2099{-
2100 Q_D(const QPainter);-
2101 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2102 qWarning("QPainter::brushOrigin: Painter not active");-
2103 return QPoint();
never executed: return QPoint();
0
2104 }-
2105 return QPointF(d->state->brushOrigin).toPoint();
never executed: return QPointF(d->state->brushOrigin).toPoint();
0
2106}-
2107-
2108/*!-
2109 \fn void QPainter::setBrushOrigin(const QPointF &position)-
2110-
2111 Sets the brush origin to \a position.-
2112-
2113 The brush origin specifies the (0, 0) coordinate of the painter's-
2114 brush.-
2115-
2116 Note that while the brushOrigin() was necessary to adopt the-
2117 parent's background for a widget in Qt 3, this is no longer the-
2118 case since the Qt 4 painter doesn't paint the background unless-
2119 you explicitly tell it to do so by setting the widget's \l-
2120 {QWidget::autoFillBackground}{autoFillBackground} property to-
2121 true.-
2122-
2123 \sa brushOrigin(), {QPainter#Settings}{Settings}-
2124*/-
2125-
2126void QPainter::setBrushOrigin(const QPointF &p)-
2127{-
2128 Q_D(QPainter);-
2129#ifdef QT_DEBUG_DRAW-
2130 if (qt_show_painter_debug_output)-
2131 printf("QPainter::setBrushOrigin(), (%.2f,%.2f)\n", p.x(), p.y());-
2132#endif-
2133-
2134 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2135 qWarning("QPainter::setBrushOrigin: Painter not active");-
2136 return;
never executed: return;
0
2137 }-
2138-
2139 d->state->brushOrigin = p;-
2140-
2141 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2142 d->extended->brushOriginChanged();-
2143 return;
never executed: return;
0
2144 }-
2145-
2146 d->state->dirtyFlags |= QPaintEngine::DirtyBrushOrigin;-
2147}
never executed: end of block
0
2148-
2149/*!-
2150 \fn void QPainter::setBrushOrigin(const QPoint &position)-
2151 \overload-
2152-
2153 Sets the brush's origin to the given \a position.-
2154*/-
2155-
2156/*!-
2157 \fn void QPainter::setBrushOrigin(int x, int y)-
2158-
2159 \overload-
2160-
2161 Sets the brush's origin to point (\a x, \a y).-
2162*/-
2163-
2164/*!-
2165 \enum QPainter::CompositionMode-
2166-
2167 Defines the modes supported for digital image compositing.-
2168 Composition modes are used to specify how the pixels in one image,-
2169 the source, are merged with the pixel in another image, the-
2170 destination.-
2171-
2172 Please note that the bitwise raster operation modes, denoted with-
2173 a RasterOp prefix, are only natively supported in the X11 and-
2174 raster paint engines. This means that the only way to utilize-
2175 these modes on the Mac is via a QImage. The RasterOp denoted blend-
2176 modes are \e not supported for pens and brushes with alpha-
2177 components. Also, turning on the QPainter::Antialiasing render-
2178 hint will effectively disable the RasterOp modes.-
2179-
2180-
2181 \image qpainter-compositionmode1.png-
2182 \image qpainter-compositionmode2.png-
2183-
2184 The most common type is SourceOver (often referred to as just-
2185 alpha blending) where the source pixel is blended on top of the-
2186 destination pixel in such a way that the alpha component of the-
2187 source defines the translucency of the pixel.-
2188-
2189 Several composition modes require an alpha channel in the source or-
2190 target images to have an effect. For optimal performance the-
2191 image format \l {QImage::Format}{Format_ARGB32_Premultiplied} is-
2192 preferred.-
2193-
2194 When a composition mode is set it applies to all painting-
2195 operator, pens, brushes, gradients and pixmap/image drawing.-
2196-
2197 \value CompositionMode_SourceOver This is the default mode. The-
2198 alpha of the source is used to blend the pixel on top of the-
2199 destination.-
2200-
2201 \value CompositionMode_DestinationOver The alpha of the-
2202 destination is used to blend it on top of the source pixels. This-
2203 mode is the inverse of CompositionMode_SourceOver.-
2204-
2205 \value CompositionMode_Clear The pixels in the destination are-
2206 cleared (set to fully transparent) independent of the source.-
2207-
2208 \value CompositionMode_Source The output is the source-
2209 pixel. (This means a basic copy operation and is identical to-
2210 SourceOver when the source pixel is opaque).-
2211-
2212 \value CompositionMode_Destination The output is the destination-
2213 pixel. This means that the blending has no effect. This mode is-
2214 the inverse of CompositionMode_Source.-
2215-
2216 \value CompositionMode_SourceIn The output is the source, where-
2217 the alpha is reduced by that of the destination.-
2218-
2219 \value CompositionMode_DestinationIn The output is the-
2220 destination, where the alpha is reduced by that of the-
2221 source. This mode is the inverse of CompositionMode_SourceIn.-
2222-
2223 \value CompositionMode_SourceOut The output is the source, where-
2224 the alpha is reduced by the inverse of destination.-
2225-
2226 \value CompositionMode_DestinationOut The output is the-
2227 destination, where the alpha is reduced by the inverse of the-
2228 source. This mode is the inverse of CompositionMode_SourceOut.-
2229-
2230 \value CompositionMode_SourceAtop The source pixel is blended on-
2231 top of the destination, with the alpha of the source pixel reduced-
2232 by the alpha of the destination pixel.-
2233-
2234 \value CompositionMode_DestinationAtop The destination pixel is-
2235 blended on top of the source, with the alpha of the destination-
2236 pixel is reduced by the alpha of the destination pixel. This mode-
2237 is the inverse of CompositionMode_SourceAtop.-
2238-
2239 \value CompositionMode_Xor The source, whose alpha is reduced with-
2240 the inverse of the destination alpha, is merged with the-
2241 destination, whose alpha is reduced by the inverse of the source-
2242 alpha. CompositionMode_Xor is not the same as the bitwise Xor.-
2243-
2244 \value CompositionMode_Plus Both the alpha and color of the source-
2245 and destination pixels are added together.-
2246-
2247 \value CompositionMode_Multiply The output is the source color-
2248 multiplied by the destination. Multiplying a color with white-
2249 leaves the color unchanged, while multiplying a color-
2250 with black produces black.-
2251-
2252 \value CompositionMode_Screen The source and destination colors-
2253 are inverted and then multiplied. Screening a color with white-
2254 produces white, whereas screening a color with black leaves the-
2255 color unchanged.-
2256-
2257 \value CompositionMode_Overlay Multiplies or screens the colors-
2258 depending on the destination color. The destination color is mixed-
2259 with the source color to reflect the lightness or darkness of the-
2260 destination.-
2261-
2262 \value CompositionMode_Darken The darker of the source and-
2263 destination colors is selected.-
2264-
2265 \value CompositionMode_Lighten The lighter of the source and-
2266 destination colors is selected.-
2267-
2268 \value CompositionMode_ColorDodge The destination color is-
2269 brightened to reflect the source color. A black source color-
2270 leaves the destination color unchanged.-
2271-
2272 \value CompositionMode_ColorBurn The destination color is darkened-
2273 to reflect the source color. A white source color leaves the-
2274 destination color unchanged.-
2275-
2276 \value CompositionMode_HardLight Multiplies or screens the colors-
2277 depending on the source color. A light source color will lighten-
2278 the destination color, whereas a dark source color will darken the-
2279 destination color.-
2280-
2281 \value CompositionMode_SoftLight Darkens or lightens the colors-
2282 depending on the source color. Similar to-
2283 CompositionMode_HardLight.-
2284-
2285 \value CompositionMode_Difference Subtracts the darker of the-
2286 colors from the lighter. Painting with white inverts the-
2287 destination color, whereas painting with black leaves the-
2288 destination color unchanged.-
2289-
2290 \value CompositionMode_Exclusion Similar to-
2291 CompositionMode_Difference, but with a lower contrast. Painting-
2292 with white inverts the destination color, whereas painting with-
2293 black leaves the destination color unchanged.-
2294-
2295 \value RasterOp_SourceOrDestination Does a bitwise OR operation on-
2296 the source and destination pixels (src OR dst).-
2297-
2298 \value RasterOp_SourceAndDestination Does a bitwise AND operation-
2299 on the source and destination pixels (src AND dst).-
2300-
2301 \value RasterOp_SourceXorDestination Does a bitwise XOR operation-
2302 on the source and destination pixels (src XOR dst).-
2303-
2304 \value RasterOp_NotSourceAndNotDestination Does a bitwise NOR-
2305 operation on the source and destination pixels ((NOT src) AND (NOT-
2306 dst)).-
2307-
2308 \value RasterOp_NotSourceOrNotDestination Does a bitwise NAND-
2309 operation on the source and destination pixels ((NOT src) OR (NOT-
2310 dst)).-
2311-
2312 \value RasterOp_NotSourceXorDestination Does a bitwise operation-
2313 where the source pixels are inverted and then XOR'ed with the-
2314 destination ((NOT src) XOR dst).-
2315-
2316 \value RasterOp_NotSource Does a bitwise operation where the-
2317 source pixels are inverted (NOT src).-
2318-
2319 \value RasterOp_NotSourceAndDestination Does a bitwise operation-
2320 where the source is inverted and then AND'ed with the destination-
2321 ((NOT src) AND dst).-
2322-
2323 \value RasterOp_SourceAndNotDestination Does a bitwise operation-
2324 where the source is AND'ed with the inverted destination pixels-
2325 (src AND (NOT dst)).-
2326-
2327 \value RasterOp_NotSourceOrDestination Does a bitwise operation-
2328 where the source is inverted and then OR'ed with the destination-
2329 ((NOT src) OR dst).-
2330-
2331 \value RasterOp_ClearDestination The pixels in the destination are-
2332 cleared (set to 0) independent of the source.-
2333-
2334 \value RasterOp_SetDestination The pixels in the destination are-
2335 set (set to 1) independent of the source.-
2336-
2337 \value RasterOp_NotDestination Does a bitwise operation-
2338 where the destination pixels are inverted (NOT dst).-
2339-
2340 \value RasterOp_SourceOrNotDestination Does a bitwise operation-
2341 where the source is OR'ed with the inverted destination pixels-
2342 (src OR (NOT dst)).-
2343-
2344 \sa compositionMode(), setCompositionMode(), {QPainter#Composition-
2345 Modes}{Composition Modes}, {Image Composition Example}-
2346*/-
2347-
2348/*!-
2349 Sets the composition mode to the given \a mode.-
2350-
2351 \warning Only a QPainter operating on a QImage fully supports all-
2352 composition modes. The RasterOp modes are supported for X11 as-
2353 described in compositionMode().-
2354-
2355 \sa compositionMode()-
2356*/-
2357void QPainter::setCompositionMode(CompositionMode mode)-
2358{-
2359 Q_D(QPainter);-
2360 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2361 qWarning("QPainter::setCompositionMode: Painter not active");-
2362 return;
never executed: return;
0
2363 }-
2364 if (d->state->composition_mode == mode)
d->state->comp...n_mode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2365 return;
never executed: return;
0
2366 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2367 d->state->composition_mode = mode;-
2368 d->extended->compositionModeChanged();-
2369 return;
never executed: return;
0
2370 }-
2371-
2372 if (mode >= QPainter::RasterOp_SourceOrDestination) {
mode >= QPaint...eOrDestinationDescription
TRUEnever evaluated
FALSEnever evaluated
0
2373 if (!d->engine->hasFeature(QPaintEngine::RasterOpModes)) {
!d->engine->ha...RasterOpModes)Description
TRUEnever evaluated
FALSEnever evaluated
0
2374 qWarning("QPainter::setCompositionMode: "-
2375 "Raster operation modes not supported on device");-
2376 return;
never executed: return;
0
2377 }-
2378 } else if (mode >= QPainter::CompositionMode_Plus) {
never executed: end of block
mode >= QPaint...itionMode_PlusDescription
TRUEnever evaluated
FALSEnever evaluated
0
2379 if (!d->engine->hasFeature(QPaintEngine::BlendModes)) {
!d->engine->ha...e::BlendModes)Description
TRUEnever evaluated
FALSEnever evaluated
0
2380 qWarning("QPainter::setCompositionMode: "-
2381 "Blend modes not supported on device");-
2382 return;
never executed: return;
0
2383 }-
2384 } else if (!d->engine->hasFeature(QPaintEngine::PorterDuff)) {
never executed: end of block
!d->engine->ha...e::PorterDuff)Description
TRUEnever evaluated
FALSEnever evaluated
0
2385 if (mode != CompositionMode_Source && mode != CompositionMode_SourceOver) {
mode != CompositionMode_SourceDescription
TRUEnever evaluated
FALSEnever evaluated
mode != Compos...ode_SourceOverDescription
TRUEnever evaluated
FALSEnever evaluated
0
2386 qWarning("QPainter::setCompositionMode: "-
2387 "PorterDuff modes not supported on device");-
2388 return;
never executed: return;
0
2389 }-
2390 }
never executed: end of block
0
2391-
2392 d->state->composition_mode = mode;-
2393 d->state->dirtyFlags |= QPaintEngine::DirtyCompositionMode;-
2394}
never executed: end of block
0
2395-
2396/*!-
2397 Returns the current composition mode.-
2398-
2399 \sa CompositionMode, setCompositionMode()-
2400*/-
2401QPainter::CompositionMode QPainter::compositionMode() const-
2402{-
2403 Q_D(const QPainter);-
2404 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2405 qWarning("QPainter::compositionMode: Painter not active");-
2406 return QPainter::CompositionMode_SourceOver;
never executed: return QPainter::CompositionMode_SourceOver;
0
2407 }-
2408 return d->state->composition_mode;
never executed: return d->state->composition_mode;
0
2409}-
2410-
2411/*!-
2412 Returns the current background brush.-
2413-
2414 \sa setBackground(), {QPainter#Settings}{Settings}-
2415*/-
2416-
2417const QBrush &QPainter::background() const-
2418{-
2419 Q_D(const QPainter);-
2420 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2421 qWarning("QPainter::background: Painter not active");-
2422 return d->fakeState()->brush;
never executed: return d->fakeState()->brush;
0
2423 }-
2424 return d->state->bgBrush;
never executed: return d->state->bgBrush;
0
2425}-
2426-
2427-
2428/*!-
2429 Returns \c true if clipping has been set; otherwise returns \c false.-
2430-
2431 \sa setClipping(), {QPainter#Clipping}{Clipping}-
2432*/-
2433-
2434bool QPainter::hasClipping() const-
2435{-
2436 Q_D(const QPainter);-
2437 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2438 qWarning("QPainter::hasClipping: Painter not active");-
2439 return false;
never executed: return false;
0
2440 }-
2441 return d->state->clipEnabled && d->state->clipOperation != Qt::NoClip;
never executed: return d->state->clipEnabled && d->state->clipOperation != Qt::NoClip;
0
2442}-
2443-
2444-
2445/*!-
2446 Enables clipping if \a enable is true, or disables clipping if \a-
2447 enable is false.-
2448-
2449 \sa hasClipping(), {QPainter#Clipping}{Clipping}-
2450*/-
2451-
2452void QPainter::setClipping(bool enable)-
2453{-
2454 Q_D(QPainter);-
2455#ifdef QT_DEBUG_DRAW-
2456 if (qt_show_painter_debug_output)-
2457 printf("QPainter::setClipping(), enable=%s, was=%s\n",-
2458 enable ? "on" : "off",-
2459 hasClipping() ? "on" : "off");-
2460#endif-
2461 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2462 qWarning("QPainter::setClipping: Painter not active, state will be reset by begin");-
2463 return;
never executed: return;
0
2464 }-
2465-
2466 if (hasClipping() == enable)
hasClipping() == enableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2467 return;
never executed: return;
0
2468-
2469 // we can't enable clipping if we don't have a clip-
2470 if (enable
enableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2471 && (d->state->clipInfo.isEmpty() || d->state->clipInfo.constLast().operation == Qt::NoClip))
d->state->clipInfo.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
d->state->clip... == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2472 return;
never executed: return;
0
2473 d->state->clipEnabled = enable;-
2474-
2475 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2476 d->extended->clipEnabledChanged();-
2477 return;
never executed: return;
0
2478 }-
2479-
2480 d->state->dirtyFlags |= QPaintEngine::DirtyClipEnabled;-
2481 d->updateState(d->state);-
2482}
never executed: end of block
0
2483-
2484-
2485/*!-
2486 Returns the currently set clip region. Note that the clip region-
2487 is given in logical coordinates.-
2488-
2489 \warning QPainter does not store the combined clip explicitly as-
2490 this is handled by the underlying QPaintEngine, so the path is-
2491 recreated on demand and transformed to the current logical-
2492 coordinate system. This is potentially an expensive operation.-
2493-
2494 \sa setClipRegion(), clipPath(), setClipping()-
2495*/-
2496-
2497QRegion QPainter::clipRegion() const-
2498{-
2499 Q_D(const QPainter);-
2500 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2501 qWarning("QPainter::clipRegion: Painter not active");-
2502 return QRegion();
never executed: return QRegion();
0
2503 }-
2504-
2505 QRegion region;-
2506 bool lastWasNothing = true;-
2507-
2508 if (!d->txinv)
!d->txinvDescription
TRUEnever evaluated
FALSEnever evaluated
0
2509 const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
0
2510-
2511 // ### Falcon: Use QPainterPath-
2512 for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {-
2513 switch (info.clipType) {-
2514-
2515 case QPainterClipInfo::RegionClip: {
never executed: case QPainterClipInfo::RegionClip:
0
2516 QTransform matrix = (info.matrix * d->invMatrix);-
2517 if (lastWasNothing) {
lastWasNothingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2518 region = info.region * matrix;-
2519 lastWasNothing = false;-
2520 continue;
never executed: continue;
0
2521 }-
2522 if (info.operation == Qt::IntersectClip)
info.operation...:IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2523 region &= info.region * matrix;
never executed: region &= info.region * matrix;
0
2524 else if (info.operation == Qt::NoClip) {
info.operation == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2525 lastWasNothing = true;-
2526 region = QRegion();-
2527 } else
never executed: end of block
0
2528 region = info.region * matrix;
never executed: region = info.region * matrix;
0
2529 break;
never executed: break;
0
2530 }-
2531-
2532 case QPainterClipInfo::PathClip: {
never executed: case QPainterClipInfo::PathClip:
0
2533 QTransform matrix = (info.matrix * d->invMatrix);-
2534 if (lastWasNothing) {
lastWasNothingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2535 region = QRegion((info.path * matrix).toFillPolygon().toPolygon(),-
2536 info.path.fillRule());-
2537 lastWasNothing = false;-
2538 continue;
never executed: continue;
0
2539 }-
2540 if (info.operation == Qt::IntersectClip) {
info.operation...:IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2541 region &= QRegion((info.path * matrix).toFillPolygon().toPolygon(),-
2542 info.path.fillRule());-
2543 } else if (info.operation == Qt::NoClip) {
never executed: end of block
info.operation == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2544 lastWasNothing = true;-
2545 region = QRegion();-
2546 } else {
never executed: end of block
0
2547 region = QRegion((info.path * matrix).toFillPolygon().toPolygon(),-
2548 info.path.fillRule());-
2549 }
never executed: end of block
0
2550 break;
never executed: break;
0
2551 }-
2552-
2553 case QPainterClipInfo::RectClip: {
never executed: case QPainterClipInfo::RectClip:
0
2554 QTransform matrix = (info.matrix * d->invMatrix);-
2555 if (lastWasNothing) {
lastWasNothingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2556 region = QRegion(info.rect) * matrix;-
2557 lastWasNothing = false;-
2558 continue;
never executed: continue;
0
2559 }-
2560 if (info.operation == Qt::IntersectClip) {
info.operation...:IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2561 // Use rect intersection if possible.-
2562 if (matrix.type() <= QTransform::TxScale)
matrix.type() ...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2563 region &= matrix.mapRect(info.rect);
never executed: region &= matrix.mapRect(info.rect);
0
2564 else-
2565 region &= matrix.map(QRegion(info.rect));
never executed: region &= matrix.map(QRegion(info.rect));
0
2566 } else if (info.operation == Qt::NoClip) {
info.operation == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2567 lastWasNothing = true;-
2568 region = QRegion();-
2569 } else {
never executed: end of block
0
2570 region = QRegion(info.rect) * matrix;-
2571 }
never executed: end of block
0
2572 break;
never executed: break;
0
2573 }-
2574-
2575 case QPainterClipInfo::RectFClip: {
never executed: case QPainterClipInfo::RectFClip:
0
2576 QTransform matrix = (info.matrix * d->invMatrix);-
2577 if (lastWasNothing) {
lastWasNothingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2578 region = QRegion(info.rectf.toRect()) * matrix;-
2579 lastWasNothing = false;-
2580 continue;
never executed: continue;
0
2581 }-
2582 if (info.operation == Qt::IntersectClip) {
info.operation...:IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2583 // Use rect intersection if possible.-
2584 if (matrix.type() <= QTransform::TxScale)
matrix.type() ...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2585 region &= matrix.mapRect(info.rectf.toRect());
never executed: region &= matrix.mapRect(info.rectf.toRect());
0
2586 else-
2587 region &= matrix.map(QRegion(info.rectf.toRect()));
never executed: region &= matrix.map(QRegion(info.rectf.toRect()));
0
2588 } else if (info.operation == Qt::NoClip) {
info.operation == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2589 lastWasNothing = true;-
2590 region = QRegion();-
2591 } else {
never executed: end of block
0
2592 region = QRegion(info.rectf.toRect()) * matrix;-
2593 }
never executed: end of block
0
2594 break;
never executed: break;
0
2595 }-
2596 }-
2597 }
never executed: end of block
0
2598-
2599 return region;
never executed: return region;
0
2600}-
2601-
2602extern QPainterPath qt_regionToPath(const QRegion &region);-
2603-
2604/*!-
2605 Returns the current clip path in logical coordinates.-
2606-
2607 \warning QPainter does not store the combined clip explicitly as-
2608 this is handled by the underlying QPaintEngine, so the path is-
2609 recreated on demand and transformed to the current logical-
2610 coordinate system. This is potentially an expensive operation.-
2611-
2612 \sa setClipPath(), clipRegion(), setClipping()-
2613*/-
2614QPainterPath QPainter::clipPath() const-
2615{-
2616 Q_D(const QPainter);-
2617-
2618 // ### Since we do not support path intersections and path unions yet,-
2619 // we just use clipRegion() here...-
2620 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2621 qWarning("QPainter::clipPath: Painter not active");-
2622 return QPainterPath();
never executed: return QPainterPath();
0
2623 }-
2624-
2625 // No clip, return empty-
2626 if (d->state->clipInfo.isEmpty()) {
d->state->clipInfo.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2627 return QPainterPath();
never executed: return QPainterPath();
0
2628 } else {-
2629-
2630 // Update inverse matrix, used below.-
2631 if (!d->txinv)
!d->txinvDescription
TRUEnever evaluated
FALSEnever evaluated
0
2632 const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
0
2633-
2634 // For the simple case avoid conversion.-
2635 if (d->state->clipInfo.size() == 1
d->state->clipInfo.size() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2636 && d->state->clipInfo.at(0).clipType == QPainterClipInfo::PathClip) {
d->state->clip...Info::PathClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2637 QTransform matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix);-
2638 return d->state->clipInfo.at(0).path * matrix;
never executed: return d->state->clipInfo.at(0).path * matrix;
0
2639-
2640 } else if (d->state->clipInfo.size() == 1
d->state->clipInfo.size() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2641 && d->state->clipInfo.at(0).clipType == QPainterClipInfo::RectClip) {
d->state->clip...Info::RectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2642 QTransform matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix);-
2643 QPainterPath path;-
2644 path.addRect(d->state->clipInfo.at(0).rect);-
2645 return path * matrix;
never executed: return path * matrix;
0
2646 } else {-
2647 // Fallback to clipRegion() for now, since we don't have isect/unite for paths-
2648 return qt_regionToPath(clipRegion());
never executed: return qt_regionToPath(clipRegion());
0
2649 }-
2650 }-
2651}-
2652-
2653/*!-
2654 Returns the bounding rectangle of the current clip if there is a clip;-
2655 otherwise returns an empty rectangle. Note that the clip region is-
2656 given in logical coordinates.-
2657-
2658 The bounding rectangle is not guaranteed to be tight.-
2659-
2660 \sa setClipRect(), setClipPath(), setClipRegion()-
2661-
2662 \since 4.8-
2663 */-
2664-
2665QRectF QPainter::clipBoundingRect() const-
2666{-
2667 Q_D(const QPainter);-
2668-
2669 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2670 qWarning("QPainter::clipBoundingRect: Painter not active");-
2671 return QRectF();
never executed: return QRectF();
0
2672 }-
2673-
2674 // Accumulate the bounding box in device space. This is not 100%-
2675 // precise, but it fits within the guarantee and it is reasonably-
2676 // fast.-
2677 QRectF bounds;-
2678 bool first = true;-
2679 for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {-
2680 QRectF r;-
2681-
2682 if (info.clipType == QPainterClipInfo::RectClip)
info.clipType ...Info::RectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2683 r = info.rect;
never executed: r = info.rect;
0
2684 else if (info.clipType == QPainterClipInfo::RectFClip)
info.clipType ...nfo::RectFClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2685 r = info.rectf;
never executed: r = info.rectf;
0
2686 else if (info.clipType == QPainterClipInfo::RegionClip)
info.clipType ...fo::RegionClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2687 r = info.region.boundingRect();
never executed: r = info.region.boundingRect();
0
2688 else-
2689 r = info.path.boundingRect();
never executed: r = info.path.boundingRect();
0
2690-
2691 r = info.matrix.mapRect(r);-
2692-
2693 if (first)
firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
2694 bounds = r;
never executed: bounds = r;
0
2695 else if (info.operation == Qt::IntersectClip)
info.operation...:IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2696 bounds &= r;
never executed: bounds &= r;
0
2697 first = false;-
2698 }
never executed: end of block
0
2699-
2700-
2701 // Map the rectangle back into logical space using the inverse-
2702 // matrix.-
2703 if (!d->txinv)
!d->txinvDescription
TRUEnever evaluated
FALSEnever evaluated
0
2704 const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
0
2705-
2706 return d->invMatrix.mapRect(bounds);
never executed: return d->invMatrix.mapRect(bounds);
0
2707}-
2708-
2709/*!-
2710 \fn void QPainter::setClipRect(const QRectF &rectangle, Qt::ClipOperation operation)-
2711-
2712 Enables clipping, and sets the clip region to the given \a-
2713 rectangle using the given clip \a operation. The default operation-
2714 is to replace the current clip rectangle.-
2715-
2716 Note that the clip rectangle is specified in logical (painter)-
2717 coordinates.-
2718-
2719 \sa clipRegion(), setClipping(), {QPainter#Clipping}{Clipping}-
2720*/-
2721void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op)-
2722{-
2723 Q_D(QPainter);-
2724-
2725 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2726 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2727 qWarning("QPainter::setClipRect: Painter not active");-
2728 return;
never executed: return;
0
2729 }-
2730 bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture);-
2731 if (simplifyClipOp && (!d->state->clipEnabled && op != Qt::NoClip))
simplifyClipOpDescription
TRUEnever evaluated
FALSEnever evaluated
!d->state->clipEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
op != Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2732 op = Qt::ReplaceClip;
never executed: op = Qt::ReplaceClip;
0
2733-
2734 qreal right = rect.x() + rect.width();-
2735 qreal bottom = rect.y() + rect.height();-
2736 qreal pts[] = { rect.x(), rect.y(),-
2737 right, rect.y(),-
2738 right, bottom,-
2739 rect.x(), bottom };-
2740 QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint);-
2741 d->state->clipEnabled = true;-
2742 d->extended->clip(vp, op);-
2743 if (op == Qt::ReplaceClip || op == Qt::NoClip)
op == Qt::ReplaceClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2744 d->state->clipInfo.clear();
never executed: d->state->clipInfo.clear();
0
2745 d->state->clipInfo.append(QPainterClipInfo(rect, op, d->state->matrix));-
2746 d->state->clipOperation = op;-
2747 return;
never executed: return;
0
2748 }-
2749-
2750 if (qreal(int(rect.top())) == rect.top()
qreal(int(rect... == rect.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
2751 && qreal(int(rect.bottom())) == rect.bottom()
qreal(int(rect... rect.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
2752 && qreal(int(rect.left())) == rect.left()
qreal(int(rect...== rect.left()Description
TRUEnever evaluated
FALSEnever evaluated
0
2753 && qreal(int(rect.right())) == rect.right())
qreal(int(rect...= rect.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
2754 {-
2755 setClipRect(rect.toRect(), op);-
2756 return;
never executed: return;
0
2757 }-
2758-
2759 if (rect.isEmpty()) {
rect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2760 setClipRegion(QRegion(), op);-
2761 return;
never executed: return;
0
2762 }-
2763-
2764 QPainterPath path;-
2765 path.addRect(rect);-
2766 setClipPath(path, op);-
2767}
never executed: end of block
0
2768-
2769/*!-
2770 \fn void QPainter::setClipRect(const QRect &rectangle, Qt::ClipOperation operation)-
2771 \overload-
2772-
2773 Enables clipping, and sets the clip region to the given \a rectangle using the given-
2774 clip \a operation.-
2775*/-
2776void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op)-
2777{-
2778 Q_D(QPainter);-
2779-
2780 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2781 qWarning("QPainter::setClipRect: Painter not active");-
2782 return;
never executed: return;
0
2783 }-
2784 bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture);-
2785-
2786 if (simplifyClipOp && (!d->state->clipEnabled && op != Qt::NoClip))
simplifyClipOpDescription
TRUEnever evaluated
FALSEnever evaluated
!d->state->clipEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
op != Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2787 op = Qt::ReplaceClip;
never executed: op = Qt::ReplaceClip;
0
2788-
2789 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2790 d->state->clipEnabled = true;-
2791 d->extended->clip(rect, op);-
2792 if (op == Qt::ReplaceClip || op == Qt::NoClip)
op == Qt::ReplaceClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2793 d->state->clipInfo.clear();
never executed: d->state->clipInfo.clear();
0
2794 d->state->clipInfo.append(QPainterClipInfo(rect, op, d->state->matrix));-
2795 d->state->clipOperation = op;-
2796 return;
never executed: return;
0
2797 }-
2798-
2799 if (simplifyClipOp && d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip)
simplifyClipOpDescription
TRUEnever evaluated
FALSEnever evaluated
d->state->clip... == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2800 op = Qt::ReplaceClip;
never executed: op = Qt::ReplaceClip;
0
2801-
2802 d->state->clipRegion = rect;-
2803 d->state->clipOperation = op;-
2804 if (op == Qt::NoClip || op == Qt::ReplaceClip)
op == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::ReplaceClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2805 d->state->clipInfo.clear();
never executed: d->state->clipInfo.clear();
0
2806 d->state->clipInfo.append(QPainterClipInfo(rect, op, d->state->matrix));-
2807 d->state->clipEnabled = true;-
2808 d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled;-
2809 d->updateState(d->state);-
2810}
never executed: end of block
0
2811-
2812/*!-
2813 \fn void QPainter::setClipRect(int x, int y, int width, int height, Qt::ClipOperation operation)-
2814-
2815 Enables clipping, and sets the clip region to the rectangle beginning at (\a x, \a y)-
2816 with the given \a width and \a height.-
2817*/-
2818-
2819/*!-
2820 \fn void QPainter::setClipRegion(const QRegion &region, Qt::ClipOperation operation)-
2821-
2822 Sets the clip region to the given \a region using the specified clip-
2823 \a operation. The default clip operation is to replace the current-
2824 clip region.-
2825-
2826 Note that the clip region is given in logical coordinates.-
2827-
2828 \sa clipRegion(), setClipRect(), {QPainter#Clipping}{Clipping}-
2829*/-
2830void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)-
2831{-
2832 Q_D(QPainter);-
2833#ifdef QT_DEBUG_DRAW-
2834 QRect rect = r.boundingRect();-
2835 if (qt_show_painter_debug_output)-
2836 printf("QPainter::setClipRegion(), size=%d, [%d,%d,%d,%d]\n",-
2837 r.rects().size(), rect.x(), rect.y(), rect.width(), rect.height());-
2838#endif-
2839 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2840 qWarning("QPainter::setClipRegion: Painter not active");-
2841 return;
never executed: return;
0
2842 }-
2843 bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture);-
2844-
2845 if (simplifyClipOp && (!d->state->clipEnabled && op != Qt::NoClip))
simplifyClipOpDescription
TRUEnever evaluated
FALSEnever evaluated
!d->state->clipEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
op != Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2846 op = Qt::ReplaceClip;
never executed: op = Qt::ReplaceClip;
0
2847-
2848 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2849 d->state->clipEnabled = true;-
2850 d->extended->clip(r, op);-
2851 if (op == Qt::NoClip || op == Qt::ReplaceClip)
op == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::ReplaceClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2852 d->state->clipInfo.clear();
never executed: d->state->clipInfo.clear();
0
2853 d->state->clipInfo.append(QPainterClipInfo(r, op, d->state->matrix));-
2854 d->state->clipOperation = op;-
2855 return;
never executed: return;
0
2856 }-
2857-
2858 if (simplifyClipOp && d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip)
simplifyClipOpDescription
TRUEnever evaluated
FALSEnever evaluated
d->state->clip... == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2859 op = Qt::ReplaceClip;
never executed: op = Qt::ReplaceClip;
0
2860-
2861 d->state->clipRegion = r;-
2862 d->state->clipOperation = op;-
2863 if (op == Qt::NoClip || op == Qt::ReplaceClip)
op == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::ReplaceClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2864 d->state->clipInfo.clear();
never executed: d->state->clipInfo.clear();
0
2865 d->state->clipInfo.append(QPainterClipInfo(r, op, d->state->matrix));-
2866 d->state->clipEnabled = true;-
2867 d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled;-
2868 d->updateState(d->state);-
2869}
never executed: end of block
0
2870-
2871/*!-
2872 \since 4.2-
2873 \obsolete-
2874-
2875 Sets the transformation matrix to \a matrix and enables transformations.-
2876-
2877 \note It is advisable to use setWorldTransform() instead of this function to-
2878 preserve the properties of perspective transformations.-
2879-
2880 If \a combine is true, then \a matrix is combined with the current-
2881 transformation matrix; otherwise \a matrix replaces the current-
2882 transformation matrix.-
2883-
2884 If \a matrix is the identity matrix and \a combine is false, this-
2885 function calls setWorldMatrixEnabled(false). (The identity matrix is the-
2886 matrix where QMatrix::m11() and QMatrix::m22() are 1.0 and the-
2887 rest are 0.0.)-
2888-
2889 The following functions can transform the coordinate system without using-
2890 a QMatrix:-
2891 \list-
2892 \li translate()-
2893 \li scale()-
2894 \li shear()-
2895 \li rotate()-
2896 \endlist-
2897-
2898 They operate on the painter's worldMatrix() and are implemented like this:-
2899-
2900 \snippet code/src_gui_painting_qpainter.cpp 4-
2901-
2902 Note that when using setWorldMatrix() function you should always have-
2903 \a combine be true when you are drawing into a QPicture. Otherwise-
2904 it may not be possible to replay the picture with additional-
2905 transformations; using the translate(), scale(), etc. convenience-
2906 functions is safe.-
2907-
2908 For more information about the coordinate system, transformations-
2909 and window-viewport conversion, see \l {Coordinate System}.-
2910-
2911 \sa setWorldTransform(), QTransform-
2912*/-
2913-
2914void QPainter::setWorldMatrix(const QMatrix &matrix, bool combine)-
2915{-
2916 setWorldTransform(QTransform(matrix), combine);-
2917}
never executed: end of block
0
2918-
2919/*!-
2920 \since 4.2-
2921 \obsolete-
2922-
2923 Returns the world transformation matrix.-
2924-
2925 It is advisable to use worldTransform() because worldMatrix() does not-
2926 preserve the properties of perspective transformations.-
2927-
2928 \sa {QPainter#Coordinate Transformations}{Coordinate Transformations},-
2929 {Coordinate System}-
2930*/-
2931-
2932const QMatrix &QPainter::worldMatrix() const-
2933{-
2934 Q_D(const QPainter);-
2935 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2936 qWarning("QPainter::worldMatrix: Painter not active");-
2937 return d->fakeState()->transform.toAffine();
never executed: return d->fakeState()->transform.toAffine();
0
2938 }-
2939 return d->state->worldMatrix.toAffine();
never executed: return d->state->worldMatrix.toAffine();
0
2940}-
2941-
2942/*!-
2943 \obsolete-
2944-
2945 Use setWorldTransform() instead.-
2946-
2947 \sa setWorldTransform()-
2948*/-
2949-
2950void QPainter::setMatrix(const QMatrix &matrix, bool combine)-
2951{-
2952 setWorldTransform(QTransform(matrix), combine);-
2953}
never executed: end of block
0
2954-
2955/*!-
2956 \obsolete-
2957-
2958 Use worldTransform() instead.-
2959-
2960 \sa worldTransform()-
2961*/-
2962-
2963const QMatrix &QPainter::matrix() const-
2964{-
2965 return worldMatrix();
never executed: return worldMatrix();
0
2966}-
2967-
2968-
2969/*!-
2970 \since 4.2-
2971 \obsolete-
2972-
2973 Returns the transformation matrix combining the current-
2974 window/viewport and world transformation.-
2975-
2976 It is advisable to use combinedTransform() instead of this-
2977 function to preserve the properties of perspective transformations.-
2978-
2979 \sa setWorldTransform(), setWindow(), setViewport()-
2980*/-
2981QMatrix QPainter::combinedMatrix() const-
2982{-
2983 return combinedTransform().toAffine();
never executed: return combinedTransform().toAffine();
0
2984}-
2985-
2986-
2987/*!-
2988 \obsolete-
2989-
2990 Returns the matrix that transforms from logical coordinates to-
2991 device coordinates of the platform dependent paint device.-
2992-
2993 \note It is advisable to use deviceTransform() instead of this-
2994 function to preserve the properties of perspective transformations.-
2995-
2996 This function is \e only needed when using platform painting-
2997 commands on the platform dependent handle (Qt::HANDLE), and the-
2998 platform does not do transformations nativly.-
2999-
3000 The QPaintEngine::PaintEngineFeature enum can be queried to-
3001 determine whether the platform performs the transformations or-
3002 not.-
3003-
3004 \sa worldMatrix(), QPaintEngine::hasFeature(),-
3005*/-
3006const QMatrix &QPainter::deviceMatrix() const-
3007{-
3008 Q_D(const QPainter);-
3009 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3010 qWarning("QPainter::deviceMatrix: Painter not active");-
3011 return d->fakeState()->transform.toAffine();
never executed: return d->fakeState()->transform.toAffine();
0
3012 }-
3013 return d->state->matrix.toAffine();
never executed: return d->state->matrix.toAffine();
0
3014}-
3015-
3016/*!-
3017 \obsolete-
3018-
3019 Resets any transformations that were made using translate(), scale(),-
3020 shear(), rotate(), setWorldMatrix(), setViewport() and-
3021 setWindow().-
3022-
3023 It is advisable to use resetTransform() instead of this function-
3024 to preserve the properties of perspective transformations.-
3025-
3026 \sa {QPainter#Coordinate Transformations}{Coordinate-
3027 Transformations}-
3028*/-
3029-
3030void QPainter::resetMatrix()-
3031{-
3032 resetTransform();-
3033}
never executed: end of block
0
3034-
3035-
3036/*!-
3037 \since 4.2-
3038-
3039 Enables transformations if \a enable is true, or disables-
3040 transformations if \a enable is false. The world transformation-
3041 matrix is not changed.-
3042-
3043 \sa worldMatrixEnabled(), worldTransform(), {QPainter#Coordinate-
3044 Transformations}{Coordinate Transformations}-
3045*/-
3046-
3047void QPainter::setWorldMatrixEnabled(bool enable)-
3048{-
3049 Q_D(QPainter);-
3050#ifdef QT_DEBUG_DRAW-
3051 if (qt_show_painter_debug_output)-
3052 printf("QPainter::setMatrixEnabled(), enable=%d\n", enable);-
3053#endif-
3054-
3055 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3056 qWarning("QPainter::setMatrixEnabled: Painter not active");-
3057 return;
never executed: return;
0
3058 }-
3059 if (enable == d->state->WxF)
enable == d->state->WxFDescription
TRUEnever evaluated
FALSEnever evaluated
0
3060 return;
never executed: return;
0
3061-
3062 d->state->WxF = enable;-
3063 d->updateMatrix();-
3064}
never executed: end of block
0
3065-
3066/*!-
3067 \since 4.2-
3068-
3069 Returns \c true if world transformation is enabled; otherwise returns-
3070 false.-
3071-
3072 \sa setWorldMatrixEnabled(), worldTransform(), {Coordinate System}-
3073*/-
3074-
3075bool QPainter::worldMatrixEnabled() const-
3076{-
3077 Q_D(const QPainter);-
3078 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3079 qWarning("QPainter::worldMatrixEnabled: Painter not active");-
3080 return false;
never executed: return false;
0
3081 }-
3082 return d->state->WxF;
never executed: return d->state->WxF;
0
3083}-
3084-
3085/*!-
3086 \obsolete-
3087-
3088 Use setWorldMatrixEnabled() instead.-
3089-
3090 \sa setWorldMatrixEnabled()-
3091*/-
3092-
3093void QPainter::setMatrixEnabled(bool enable)-
3094{-
3095 setWorldMatrixEnabled(enable);-
3096}
never executed: end of block
0
3097-
3098/*!-
3099 \obsolete-
3100-
3101 Use worldMatrixEnabled() instead-
3102-
3103 \sa worldMatrixEnabled()-
3104*/-
3105-
3106bool QPainter::matrixEnabled() const-
3107{-
3108 return worldMatrixEnabled();
never executed: return worldMatrixEnabled();
0
3109}-
3110-
3111/*!-
3112 Scales the coordinate system by (\a{sx}, \a{sy}).-
3113-
3114 \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations}-
3115*/-
3116-
3117void QPainter::scale(qreal sx, qreal sy)-
3118{-
3119#ifdef QT_DEBUG_DRAW-
3120 if (qt_show_painter_debug_output)-
3121 printf("QPainter::scale(), sx=%f, sy=%f\n", sx, sy);-
3122#endif-
3123 Q_D(QPainter);-
3124 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3125 qWarning("QPainter::scale: Painter not active");-
3126 return;
never executed: return;
0
3127 }-
3128-
3129 d->state->worldMatrix.scale(sx,sy);-
3130 d->state->WxF = true;-
3131 d->updateMatrix();-
3132}
never executed: end of block
0
3133-
3134/*!-
3135 Shears the coordinate system by (\a{sh}, \a{sv}).-
3136-
3137 \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations}-
3138*/-
3139-
3140void QPainter::shear(qreal sh, qreal sv)-
3141{-
3142#ifdef QT_DEBUG_DRAW-
3143 if (qt_show_painter_debug_output)-
3144 printf("QPainter::shear(), sh=%f, sv=%f\n", sh, sv);-
3145#endif-
3146 Q_D(QPainter);-
3147 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3148 qWarning("QPainter::shear: Painter not active");-
3149 return;
never executed: return;
0
3150 }-
3151-
3152 d->state->worldMatrix.shear(sh, sv);-
3153 d->state->WxF = true;-
3154 d->updateMatrix();-
3155}
never executed: end of block
0
3156-
3157/*!-
3158 \fn void QPainter::rotate(qreal angle)-
3159-
3160 Rotates the coordinate system clockwise. The given \a angle parameter is in degrees.-
3161-
3162 \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations}-
3163*/-
3164-
3165void QPainter::rotate(qreal a)-
3166{-
3167#ifdef QT_DEBUG_DRAW-
3168 if (qt_show_painter_debug_output)-
3169 printf("QPainter::rotate(), angle=%f\n", a);-
3170#endif-
3171 Q_D(QPainter);-
3172 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3173 qWarning("QPainter::rotate: Painter not active");-
3174 return;
never executed: return;
0
3175 }-
3176-
3177 d->state->worldMatrix.rotate(a);-
3178 d->state->WxF = true;-
3179 d->updateMatrix();-
3180}
never executed: end of block
0
3181-
3182/*!-
3183 Translates the coordinate system by the given \a offset; i.e. the-
3184 given \a offset is added to points.-
3185-
3186 \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations}-
3187*/-
3188void QPainter::translate(const QPointF &offset)-
3189{-
3190 qreal dx = offset.x();-
3191 qreal dy = offset.y();-
3192#ifdef QT_DEBUG_DRAW-
3193 if (qt_show_painter_debug_output)-
3194 printf("QPainter::translate(), dx=%f, dy=%f\n", dx, dy);-
3195#endif-
3196 Q_D(QPainter);-
3197 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3198 qWarning("QPainter::translate: Painter not active");-
3199 return;
never executed: return;
0
3200 }-
3201-
3202 d->state->worldMatrix.translate(dx, dy);-
3203 d->state->WxF = true;-
3204 d->updateMatrix();-
3205}
never executed: end of block
0
3206-
3207/*!-
3208 \fn void QPainter::translate(const QPoint &offset)-
3209 \overload-
3210-
3211 Translates the coordinate system by the given \a offset.-
3212*/-
3213-
3214/*!-
3215 \fn void QPainter::translate(qreal dx, qreal dy)-
3216 \overload-
3217-
3218 Translates the coordinate system by the vector (\a dx, \a dy).-
3219*/-
3220-
3221/*!-
3222 \fn void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation operation)-
3223-
3224 Enables clipping, and sets the clip path for the painter to the-
3225 given \a path, with the clip \a operation.-
3226-
3227 Note that the clip path is specified in logical (painter)-
3228 coordinates.-
3229-
3230 \sa clipPath(), clipRegion(), {QPainter#Clipping}{Clipping}-
3231-
3232*/-
3233void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op)-
3234{-
3235#ifdef QT_DEBUG_DRAW-
3236 if (qt_show_painter_debug_output) {-
3237 QRectF b = path.boundingRect();-
3238 printf("QPainter::setClipPath(), size=%d, op=%d, bounds=[%.2f,%.2f,%.2f,%.2f]\n",-
3239 path.elementCount(), op, b.x(), b.y(), b.width(), b.height());-
3240 }-
3241#endif-
3242 Q_D(QPainter);-
3243-
3244 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3245 qWarning("QPainter::setClipPath: Painter not active");-
3246 return;
never executed: return;
0
3247 }-
3248-
3249 if ((!d->state->clipEnabled && op != Qt::NoClip))
!d->state->clipEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
op != Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
3250 op = Qt::ReplaceClip;
never executed: op = Qt::ReplaceClip;
0
3251-
3252 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3253 d->state->clipEnabled = true;-
3254 d->extended->clip(path, op);-
3255 if (op == Qt::NoClip || op == Qt::ReplaceClip)
op == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::ReplaceClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
3256 d->state->clipInfo.clear();
never executed: d->state->clipInfo.clear();
0
3257 d->state->clipInfo.append(QPainterClipInfo(path, op, d->state->matrix));-
3258 d->state->clipOperation = op;-
3259 return;
never executed: return;
0
3260 }-
3261-
3262 if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip)
d->state->clip... == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
3263 op = Qt::ReplaceClip;
never executed: op = Qt::ReplaceClip;
0
3264-
3265 d->state->clipPath = path;-
3266 d->state->clipOperation = op;-
3267 if (op == Qt::NoClip || op == Qt::ReplaceClip)
op == Qt::NoClipDescription
TRUEnever evaluated
FALSEnever evaluated
op == Qt::ReplaceClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
3268 d->state->clipInfo.clear();
never executed: d->state->clipInfo.clear();
0
3269 d->state->clipInfo.append(QPainterClipInfo(path, op, d->state->matrix));-
3270 d->state->clipEnabled = true;-
3271 d->state->dirtyFlags |= QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipEnabled;-
3272 d->updateState(d->state);-
3273}
never executed: end of block
0
3274-
3275/*!-
3276 Draws the outline (strokes) the path \a path with the pen specified-
3277 by \a pen-
3278-
3279 \sa fillPath(), {QPainter#Drawing}{Drawing}-
3280*/-
3281void QPainter::strokePath(const QPainterPath &path, const QPen &pen)-
3282{-
3283 Q_D(QPainter);-
3284-
3285 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3286 qWarning("QPainter::strokePath: Painter not active");-
3287 return;
never executed: return;
0
3288 }-
3289-
3290 if (path.isEmpty())
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3291 return;
never executed: return;
0
3292-
3293 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3294 const QGradient *g = qpen_brush(pen).gradient();-
3295 if (!g || g->coordinateMode() == QGradient::LogicalMode) {
!gDescription
TRUEnever evaluated
FALSEnever evaluated
g->coordinateM...t::LogicalModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3296 d->extended->stroke(qtVectorPathForPath(path), pen);-
3297 return;
never executed: return;
0
3298 }-
3299 }
never executed: end of block
0
3300-
3301 QBrush oldBrush = d->state->brush;-
3302 QPen oldPen = d->state->pen;-
3303-
3304 setPen(pen);-
3305 setBrush(Qt::NoBrush);-
3306-
3307 drawPath(path);-
3308-
3309 // Reset old state-
3310 setPen(oldPen);-
3311 setBrush(oldBrush);-
3312}
never executed: end of block
0
3313-
3314/*!-
3315 Fills the given \a path using the given \a brush. The outline is-
3316 not drawn.-
3317-
3318 Alternatively, you can specify a QColor instead of a QBrush; the-
3319 QBrush constructor (taking a QColor argument) will automatically-
3320 create a solid pattern brush.-
3321-
3322 \sa drawPath()-
3323*/-
3324void QPainter::fillPath(const QPainterPath &path, const QBrush &brush)-
3325{-
3326 Q_D(QPainter);-
3327-
3328 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3329 qWarning("QPainter::fillPath: Painter not active");-
3330 return;
never executed: return;
0
3331 }-
3332-
3333 if (path.isEmpty())
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3334 return;
never executed: return;
0
3335-
3336 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3337 const QGradient *g = brush.gradient();-
3338 if (!g || g->coordinateMode() == QGradient::LogicalMode) {
!gDescription
TRUEnever evaluated
FALSEnever evaluated
g->coordinateM...t::LogicalModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3339 d->extended->fill(qtVectorPathForPath(path), brush);-
3340 return;
never executed: return;
0
3341 }-
3342 }
never executed: end of block
0
3343-
3344 QBrush oldBrush = d->state->brush;-
3345 QPen oldPen = d->state->pen;-
3346-
3347 setPen(Qt::NoPen);-
3348 setBrush(brush);-
3349-
3350 drawPath(path);-
3351-
3352 // Reset old state-
3353 setPen(oldPen);-
3354 setBrush(oldBrush);-
3355}
never executed: end of block
0
3356-
3357/*!-
3358 Draws the given painter \a path using the current pen for outline-
3359 and the current brush for filling.-
3360-
3361 \table 100%-
3362 \row-
3363 \li \inlineimage qpainter-path.png-
3364 \li-
3365 \snippet code/src_gui_painting_qpainter.cpp 5-
3366 \endtable-
3367-
3368 \sa {painting/painterpaths}{the Painter Paths-
3369 example},{painting/deform}{the Vector Deformation example}-
3370*/-
3371void QPainter::drawPath(const QPainterPath &path)-
3372{-
3373#ifdef QT_DEBUG_DRAW-
3374 QRectF pathBounds = path.boundingRect();-
3375 if (qt_show_painter_debug_output)-
3376 printf("QPainter::drawPath(), size=%d, [%.2f,%.2f,%.2f,%.2f]\n",-
3377 path.elementCount(),-
3378 pathBounds.x(), pathBounds.y(), pathBounds.width(), pathBounds.height());-
3379#endif-
3380-
3381 Q_D(QPainter);-
3382-
3383 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3384 qWarning("QPainter::drawPath: Painter not active");-
3385 return;
never executed: return;
0
3386 }-
3387-
3388 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3389 d->extended->drawPath(path);-
3390 return;
never executed: return;
0
3391 }-
3392 d->updateState(d->state);-
3393-
3394 if (d->engine->hasFeature(QPaintEngine::PainterPaths) && d->state->emulationSpecifier == 0) {
d->engine->has...:PainterPaths)Description
TRUEnever evaluated
FALSEnever evaluated
d->state->emul...Specifier == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3395 d->engine->drawPath(path);-
3396 } else {
never executed: end of block
0
3397 d->draw_helper(path);-
3398 }
never executed: end of block
0
3399}-
3400-
3401/*!-
3402 \fn void QPainter::drawLine(const QLineF &line)-
3403-
3404 Draws a line defined by \a line.-
3405-
3406 \table 100%-
3407 \row-
3408 \li \inlineimage qpainter-line.png-
3409 \li-
3410 \snippet code/src_gui_painting_qpainter.cpp 6-
3411 \endtable-
3412-
3413 \sa drawLines(), drawPolyline(), {Coordinate System}-
3414*/-
3415-
3416/*!-
3417 \fn void QPainter::drawLine(const QLine &line)-
3418 \overload-
3419-
3420 Draws a line defined by \a line.-
3421*/-
3422-
3423/*!-
3424 \fn void QPainter::drawLine(const QPoint &p1, const QPoint &p2)-
3425 \overload-
3426-
3427 Draws a line from \a p1 to \a p2.-
3428*/-
3429-
3430/*!-
3431 \fn void QPainter::drawLine(const QPointF &p1, const QPointF &p2)-
3432 \overload-
3433-
3434 Draws a line from \a p1 to \a p2.-
3435*/-
3436-
3437/*!-
3438 \fn void QPainter::drawLine(int x1, int y1, int x2, int y2)-
3439 \overload-
3440-
3441 Draws a line from (\a x1, \a y1) to (\a x2, \a y2).-
3442*/-
3443-
3444/*!-
3445 \fn void QPainter::drawRect(const QRectF &rectangle)-
3446-
3447 Draws the current \a rectangle with the current pen and brush.-
3448-
3449 A filled rectangle has a size of \a{rectangle}.size(). A stroked-
3450 rectangle has a size of \a{rectangle}.size() plus the pen width.-
3451-
3452 \table 100%-
3453 \row-
3454 \li \inlineimage qpainter-rectangle.png-
3455 \li-
3456 \snippet code/src_gui_painting_qpainter.cpp 7-
3457 \endtable-
3458-
3459 \sa drawRects(), drawPolygon(), {Coordinate System}-
3460*/-
3461-
3462/*!-
3463 \fn void QPainter::drawRect(const QRect &rectangle)-
3464-
3465 \overload-
3466-
3467 Draws the current \a rectangle with the current pen and brush.-
3468*/-
3469-
3470/*!-
3471 \fn void QPainter::drawRect(int x, int y, int width, int height)-
3472-
3473 \overload-
3474-
3475 Draws a rectangle with upper left corner at (\a{x}, \a{y}) and-
3476 with the given \a width and \a height.-
3477*/-
3478-
3479/*!-
3480 \fn void QPainter::drawRects(const QRectF *rectangles, int rectCount)-
3481-
3482 Draws the first \a rectCount of the given \a rectangles using the-
3483 current pen and brush.-
3484-
3485 \sa drawRect()-
3486*/-
3487void QPainter::drawRects(const QRectF *rects, int rectCount)-
3488{-
3489#ifdef QT_DEBUG_DRAW-
3490 if (qt_show_painter_debug_output)-
3491 printf("QPainter::drawRects(), count=%d\n", rectCount);-
3492#endif-
3493 Q_D(QPainter);-
3494-
3495 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3496 qWarning("QPainter::drawRects: Painter not active");-
3497 return;
never executed: return;
0
3498 }-
3499-
3500 if (rectCount <= 0)
rectCount <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3501 return;
never executed: return;
0
3502-
3503 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3504 d->extended->drawRects(rects, rectCount);-
3505 return;
never executed: return;
0
3506 }-
3507-
3508 d->updateState(d->state);-
3509-
3510 if (!d->state->emulationSpecifier) {
!d->state->emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
3511 d->engine->drawRects(rects, rectCount);-
3512 return;
never executed: return;
0
3513 }-
3514-
3515 if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform
d->state->emul...itiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
3516 && d->state->matrix.type() == QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3517 for (int i=0; i<rectCount; ++i) {
i<rectCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3518 QRectF r(rects[i].x() + d->state->matrix.dx(),-
3519 rects[i].y() + d->state->matrix.dy(),-
3520 rects[i].width(),-
3521 rects[i].height());-
3522 d->engine->drawRects(&r, 1);-
3523 }
never executed: end of block
0
3524 } else {
never executed: end of block
0
3525 if (d->state->brushNeedsResolving() || d->state->penNeedsResolving()) {
d->state->brus...edsResolving()Description
TRUEnever evaluated
FALSEnever evaluated
d->state->penNeedsResolving()Description
TRUEnever evaluated
FALSEnever evaluated
0
3526 for (int i=0; i<rectCount; ++i) {
i<rectCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3527 QPainterPath rectPath;-
3528 rectPath.addRect(rects[i]);-
3529 d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw);-
3530 }
never executed: end of block
0
3531 } else {
never executed: end of block
0
3532 QPainterPath rectPath;-
3533 for (int i=0; i<rectCount; ++i)
i<rectCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3534 rectPath.addRect(rects[i]);
never executed: rectPath.addRect(rects[i]);
0
3535 d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw);-
3536 }
never executed: end of block
0
3537 }-
3538}-
3539-
3540/*!-
3541 \fn void QPainter::drawRects(const QRect *rectangles, int rectCount)-
3542 \overload-
3543-
3544 Draws the first \a rectCount of the given \a rectangles using the-
3545 current pen and brush.-
3546*/-
3547void QPainter::drawRects(const QRect *rects, int rectCount)-
3548{-
3549#ifdef QT_DEBUG_DRAW-
3550 if (qt_show_painter_debug_output)-
3551 printf("QPainter::drawRects(), count=%d\n", rectCount);-
3552#endif-
3553 Q_D(QPainter);-
3554-
3555 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3556 qWarning("QPainter::drawRects: Painter not active");-
3557 return;
never executed: return;
0
3558 }-
3559-
3560 if (rectCount <= 0)
rectCount <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3561 return;
never executed: return;
0
3562-
3563 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3564 d->extended->drawRects(rects, rectCount);-
3565 return;
never executed: return;
0
3566 }-
3567-
3568 d->updateState(d->state);-
3569-
3570 if (!d->state->emulationSpecifier) {
!d->state->emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
3571 d->engine->drawRects(rects, rectCount);-
3572 return;
never executed: return;
0
3573 }-
3574-
3575 if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform
d->state->emul...itiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
3576 && d->state->matrix.type() == QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3577 for (int i=0; i<rectCount; ++i) {
i<rectCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3578 QRectF r(rects[i].x() + d->state->matrix.dx(),-
3579 rects[i].y() + d->state->matrix.dy(),-
3580 rects[i].width(),-
3581 rects[i].height());-
3582-
3583 d->engine->drawRects(&r, 1);-
3584 }
never executed: end of block
0
3585 } else {
never executed: end of block
0
3586 if (d->state->brushNeedsResolving() || d->state->penNeedsResolving()) {
d->state->brus...edsResolving()Description
TRUEnever evaluated
FALSEnever evaluated
d->state->penNeedsResolving()Description
TRUEnever evaluated
FALSEnever evaluated
0
3587 for (int i=0; i<rectCount; ++i) {
i<rectCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3588 QPainterPath rectPath;-
3589 rectPath.addRect(rects[i]);-
3590 d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw);-
3591 }
never executed: end of block
0
3592 } else {
never executed: end of block
0
3593 QPainterPath rectPath;-
3594 for (int i=0; i<rectCount; ++i)
i<rectCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3595 rectPath.addRect(rects[i]);
never executed: rectPath.addRect(rects[i]);
0
3596-
3597 d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw);-
3598 }
never executed: end of block
0
3599 }-
3600}-
3601-
3602/*!-
3603 \fn void QPainter::drawRects(const QVector<QRectF> &rectangles)-
3604 \overload-
3605-
3606 Draws the given \a rectangles using the current pen and brush.-
3607*/-
3608-
3609/*!-
3610 \fn void QPainter::drawRects(const QVector<QRect> &rectangles)-
3611-
3612 \overload-
3613-
3614 Draws the given \a rectangles using the current pen and brush.-
3615*/-
3616-
3617/*!-
3618 \fn void QPainter::drawPoint(const QPointF &position)-
3619-
3620 Draws a single point at the given \a position using the current-
3621 pen's color.-
3622-
3623 \sa {Coordinate System}-
3624*/-
3625-
3626/*!-
3627 \fn void QPainter::drawPoint(const QPoint &position)-
3628 \overload-
3629-
3630 Draws a single point at the given \a position using the current-
3631 pen's color.-
3632*/-
3633-
3634/*! \fn void QPainter::drawPoint(int x, int y)-
3635-
3636 \overload-
3637-
3638 Draws a single point at position (\a x, \a y).-
3639*/-
3640-
3641/*!-
3642 Draws the first \a pointCount points in the array \a points using-
3643 the current pen's color.-
3644-
3645 \sa {Coordinate System}-
3646*/-
3647void QPainter::drawPoints(const QPointF *points, int pointCount)-
3648{-
3649#ifdef QT_DEBUG_DRAW-
3650 if (qt_show_painter_debug_output)-
3651 printf("QPainter::drawPoints(), count=%d\n", pointCount);-
3652#endif-
3653 Q_D(QPainter);-
3654-
3655 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3656 qWarning("QPainter::drawPoints: Painter not active");-
3657 return;
never executed: return;
0
3658 }-
3659-
3660 if (pointCount <= 0)
pointCount <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3661 return;
never executed: return;
0
3662-
3663 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3664 d->extended->drawPoints(points, pointCount);-
3665 return;
never executed: return;
0
3666 }-
3667-
3668 d->updateState(d->state);-
3669-
3670 if (!d->state->emulationSpecifier) {
!d->state->emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
3671 d->engine->drawPoints(points, pointCount);-
3672 return;
never executed: return;
0
3673 }-
3674-
3675 if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform
d->state->emul...itiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
3676 && d->state->matrix.type() == QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3677 // ### use drawPoints function-
3678 for (int i=0; i<pointCount; ++i) {
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3679 QPointF pt(points[i].x() + d->state->matrix.dx(),-
3680 points[i].y() + d->state->matrix.dy());-
3681 d->engine->drawPoints(&pt, 1);-
3682 }
never executed: end of block
0
3683 } else {
never executed: end of block
0
3684 QPen pen = d->state->pen;-
3685 bool flat_pen = pen.capStyle() == Qt::FlatCap;-
3686 if (flat_pen) {
flat_penDescription
TRUEnever evaluated
FALSEnever evaluated
0
3687 save();-
3688 pen.setCapStyle(Qt::SquareCap);-
3689 setPen(pen);-
3690 }
never executed: end of block
0
3691 QPainterPath path;-
3692 for (int i=0; i<pointCount; ++i) {
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3693 path.moveTo(points[i].x(), points[i].y());-
3694 path.lineTo(points[i].x() + 0.0001, points[i].y());-
3695 }
never executed: end of block
0
3696 d->draw_helper(path, QPainterPrivate::StrokeDraw);-
3697 if (flat_pen)
flat_penDescription
TRUEnever evaluated
FALSEnever evaluated
0
3698 restore();
never executed: restore();
0
3699 }
never executed: end of block
0
3700}-
3701-
3702/*!-
3703 \overload-
3704-
3705 Draws the first \a pointCount points in the array \a points using-
3706 the current pen's color.-
3707*/-
3708-
3709void QPainter::drawPoints(const QPoint *points, int pointCount)-
3710{-
3711#ifdef QT_DEBUG_DRAW-
3712 if (qt_show_painter_debug_output)-
3713 printf("QPainter::drawPoints(), count=%d\n", pointCount);-
3714#endif-
3715 Q_D(QPainter);-
3716-
3717 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3718 qWarning("QPainter::drawPoints: Painter not active");-
3719 return;
never executed: return;
0
3720 }-
3721-
3722 if (pointCount <= 0)
pointCount <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3723 return;
never executed: return;
0
3724-
3725 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3726 d->extended->drawPoints(points, pointCount);-
3727 return;
never executed: return;
0
3728 }-
3729-
3730 d->updateState(d->state);-
3731-
3732 if (!d->state->emulationSpecifier) {
!d->state->emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
3733 d->engine->drawPoints(points, pointCount);-
3734 return;
never executed: return;
0
3735 }-
3736-
3737 if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform
d->state->emul...itiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
3738 && d->state->matrix.type() == QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3739 // ### use drawPoints function-
3740 for (int i=0; i<pointCount; ++i) {
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3741 QPointF pt(points[i].x() + d->state->matrix.dx(),-
3742 points[i].y() + d->state->matrix.dy());-
3743 d->engine->drawPoints(&pt, 1);-
3744 }
never executed: end of block
0
3745 } else {
never executed: end of block
0
3746 QPen pen = d->state->pen;-
3747 bool flat_pen = (pen.capStyle() == Qt::FlatCap);-
3748 if (flat_pen) {
flat_penDescription
TRUEnever evaluated
FALSEnever evaluated
0
3749 save();-
3750 pen.setCapStyle(Qt::SquareCap);-
3751 setPen(pen);-
3752 }
never executed: end of block
0
3753 QPainterPath path;-
3754 for (int i=0; i<pointCount; ++i) {
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3755 path.moveTo(points[i].x(), points[i].y());-
3756 path.lineTo(points[i].x() + 0.0001, points[i].y());-
3757 }
never executed: end of block
0
3758 d->draw_helper(path, QPainterPrivate::StrokeDraw);-
3759 if (flat_pen)
flat_penDescription
TRUEnever evaluated
FALSEnever evaluated
0
3760 restore();
never executed: restore();
0
3761 }
never executed: end of block
0
3762}-
3763-
3764/*!-
3765 \fn void QPainter::drawPoints(const QPolygonF &points)-
3766-
3767 \overload-
3768-
3769 Draws the points in the vector \a points.-
3770*/-
3771-
3772/*!-
3773 \fn void QPainter::drawPoints(const QPolygon &points)-
3774-
3775 \overload-
3776-
3777 Draws the points in the vector \a points.-
3778*/-
3779-
3780/*!-
3781 Sets the background mode of the painter to the given \a mode-
3782-
3783 Qt::TransparentMode (the default) draws stippled lines and text-
3784 without setting the background pixels. Qt::OpaqueMode fills these-
3785 space with the current background color.-
3786-
3787 Note that in order to draw a bitmap or pixmap transparently, you-
3788 must use QPixmap::setMask().-
3789-
3790 \sa backgroundMode(), setBackground(),-
3791 {QPainter#Settings}{Settings}-
3792*/-
3793-
3794void QPainter::setBackgroundMode(Qt::BGMode mode)-
3795{-
3796#ifdef QT_DEBUG_DRAW-
3797 if (qt_show_painter_debug_output)-
3798 printf("QPainter::setBackgroundMode(), mode=%d\n", mode);-
3799#endif-
3800-
3801 Q_D(QPainter);-
3802 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3803 qWarning("QPainter::setBackgroundMode: Painter not active");-
3804 return;
never executed: return;
0
3805 }-
3806 if (d->state->bgMode == mode)
d->state->bgMode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3807 return;
never executed: return;
0
3808-
3809 d->state->bgMode = mode;-
3810 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3811 d->checkEmulation();-
3812 } else {
never executed: end of block
0
3813 d->state->dirtyFlags |= QPaintEngine::DirtyBackgroundMode;-
3814 }
never executed: end of block
0
3815}-
3816-
3817/*!-
3818 Returns the current background mode.-
3819-
3820 \sa setBackgroundMode(), {QPainter#Settings}{Settings}-
3821*/-
3822Qt::BGMode QPainter::backgroundMode() const-
3823{-
3824 Q_D(const QPainter);-
3825 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3826 qWarning("QPainter::backgroundMode: Painter not active");-
3827 return Qt::TransparentMode;
never executed: return Qt::TransparentMode;
0
3828 }-
3829 return d->state->bgMode;
never executed: return d->state->bgMode;
0
3830}-
3831-
3832-
3833/*!-
3834 \overload-
3835-
3836 Sets the painter's pen to have style Qt::SolidLine, width 1 and the-
3837 specified \a color.-
3838*/-
3839-
3840void QPainter::setPen(const QColor &color)-
3841{-
3842#ifdef QT_DEBUG_DRAW-
3843 if (qt_show_painter_debug_output)-
3844 printf("QPainter::setPen(), color=%04x\n", color.rgb());-
3845#endif-
3846 Q_D(QPainter);-
3847 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3848 qWarning("QPainter::setPen: Painter not active");-
3849 return;
never executed: return;
0
3850 }-
3851-
3852 QPen pen(color.isValid() ? color : QColor(Qt::black));-
3853-
3854 if (d->state->pen == pen)
d->state->pen == penDescription
TRUEnever evaluated
FALSEnever evaluated
0
3855 return;
never executed: return;
0
3856-
3857 d->state->pen = pen;-
3858 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3859 d->extended->penChanged();
never executed: d->extended->penChanged();
0
3860 else-
3861 d->state->dirtyFlags |= QPaintEngine::DirtyPen;
never executed: d->state->dirtyFlags |= QPaintEngine::DirtyPen;
0
3862}-
3863-
3864/*!-
3865 Sets the painter's pen to be the given \a pen.-
3866-
3867 The \a pen defines how to draw lines and outlines, and it also-
3868 defines the text color.-
3869-
3870 \sa pen(), {QPainter#Settings}{Settings}-
3871*/-
3872-
3873void QPainter::setPen(const QPen &pen)-
3874{-
3875-
3876#ifdef QT_DEBUG_DRAW-
3877 if (qt_show_painter_debug_output)-
3878 printf("QPainter::setPen(), color=%04x, (brushStyle=%d) style=%d, cap=%d, join=%d\n",-
3879 pen.color().rgb(), pen.brush().style(), pen.style(), pen.capStyle(), pen.joinStyle());-
3880#endif-
3881 Q_D(QPainter);-
3882 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3883 qWarning("QPainter::setPen: Painter not active");-
3884 return;
never executed: return;
0
3885 }-
3886-
3887 if (d->state->pen == pen)
d->state->pen == penDescription
TRUEnever evaluated
FALSEnever evaluated
0
3888 return;
never executed: return;
0
3889-
3890 d->state->pen = pen;-
3891-
3892 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3893 d->checkEmulation();-
3894 d->extended->penChanged();-
3895 return;
never executed: return;
0
3896 }-
3897-
3898 d->state->dirtyFlags |= QPaintEngine::DirtyPen;-
3899}
never executed: end of block
0
3900-
3901/*!-
3902 \overload-
3903-
3904 Sets the painter's pen to have the given \a style, width 1 and-
3905 black color.-
3906*/-
3907-
3908void QPainter::setPen(Qt::PenStyle style)-
3909{-
3910 Q_D(QPainter);-
3911 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3912 qWarning("QPainter::setPen: Painter not active");-
3913 return;
never executed: return;
0
3914 }-
3915-
3916 QPen pen = QPen(style);-
3917-
3918 if (d->state->pen == pen)
d->state->pen == penDescription
TRUEnever evaluated
FALSEnever evaluated
0
3919 return;
never executed: return;
0
3920-
3921 d->state->pen = pen;-
3922-
3923 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3924 d->extended->penChanged();
never executed: d->extended->penChanged();
0
3925 else-
3926 d->state->dirtyFlags |= QPaintEngine::DirtyPen;
never executed: d->state->dirtyFlags |= QPaintEngine::DirtyPen;
0
3927-
3928}-
3929-
3930/*!-
3931 Returns the painter's current pen.-
3932-
3933 \sa setPen(), {QPainter#Settings}{Settings}-
3934*/-
3935-
3936const QPen &QPainter::pen() const-
3937{-
3938 Q_D(const QPainter);-
3939 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3940 qWarning("QPainter::pen: Painter not active");-
3941 return d->fakeState()->pen;
never executed: return d->fakeState()->pen;
0
3942 }-
3943 return d->state->pen;
never executed: return d->state->pen;
0
3944}-
3945-
3946-
3947/*!-
3948 Sets the painter's brush to the given \a brush.-
3949-
3950 The painter's brush defines how shapes are filled.-
3951-
3952 \sa brush(), {QPainter#Settings}{Settings}-
3953*/-
3954-
3955void QPainter::setBrush(const QBrush &brush)-
3956{-
3957#ifdef QT_DEBUG_DRAW-
3958 if (qt_show_painter_debug_output)-
3959 printf("QPainter::setBrush(), color=%04x, style=%d\n", brush.color().rgb(), brush.style());-
3960#endif-
3961 Q_D(QPainter);-
3962 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3963 qWarning("QPainter::setBrush: Painter not active");-
3964 return;
never executed: return;
0
3965 }-
3966-
3967 if (d->state->brush.d == brush.d)
d->state->brush.d == brush.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3968 return;
never executed: return;
0
3969-
3970 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3971 d->state->brush = brush;-
3972 d->checkEmulation();-
3973 d->extended->brushChanged();-
3974 return;
never executed: return;
0
3975 }-
3976-
3977 d->state->brush = brush;-
3978 d->state->dirtyFlags |= QPaintEngine::DirtyBrush;-
3979}
never executed: end of block
0
3980-
3981-
3982/*!-
3983 \overload-
3984-
3985 Sets the painter's brush to black color and the specified \a-
3986 style.-
3987*/-
3988-
3989void QPainter::setBrush(Qt::BrushStyle style)-
3990{-
3991 Q_D(QPainter);-
3992 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3993 qWarning("QPainter::setBrush: Painter not active");-
3994 return;
never executed: return;
0
3995 }-
3996 if (d->state->brush.style() == style &&
d->state->brus...yle() == styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
3997 (style == Qt::NoBrush
style == Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
3998 || (style == Qt::SolidPattern && d->state->brush.color() == QColor(0, 0, 0))))
style == Qt::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
d->state->brus...Color(0, 0, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
3999 return;
never executed: return;
0
4000 d->state->brush = QBrush(Qt::black, style);-
4001 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4002 d->extended->brushChanged();
never executed: d->extended->brushChanged();
0
4003 else-
4004 d->state->dirtyFlags |= QPaintEngine::DirtyBrush;
never executed: d->state->dirtyFlags |= QPaintEngine::DirtyBrush;
0
4005}-
4006-
4007/*!-
4008 Returns the painter's current brush.-
4009-
4010 \sa QPainter::setBrush(), {QPainter#Settings}{Settings}-
4011*/-
4012-
4013const QBrush &QPainter::brush() const-
4014{-
4015 Q_D(const QPainter);-
4016 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4017 qWarning("QPainter::brush: Painter not active");-
4018 return d->fakeState()->brush;
never executed: return d->fakeState()->brush;
0
4019 }-
4020 return d->state->brush;
never executed: return d->state->brush;
0
4021}-
4022-
4023/*!-
4024 \fn void QPainter::setBackground(const QBrush &brush)-
4025-
4026 Sets the background brush of the painter to the given \a brush.-
4027-
4028 The background brush is the brush that is filled in when drawing-
4029 opaque text, stippled lines and bitmaps. The background brush has-
4030 no effect in transparent background mode (which is the default).-
4031-
4032 \sa background(), setBackgroundMode(),-
4033 {QPainter#Settings}{Settings}-
4034*/-
4035-
4036void QPainter::setBackground(const QBrush &bg)-
4037{-
4038#ifdef QT_DEBUG_DRAW-
4039 if (qt_show_painter_debug_output)-
4040 printf("QPainter::setBackground(), color=%04x, style=%d\n", bg.color().rgb(), bg.style());-
4041#endif-
4042-
4043 Q_D(QPainter);-
4044 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4045 qWarning("QPainter::setBackground: Painter not active");-
4046 return;
never executed: return;
0
4047 }-
4048 d->state->bgBrush = bg;-
4049 if (!d->extended)
!d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4050 d->state->dirtyFlags |= QPaintEngine::DirtyBackground;
never executed: d->state->dirtyFlags |= QPaintEngine::DirtyBackground;
0
4051}
never executed: end of block
0
4052-
4053/*!-
4054 Sets the painter's font to the given \a font.-
4055-
4056 This font is used by subsequent drawText() functions. The text-
4057 color is the same as the pen color.-
4058-
4059 If you set a font that isn't available, Qt finds a close match.-
4060 font() will return what you set using setFont() and fontInfo() returns the-
4061 font actually being used (which may be the same).-
4062-
4063 \sa font(), drawText(), {QPainter#Settings}{Settings}-
4064*/-
4065-
4066void QPainter::setFont(const QFont &font)-
4067{-
4068 Q_D(QPainter);-
4069-
4070#ifdef QT_DEBUG_DRAW-
4071 if (qt_show_painter_debug_output)-
4072 printf("QPainter::setFont(), family=%s, pointSize=%d\n", font.family().toLatin1().constData(), font.pointSize());-
4073#endif-
4074-
4075 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4076 qWarning("QPainter::setFont: Painter not active");-
4077 return;
never executed: return;
0
4078 }-
4079-
4080 d->state->font = QFont(font.resolve(d->state->deviceFont), device());-
4081 if (!d->extended)
!d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4082 d->state->dirtyFlags |= QPaintEngine::DirtyFont;
never executed: d->state->dirtyFlags |= QPaintEngine::DirtyFont;
0
4083}
never executed: end of block
0
4084-
4085/*!-
4086 Returns the currently set font used for drawing text.-
4087-
4088 \sa setFont(), drawText(), {QPainter#Settings}{Settings}-
4089*/-
4090const QFont &QPainter::font() const-
4091{-
4092 Q_D(const QPainter);-
4093 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4094 qWarning("QPainter::font: Painter not active");-
4095 return d->fakeState()->font;
never executed: return d->fakeState()->font;
0
4096 }-
4097 return d->state->font;
never executed: return d->state->font;
0
4098}-
4099-
4100/*!-
4101 \since 4.4-
4102-
4103 Draws the given rectangle \a rect with rounded corners.-
4104-
4105 The \a xRadius and \a yRadius arguments specify the radii-
4106 of the ellipses defining the corners of the rounded rectangle.-
4107 When \a mode is Qt::RelativeSize, \a xRadius and-
4108 \a yRadius are specified in percentage of half the rectangle's-
4109 width and height respectively, and should be in the range-
4110 0.0 to 100.0.-
4111-
4112 A filled rectangle has a size of rect.size(). A stroked rectangle-
4113 has a size of rect.size() plus the pen width.-
4114-
4115 \table 100%-
4116 \row-
4117 \li \inlineimage qpainter-roundrect.png-
4118 \li-
4119 \snippet code/src_gui_painting_qpainter.cpp 8-
4120 \endtable-
4121-
4122 \sa drawRect(), QPen-
4123*/-
4124void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)-
4125{-
4126#ifdef QT_DEBUG_DRAW-
4127 if (qt_show_painter_debug_output)-
4128 printf("QPainter::drawRoundedRect(), [%.2f,%.2f,%.2f,%.2f]\n", rect.x(), rect.y(), rect.width(), rect.height());-
4129#endif-
4130 Q_D(QPainter);-
4131-
4132 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4133 return;
never executed: return;
0
4134-
4135 if (xRadius <= 0 || yRadius <= 0) { // draw normal rectangle
xRadius <= 0Description
TRUEnever evaluated
FALSEnever evaluated
yRadius <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4136 drawRect(rect);-
4137 return;
never executed: return;
0
4138 }-
4139-
4140 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4141 d->extended->drawRoundedRect(rect, xRadius, yRadius, mode);-
4142 return;
never executed: return;
0
4143 }-
4144-
4145 QPainterPath path;-
4146 path.addRoundedRect(rect, xRadius, yRadius, mode);-
4147 drawPath(path);-
4148}
never executed: end of block
0
4149-
4150/*!-
4151 \fn void QPainter::drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,-
4152 Qt::SizeMode mode = Qt::AbsoluteSize);-
4153 \since 4.4-
4154 \overload-
4155-
4156 Draws the given rectangle \a rect with rounded corners.-
4157*/-
4158-
4159/*!-
4160 \fn void QPainter::drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,-
4161 Qt::SizeMode mode = Qt::AbsoluteSize);-
4162 \since 4.4-
4163 \overload-
4164-
4165 Draws the given rectangle \a x, \a y, \a w, \a h with rounded corners.-
4166*/-
4167-
4168/*!-
4169 \obsolete-
4170-
4171 Draws a rectangle \a r with rounded corners.-
4172-
4173 The \a xRnd and \a yRnd arguments specify how rounded the corners-
4174 should be. 0 is angled corners, 99 is maximum roundedness.-
4175-
4176 A filled rectangle has a size of r.size(). A stroked rectangle-
4177 has a size of r.size() plus the pen width.-
4178-
4179 \sa drawRoundedRect()-
4180*/-
4181void QPainter::drawRoundRect(const QRectF &r, int xRnd, int yRnd)-
4182{-
4183 drawRoundedRect(r, xRnd, yRnd, Qt::RelativeSize);-
4184}
never executed: end of block
0
4185-
4186-
4187/*!-
4188 \fn void QPainter::drawRoundRect(const QRect &r, int xRnd = 25, int yRnd = 25)-
4189-
4190 \overload-
4191 \obsolete-
4192-
4193 Draws the rectangle \a r with rounded corners.-
4194*/-
4195-
4196/*!-
4197 \obsolete-
4198-
4199 \fn QPainter::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd)-
4200-
4201 \overload-
4202-
4203 Draws the rectangle \a x, \a y, \a w, \a h with rounded corners.-
4204*/-
4205-
4206/*!-
4207 \fn void QPainter::drawEllipse(const QRectF &rectangle)-
4208-
4209 Draws the ellipse defined by the given \a rectangle.-
4210-
4211 A filled ellipse has a size of \a{rectangle}.\l-
4212 {QRect::size()}{size()}. A stroked ellipse has a size of-
4213 \a{rectangle}.\l {QRect::size()}{size()} plus the pen width.-
4214-
4215 \table 100%-
4216 \row-
4217 \li \inlineimage qpainter-ellipse.png-
4218 \li-
4219 \snippet code/src_gui_painting_qpainter.cpp 9-
4220 \endtable-
4221-
4222 \sa drawPie(), {Coordinate System}-
4223*/-
4224void QPainter::drawEllipse(const QRectF &r)-
4225{-
4226#ifdef QT_DEBUG_DRAW-
4227 if (qt_show_painter_debug_output)-
4228 printf("QPainter::drawEllipse(), [%.2f,%.2f,%.2f,%.2f]\n", r.x(), r.y(), r.width(), r.height());-
4229#endif-
4230 Q_D(QPainter);-
4231-
4232 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4233 return;
never executed: return;
0
4234-
4235 QRectF rect(r.normalized());-
4236-
4237 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4238 d->extended->drawEllipse(rect);-
4239 return;
never executed: return;
0
4240 }-
4241-
4242 d->updateState(d->state);-
4243 if (d->state->emulationSpecifier) {
d->state->emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
4244 if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform
d->state->emul...itiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4245 && d->state->matrix.type() == QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4246 rect.translate(QPointF(d->state->matrix.dx(), d->state->matrix.dy()));-
4247 } else {
never executed: end of block
0
4248 QPainterPath path;-
4249 path.addEllipse(rect);-
4250 d->draw_helper(path, QPainterPrivate::StrokeAndFillDraw);-
4251 return;
never executed: return;
0
4252 }-
4253 }-
4254-
4255 d->engine->drawEllipse(rect);-
4256}
never executed: end of block
0
4257-
4258/*!-
4259 \fn QPainter::drawEllipse(const QRect &rectangle)-
4260-
4261 \overload-
4262-
4263 Draws the ellipse defined by the given \a rectangle.-
4264*/-
4265void QPainter::drawEllipse(const QRect &r)-
4266{-
4267#ifdef QT_DEBUG_DRAW-
4268 if (qt_show_painter_debug_output)-
4269 printf("QPainter::drawEllipse(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height());-
4270#endif-
4271 Q_D(QPainter);-
4272-
4273 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4274 return;
never executed: return;
0
4275-
4276 QRect rect(r.normalized());-
4277-
4278 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4279 d->extended->drawEllipse(rect);-
4280 return;
never executed: return;
0
4281 }-
4282-
4283 d->updateState(d->state);-
4284-
4285 if (d->state->emulationSpecifier) {
d->state->emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
4286 if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform
d->state->emul...itiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4287 && d->state->matrix.type() == QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4288 rect.translate(QPoint(qRound(d->state->matrix.dx()), qRound(d->state->matrix.dy())));-
4289 } else {
never executed: end of block
0
4290 QPainterPath path;-
4291 path.addEllipse(rect);-
4292 d->draw_helper(path, QPainterPrivate::StrokeAndFillDraw);-
4293 return;
never executed: return;
0
4294 }-
4295 }-
4296-
4297 d->engine->drawEllipse(rect);-
4298}
never executed: end of block
0
4299-
4300/*!-
4301 \fn QPainter::drawEllipse(int x, int y, int width, int height)-
4302-
4303 \overload-
4304-
4305 Draws the ellipse defined by the rectangle beginning at (\a{x},-
4306 \a{y}) with the given \a width and \a height.-
4307*/-
4308-
4309/*!-
4310 \since 4.4-
4311-
4312 \fn QPainter::drawEllipse(const QPointF &center, qreal rx, qreal ry)-
4313-
4314 \overload-
4315-
4316 Draws the ellipse positioned at \a{center} with radii \a{rx} and \a{ry}.-
4317*/-
4318-
4319/*!-
4320 \since 4.4-
4321-
4322 \fn QPainter::drawEllipse(const QPoint &center, int rx, int ry)-
4323-
4324 \overload-
4325-
4326 Draws the ellipse positioned at \a{center} with radii \a{rx} and \a{ry}.-
4327*/-
4328-
4329/*!-
4330 \fn void QPainter::drawArc(const QRectF &rectangle, int startAngle, int spanAngle)-
4331-
4332 Draws the arc defined by the given \a rectangle, \a startAngle and-
4333 \a spanAngle.-
4334-
4335 The \a startAngle and \a spanAngle must be specified in 1/16th of-
4336 a degree, i.e. a full circle equals 5760 (16 * 360). Positive-
4337 values for the angles mean counter-clockwise while negative values-
4338 mean the clockwise direction. Zero degrees is at the 3 o'clock-
4339 position.-
4340-
4341 \table 100%-
4342 \row-
4343 \li \inlineimage qpainter-arc.png-
4344 \li-
4345 \snippet code/src_gui_painting_qpainter.cpp 10-
4346 \endtable-
4347-
4348 \sa drawPie(), drawChord(), {Coordinate System}-
4349*/-
4350-
4351void QPainter::drawArc(const QRectF &r, int a, int alen)-
4352{-
4353#ifdef QT_DEBUG_DRAW-
4354 if (qt_show_painter_debug_output)-
4355 printf("QPainter::drawArc(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n",-
4356 r.x(), r.y(), r.width(), r.height(), a/16, alen/16);-
4357#endif-
4358 Q_D(QPainter);-
4359-
4360 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4361 return;
never executed: return;
0
4362-
4363 QRectF rect = r.normalized();-
4364-
4365 QPainterPath path;-
4366 path.arcMoveTo(rect, a/16.0);-
4367 path.arcTo(rect, a/16.0, alen/16.0);-
4368 strokePath(path, d->state->pen);-
4369}
never executed: end of block
0
4370-
4371/*! \fn void QPainter::drawArc(const QRect &rectangle, int startAngle,-
4372 int spanAngle)-
4373-
4374 \overload-
4375-
4376 Draws the arc defined by the given \a rectangle, \a startAngle and-
4377 \a spanAngle.-
4378*/-
4379-
4380/*!-
4381 \fn void QPainter::drawArc(int x, int y, int width, int height,-
4382 int startAngle, int spanAngle)-
4383-
4384 \overload-
4385-
4386 Draws the arc defined by the rectangle beginning at (\a x, \a y)-
4387 with the specified \a width and \a height, and the given \a-
4388 startAngle and \a spanAngle.-
4389*/-
4390-
4391/*!-
4392 \fn void QPainter::drawPie(const QRectF &rectangle, int startAngle, int spanAngle)-
4393-
4394 Draws a pie defined by the given \a rectangle, \a startAngle and \a spanAngle.-
4395-
4396 The pie is filled with the current brush().-
4397-
4398 The startAngle and spanAngle must be specified in 1/16th of a-
4399 degree, i.e. a full circle equals 5760 (16 * 360). Positive values-
4400 for the angles mean counter-clockwise while negative values mean-
4401 the clockwise direction. Zero degrees is at the 3 o'clock-
4402 position.-
4403-
4404 \table 100%-
4405 \row-
4406 \li \inlineimage qpainter-pie.png-
4407 \li-
4408 \snippet code/src_gui_painting_qpainter.cpp 11-
4409 \endtable-
4410-
4411 \sa drawEllipse(), drawChord(), {Coordinate System}-
4412*/-
4413void QPainter::drawPie(const QRectF &r, int a, int alen)-
4414{-
4415#ifdef QT_DEBUG_DRAW-
4416 if (qt_show_painter_debug_output)-
4417 printf("QPainter::drawPie(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n",-
4418 r.x(), r.y(), r.width(), r.height(), a/16, alen/16);-
4419#endif-
4420 Q_D(QPainter);-
4421-
4422 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4423 return;
never executed: return;
0
4424-
4425 if (a > (360*16)) {
a > (360*16)Description
TRUEnever evaluated
FALSEnever evaluated
0
4426 a = a % (360*16);-
4427 } else if (a < 0) {
never executed: end of block
a < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4428 a = a % (360*16);-
4429 if (a < 0) a += (360*16);
never executed: a += (360*16);
a < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4430 }
never executed: end of block
0
4431-
4432 QRectF rect = r.normalized();-
4433-
4434 QPainterPath path;-
4435 path.moveTo(rect.center());-
4436 path.arcTo(rect.x(), rect.y(), rect.width(), rect.height(), a/16.0, alen/16.0);-
4437 path.closeSubpath();-
4438 drawPath(path);-
4439-
4440}
never executed: end of block
0
4441-
4442/*!-
4443 \fn void QPainter::drawPie(const QRect &rectangle, int startAngle, int spanAngle)-
4444 \overload-
4445-
4446 Draws a pie defined by the given \a rectangle, \a startAngle and-
4447 and \a spanAngle.-
4448*/-
4449-
4450/*!-
4451 \fn void QPainter::drawPie(int x, int y, int width, int height, int-
4452 startAngle, int spanAngle)-
4453-
4454 \overload-
4455-
4456 Draws the pie defined by the rectangle beginning at (\a x, \a y) with-
4457 the specified \a width and \a height, and the given \a startAngle and-
4458 \a spanAngle.-
4459*/-
4460-
4461/*!-
4462 \fn void QPainter::drawChord(const QRectF &rectangle, int startAngle, int spanAngle)-
4463-
4464 Draws the chord defined by the given \a rectangle, \a startAngle and-
4465 \a spanAngle. The chord is filled with the current brush().-
4466-
4467 The startAngle and spanAngle must be specified in 1/16th of a-
4468 degree, i.e. a full circle equals 5760 (16 * 360). Positive values-
4469 for the angles mean counter-clockwise while negative values mean-
4470 the clockwise direction. Zero degrees is at the 3 o'clock-
4471 position.-
4472-
4473 \table 100%-
4474 \row-
4475 \li \inlineimage qpainter-chord.png-
4476 \li-
4477 \snippet code/src_gui_painting_qpainter.cpp 12-
4478 \endtable-
4479-
4480 \sa drawArc(), drawPie(), {Coordinate System}-
4481*/-
4482void QPainter::drawChord(const QRectF &r, int a, int alen)-
4483{-
4484#ifdef QT_DEBUG_DRAW-
4485 if (qt_show_painter_debug_output)-
4486 printf("QPainter::drawChord(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n",-
4487 r.x(), r.y(), r.width(), r.height(), a/16, alen/16);-
4488#endif-
4489 Q_D(QPainter);-
4490-
4491 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
4492 return;
never executed: return;
0
4493-
4494 QRectF rect = r.normalized();-
4495-
4496 QPainterPath path;-
4497 path.arcMoveTo(rect, a/16.0);-
4498 path.arcTo(rect, a/16.0, alen/16.0);-
4499 path.closeSubpath();-
4500 drawPath(path);-
4501}
never executed: end of block
0
4502/*!-
4503 \fn void QPainter::drawChord(const QRect &rectangle, int startAngle, int spanAngle)-
4504-
4505 \overload-
4506-
4507 Draws the chord defined by the given \a rectangle, \a startAngle and-
4508 \a spanAngle.-
4509*/-
4510-
4511/*!-
4512 \fn void QPainter::drawChord(int x, int y, int width, int height, int-
4513 startAngle, int spanAngle)-
4514-
4515 \overload-
4516-
4517 Draws the chord defined by the rectangle beginning at (\a x, \a y)-
4518 with the specified \a width and \a height, and the given \a-
4519 startAngle and \a spanAngle.-
4520*/-
4521-
4522-
4523/*!-
4524 Draws the first \a lineCount lines in the array \a lines-
4525 using the current pen.-
4526-
4527 \sa drawLine(), drawPolyline()-
4528*/-
4529void QPainter::drawLines(const QLineF *lines, int lineCount)-
4530{-
4531#ifdef QT_DEBUG_DRAW-
4532 if (qt_show_painter_debug_output)-
4533 printf("QPainter::drawLines(), line count=%d\n", lineCount);-
4534#endif-
4535-
4536 Q_D(QPainter);-
4537-
4538 if (!d->engine || lineCount < 1)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
lineCount < 1Description
TRUEnever evaluated
FALSEnever evaluated
0
4539 return;
never executed: return;
0
4540-
4541 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4542 d->extended->drawLines(lines, lineCount);-
4543 return;
never executed: return;
0
4544 }-
4545-
4546 d->updateState(d->state);-
4547-
4548 uint lineEmulation = line_emulation(d->state->emulationSpecifier);-
4549-
4550 if (lineEmulation) {
lineEmulationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4551 if (lineEmulation == QPaintEngine::PrimitiveTransform
lineEmulation ...itiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4552 && d->state->matrix.type() == QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4553 for (int i = 0; i < lineCount; ++i) {
i < lineCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4554 QLineF line = lines[i];-
4555 line.translate(d->state->matrix.dx(), d->state->matrix.dy());-
4556 d->engine->drawLines(&line, 1);-
4557 }
never executed: end of block
0
4558 } else {
never executed: end of block
0
4559 QPainterPath linePath;-
4560 for (int i = 0; i < lineCount; ++i) {
i < lineCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4561 linePath.moveTo(lines[i].p1());-
4562 linePath.lineTo(lines[i].p2());-
4563 }
never executed: end of block
0
4564 d->draw_helper(linePath, QPainterPrivate::StrokeDraw);-
4565 }
never executed: end of block
0
4566 return;
never executed: return;
0
4567 }-
4568 d->engine->drawLines(lines, lineCount);-
4569}
never executed: end of block
0
4570-
4571/*!-
4572 \fn void QPainter::drawLines(const QLine *lines, int lineCount)-
4573 \overload-
4574-
4575 Draws the first \a lineCount lines in the array \a lines-
4576 using the current pen.-
4577*/-
4578void QPainter::drawLines(const QLine *lines, int lineCount)-
4579{-
4580#ifdef QT_DEBUG_DRAW-
4581 if (qt_show_painter_debug_output)-
4582 printf("QPainter::drawLine(), line count=%d\n", lineCount);-
4583#endif-
4584-
4585 Q_D(QPainter);-
4586-
4587 if (!d->engine || lineCount < 1)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
lineCount < 1Description
TRUEnever evaluated
FALSEnever evaluated
0
4588 return;
never executed: return;
0
4589-
4590 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4591 d->extended->drawLines(lines, lineCount);-
4592 return;
never executed: return;
0
4593 }-
4594-
4595 d->updateState(d->state);-
4596-
4597 uint lineEmulation = line_emulation(d->state->emulationSpecifier);-
4598-
4599 if (lineEmulation) {
lineEmulationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4600 if (lineEmulation == QPaintEngine::PrimitiveTransform
lineEmulation ...itiveTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4601 && d->state->matrix.type() == QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4602 for (int i = 0; i < lineCount; ++i) {
i < lineCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4603 QLineF line = lines[i];-
4604 line.translate(d->state->matrix.dx(), d->state->matrix.dy());-
4605 d->engine->drawLines(&line, 1);-
4606 }
never executed: end of block
0
4607 } else {
never executed: end of block
0
4608 QPainterPath linePath;-
4609 for (int i = 0; i < lineCount; ++i) {
i < lineCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4610 linePath.moveTo(lines[i].p1());-
4611 linePath.lineTo(lines[i].p2());-
4612 }
never executed: end of block
0
4613 d->draw_helper(linePath, QPainterPrivate::StrokeDraw);-
4614 }
never executed: end of block
0
4615 return;
never executed: return;
0
4616 }-
4617 d->engine->drawLines(lines, lineCount);-
4618}
never executed: end of block
0
4619-
4620/*!-
4621 \overload-
4622-
4623 Draws the first \a lineCount lines in the array \a pointPairs-
4624 using the current pen. The lines are specified as pairs of points-
4625 so the number of entries in \a pointPairs must be at least \a-
4626 lineCount * 2.-
4627*/-
4628void QPainter::drawLines(const QPointF *pointPairs, int lineCount)-
4629{-
4630 Q_ASSERT(sizeof(QLineF) == 2*sizeof(QPointF));-
4631-
4632 drawLines((const QLineF*)pointPairs, lineCount);-
4633}
never executed: end of block
0
4634-
4635/*!-
4636 \overload-
4637-
4638 Draws the first \a lineCount lines in the array \a pointPairs-
4639 using the current pen.-
4640*/-
4641void QPainter::drawLines(const QPoint *pointPairs, int lineCount)-
4642{-
4643 Q_ASSERT(sizeof(QLine) == 2*sizeof(QPoint));-
4644-
4645 drawLines((const QLine*)pointPairs, lineCount);-
4646}
never executed: end of block
0
4647-
4648-
4649/*!-
4650 \fn void QPainter::drawLines(const QVector<QPointF> &pointPairs)-
4651 \overload-
4652-
4653 Draws a line for each pair of points in the vector \a pointPairs-
4654 using the current pen. If there is an odd number of points in the-
4655 array, the last point will be ignored.-
4656*/-
4657-
4658/*!-
4659 \fn void QPainter::drawLines(const QVector<QPoint> &pointPairs)-
4660 \overload-
4661-
4662 Draws a line for each pair of points in the vector \a pointPairs-
4663 using the current pen.-
4664*/-
4665-
4666/*!-
4667 \fn void QPainter::drawLines(const QVector<QLineF> &lines)-
4668 \overload-
4669-
4670 Draws the set of lines defined by the list \a lines using the-
4671 current pen and brush.-
4672*/-
4673-
4674/*!-
4675 \fn void QPainter::drawLines(const QVector<QLine> &lines)-
4676 \overload-
4677-
4678 Draws the set of lines defined by the list \a lines using the-
4679 current pen and brush.-
4680*/-
4681-
4682/*!-
4683 Draws the polyline defined by the first \a pointCount points in \a-
4684 points using the current pen.-
4685-
4686 Note that unlike the drawPolygon() function the last point is \e-
4687 not connected to the first, neither is the polyline filled.-
4688-
4689 \table 100%-
4690 \row-
4691 \li-
4692 \snippet code/src_gui_painting_qpainter.cpp 13-
4693 \endtable-
4694-
4695 \sa drawLines(), drawPolygon(), {Coordinate System}-
4696*/-
4697void QPainter::drawPolyline(const QPointF *points, int pointCount)-
4698{-
4699#ifdef QT_DEBUG_DRAW-
4700 if (qt_show_painter_debug_output)-
4701 printf("QPainter::drawPolyline(), count=%d\n", pointCount);-
4702#endif-
4703 Q_D(QPainter);-
4704-
4705 if (!d->engine || pointCount < 2)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pointCount < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
4706 return;
never executed: return;
0
4707-
4708 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4709 d->extended->drawPolygon(points, pointCount, QPaintEngine::PolylineMode);-
4710 return;
never executed: return;
0
4711 }-
4712-
4713 d->updateState(d->state);-
4714-
4715 uint lineEmulation = line_emulation(d->state->emulationSpecifier);-
4716-
4717 if (lineEmulation) {
lineEmulationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4718 // ###-
4719// if (lineEmulation == QPaintEngine::PrimitiveTransform-
4720// && d->state->matrix.type() == QTransform::TxTranslate) {-
4721// } else {-
4722 QPainterPath polylinePath(points[0]);-
4723 for (int i=1; i<pointCount; ++i)
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4724 polylinePath.lineTo(points[i]);
never executed: polylinePath.lineTo(points[i]);
0
4725 d->draw_helper(polylinePath, QPainterPrivate::StrokeDraw);-
4726// }-
4727 } else {
never executed: end of block
0
4728 d->engine->drawPolygon(points, pointCount, QPaintEngine::PolylineMode);-
4729 }
never executed: end of block
0
4730}-
4731-
4732/*!-
4733 \overload-
4734-
4735 Draws the polyline defined by the first \a pointCount points in \a-
4736 points using the current pen.-
4737 */-
4738void QPainter::drawPolyline(const QPoint *points, int pointCount)-
4739{-
4740#ifdef QT_DEBUG_DRAW-
4741 if (qt_show_painter_debug_output)-
4742 printf("QPainter::drawPolyline(), count=%d\n", pointCount);-
4743#endif-
4744 Q_D(QPainter);-
4745-
4746 if (!d->engine || pointCount < 2)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pointCount < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
4747 return;
never executed: return;
0
4748-
4749 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4750 d->extended->drawPolygon(points, pointCount, QPaintEngine::PolylineMode);-
4751 return;
never executed: return;
0
4752 }-
4753-
4754 d->updateState(d->state);-
4755-
4756 uint lineEmulation = line_emulation(d->state->emulationSpecifier);-
4757-
4758 if (lineEmulation) {
lineEmulationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4759 // ###-
4760// if (lineEmulation == QPaintEngine::PrimitiveTransform-
4761// && d->state->matrix.type() == QTransform::TxTranslate) {-
4762// } else {-
4763 QPainterPath polylinePath(points[0]);-
4764 for (int i=1; i<pointCount; ++i)
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4765 polylinePath.lineTo(points[i]);
never executed: polylinePath.lineTo(points[i]);
0
4766 d->draw_helper(polylinePath, QPainterPrivate::StrokeDraw);-
4767// }-
4768 } else {
never executed: end of block
0
4769 d->engine->drawPolygon(points, pointCount, QPaintEngine::PolylineMode);-
4770 }
never executed: end of block
0
4771}-
4772-
4773/*!-
4774 \fn void QPainter::drawPolyline(const QPolygonF &points)-
4775-
4776 \overload-
4777-
4778 Draws the polyline defined by the given \a points using the-
4779 current pen.-
4780*/-
4781-
4782/*!-
4783 \fn void QPainter::drawPolyline(const QPolygon &points)-
4784-
4785 \overload-
4786-
4787 Draws the polyline defined by the given \a points using the-
4788 current pen.-
4789*/-
4790-
4791/*!-
4792 Draws the polygon defined by the first \a pointCount points in the-
4793 array \a points using the current pen and brush.-
4794-
4795 \table 100%-
4796 \row-
4797 \li \inlineimage qpainter-polygon.png-
4798 \li-
4799 \snippet code/src_gui_painting_qpainter.cpp 14-
4800 \endtable-
4801-
4802 The first point is implicitly connected to the last point, and the-
4803 polygon is filled with the current brush().-
4804-
4805 If \a fillRule is Qt::WindingFill, the polygon is filled using the-
4806 winding fill algorithm. If \a fillRule is Qt::OddEvenFill, the-
4807 polygon is filled using the odd-even fill algorithm. See-
4808 \l{Qt::FillRule} for a more detailed description of these fill-
4809 rules.-
4810-
4811 \sa drawConvexPolygon(), drawPolyline(), {Coordinate System}-
4812*/-
4813void QPainter::drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)-
4814{-
4815#ifdef QT_DEBUG_DRAW-
4816 if (qt_show_painter_debug_output)-
4817 printf("QPainter::drawPolygon(), count=%d\n", pointCount);-
4818#endif-
4819-
4820 Q_D(QPainter);-
4821-
4822 if (!d->engine || pointCount < 2)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pointCount < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
4823 return;
never executed: return;
0
4824-
4825 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4826 d->extended->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule));-
4827 return;
never executed: return;
0
4828 }-
4829-
4830 d->updateState(d->state);-
4831-
4832 uint emulationSpecifier = d->state->emulationSpecifier;-
4833-
4834 if (emulationSpecifier) {
emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
4835 QPainterPath polygonPath(points[0]);-
4836 for (int i=1; i<pointCount; ++i)
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4837 polygonPath.lineTo(points[i]);
never executed: polygonPath.lineTo(points[i]);
0
4838 polygonPath.closeSubpath();-
4839 polygonPath.setFillRule(fillRule);-
4840 d->draw_helper(polygonPath);-
4841 return;
never executed: return;
0
4842 }-
4843-
4844 d->engine->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule));-
4845}
never executed: end of block
0
4846-
4847/*! \overload-
4848-
4849 Draws the polygon defined by the first \a pointCount points in the-
4850 array \a points.-
4851*/-
4852void QPainter::drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fillRule)-
4853{-
4854#ifdef QT_DEBUG_DRAW-
4855 if (qt_show_painter_debug_output)-
4856 printf("QPainter::drawPolygon(), count=%d\n", pointCount);-
4857#endif-
4858-
4859 Q_D(QPainter);-
4860-
4861 if (!d->engine || pointCount < 2)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pointCount < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
4862 return;
never executed: return;
0
4863-
4864 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4865 d->extended->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule));-
4866 return;
never executed: return;
0
4867 }-
4868-
4869 d->updateState(d->state);-
4870-
4871 uint emulationSpecifier = d->state->emulationSpecifier;-
4872-
4873 if (emulationSpecifier) {
emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
4874 QPainterPath polygonPath(points[0]);-
4875 for (int i=1; i<pointCount; ++i)
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4876 polygonPath.lineTo(points[i]);
never executed: polygonPath.lineTo(points[i]);
0
4877 polygonPath.closeSubpath();-
4878 polygonPath.setFillRule(fillRule);-
4879 d->draw_helper(polygonPath);-
4880 return;
never executed: return;
0
4881 }-
4882-
4883 d->engine->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule));-
4884}
never executed: end of block
0
4885-
4886/*! \fn void QPainter::drawPolygon(const QPolygonF &points, Qt::FillRule fillRule)-
4887-
4888 \overload-
4889-
4890 Draws the polygon defined by the given \a points using the fill-
4891 rule \a fillRule.-
4892*/-
4893-
4894/*! \fn void QPainter::drawPolygon(const QPolygon &points, Qt::FillRule fillRule)-
4895-
4896 \overload-
4897-
4898 Draws the polygon defined by the given \a points using the fill-
4899 rule \a fillRule.-
4900*/-
4901-
4902/*!-
4903 \fn void QPainter::drawConvexPolygon(const QPointF *points, int pointCount)-
4904-
4905 Draws the convex polygon defined by the first \a pointCount points-
4906 in the array \a points using the current pen.-
4907-
4908 \table 100%-
4909 \row-
4910 \li \inlineimage qpainter-polygon.png-
4911 \li-
4912 \snippet code/src_gui_painting_qpainter.cpp 15-
4913 \endtable-
4914-
4915 The first point is implicitly connected to the last point, and the-
4916 polygon is filled with the current brush(). If the supplied-
4917 polygon is not convex, i.e. it contains at least one angle larger-
4918 than 180 degrees, the results are undefined.-
4919-
4920 On some platforms (e.g. X11), the drawConvexPolygon() function can-
4921 be faster than the drawPolygon() function.-
4922-
4923 \sa drawPolygon(), drawPolyline(), {Coordinate System}-
4924*/-
4925-
4926/*!-
4927 \fn void QPainter::drawConvexPolygon(const QPoint *points, int pointCount)-
4928 \overload-
4929-
4930 Draws the convex polygon defined by the first \a pointCount points-
4931 in the array \a points using the current pen.-
4932*/-
4933-
4934/*!-
4935 \fn void QPainter::drawConvexPolygon(const QPolygonF &polygon)-
4936-
4937 \overload-
4938-
4939 Draws the convex polygon defined by \a polygon using the current-
4940 pen and brush.-
4941*/-
4942-
4943/*!-
4944 \fn void QPainter::drawConvexPolygon(const QPolygon &polygon)-
4945 \overload-
4946-
4947 Draws the convex polygon defined by \a polygon using the current-
4948 pen and brush.-
4949*/-
4950-
4951void QPainter::drawConvexPolygon(const QPoint *points, int pointCount)-
4952{-
4953#ifdef QT_DEBUG_DRAW-
4954 if (qt_show_painter_debug_output)-
4955 printf("QPainter::drawConvexPolygon(), count=%d\n", pointCount);-
4956#endif-
4957-
4958 Q_D(QPainter);-
4959-
4960 if (!d->engine || pointCount < 2)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pointCount < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
4961 return;
never executed: return;
0
4962-
4963 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4964 d->extended->drawPolygon(points, pointCount, QPaintEngine::ConvexMode);-
4965 return;
never executed: return;
0
4966 }-
4967-
4968 d->updateState(d->state);-
4969-
4970 uint emulationSpecifier = d->state->emulationSpecifier;-
4971-
4972 if (emulationSpecifier) {
emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
4973 QPainterPath polygonPath(points[0]);-
4974 for (int i=1; i<pointCount; ++i)
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
4975 polygonPath.lineTo(points[i]);
never executed: polygonPath.lineTo(points[i]);
0
4976 polygonPath.closeSubpath();-
4977 polygonPath.setFillRule(Qt::WindingFill);-
4978 d->draw_helper(polygonPath);-
4979 return;
never executed: return;
0
4980 }-
4981-
4982 d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode);-
4983}
never executed: end of block
0
4984-
4985void QPainter::drawConvexPolygon(const QPointF *points, int pointCount)-
4986{-
4987#ifdef QT_DEBUG_DRAW-
4988 if (qt_show_painter_debug_output)-
4989 printf("QPainter::drawConvexPolygon(), count=%d\n", pointCount);-
4990#endif-
4991-
4992 Q_D(QPainter);-
4993-
4994 if (!d->engine || pointCount < 2)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pointCount < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
4995 return;
never executed: return;
0
4996-
4997 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4998 d->extended->drawPolygon(points, pointCount, QPaintEngine::ConvexMode);-
4999 return;
never executed: return;
0
5000 }-
5001-
5002 d->updateState(d->state);-
5003-
5004 uint emulationSpecifier = d->state->emulationSpecifier;-
5005-
5006 if (emulationSpecifier) {
emulationSpecifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
5007 QPainterPath polygonPath(points[0]);-
5008 for (int i=1; i<pointCount; ++i)
i<pointCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
5009 polygonPath.lineTo(points[i]);
never executed: polygonPath.lineTo(points[i]);
0
5010 polygonPath.closeSubpath();-
5011 polygonPath.setFillRule(Qt::WindingFill);-
5012 d->draw_helper(polygonPath);-
5013 return;
never executed: return;
0
5014 }-
5015-
5016 d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode);-
5017}
never executed: end of block
0
5018-
5019static inline QPointF roundInDeviceCoordinates(const QPointF &p, const QTransform &m)-
5020{-
5021 return m.inverted().map(QPointF(m.map(p).toPoint()));
never executed: return m.inverted().map(QPointF(m.map(p).toPoint()));
0
5022}-
5023-
5024/*!-
5025 \fn void QPainter::drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source)-
5026-
5027 Draws the rectangular portion \a source of the given \a pixmap-
5028 into the given \a target in the paint device.-
5029-
5030 \note The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.-
5031 \note See \l{Drawing High Resolution Versions of Pixmaps and Images} on how this is affected-
5032 by QPixmap::devicePixelRatio().-
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(), QPixmap::devicePixelRatio()-
5048*/-
5049void 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);-
5059-
5060 if (!d->engine || pm.isNull())
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5061 return;
never executed: return;
0
5062-
5063#ifndef QT_NO_DEBUG-
5064 qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawPixmap()");-
5065#endif-
5066-
5067 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5068 d->extended->drawPixmap(p, pm);-
5069 return;
never executed: return;
0
5070 }-
5071-
5072 qreal x = p.x();-
5073 qreal y = p.y();-
5074-
5075 int w = pm.width();-
5076 int h = pm.height();-
5077-
5078 if (w <= 0)
w <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5079 return;
never executed: return;
0
5080-
5081 // Emulate opaque background for bitmaps-
5082 if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap()) {
d->state->bgMo...Qt::OpaqueModeDescription
TRUEnever evaluated
FALSEnever evaluated
pm.isQBitmap()Description
TRUEnever evaluated
FALSEnever evaluated
0
5083 fillRect(QRectF(x, y, w, h), d->state->bgBrush.color());-
5084 }
never executed: end of block
0
5085-
5086 d->updateState(d->state);-
5087-
5088 if ((d->state->matrix.type() > QTransform::TxTranslate
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
5089 && !d->engine->hasFeature(QPaintEngine::PixmapTransform))
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5090 || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform))
!d->state->matrix.isAffine()Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...tiveTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5091 || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity)))
d->state->opacity != 1.0Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...nstantOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5092 {-
5093 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) {
d->state->matr...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5097 const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix);-
5098 x = p.x();-
5099 y = p.y();-
5100 }
never executed: end of block
0
5101 translate(x, y);-
5102 setBackgroundMode(Qt::TransparentMode);-
5103 setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform);-
5104 QBrush brush(d->state->pen.color(), pm);-
5105 setBrush(brush);-
5106 setPen(Qt::NoPen);-
5107 setBrushOrigin(QPointF(0, 0));-
5108-
5109 drawRect(pm.rect());-
5110 restore();-
5111 } else {
never executed: end of block
0
5112 if (!d->engine->hasFeature(QPaintEngine::PixmapTransform)) {
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5113 x += d->state->matrix.dx();-
5114 y += d->state->matrix.dy();-
5115 }
never executed: end of block
0
5116 qreal scale = pm.devicePixelRatio();-
5117 d->engine->drawPixmap(QRectF(x, y, w / scale, h / scale), pm, QRectF(0, 0, w, h));-
5118 }
never executed: end of block
0
5119}-
5120-
5121void 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);-
5132 if (!d->engine || pm.isNull())
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5133 return;
never executed: return;
0
5134#ifndef QT_NO_DEBUG-
5135 qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawPixmap()");-
5136#endif-
5137-
5138 qreal x = r.x();-
5139 qreal y = r.y();-
5140 qreal w = r.width();-
5141 qreal h = r.height();-
5142 qreal sx = sr.x();-
5143 qreal sy = sr.y();-
5144 qreal sw = sr.width();-
5145 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();-
5151-
5152 // Sanity-check clipping-
5153 if (sw <= 0)
sw <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5154 sw = pm.width() - sx;
never executed: sw = pm.width() - sx;
0
5155-
5156 if (sh <= 0)
sh <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5157 sh = pm.height() - sy;
never executed: sh = pm.height() - sy;
0
5158-
5159 if (w < 0)
w < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5160 w = sw / pmscale;
never executed: w = sw / pmscale;
0
5161 if (h < 0)
h < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5162 h = sh / pmscale;
never executed: h = sh / pmscale;
0
5163-
5164 if (sx < 0) {
sx < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5165 qreal w_ratio = sx * w/sw;-
5166 x -= w_ratio;-
5167 w += w_ratio;-
5168 sw += sx;-
5169 sx = 0;-
5170 }
never executed: end of block
0
5171-
5172 if (sy < 0) {
sy < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5173 qreal h_ratio = sy * h/sh;-
5174 y -= h_ratio;-
5175 h += h_ratio;-
5176 sh += sy;-
5177 sy = 0;-
5178 }
never executed: end of block
0
5179-
5180 if (sw + sx > pm.width()) {
sw + sx > pm.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
5181 qreal delta = sw - (pm.width() - sx);-
5182 qreal w_ratio = delta * w/sw;-
5183 sw -= delta;-
5184 w -= w_ratio;-
5185 }
never executed: end of block
0
5186-
5187 if (sh + sy > pm.height()) {
sh + sy > pm.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
5188 qreal delta = sh - (pm.height() - sy);-
5189 qreal h_ratio = delta * h/sh;-
5190 sh -= delta;-
5191 h -= h_ratio;-
5192 }
never executed: end of block
0
5193-
5194 if (w == 0 || h == 0 || sw <= 0 || sh <= 0)
w == 0Description
TRUEnever evaluated
FALSEnever evaluated
h == 0Description
TRUEnever evaluated
FALSEnever evaluated
sw <= 0Description
TRUEnever evaluated
FALSEnever evaluated
sh <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5195 return;
never executed: return;
0
5196-
5197 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5198 d->extended->drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh));-
5199 return;
never executed: return;
0
5200 }-
5201-
5202 // Emulate opaque background for bitmaps-
5203 if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap())
d->state->bgMo...Qt::OpaqueModeDescription
TRUEnever evaluated
FALSEnever evaluated
pm.isQBitmap()Description
TRUEnever evaluated
FALSEnever evaluated
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);-
5207-
5208 if ((d->state->matrix.type() > QTransform::TxTranslate
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
5209 && !d->engine->hasFeature(QPaintEngine::PixmapTransform))
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5210 || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform))
!d->state->matrix.isAffine()Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...tiveTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5211 || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))
d->state->opacity != 1.0Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...nstantOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5212 || ((sw != w || sh != h) && !d->engine->hasFeature(QPaintEngine::PixmapTransform)))
sw != wDescription
TRUEnever evaluated
FALSEnever evaluated
sh != hDescription
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5213 {-
5214 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) {
d->state->matr...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5218 const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix);-
5219 x = p.x();-
5220 y = p.y();-
5221 }
never executed: end of block
0
5222-
5223 if (d->state->matrix.type() <= QTransform::TxTranslate && sw == w && sh == h) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
sw == wDescription
TRUEnever evaluated
FALSEnever evaluated
sh == hDescription
TRUEnever evaluated
FALSEnever evaluated
0
5224 sx = qRound(sx);-
5225 sy = qRound(sy);-
5226 sw = qRound(sw);-
5227 sh = qRound(sh);-
5228 }
never executed: end of block
0
5229-
5230 translate(x, y);-
5231 scale(w / sw, h / sh);-
5232 setBackgroundMode(Qt::TransparentMode);-
5233 setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform);-
5234 QBrush brush;-
5235-
5236 if (sw == pm.width() && sh == pm.height())
sw == pm.width()Description
TRUEnever evaluated
FALSEnever evaluated
sh == pm.height()Description
TRUEnever evaluated
FALSEnever evaluated
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);-
5242 setPen(Qt::NoPen);-
5243-
5244 drawRect(QRectF(0, 0, sw, sh));-
5245 restore();-
5246 } else {
never executed: end of block
0
5247 if (!d->engine->hasFeature(QPaintEngine::PixmapTransform)) {
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5248 x += d->state->matrix.dx();-
5249 y += d->state->matrix.dy();-
5250 }
never executed: end of block
0
5251 d->engine->drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh));-
5252 }
never executed: end of block
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-
5358void QPainter::drawImage(const QPointF &p, const QImage &image)-
5359{-
5360 Q_D(QPainter);-
5361-
5362 if (!d->engine || image.isNull())
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5363 return;
never executed: return;
0
5364-
5365 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5366 d->extended->drawImage(p, image);-
5367 return;
never executed: return;
0
5368 }-
5369-
5370 qreal x = p.x();-
5371 qreal y = p.y();-
5372-
5373 int w = image.width();-
5374 int h = image.height();-
5375 qreal scale = image.devicePixelRatio();-
5376-
5377 d->updateState(d->state);-
5378-
5379 if (((d->state->matrix.type() > QTransform::TxTranslate)
(d->state->mat...::TxTranslate)Description
TRUEnever evaluated
FALSEnever evaluated
0
5380 && !d->engine->hasFeature(QPaintEngine::PixmapTransform))
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5381 || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform))
!d->state->matrix.isAffine()Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...tiveTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5382 || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity)))
d->state->opacity != 1.0Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...nstantOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5383 {-
5384 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) {
d->state->matr...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5388 const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix);-
5389 x = p.x();-
5390 y = p.y();-
5391 }
never executed: end of block
0
5392 translate(x, y);-
5393 setBackgroundMode(Qt::TransparentMode);-
5394 setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform);-
5395 QBrush brush(image);-
5396 setBrush(brush);-
5397 setPen(Qt::NoPen);-
5398 setBrushOrigin(QPointF(0, 0));-
5399 drawRect(QRect(QPoint(0, 0), image.size() / scale));-
5400 restore();-
5401 return;
never executed: return;
0
5402 }-
5403-
5404 if (d->state->matrix.type() == QTransform::TxTranslate
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
5405 && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) {
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5406 x += d->state->matrix.dx();-
5407 y += d->state->matrix.dy();-
5408 }
never executed: end of block
0
5409-
5410 d->engine->drawImage(QRectF(x, y, w / scale, h / scale), image, QRectF(0, 0, w, h), Qt::AutoColor);-
5411}
never executed: end of block
0
5412-
5413void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect,-
5414 Qt::ImageConversionFlags flags)-
5415{-
5416 Q_D(QPainter);-
5417-
5418 if (!d->engine || image.isNull())
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5419 return;
never executed: return;
0
5420-
5421 qreal x = targetRect.x();-
5422 qreal y = targetRect.y();-
5423 qreal w = targetRect.width();-
5424 qreal h = targetRect.height();-
5425 qreal sx = sourceRect.x();-
5426 qreal sy = sourceRect.y();-
5427 qreal sw = sourceRect.width();-
5428 qreal sh = sourceRect.height();-
5429 qreal imageScale = image.devicePixelRatio();-
5430-
5431 // Sanity-check clipping-
5432 if (sw <= 0)
sw <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5433 sw = image.width() - sx;
never executed: sw = image.width() - sx;
0
5434-
5435 if (sh <= 0)
sh <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5436 sh = image.height() - sy;
never executed: sh = image.height() - sy;
0
5437-
5438 if (w < 0)
w < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5439 w = sw / imageScale;
never executed: w = sw / imageScale;
0
5440 if (h < 0)
h < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5441 h = sh / imageScale;
never executed: h = sh / imageScale;
0
5442-
5443 if (sx < 0) {
sx < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5444 qreal w_ratio = sx * w/sw;-
5445 x -= w_ratio;-
5446 w += w_ratio;-
5447 sw += sx;-
5448 sx = 0;-
5449 }
never executed: end of block
0
5450-
5451 if (sy < 0) {
sy < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5452 qreal h_ratio = sy * h/sh;-
5453 y -= h_ratio;-
5454 h += h_ratio;-
5455 sh += sy;-
5456 sy = 0;-
5457 }
never executed: end of block
0
5458-
5459 if (sw + sx > image.width()) {
sw + sx > image.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
5460 qreal delta = sw - (image.width() - sx);-
5461 qreal w_ratio = delta * w/sw;-
5462 sw -= delta;-
5463 w -= w_ratio;-
5464 }
never executed: end of block
0
5465-
5466 if (sh + sy > image.height()) {
sh + sy > image.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
5467 qreal delta = sh - (image.height() - sy);-
5468 qreal h_ratio = delta * h/sh;-
5469 sh -= delta;-
5470 h -= h_ratio;-
5471 }
never executed: end of block
0
5472-
5473 if (w == 0 || h == 0 || sw <= 0 || sh <= 0)
w == 0Description
TRUEnever evaluated
FALSEnever evaluated
h == 0Description
TRUEnever evaluated
FALSEnever evaluated
sw <= 0Description
TRUEnever evaluated
FALSEnever evaluated
sh <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5474 return;
never executed: return;
0
5475-
5476 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5477 d->extended->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags);-
5478 return;
never executed: return;
0
5479 }-
5480-
5481 d->updateState(d->state);-
5482-
5483 if (((d->state->matrix.type() > QTransform::TxTranslate || (sw != w || sh != h))
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
sw != wDescription
TRUEnever evaluated
FALSEnever evaluated
sh != hDescription
TRUEnever evaluated
FALSEnever evaluated
0
5484 && !d->engine->hasFeature(QPaintEngine::PixmapTransform))
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5485 || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform))
!d->state->matrix.isAffine()Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...tiveTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5486 || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity)))
d->state->opacity != 1.0Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...nstantOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5487 {-
5488 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) {
d->state->matr...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5492 const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix);-
5493 x = p.x();-
5494 y = p.y();-
5495 }
never executed: end of block
0
5496-
5497 if (d->state->matrix.type() <= QTransform::TxTranslate && sw == w && sh == h) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
sw == wDescription
TRUEnever evaluated
FALSEnever evaluated
sh == hDescription
TRUEnever evaluated
FALSEnever evaluated
0
5498 sx = qRound(sx);-
5499 sy = qRound(sy);-
5500 sw = qRound(sw);-
5501 sh = qRound(sh);-
5502 }
never executed: end of block
0
5503 translate(x, y);-
5504 scale(w / sw, h / sh);-
5505 setBackgroundMode(Qt::TransparentMode);-
5506 setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform);-
5507 QBrush brush(image);-
5508 setBrush(brush);-
5509 setPen(Qt::NoPen);-
5510 setBrushOrigin(QPointF(-sx, -sy));-
5511-
5512 drawRect(QRectF(0, 0, sw, sh));-
5513 restore();-
5514 return;
never executed: return;
0
5515 }-
5516-
5517 if (d->state->matrix.type() == QTransform::TxTranslate
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
5518 && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) {
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
5519 x += d->state->matrix.dx();-
5520 y += d->state->matrix.dy();-
5521 }
never executed: end of block
0
5522-
5523 d->engine->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags);-
5524}
never executed: end of block
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)-
5538void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun)-
5539{-
5540 Q_D(QPainter);-
5541-
5542 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
5543 qWarning("QPainter::drawGlyphRun: Painter not active");-
5544 return;
never executed: return;
0
5545 }-
5546-
5547 QRawFont font = glyphRun.rawFont();-
5548 if (!font.isValid())
!font.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
5549 return;
never executed: return;
0
5550-
5551 QGlyphRunPrivate *glyphRun_d = QGlyphRunPrivate::get(glyphRun);-
5552-
5553 const quint32 *glyphIndexes = glyphRun_d->glyphIndexData;-
5554 const QPointF *glyphPositions = glyphRun_d->glyphPositionData;-
5555-
5556 int count = qMin(glyphRun_d->glyphIndexDataSize, glyphRun_d->glyphPositionDataSize);-
5557 QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count);-
5558-
5559 QRawFontPrivate *fontD = QRawFontPrivate::get(font);-
5560 bool engineRequiresPretransformedGlyphPositions = d->extended
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5561 ? d->extended->requiresPretransformedGlyphPositions(fontD->fontEngine, d->state->matrix)-
5562 : d->engine->type() != QPaintEngine::CoreGraphics && !d->state->matrix.isAffine();
d->engine->typ...::CoreGraphicsDescription
TRUEnever evaluated
FALSEnever evaluated
!d->state->matrix.isAffine()Description
TRUEnever evaluated
FALSEnever evaluated
0
5563-
5564 for (int i=0; i<count; ++i) {
i<countDescription
TRUEnever evaluated
FALSEnever evaluated
0
5565 QPointF processedPosition = position + glyphPositions[i];-
5566 if (engineRequiresPretransformedGlyphPositions)
engineRequires...GlyphPositionsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5567 processedPosition = d->state->transform().map(processedPosition);
never executed: processedPosition = d->state->transform().map(processedPosition);
0
5568 fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition);-
5569 }
never executed: end of block
0
5570-
5571 d->drawGlyphs(glyphIndexes, fixedPointPositions.data(), count, fontD->fontEngine,-
5572 glyphRun.overline(), glyphRun.underline(), glyphRun.strikeOut());-
5573}
never executed: end of block
0
5574-
5575void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positions,-
5576 int glyphCount,-
5577 QFontEngine *fontEngine, bool overline, bool underline,-
5578 bool strikeOut)-
5579{-
5580 Q_Q(QPainter);-
5581-
5582 updateState(state);-
5583-
5584 QFixed leftMost;-
5585 QFixed rightMost;-
5586 QFixed baseLine;-
5587 for (int i=0; i<glyphCount; ++i) {
i<glyphCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
5588 glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]);-
5589 if (i == 0 || leftMost > positions[i].x)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
leftMost > positions[i].xDescription
TRUEnever evaluated
FALSEnever evaluated
0
5590 leftMost = positions[i].x;
never executed: leftMost = positions[i].x;
0
5591-
5592 // We don't support glyphs that do not share a common baseline. If this turns out to-
5593 // be a relevant use case, then we need to find clusters of glyphs that share a baseline-
5594 // and do a drawTextItemDecorations call per cluster.-
5595 if (i == 0 || baseLine < positions[i].y)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
baseLine < positions[i].yDescription
TRUEnever evaluated
FALSEnever evaluated
0
5596 baseLine = positions[i].y;
never executed: baseLine = positions[i].y;
0
5597-
5598 // We use the advance rather than the actual bounds to match the algorithm in drawText()-
5599 if (i == 0 || rightMost < positions[i].x + gm.xoff)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
rightMost < po...i].x + gm.xoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
5600 rightMost = positions[i].x + gm.xoff;
never executed: rightMost = positions[i].x + gm.xoff;
0
5601 }
never executed: end of block
0
5602-
5603 QFixed width = rightMost - leftMost;-
5604-
5605 if (extended != 0 && state->matrix.isAffine()) {
extended != 0Description
TRUEnever evaluated
FALSEnever evaluated
state->matrix.isAffine()Description
TRUEnever evaluated
FALSEnever evaluated
0
5606 QStaticTextItem staticTextItem;-
5607 staticTextItem.color = state->pen.color();-
5608 staticTextItem.font = state->font;-
5609 staticTextItem.setFontEngine(fontEngine);-
5610 staticTextItem.numGlyphs = glyphCount;-
5611 staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray));-
5612 staticTextItem.glyphPositions = positions;-
5613 // The font property is meaningless, the fontengine must be used directly:-
5614 staticTextItem.usesRawFont = true;-
5615-
5616 extended->drawStaticTextItem(&staticTextItem);-
5617 } else {
never executed: end of block
0
5618 QTextItemInt textItem;-
5619 textItem.fontEngine = fontEngine;-
5620-
5621 QVarLengthArray<QFixed, 128> advances(glyphCount);-
5622 QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount);-
5623 QVarLengthArray<QGlyphAttributes, 128> glyphAttributes(glyphCount);-
5624 memset(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(QGlyphAttributes));-
5625 memset(advances.data(), 0, advances.size() * sizeof(QFixed));-
5626 memset(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification));-
5627-
5628 textItem.glyphs.numGlyphs = glyphCount;-
5629 textItem.glyphs.glyphs = const_cast<glyph_t *>(glyphArray);-
5630 textItem.glyphs.offsets = positions;-
5631 textItem.glyphs.advances = advances.data();-
5632 textItem.glyphs.justifications = glyphJustifications.data();-
5633 textItem.glyphs.attributes = glyphAttributes.data();-
5634-
5635 engine->drawTextItem(QPointF(0, 0), textItem);-
5636 }
never executed: end of block
0
5637-
5638 QTextItemInt::RenderFlags flags;-
5639 if (underline)
underlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
5640 flags |= QTextItemInt::Underline;
never executed: flags |= QTextItemInt::Underline;
0
5641 if (overline)
overlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
5642 flags |= QTextItemInt::Overline;
never executed: flags |= QTextItemInt::Overline;
0
5643 if (strikeOut)
strikeOutDescription
TRUEnever evaluated
FALSEnever evaluated
0
5644 flags |= QTextItemInt::StrikeOut;
never executed: flags |= QTextItemInt::StrikeOut;
0
5645-
5646 drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()),-
5647 fontEngine,-
5648 0, // textEngine-
5649 (underline-
5650 ? QTextCharFormat::SingleUnderline-
5651 : QTextCharFormat::NoUnderline),-
5652 flags, width.toReal(), QTextCharFormat());-
5653}
never executed: end of block
0
5654#endif // QT_NO_RAWFONT-
5655-
5656/*!-
5657-
5658 \fn void QPainter::drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText)-
5659 \since 4.7-
5660 \overload-
5661-
5662 Draws the \a staticText at the \a topLeftPosition.-
5663-
5664 \note The y-position is used as the top of the font.-
5665-
5666*/-
5667-
5668/*!-
5669 \fn void QPainter::drawStaticText(int left, int top, const QStaticText &staticText)-
5670 \since 4.7-
5671 \overload-
5672-
5673 Draws the \a staticText at coordinates \a left and \a top.-
5674-
5675 \note The y-position is used as the top of the font.-
5676*/-
5677-
5678/*!-
5679 \fn void QPainter::drawText(const QPointF &position, const QString &text)-
5680-
5681 Draws the given \a text with the currently defined text direction,-
5682 beginning at the given \a position.-
5683-
5684 This function does not handle the newline character (\\n), as it cannot-
5685 break text into multiple lines, and it cannot display the newline character.-
5686 Use the QPainter::drawText() overload that takes a rectangle instead-
5687 if you want to draw multiple lines of text with the newline character, or-
5688 if you want the text to be wrapped.-
5689-
5690 By default, QPainter draws text anti-aliased.-
5691-
5692 \note The y-position is used as the baseline of the font.-
5693-
5694 \sa setFont(), setPen()-
5695*/-
5696-
5697void QPainter::drawText(const QPointF &p, const QString &str)-
5698{-
5699 drawText(p, str, 0, 0);-
5700}
never executed: end of block
0
5701-
5702/*!-
5703 \since 4.7-
5704-
5705 Draws the given \a staticText at the given \a topLeftPosition.-
5706-
5707 The text will be drawn using the font and the transformation set on the painter. If the-
5708 font and/or transformation set on the painter are different from the ones used to initialize-
5709 the layout of the QStaticText, then the layout will have to be recalculated. Use-
5710 QStaticText::prepare() to initialize \a staticText with the font and transformation with which-
5711 it will later be drawn.-
5712-
5713 If \a topLeftPosition is not the same as when \a staticText was initialized, or when it was-
5714 last drawn, then there will be a slight overhead when translating the text to its new position.-
5715-
5716 \note If the painter's transformation is not affine, then \a staticText will be drawn using-
5717 regular calls to drawText(), losing any potential for performance improvement.-
5718-
5719 \note The y-position is used as the top of the font.-
5720-
5721 \sa QStaticText-
5722*/-
5723void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText)-
5724{-
5725 Q_D(QPainter);-
5726 if (!d->engine || staticText.text().isEmpty() || pen().style() == Qt::NoPen)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
staticText.text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5727 return;
never executed: return;
0
5728-
5729 QStaticTextPrivate *staticText_d =-
5730 const_cast<QStaticTextPrivate *>(QStaticTextPrivate::get(&staticText));-
5731-
5732 if (font() != staticText_d->font) {
font() != staticText_d->fontDescription
TRUEnever evaluated
FALSEnever evaluated
0
5733 staticText_d->font = font();-
5734 staticText_d->needsRelayout = true;-
5735 }
never executed: end of block
0
5736-
5737 QFontEngine *fe = staticText_d->font.d->engineForScript(QChar::Script_Common);-
5738 if (fe->type() == QFontEngine::Multi)
fe->type() == ...tEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
0
5739 fe = static_cast<QFontEngineMulti *>(fe)->engine(0);
never executed: fe = static_cast<QFontEngineMulti *>(fe)->engine(0);
0
5740-
5741 // If we don't have an extended paint engine, if the painter is projected,-
5742 // or if the font engine does not support the matrix, we go through standard-
5743 // code path-
5744 if (d->extended == 0
d->extended == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5745 || !d->state->matrix.isAffine()
!d->state->matrix.isAffine()Description
TRUEnever evaluated
FALSEnever evaluated
0
5746 || !fe->supportsTransformation(d->state->matrix)) {
!fe->supportsT...state->matrix)Description
TRUEnever evaluated
FALSEnever evaluated
0
5747 staticText_d->paintText(topLeftPosition, this);-
5748 return;
never executed: return;
0
5749 }-
5750-
5751 bool engineRequiresPretransform = d->extended->requiresPretransformedGlyphPositions(fe, d->state->matrix);-
5752 if (staticText_d->untransformedCoordinates && engineRequiresPretransform) {
staticText_d->...medCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
engineRequiresPretransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
5753 // The coordinates are untransformed, and the engine can't deal with that-
5754 // nativly, so we have to pre-transform the static text.-
5755 staticText_d->untransformedCoordinates = false;-
5756 staticText_d->needsRelayout = true;-
5757 } else if (!staticText_d->untransformedCoordinates && !engineRequiresPretransform) {
never executed: end of block
!staticText_d-...medCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
!engineRequiresPretransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
5758 // The coordinates are already transformed, but the engine can handle that-
5759 // nativly, so undo the transform of the static text.-
5760 staticText_d->untransformedCoordinates = true;-
5761 staticText_d->needsRelayout = true;-
5762 }
never executed: end of block
0
5763-
5764 // Don't recalculate entire layout because of translation, rather add the dx and dy-
5765 // into the position to move each text item the correct distance.-
5766 QPointF transformedPosition = topLeftPosition;-
5767 if (!staticText_d->untransformedCoordinates)
!staticText_d-...medCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
5768 transformedPosition = transformedPosition * d->state->matrix;
never executed: transformedPosition = transformedPosition * d->state->matrix;
0
5769 QTransform oldMatrix;-
5770-
5771 // The translation has been applied to transformedPosition. Remove translation-
5772 // component from matrix.-
5773 if (d->state->matrix.isTranslating() && !staticText_d->untransformedCoordinates) {
d->state->matr...sTranslating()Description
TRUEnever evaluated
FALSEnever evaluated
!staticText_d-...medCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
5774 qreal m11 = d->state->matrix.m11();-
5775 qreal m12 = d->state->matrix.m12();-
5776 qreal m13 = d->state->matrix.m13();-
5777 qreal m21 = d->state->matrix.m21();-
5778 qreal m22 = d->state->matrix.m22();-
5779 qreal m23 = d->state->matrix.m23();-
5780 qreal m33 = d->state->matrix.m33();-
5781-
5782 oldMatrix = d->state->matrix;-
5783 d->state->matrix.setMatrix(m11, m12, m13,-
5784 m21, m22, m23,-
5785 0.0, 0.0, m33);-
5786 }
never executed: end of block
0
5787-
5788 // If the transform is not identical to the text transform,-
5789 // we have to relayout the text (for other transformations than plain translation)-
5790 bool staticTextNeedsReinit = staticText_d->needsRelayout;-
5791 if (!staticText_d->untransformedCoordinates && staticText_d->matrix != d->state->matrix) {
!staticText_d-...medCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
staticText_d->...>state->matrixDescription
TRUEnever evaluated
FALSEnever evaluated
0
5792 staticText_d->matrix = d->state->matrix;-
5793 staticTextNeedsReinit = true;-
5794 }
never executed: end of block
0
5795-
5796 // Recreate the layout of the static text because the matrix or font has changed-
5797 if (staticTextNeedsReinit)
staticTextNeedsReinitDescription
TRUEnever evaluated
FALSEnever evaluated
0
5798 staticText_d->init();
never executed: staticText_d->init();
0
5799-
5800 if (transformedPosition != staticText_d->position) { // Translate to actual position
transformedPos...xt_d->positionDescription
TRUEnever evaluated
FALSEnever evaluated
0
5801 QFixed fx = QFixed::fromReal(transformedPosition.x());-
5802 QFixed fy = QFixed::fromReal(transformedPosition.y());-
5803 QFixed oldX = QFixed::fromReal(staticText_d->position.x());-
5804 QFixed oldY = QFixed::fromReal(staticText_d->position.y());-
5805 for (int item=0; item<staticText_d->itemCount;++item) {
item<staticText_d->itemCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
5806 QStaticTextItem *textItem = staticText_d->items + item;-
5807 for (int i=0; i<textItem->numGlyphs; ++i) {
i<textItem->numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5808 textItem->glyphPositions[i].x += fx - oldX;-
5809 textItem->glyphPositions[i].y += fy - oldY;-
5810 }
never executed: end of block
0
5811 textItem->userDataNeedsUpdate = true;-
5812 }
never executed: end of block
0
5813-
5814 staticText_d->position = transformedPosition;-
5815 }
never executed: end of block
0
5816-
5817 QPen oldPen = d->state->pen;-
5818 QColor currentColor = oldPen.color();-
5819 for (int i=0; i<staticText_d->itemCount; ++i) {
i<staticText_d->itemCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
5820 QStaticTextItem *item = staticText_d->items + i;-
5821 if (item->color.isValid() && currentColor != item->color) {
item->color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
currentColor != item->colorDescription
TRUEnever evaluated
FALSEnever evaluated
0
5822 setPen(item->color);-
5823 currentColor = item->color;-
5824 }
never executed: end of block
0
5825 d->extended->drawStaticTextItem(item);-
5826-
5827 qt_draw_decoration_for_glyphs(this, item->glyphs, item->glyphPositions,-
5828 item->numGlyphs, item->fontEngine(), staticText_d->font,-
5829 QTextCharFormat());-
5830 }
never executed: end of block
0
5831 if (currentColor != oldPen.color())
currentColor != oldPen.color()Description
TRUEnever evaluated
FALSEnever evaluated
0
5832 setPen(oldPen);
never executed: setPen(oldPen);
0
5833-
5834 if (!staticText_d->untransformedCoordinates && oldMatrix.isTranslating())
!staticText_d-...medCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
oldMatrix.isTranslating()Description
TRUEnever evaluated
FALSEnever evaluated
0
5835 d->state->matrix = oldMatrix;
never executed: d->state->matrix = oldMatrix;
0
5836}
never executed: end of block
0
5837-
5838/*!-
5839 \internal-
5840*/-
5841void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justificationPadding)-
5842{-
5843#ifdef QT_DEBUG_DRAW-
5844 if (qt_show_painter_debug_output)-
5845 printf("QPainter::drawText(), pos=[%.2f,%.2f], str='%s'\n", p.x(), p.y(), str.toLatin1().constData());-
5846#endif-
5847-
5848 Q_D(QPainter);-
5849-
5850 if (!d->engine || str.isEmpty() || pen().style() == Qt::NoPen)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5851 return;
never executed: return;
0
5852-
5853 if (tf & Qt::TextBypassShaping) {
tf & Qt::TextBypassShapingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5854 // Skip complex shaping, shape using glyph advances only-
5855 int len = str.length();-
5856 int numGlyphs = len;-
5857 QVarLengthGlyphLayoutArray glyphs(len);-
5858 QFontEngine *fontEngine = d->state->font.d->engineForScript(QChar::Script_Common);-
5859 if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0))
!fontEngine->s...&numGlyphs, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
5860 Q_UNREACHABLE();
never executed: end of block
0
5861-
5862 QTextItemInt gf(glyphs, &d->state->font, str.data(), len, fontEngine);-
5863 drawTextItem(p, gf);-
5864 return;
never executed: return;
0
5865 }-
5866-
5867 QStackTextEngine engine(str, d->state->font);-
5868 engine.option.setTextDirection(d->state->layoutDirection);-
5869 if (tf & (Qt::TextForceLeftToRight|Qt::TextForceRightToLeft)) {
tf & (Qt::Text...ceRightToLeft)Description
TRUEnever evaluated
FALSEnever evaluated
0
5870 engine.ignoreBidi = true;-
5871 engine.option.setTextDirection((tf & Qt::TextForceLeftToRight) ? Qt::LeftToRight : Qt::RightToLeft);-
5872 }
never executed: end of block
0
5873 engine.itemize();-
5874 QScriptLine line;-
5875 line.length = str.length();-
5876 engine.shapeLine(line);-
5877-
5878 int nItems = engine.layoutData->items.size();-
5879 QVarLengthArray<int> visualOrder(nItems);-
5880 QVarLengthArray<uchar> levels(nItems);-
5881 for (int i = 0; i < nItems; ++i)
i < nItemsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5882 levels[i] = engine.layoutData->items[i].analysis.bidiLevel;
never executed: levels[i] = engine.layoutData->items[i].analysis.bidiLevel;
0
5883 QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());-
5884-
5885 if (justificationPadding > 0) {
justificationPadding > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5886 engine.option.setAlignment(Qt::AlignJustify);-
5887 engine.forceJustification = true;-
5888 // this works because justify() is only interested in the difference between width and textWidth-
5889 line.width = justificationPadding;-
5890 engine.justify(line);-
5891 }
never executed: end of block
0
5892 QFixed x = QFixed::fromReal(p.x());-
5893-
5894 for (int i = 0; i < nItems; ++i) {
i < nItemsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5895 int item = visualOrder[i];-
5896 const QScriptItem &si = engine.layoutData->items.at(item);-
5897 if (si.analysis.flags >= QScriptAnalysis::TabOrObject) {
si.analysis.fl...s::TabOrObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5898 x += si.width;-
5899 continue;
never executed: continue;
0
5900 }-
5901 QFont f = engine.font(si);-
5902 QTextItemInt gf(si, &f);-
5903 gf.glyphs = engine.shapedGlyphs(&si);-
5904 gf.chars = engine.layoutData->string.unicode() + si.position;-
5905 gf.num_chars = engine.length(item);-
5906 if (engine.forceJustification) {
engine.forceJustificationDescription
TRUEnever evaluated
FALSEnever evaluated
0
5907 for (int j=0; j<gf.glyphs.numGlyphs; ++j)
j<gf.glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5908 gf.width += gf.glyphs.effectiveAdvance(j);
never executed: gf.width += gf.glyphs.effectiveAdvance(j);
0
5909 } else {
never executed: end of block
0
5910 gf.width = si.width;-
5911 }
never executed: end of block
0
5912 gf.logClusters = engine.logClusters(&si);-
5913-
5914 drawTextItem(QPointF(x.toReal(), p.y()), gf);-
5915-
5916 x += gf.width;-
5917 }
never executed: end of block
0
5918}
never executed: end of block
0
5919-
5920void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br)-
5921{-
5922#ifdef QT_DEBUG_DRAW-
5923 if (qt_show_painter_debug_output)-
5924 printf("QPainter::drawText(), r=[%d,%d,%d,%d], flags=%d, str='%s'\n",-
5925 r.x(), r.y(), r.width(), r.height(), flags, str.toLatin1().constData());-
5926#endif-
5927-
5928 Q_D(QPainter);-
5929-
5930 if (!d->engine || str.length() == 0 || pen().style() == Qt::NoPen)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
str.length() == 0Description
TRUEnever evaluated
FALSEnever evaluated
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5931 return;
never executed: return;
0
5932-
5933 if (!d->extended)
!d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5934 d->updateState(d->state);
never executed: d->updateState(d->state);
0
5935-
5936 QRectF bounds;-
5937 qt_format_text(d->state->font, r, flags, 0, str, br ? &bounds : 0, 0, 0, 0, this);-
5938 if (br)
brDescription
TRUEnever evaluated
FALSEnever evaluated
0
5939 *br = bounds.toAlignedRect();
never executed: *br = bounds.toAlignedRect();
0
5940}
never executed: end of block
0
5941-
5942/*!-
5943 \fn void QPainter::drawText(const QPoint &position, const QString &text)-
5944-
5945 \overload-
5946-
5947 Draws the given \a text with the currently defined text direction,-
5948 beginning at the given \a position.-
5949-
5950 By default, QPainter draws text anti-aliased.-
5951-
5952 \note The y-position is used as the baseline of the font.-
5953-
5954 \sa setFont(), setPen()-
5955*/-
5956-
5957/*!-
5958 \fn void QPainter::drawText(const QRectF &rectangle, int flags, const QString &text, QRectF *boundingRect)-
5959 \overload-
5960-
5961 Draws the given \a text within the provided \a rectangle.-
5962 The \a rectangle along with alignment \a flags defines the anchors for the \a text.-
5963-
5964 \table 100%-
5965 \row-
5966 \li \inlineimage qpainter-text.png-
5967 \li-
5968 \snippet code/src_gui_painting_qpainter.cpp 17-
5969 \endtable-
5970-
5971 The \a boundingRect (if not null) is set to the what the bounding rectangle-
5972 should be in order to enclose the whole text. For example, in the following-
5973 image, the dotted line represents \a boundingRect as calculated by the-
5974 function, and the dashed line represents \a rectangle:-
5975-
5976 \table 100%-
5977 \row-
5978 \li \inlineimage qpainter-text-bounds.png-
5979 \li \snippet code/src_gui_painting_qpainter.cpp drawText-
5980 \endtable-
5981-
5982 The \a flags argument is a bitwise OR of the following flags:-
5983-
5984 \list-
5985 \li Qt::AlignLeft-
5986 \li Qt::AlignRight-
5987 \li Qt::AlignHCenter-
5988 \li Qt::AlignJustify-
5989 \li Qt::AlignTop-
5990 \li Qt::AlignBottom-
5991 \li Qt::AlignVCenter-
5992 \li Qt::AlignCenter-
5993 \li Qt::TextDontClip-
5994 \li Qt::TextSingleLine-
5995 \li Qt::TextExpandTabs-
5996 \li Qt::TextShowMnemonic-
5997 \li Qt::TextWordWrap-
5998 \li Qt::TextIncludeTrailingSpaces-
5999 \endlist-
6000-
6001 \sa Qt::AlignmentFlag, Qt::TextFlag, boundingRect(), layoutDirection()-
6002-
6003 By default, QPainter draws text anti-aliased.-
6004-
6005 \note The y-coordinate of \a rectangle is used as the top of the font.-
6006*/-
6007void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF *br)-
6008{-
6009#ifdef QT_DEBUG_DRAW-
6010 if (qt_show_painter_debug_output)-
6011 printf("QPainter::drawText(), r=[%.2f,%.2f,%.2f,%.2f], flags=%d, str='%s'\n",-
6012 r.x(), r.y(), r.width(), r.height(), flags, str.toLatin1().constData());-
6013#endif-
6014-
6015 Q_D(QPainter);-
6016-
6017 if (!d->engine || str.length() == 0 || pen().style() == Qt::NoPen)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
str.length() == 0Description
TRUEnever evaluated
FALSEnever evaluated
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
6018 return;
never executed: return;
0
6019-
6020 if (!d->extended)
!d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6021 d->updateState(d->state);
never executed: d->updateState(d->state);
0
6022-
6023 qt_format_text(d->state->font, r, flags, 0, str, br, 0, 0, 0, this);-
6024}
never executed: end of block
0
6025-
6026/*!-
6027 \fn void QPainter::drawText(const QRect &rectangle, int flags, const QString &text, QRect *boundingRect)-
6028 \overload-
6029-
6030 Draws the given \a text within the provided \a rectangle according-
6031 to the specified \a flags.-
6032-
6033 The \a boundingRect (if not null) is set to the what the bounding rectangle-
6034 should be in order to enclose the whole text. For example, in the following-
6035 image, the dotted line represents \a boundingRect as calculated by the-
6036 function, and the dashed line represents \a rectangle:-
6037-
6038 \table 100%-
6039 \row-
6040 \li \inlineimage qpainter-text-bounds.png-
6041 \li \snippet code/src_gui_painting_qpainter.cpp drawText-
6042 \endtable-
6043-
6044 By default, QPainter draws text anti-aliased.-
6045-
6046 \note The y-coordinate of \a rectangle is used as the top of the font.-
6047-
6048 \sa setFont(), setPen()-
6049*/-
6050-
6051/*!-
6052 \fn void QPainter::drawText(int x, int y, const QString &text)-
6053-
6054 \overload-
6055-
6056 Draws the given \a text at position (\a{x}, \a{y}), using the painter's-
6057 currently defined text direction.-
6058-
6059 By default, QPainter draws text anti-aliased.-
6060-
6061 \note The y-position is used as the baseline of the font.-
6062-
6063 \sa setFont(), setPen()-
6064*/-
6065-
6066/*!-
6067 \fn void QPainter::drawText(int x, int y, int width, int height, int flags,-
6068 const QString &text, QRect *boundingRect)-
6069-
6070 \overload-
6071-
6072 Draws the given \a text within the rectangle with origin (\a{x},-
6073 \a{y}), \a width and \a height.-
6074-
6075 The \a boundingRect (if not null) is set to the what the bounding rectangle-
6076 should be in order to enclose the whole text. For example, in the following-
6077 image, the dotted line represents \a boundingRect as calculated by the-
6078 function, and the dashed line represents the rectangle defined by-
6079 \a x, \a y, \a width and \a height:-
6080-
6081 \table 100%-
6082 \row-
6083 \li \inlineimage qpainter-text-bounds.png-
6084 \li \snippet code/src_gui_painting_qpainter.cpp drawText-
6085 \endtable-
6086-
6087 The \a flags argument is a bitwise OR of the following flags:-
6088-
6089 \list-
6090 \li Qt::AlignLeft-
6091 \li Qt::AlignRight-
6092 \li Qt::AlignHCenter-
6093 \li Qt::AlignJustify-
6094 \li Qt::AlignTop-
6095 \li Qt::AlignBottom-
6096 \li Qt::AlignVCenter-
6097 \li Qt::AlignCenter-
6098 \li Qt::TextSingleLine-
6099 \li Qt::TextExpandTabs-
6100 \li Qt::TextShowMnemonic-
6101 \li Qt::TextWordWrap-
6102 \endlist-
6103-
6104 By default, QPainter draws text anti-aliased.-
6105-
6106 \note The y-position is used as the top of the font.-
6107-
6108 \sa Qt::AlignmentFlag, Qt::TextFlag, setFont(), setPen()-
6109*/-
6110-
6111/*!-
6112 \fn void QPainter::drawText(const QRectF &rectangle, const QString &text,-
6113 const QTextOption &option)-
6114 \overload-
6115-
6116 Draws the given \a text in the \a rectangle specified using the \a option-
6117 to control its positioning and orientation.-
6118-
6119 By default, QPainter draws text anti-aliased.-
6120-
6121 \note The y-coordinate of \a rectangle is used as the top of the font.-
6122-
6123 \sa setFont(), setPen()-
6124*/-
6125void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption &o)-
6126{-
6127#ifdef QT_DEBUG_DRAW-
6128 if (qt_show_painter_debug_output)-
6129 printf("QPainter::drawText(), r=[%.2f,%.2f,%.2f,%.2f], str='%s'\n",-
6130 r.x(), r.y(), r.width(), r.height(), text.toLatin1().constData());-
6131#endif-
6132-
6133 Q_D(QPainter);-
6134-
6135 if (!d->engine || text.length() == 0 || pen().style() == Qt::NoPen)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
text.length() == 0Description
TRUEnever evaluated
FALSEnever evaluated
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
6136 return;
never executed: return;
0
6137-
6138 if (!d->extended)
!d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6139 d->updateState(d->state);
never executed: d->updateState(d->state);
0
6140-
6141 qt_format_text(d->state->font, r, 0, &o, text, 0, 0, 0, 0, this);-
6142}
never executed: end of block
0
6143-
6144/*!-
6145 \fn void QPainter::drawTextItem(int x, int y, const QTextItem &ti)-
6146-
6147 \internal-
6148 \overload-
6149*/-
6150-
6151/*!-
6152 \fn void QPainter::drawTextItem(const QPoint &p, const QTextItem &ti)-
6153-
6154 \internal-
6155 \overload-
6156-
6157 Draws the text item \a ti at position \a p.-
6158*/-
6159-
6160/*!-
6161 \fn void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti)-
6162-
6163 \internal-
6164 \since 4.1-
6165-
6166 Draws the text item \a ti at position \a p.-
6167-
6168 This method ignores the painters background mode and-
6169 color. drawText and qt_format_text have to do it themselves, as-
6170 only they know the extents of the complete string.-
6171-
6172 It ignores the font set on the painter as the text item has one of its own.-
6173-
6174 The underline and strikeout parameters of the text items font are-
6175 ignored aswell. You'll need to pass in the correct flags to get-
6176 underlining and strikeout.-
6177*/-
6178-
6179static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)-
6180{-
6181 const qreal radiusBase = qMax(qreal(1), maxRadius);-
6182-
6183 QString key = QLatin1String("WaveUnderline-")-
6184 % pen.color().name()-
6185 % HexString<qreal>(radiusBase)-
6186 % HexString<qreal>(pen.widthF());-
6187-
6188 QPixmap pixmap;-
6189 if (QPixmapCache::find(key, pixmap))
QPixmapCache::...d(key, pixmap)Description
TRUEnever evaluated
FALSEnever evaluated
0
6190 return pixmap;
never executed: return pixmap;
0
6191-
6192 const qreal halfPeriod = qMax(qreal(2), qreal(radiusBase * 1.61803399)); // the golden ratio-
6193 const int width = qCeil(100 / (2 * halfPeriod)) * (2 * halfPeriod);-
6194 const qreal radius = qFloor(radiusBase * 2) / 2.;-
6195-
6196 QPainterPath path;-
6197-
6198 qreal xs = 0;-
6199 qreal ys = radius;-
6200-
6201 while (xs < width) {
xs < widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
6202 xs += halfPeriod;-
6203 ys = -ys;-
6204 path.quadTo(xs - halfPeriod / 2, ys, xs, 0);-
6205 }
never executed: end of block
0
6206-
6207 pixmap = QPixmap(width, radius * 2);-
6208 pixmap.fill(Qt::transparent);-
6209 {-
6210 QPen wavePen = pen;-
6211 wavePen.setCapStyle(Qt::SquareCap);-
6212-
6213 // This is to protect against making the line too fat, as happens on OS X-
6214 // due to it having a rather thick width for the regular underline.-
6215 const qreal maxPenWidth = .8 * radius;-
6216 if (wavePen.widthF() > maxPenWidth)
wavePen.widthF() > maxPenWidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
6217 wavePen.setWidthF(maxPenWidth);
never executed: wavePen.setWidthF(maxPenWidth);
0
6218-
6219 QPainter imgPainter(&pixmap);-
6220 imgPainter.setPen(wavePen);-
6221 imgPainter.setRenderHint(QPainter::Antialiasing);-
6222 imgPainter.translate(0, radius);-
6223 imgPainter.drawPath(path);-
6224 }-
6225-
6226 QPixmapCache::insert(key, pixmap);-
6227-
6228 return pixmap;
never executed: return pixmap;
0
6229}-
6230-
6231static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextEngine *textEngine,-
6232 QTextCharFormat::UnderlineStyle underlineStyle,-
6233 QTextItem::RenderFlags flags, qreal width,-
6234 const QTextCharFormat &charFormat)-
6235{-
6236 if (underlineStyle == QTextCharFormat::NoUnderline
underlineStyle...t::NoUnderlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6237 && !(flags & (QTextItem::StrikeOut | QTextItem::Overline)))
!(flags & (QTe...em::Overline))Description
TRUEnever evaluated
FALSEnever evaluated
0
6238 return;
never executed: return;
0
6239-
6240 const QPen oldPen = painter->pen();-
6241 const QBrush oldBrush = painter->brush();-
6242 painter->setBrush(Qt::NoBrush);-
6243 QPen pen = oldPen;-
6244 pen.setStyle(Qt::SolidLine);-
6245 pen.setWidthF(fe->lineThickness().toReal());-
6246 pen.setCapStyle(Qt::FlatCap);-
6247-
6248 QLineF line(qFloor(pos.x()), pos.y(), qFloor(pos.x() + width), pos.y());-
6249-
6250 bool wasCompatiblePainting = painter->renderHints()-
6251 & QPainter::Qt4CompatiblePainting;-
6252-
6253 if (wasCompatiblePainting)
wasCompatiblePaintingDescription
TRUEnever evaluated
FALSEnever evaluated
0
6254 painter->setRenderHint(QPainter::Qt4CompatiblePainting, false);
never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting, false);
0
6255-
6256 const qreal underlineOffset = fe->underlinePosition().toReal();-
6257-
6258 if (underlineStyle == QTextCharFormat::SpellCheckUnderline) {
underlineStyle...CheckUnderlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6259 QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();-
6260 if (theme)
themeDescription
TRUEnever evaluated
FALSEnever evaluated
0
6261 underlineStyle = QTextCharFormat::UnderlineStyle(theme->themeHint(QPlatformTheme::SpellCheckUnderlineStyle).toInt());
never executed: underlineStyle = QTextCharFormat::UnderlineStyle(theme->themeHint(QPlatformTheme::SpellCheckUnderlineStyle).toInt());
0
6262 }
never executed: end of block
0
6263-
6264 if (underlineStyle == QTextCharFormat::WaveUnderline) {
underlineStyle...:WaveUnderlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6265 painter->save();-
6266 painter->translate(0, pos.y() + 1);-
6267 qreal maxHeight = fe->descent().toReal() - qreal(1);-
6268-
6269 QColor uc = charFormat.underlineColor();-
6270 if (uc.isValid())
uc.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
6271 pen.setColor(uc);
never executed: pen.setColor(uc);
0
6272-
6273 // Adapt wave to underlineOffset or pen width, whatever is larger, to make it work on all platforms-
6274 const QPixmap wave = generateWavyPixmap(qMin(qMax(underlineOffset, pen.widthF()), maxHeight / qreal(2.)), pen);-
6275 const int descent = qFloor(maxHeight);-
6276-
6277 painter->setBrushOrigin(painter->brushOrigin().x(), 0);-
6278 painter->fillRect(pos.x(), 0, qCeil(width), qMin(wave.height(), descent), wave);-
6279 painter->restore();-
6280 } else if (underlineStyle != QTextCharFormat::NoUnderline) {
never executed: end of block
underlineStyle...t::NoUnderlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6281 // Deliberately ceil the offset to avoid the underline coming too close to-
6282 // the text above it, but limit it to stay within descent.-
6283 qreal adjustedUnderlineOffset = std::ceil(underlineOffset) + 0.5;-
6284 if (underlineOffset <= fe->descent().toReal())
underlineOffse...ent().toReal()Description
TRUEnever evaluated
FALSEnever evaluated
0
6285 adjustedUnderlineOffset = qMin(adjustedUnderlineOffset, fe->descent().toReal() - qreal(0.5));
never executed: adjustedUnderlineOffset = qMin(adjustedUnderlineOffset, fe->descent().toReal() - qreal(0.5));
0
6286 const qreal underlinePos = pos.y() + adjustedUnderlineOffset;-
6287 QColor uc = charFormat.underlineColor();-
6288 if (uc.isValid())
uc.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
6289 pen.setColor(uc);
never executed: pen.setColor(uc);
0
6290-
6291 pen.setStyle((Qt::PenStyle)(underlineStyle));-
6292 painter->setPen(pen);-
6293 QLineF underline(line.x1(), underlinePos, line.x2(), underlinePos);-
6294 if (textEngine)
textEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6295 textEngine->addUnderline(painter, underline);
never executed: textEngine->addUnderline(painter, underline);
0
6296 else-
6297 painter->drawLine(underline);
never executed: painter->drawLine(underline);
0
6298 }-
6299-
6300 pen.setStyle(Qt::SolidLine);-
6301 pen.setColor(oldPen.color());-
6302-
6303 if (flags & QTextItem::StrikeOut) {
flags & QTextItem::StrikeOutDescription
TRUEnever evaluated
FALSEnever evaluated
0
6304 QLineF strikeOutLine = line;-
6305 strikeOutLine.translate(0., - fe->ascent().toReal() / 3.);-
6306 painter->setPen(pen);-
6307 if (textEngine)
textEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6308 textEngine->addStrikeOut(painter, strikeOutLine);
never executed: textEngine->addStrikeOut(painter, strikeOutLine);
0
6309 else-
6310 painter->drawLine(strikeOutLine);
never executed: painter->drawLine(strikeOutLine);
0
6311 }-
6312-
6313 if (flags & QTextItem::Overline) {
flags & QTextItem::OverlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6314 QLineF overline = line;-
6315 overline.translate(0., - fe->ascent().toReal());-
6316 painter->setPen(pen);-
6317 if (textEngine)
textEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6318 textEngine->addOverline(painter, overline);
never executed: textEngine->addOverline(painter, overline);
0
6319 else-
6320 painter->drawLine(overline);
never executed: painter->drawLine(overline);
0
6321 }-
6322-
6323 painter->setPen(oldPen);-
6324 painter->setBrush(oldBrush);-
6325-
6326 if (wasCompatiblePainting)
wasCompatiblePaintingDescription
TRUEnever evaluated
FALSEnever evaluated
0
6327 painter->setRenderHint(QPainter::Qt4CompatiblePainting);
never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting);
0
6328}
never executed: end of block
0
6329-
6330Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray,-
6331 const QFixedPoint *positions, int glyphCount,-
6332 QFontEngine *fontEngine, const QFont &font,-
6333 const QTextCharFormat &charFormat)-
6334{-
6335 if (!(font.underline() || font.strikeOut() || font.overline()))
font.underline()Description
TRUEnever evaluated
FALSEnever evaluated
font.strikeOut()Description
TRUEnever evaluated
FALSEnever evaluated
font.overline()Description
TRUEnever evaluated
FALSEnever evaluated
0
6336 return;
never executed: return;
0
6337-
6338 QFixed leftMost;-
6339 QFixed rightMost;-
6340 QFixed baseLine;-
6341 for (int i=0; i<glyphCount; ++i) {
i<glyphCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
6342 glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]);-
6343 if (i == 0 || leftMost > positions[i].x)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
leftMost > positions[i].xDescription
TRUEnever evaluated
FALSEnever evaluated
0
6344 leftMost = positions[i].x;
never executed: leftMost = positions[i].x;
0
6345-
6346 // We don't support glyphs that do not share a common baseline. If this turns out to-
6347 // be a relevant use case, then we need to find clusters of glyphs that share a baseline-
6348 // and do a drawTextItemDecoration call per cluster.-
6349 if (i == 0 || baseLine < positions[i].y)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
baseLine < positions[i].yDescription
TRUEnever evaluated
FALSEnever evaluated
0
6350 baseLine = positions[i].y;
never executed: baseLine = positions[i].y;
0
6351-
6352 // We use the advance rather than the actual bounds to match the algorithm in drawText()-
6353 if (i == 0 || rightMost < positions[i].x + gm.xoff)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
rightMost < po...i].x + gm.xoffDescription
TRUEnever evaluated
FALSEnever evaluated
0
6354 rightMost = positions[i].x + gm.xoff;
never executed: rightMost = positions[i].x + gm.xoff;
0
6355 }
never executed: end of block
0
6356-
6357 QFixed width = rightMost - leftMost;-
6358 QTextItem::RenderFlags flags = 0;-
6359-
6360 if (font.underline())
font.underline()Description
TRUEnever evaluated
FALSEnever evaluated
0
6361 flags |= QTextItem::Underline;
never executed: flags |= QTextItem::Underline;
0
6362 if (font.overline())
font.overline()Description
TRUEnever evaluated
FALSEnever evaluated
0
6363 flags |= QTextItem::Overline;
never executed: flags |= QTextItem::Overline;
0
6364 if (font.strikeOut())
font.strikeOut()Description
TRUEnever evaluated
FALSEnever evaluated
0
6365 flags |= QTextItem::StrikeOut;
never executed: flags |= QTextItem::StrikeOut;
0
6366-
6367 drawTextItemDecoration(painter, QPointF(leftMost.toReal(), baseLine.toReal()),-
6368 fontEngine,-
6369 0, // textEngine-
6370 font.underline() ? QTextCharFormat::SingleUnderline-
6371 : QTextCharFormat::NoUnderline, flags,-
6372 width.toReal(), charFormat);-
6373}
never executed: end of block
0
6374-
6375void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti)-
6376{-
6377 Q_D(QPainter);-
6378-
6379 d->drawTextItem(p, ti, static_cast<QTextEngine *>(0));-
6380}
never executed: end of block
0
6381-
6382void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QTextEngine *textEngine)-
6383{-
6384#ifdef QT_DEBUG_DRAW-
6385 if (qt_show_painter_debug_output)-
6386 printf("QPainter::drawTextItem(), pos=[%.f,%.f], str='%s'\n",-
6387 p.x(), p.y(), qPrintable(_ti.text()));-
6388#endif-
6389-
6390 Q_Q(QPainter);-
6391-
6392 if (!engine)
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6393 return;
never executed: return;
0
6394-
6395 QTextItemInt &ti = const_cast<QTextItemInt &>(static_cast<const QTextItemInt &>(_ti));-
6396-
6397 if (!extended && state->bgMode == Qt::OpaqueMode) {
!extendedDescription
TRUEnever evaluated
FALSEnever evaluated
state->bgMode ...Qt::OpaqueModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
6398 QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent).toReal());-
6399 q->fillRect(rect, state->bgBrush);-
6400 }
never executed: end of block
0
6401-
6402 if (q->pen().style() == Qt::NoPen)
q->pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
6403 return;
never executed: return;
0
6404-
6405 const QPainter::RenderHints oldRenderHints = state->renderHints;-
6406 if (!(state->renderHints & QPainter::Antialiasing) && state->matrix.type() >= QTransform::TxScale) {
!(state->rende...:Antialiasing)Description
TRUEnever evaluated
FALSEnever evaluated
state->matrix....sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
6407 // draw antialias decoration (underline/overline/strikeout) with-
6408 // transformed text-
6409-
6410 bool aa = true;-
6411 const QTransform &m = state->matrix;-
6412 if (state->matrix.type() < QTransform::TxShear) {
state->matrix....sform::TxShearDescription
TRUEnever evaluated
FALSEnever evaluated
0
6413 bool isPlain90DegreeRotation =-
6414 (qFuzzyIsNull(m.m11())
qFuzzyIsNull(m.m11())Description
TRUEnever evaluated
FALSEnever evaluated
0
6415 && qFuzzyIsNull(m.m12() - qreal(1))
qFuzzyIsNull(m...() - qreal(1))Description
TRUEnever evaluated
FALSEnever evaluated
0
6416 && qFuzzyIsNull(m.m21() + qreal(1))
qFuzzyIsNull(m...() + qreal(1))Description
TRUEnever evaluated
FALSEnever evaluated
0
6417 && qFuzzyIsNull(m.m22())
qFuzzyIsNull(m.m22())Description
TRUEnever evaluated
FALSEnever evaluated
0
6418 )-
6419 ||-
6420 (qFuzzyIsNull(m.m11() + qreal(1))
qFuzzyIsNull(m...() + qreal(1))Description
TRUEnever evaluated
FALSEnever evaluated
0
6421 && qFuzzyIsNull(m.m12())
qFuzzyIsNull(m.m12())Description
TRUEnever evaluated
FALSEnever evaluated
0
6422 && qFuzzyIsNull(m.m21())
qFuzzyIsNull(m.m21())Description
TRUEnever evaluated
FALSEnever evaluated
0
6423 && qFuzzyIsNull(m.m22() + qreal(1))
qFuzzyIsNull(m...() + qreal(1))Description
TRUEnever evaluated
FALSEnever evaluated
0
6424 )-
6425 ||-
6426 (qFuzzyIsNull(m.m11())
qFuzzyIsNull(m.m11())Description
TRUEnever evaluated
FALSEnever evaluated
0
6427 && qFuzzyIsNull(m.m12() + qreal(1))
qFuzzyIsNull(m...() + qreal(1))Description
TRUEnever evaluated
FALSEnever evaluated
0
6428 && qFuzzyIsNull(m.m21() - qreal(1))
qFuzzyIsNull(m...() - qreal(1))Description
TRUEnever evaluated
FALSEnever evaluated
0
6429 && qFuzzyIsNull(m.m22())
qFuzzyIsNull(m.m22())Description
TRUEnever evaluated
FALSEnever evaluated
0
6430 )-
6431 ;-
6432 aa = !isPlain90DegreeRotation;-
6433 }
never executed: end of block
0
6434 if (aa)
aaDescription
TRUEnever evaluated
FALSEnever evaluated
0
6435 q->setRenderHint(QPainter::Antialiasing, true);
never executed: q->setRenderHint(QPainter::Antialiasing, true);
0
6436 }
never executed: end of block
0
6437-
6438 if (!extended)
!extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6439 updateState(state);
never executed: updateState(state);
0
6440-
6441 if (!ti.glyphs.numGlyphs) {
!ti.glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6442 // nothing to do-
6443 } else if (ti.fontEngine->type() == QFontEngine::Multi) {
never executed: end of block
ti.fontEngine-...tEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
0
6444 QFontEngineMulti *multi = static_cast<QFontEngineMulti *>(ti.fontEngine);-
6445-
6446 const QGlyphLayout &glyphs = ti.glyphs;-
6447 int which = glyphs.glyphs[0] >> 24;-
6448-
6449 qreal x = p.x();-
6450 qreal y = p.y();-
6451-
6452 bool rtl = ti.flags & QTextItem::RightToLeft;-
6453 if (rtl)
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
0
6454 x += ti.width.toReal();
never executed: x += ti.width.toReal();
0
6455-
6456 int start = 0;-
6457 int end, i;-
6458 for (end = 0; end < ti.glyphs.numGlyphs; ++end) {
end < ti.glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6459 const int e = glyphs.glyphs[end] >> 24;-
6460 if (e == which)
e == whichDescription
TRUEnever evaluated
FALSEnever evaluated
0
6461 continue;
never executed: continue;
0
6462-
6463-
6464 multi->ensureEngineAt(which);-
6465 QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start);-
6466 ti2.width = 0;-
6467 // set the high byte to zero and calc the width-
6468 for (i = start; i < end; ++i) {
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
6469 glyphs.glyphs[i] = glyphs.glyphs[i] & 0xffffff;-
6470 ti2.width += ti.glyphs.effectiveAdvance(i);-
6471 }
never executed: end of block
0
6472-
6473 if (rtl)
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
0
6474 x -= ti2.width.toReal();
never executed: x -= ti2.width.toReal();
0
6475-
6476 if (extended)
extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6477 extended->drawTextItem(QPointF(x, y), ti2);
never executed: extended->drawTextItem(QPointF(x, y), ti2);
0
6478 else-
6479 engine->drawTextItem(QPointF(x, y), ti2);
never executed: engine->drawTextItem(QPointF(x, y), ti2);
0
6480-
6481 if (!rtl)
!rtlDescription
TRUEnever evaluated
FALSEnever evaluated
0
6482 x += ti2.width.toReal();
never executed: x += ti2.width.toReal();
0
6483-
6484 // reset the high byte for all glyphs and advance to the next sub-string-
6485 const int hi = which << 24;-
6486 for (i = start; i < end; ++i) {
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
6487 glyphs.glyphs[i] = hi | glyphs.glyphs[i];-
6488 }
never executed: end of block
0
6489-
6490 // change engine-
6491 start = end;-
6492 which = e;-
6493 }
never executed: end of block
0
6494-
6495 multi->ensureEngineAt(which);-
6496 QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start);-
6497 ti2.width = 0;-
6498 // set the high byte to zero and calc the width-
6499 for (i = start; i < end; ++i) {
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
6500 glyphs.glyphs[i] = glyphs.glyphs[i] & 0xffffff;-
6501 ti2.width += ti.glyphs.effectiveAdvance(i);-
6502 }
never executed: end of block
0
6503-
6504 if (rtl)
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
0
6505 x -= ti2.width.toReal();
never executed: x -= ti2.width.toReal();
0
6506-
6507 if (extended)
extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6508 extended->drawTextItem(QPointF(x, y), ti2);
never executed: extended->drawTextItem(QPointF(x, y), ti2);
0
6509 else-
6510 engine->drawTextItem(QPointF(x,y), ti2);
never executed: engine->drawTextItem(QPointF(x,y), ti2);
0
6511-
6512 // reset the high byte for all glyphs-
6513 const int hi = which << 24;-
6514 for (i = start; i < end; ++i)
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
6515 glyphs.glyphs[i] = hi | glyphs.glyphs[i];
never executed: glyphs.glyphs[i] = hi | glyphs.glyphs[i];
0
6516-
6517 } else {
never executed: end of block
0
6518 if (extended)
extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6519 extended->drawTextItem(p, ti);
never executed: extended->drawTextItem(p, ti);
0
6520 else-
6521 engine->drawTextItem(p, ti);
never executed: engine->drawTextItem(p, ti);
0
6522 }-
6523 drawTextItemDecoration(q, p, ti.fontEngine, textEngine, ti.underlineStyle,-
6524 ti.flags, ti.width.toReal(), ti.charFormat);-
6525-
6526 if (state->renderHints != oldRenderHints) {
state->renderH...oldRenderHintsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6527 state->renderHints = oldRenderHints;-
6528 if (extended)
extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6529 extended->renderHintsChanged();
never executed: extended->renderHintsChanged();
0
6530 else-
6531 state->dirtyFlags |= QPaintEngine::DirtyHints;
never executed: state->dirtyFlags |= QPaintEngine::DirtyHints;
0
6532 }-
6533}
never executed: end of block
0
6534-
6535/*!-
6536 \fn QRectF QPainter::boundingRect(const QRectF &rectangle, int flags, const QString &text)-
6537-
6538 Returns the bounding rectangle of the \a text as it will appear-
6539 when drawn inside the given \a rectangle with the specified \a-
6540 flags using the currently set font(); i.e the function tells you-
6541 where the drawText() function will draw when given the same-
6542 arguments.-
6543-
6544 If the \a text does not fit within the given \a rectangle using-
6545 the specified \a flags, the function returns the required-
6546 rectangle.-
6547-
6548 The \a flags argument is a bitwise OR of the following flags:-
6549 \list-
6550 \li Qt::AlignLeft-
6551 \li Qt::AlignRight-
6552 \li Qt::AlignHCenter-
6553 \li Qt::AlignTop-
6554 \li Qt::AlignBottom-
6555 \li Qt::AlignVCenter-
6556 \li Qt::AlignCenter-
6557 \li Qt::TextSingleLine-
6558 \li Qt::TextExpandTabs-
6559 \li Qt::TextShowMnemonic-
6560 \li Qt::TextWordWrap-
6561 \li Qt::TextIncludeTrailingSpaces-
6562 \endlist-
6563 If several of the horizontal or several of the vertical alignment-
6564 flags are set, the resulting alignment is undefined.-
6565-
6566 \sa drawText(), Qt::Alignment, Qt::TextFlag-
6567*/-
6568-
6569/*!-
6570 \fn QRect QPainter::boundingRect(const QRect &rectangle, int flags,-
6571 const QString &text)-
6572-
6573 \overload-
6574-
6575 Returns the bounding rectangle of the \a text as it will appear-
6576 when drawn inside the given \a rectangle with the specified \a-
6577 flags using the currently set font().-
6578*/-
6579-
6580/*!-
6581 \fn QRect QPainter::boundingRect(int x, int y, int w, int h, int flags,-
6582 const QString &text);-
6583-
6584 \overload-
6585-
6586 Returns the bounding rectangle of the given \a text as it will-
6587 appear when drawn inside the rectangle beginning at the point-
6588 (\a{x}, \a{y}) with width \a w and height \a h.-
6589*/-
6590QRect QPainter::boundingRect(const QRect &rect, int flags, const QString &str)-
6591{-
6592 if (str.isEmpty())
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6593 return QRect(rect.x(),rect.y(), 0,0);
never executed: return QRect(rect.x(),rect.y(), 0,0);
0
6594 QRect brect;-
6595 drawText(rect, flags | Qt::TextDontPrint, str, &brect);-
6596 return brect;
never executed: return brect;
0
6597}-
6598-
6599-
6600-
6601QRectF QPainter::boundingRect(const QRectF &rect, int flags, const QString &str)-
6602{-
6603 if (str.isEmpty())
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6604 return QRectF(rect.x(),rect.y(), 0,0);
never executed: return QRectF(rect.x(),rect.y(), 0,0);
0
6605 QRectF brect;-
6606 drawText(rect, flags | Qt::TextDontPrint, str, &brect);-
6607 return brect;
never executed: return brect;
0
6608}-
6609-
6610/*!-
6611 \fn QRectF QPainter::boundingRect(const QRectF &rectangle,-
6612 const QString &text, const QTextOption &option)-
6613-
6614 \overload-
6615-
6616 Instead of specifying flags as a bitwise OR of the-
6617 Qt::AlignmentFlag and Qt::TextFlag, this overloaded function takes-
6618 an \a option argument. The QTextOption class provides a-
6619 description of general rich text properties.-
6620-
6621 \sa QTextOption-
6622*/-
6623QRectF QPainter::boundingRect(const QRectF &r, const QString &text, const QTextOption &o)-
6624{-
6625 Q_D(QPainter);-
6626-
6627 if (!d->engine || text.length() == 0)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
text.length() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6628 return QRectF(r.x(),r.y(), 0,0);
never executed: return QRectF(r.x(),r.y(), 0,0);
0
6629-
6630 QRectF br;-
6631 qt_format_text(d->state->font, r, Qt::TextDontPrint, &o, text, &br, 0, 0, 0, this);-
6632 return br;
never executed: return br;
0
6633}-
6634-
6635/*!-
6636 \fn void QPainter::drawTiledPixmap(const QRectF &rectangle, const QPixmap &pixmap, const QPointF &position)-
6637-
6638 Draws a tiled \a pixmap, inside the given \a rectangle with its-
6639 origin at the given \a position.-
6640-
6641 Calling drawTiledPixmap() is similar to calling drawPixmap()-
6642 several times to fill (tile) an area with a pixmap, but is-
6643 potentially much more efficient depending on the underlying window-
6644 system.-
6645-
6646 \sa drawPixmap()-
6647*/-
6648void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &sp)-
6649{-
6650#ifdef QT_DEBUG_DRAW-
6651 if (qt_show_painter_debug_output)-
6652 printf("QPainter::drawTiledPixmap(), target=[%.2f,%.2f,%.2f,%.2f], pix=[%d,%d], offset=[%.2f,%.2f]\n",-
6653 r.x(), r.y(), r.width(), r.height(),-
6654 pixmap.width(), pixmap.height(),-
6655 sp.x(), sp.y());-
6656#endif-
6657-
6658 Q_D(QPainter);-
6659 if (!d->engine || pixmap.isNull() || r.isEmpty())
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
r.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6660 return;
never executed: return;
0
6661-
6662#ifndef QT_NO_DEBUG-
6663 qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawTiledPixmap()");-
6664#endif-
6665-
6666 qreal sw = pixmap.width();-
6667 qreal sh = pixmap.height();-
6668 qreal sx = sp.x();-
6669 qreal sy = sp.y();-
6670 if (sx < 0)
sx < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6671 sx = qRound(sw) - qRound(-sx) % qRound(sw);
never executed: sx = qRound(sw) - qRound(-sx) % qRound(sw);
0
6672 else-
6673 sx = qRound(sx) % qRound(sw);
never executed: sx = qRound(sx) % qRound(sw);
0
6674 if (sy < 0)
sy < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6675 sy = qRound(sh) - -qRound(sy) % qRound(sh);
never executed: sy = qRound(sh) - -qRound(sy) % qRound(sh);
0
6676 else-
6677 sy = qRound(sy) % qRound(sh);
never executed: sy = qRound(sy) % qRound(sh);
0
6678-
6679-
6680 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6681 d->extended->drawTiledPixmap(r, pixmap, QPointF(sx, sy));-
6682 return;
never executed: return;
0
6683 }-
6684-
6685 if (d->state->bgMode == Qt::OpaqueMode && pixmap.isQBitmap())
d->state->bgMo...Qt::OpaqueModeDescription
TRUEnever evaluated
FALSEnever evaluated
pixmap.isQBitmap()Description
TRUEnever evaluated
FALSEnever evaluated
0
6686 fillRect(r, d->state->bgBrush);
never executed: fillRect(r, d->state->bgBrush);
0
6687-
6688 d->updateState(d->state);-
6689 if ((d->state->matrix.type() > QTransform::TxTranslate
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
6690 && !d->engine->hasFeature(QPaintEngine::PixmapTransform))
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
6691 || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity)))
d->state->opacity != 1.0Description
TRUEnever evaluated
FALSEnever evaluated
!d->engine->ha...nstantOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
6692 {-
6693 save();-
6694 setBackgroundMode(Qt::TransparentMode);-
6695 setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform);-
6696 setBrush(QBrush(d->state->pen.color(), pixmap));-
6697 setPen(Qt::NoPen);-
6698-
6699 // If there is no rotation involved we have to make sure we use the-
6700 // antialiased and not the aliased coordinate system by rounding the coordinates.-
6701 if (d->state->matrix.type() <= QTransform::TxScale) {
d->state->matr...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
6702 const QPointF p = roundInDeviceCoordinates(r.topLeft(), d->state->matrix);-
6703-
6704 if (d->state->matrix.type() <= QTransform::TxTranslate) {
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
6705 sx = qRound(sx);-
6706 sy = qRound(sy);-
6707 }
never executed: end of block
0
6708-
6709 setBrushOrigin(QPointF(r.x()-sx, r.y()-sy));-
6710 drawRect(QRectF(p, r.size()));-
6711 } else {
never executed: end of block
0
6712 setBrushOrigin(QPointF(r.x()-sx, r.y()-sy));-
6713 drawRect(r);-
6714 }
never executed: end of block
0
6715 restore();-
6716 return;
never executed: return;
0
6717 }-
6718-
6719 qreal x = r.x();-
6720 qreal y = r.y();-
6721 if (d->state->matrix.type() == QTransform::TxTranslate
d->state->matr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
6722 && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) {
!d->engine->ha...xmapTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
6723 x += d->state->matrix.dx();-
6724 y += d->state->matrix.dy();-
6725 }
never executed: end of block
0
6726-
6727 d->engine->drawTiledPixmap(QRectF(x, y, r.width(), r.height()), pixmap, QPointF(sx, sy));-
6728}
never executed: end of block
0
6729-
6730/*!-
6731 \fn QPainter::drawTiledPixmap(const QRect &rectangle, const QPixmap &pixmap,-
6732 const QPoint &position = QPoint())-
6733 \overload-
6734-
6735 Draws a tiled \a pixmap, inside the given \a rectangle with its-
6736 origin at the given \a position.-
6737*/-
6738-
6739/*!-
6740 \fn void QPainter::drawTiledPixmap(int x, int y, int width, int height, const-
6741 QPixmap &pixmap, int sx, int sy);-
6742 \overload-
6743-
6744 Draws a tiled \a pixmap in the specified rectangle.-
6745-
6746 (\a{x}, \a{y}) specifies the top-left point in the paint device-
6747 that is to be drawn onto; with the given \a width and \a-
6748 height. (\a{sx}, \a{sy}) specifies the top-left point in the \a-
6749 pixmap that is to be drawn; this defaults to (0, 0).-
6750*/-
6751-
6752#ifndef QT_NO_PICTURE-
6753-
6754/*!-
6755 \fn void QPainter::drawPicture(const QPointF &point, const QPicture &picture)-
6756-
6757 Replays the given \a picture at the given \a point.-
6758-
6759 The QPicture class is a paint device that records and replays-
6760 QPainter commands. A picture serializes the painter commands to an-
6761 IO device in a platform-independent format. Everything that can be-
6762 painted on a widget or pixmap can also be stored in a picture.-
6763-
6764 This function does exactly the same as QPicture::play() when-
6765 called with \a point = QPoint(0, 0).-
6766-
6767 \table 100%-
6768 \row-
6769 \li-
6770 \snippet code/src_gui_painting_qpainter.cpp 18-
6771 \endtable-
6772-
6773 \sa QPicture::play()-
6774*/-
6775-
6776void QPainter::drawPicture(const QPointF &p, const QPicture &picture)-
6777{-
6778 Q_D(QPainter);-
6779-
6780 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6781 return;
never executed: return;
0
6782-
6783 if (!d->extended)
!d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6784 d->updateState(d->state);
never executed: d->updateState(d->state);
0
6785-
6786 save();-
6787 translate(p);-
6788 const_cast<QPicture *>(&picture)->play(this);-
6789 restore();-
6790}
never executed: end of block
0
6791-
6792/*!-
6793 \fn void QPainter::drawPicture(const QPoint &point, const QPicture &picture)-
6794 \overload-
6795-
6796 Replays the given \a picture at the given \a point.-
6797*/-
6798-
6799/*!-
6800 \fn void QPainter::drawPicture(int x, int y, const QPicture &picture)-
6801 \overload-
6802-
6803 Draws the given \a picture at point (\a x, \a y).-
6804*/-
6805-
6806#endif // QT_NO_PICTURE-
6807-
6808/*!-
6809 \fn void QPainter::eraseRect(const QRectF &rectangle)-
6810-
6811 Erases the area inside the given \a rectangle. Equivalent to-
6812 calling-
6813 \snippet code/src_gui_painting_qpainter.cpp 19-
6814-
6815 \sa fillRect()-
6816*/-
6817void QPainter::eraseRect(const QRectF &r)-
6818{-
6819 Q_D(QPainter);-
6820-
6821 fillRect(r, d->state->bgBrush);-
6822}
never executed: end of block
0
6823-
6824static inline bool needsResolving(const QBrush &brush)-
6825{-
6826 Qt::BrushStyle s = brush.style();-
6827 return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern ||
never executed: return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern || s == Qt::ConicalGradientPattern) && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode);
0
6828 s == Qt::ConicalGradientPattern) &&
never executed: return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern || s == Qt::ConicalGradientPattern) && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode);
0
6829 brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode);
never executed: return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern || s == Qt::ConicalGradientPattern) && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode);
0
6830}-
6831-
6832/*!-
6833 \fn void QPainter::eraseRect(const QRect &rectangle)-
6834 \overload-
6835-
6836 Erases the area inside the given \a rectangle.-
6837*/-
6838-
6839/*!-
6840 \fn void QPainter::eraseRect(int x, int y, int width, int height)-
6841 \overload-
6842-
6843 Erases the area inside the rectangle beginning at (\a x, \a y)-
6844 with the given \a width and \a height.-
6845*/-
6846-
6847-
6848/*!-
6849 \fn void QPainter::fillRect(int x, int y, int width, int height, Qt::BrushStyle style)-
6850 \overload-
6851-
6852 Fills the rectangle beginning at (\a{x}, \a{y}) with the given \a-
6853 width and \a height, using the brush \a style specified.-
6854-
6855 \since 4.5-
6856*/-
6857-
6858/*!-
6859 \fn void QPainter::fillRect(const QRect &rectangle, Qt::BrushStyle style)-
6860 \overload-
6861-
6862 Fills the given \a rectangle with the brush \a style specified.-
6863-
6864 \since 4.5-
6865*/-
6866-
6867/*!-
6868 \fn void QPainter::fillRect(const QRectF &rectangle, Qt::BrushStyle style)-
6869 \overload-
6870-
6871 Fills the given \a rectangle with the brush \a style specified.-
6872-
6873 \since 4.5-
6874*/-
6875-
6876/*!-
6877 \fn void QPainter::fillRect(const QRectF &rectangle, const QBrush &brush)-
6878-
6879 Fills the given \a rectangle with the \a brush specified.-
6880-
6881 Alternatively, you can specify a QColor instead of a QBrush; the-
6882 QBrush constructor (taking a QColor argument) will automatically-
6883 create a solid pattern brush.-
6884-
6885 \sa drawRect()-
6886*/-
6887void QPainter::fillRect(const QRectF &r, const QBrush &brush)-
6888{-
6889 Q_D(QPainter);-
6890-
6891 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6892 return;
never executed: return;
0
6893-
6894 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6895 const QGradient *g = brush.gradient();-
6896 if (!g || g->coordinateMode() == QGradient::LogicalMode) {
!gDescription
TRUEnever evaluated
FALSEnever evaluated
g->coordinateM...t::LogicalModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
6897 d->extended->fillRect(r, brush);-
6898 return;
never executed: return;
0
6899 }-
6900 }
never executed: end of block
0
6901-
6902 QPen oldPen = pen();-
6903 QBrush oldBrush = this->brush();-
6904 setPen(Qt::NoPen);-
6905 if (brush.style() == Qt::SolidPattern) {
brush.style() ...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
6906 d->colorBrush.setStyle(Qt::SolidPattern);-
6907 d->colorBrush.setColor(brush.color());-
6908 setBrush(d->colorBrush);-
6909 } else {
never executed: end of block
0
6910 setBrush(brush);-
6911 }
never executed: end of block
0
6912-
6913 drawRect(r);-
6914 setBrush(oldBrush);-
6915 setPen(oldPen);-
6916}
never executed: end of block
0
6917-
6918/*!-
6919 \fn void QPainter::fillRect(const QRect &rectangle, const QBrush &brush)-
6920 \overload-
6921-
6922 Fills the given \a rectangle with the specified \a brush.-
6923*/-
6924-
6925void QPainter::fillRect(const QRect &r, const QBrush &brush)-
6926{-
6927 Q_D(QPainter);-
6928-
6929 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6930 return;
never executed: return;
0
6931-
6932 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6933 const QGradient *g = brush.gradient();-
6934 if (!g || g->coordinateMode() == QGradient::LogicalMode) {
!gDescription
TRUEnever evaluated
FALSEnever evaluated
g->coordinateM...t::LogicalModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
6935 d->extended->fillRect(r, brush);-
6936 return;
never executed: return;
0
6937 }-
6938 }
never executed: end of block
0
6939-
6940 QPen oldPen = pen();-
6941 QBrush oldBrush = this->brush();-
6942 setPen(Qt::NoPen);-
6943 if (brush.style() == Qt::SolidPattern) {
brush.style() ...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
6944 d->colorBrush.setStyle(Qt::SolidPattern);-
6945 d->colorBrush.setColor(brush.color());-
6946 setBrush(d->colorBrush);-
6947 } else {
never executed: end of block
0
6948 setBrush(brush);-
6949 }
never executed: end of block
0
6950-
6951 drawRect(r);-
6952 setBrush(oldBrush);-
6953 setPen(oldPen);-
6954}
never executed: end of block
0
6955-
6956-
6957-
6958/*!-
6959 \fn void QPainter::fillRect(const QRect &rectangle, const QColor &color)-
6960 \overload-
6961-
6962 Fills the given \a rectangle with the \a color specified.-
6963-
6964 \since 4.5-
6965*/-
6966void QPainter::fillRect(const QRect &r, const QColor &color)-
6967{-
6968 Q_D(QPainter);-
6969-
6970 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6971 return;
never executed: return;
0
6972-
6973 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6974 d->extended->fillRect(r, color);-
6975 return;
never executed: return;
0
6976 }-
6977-
6978 fillRect(r, QBrush(color));-
6979}
never executed: end of block
0
6980-
6981-
6982/*!-
6983 \fn void QPainter::fillRect(const QRectF &rectangle, const QColor &color)-
6984 \overload-
6985-
6986 Fills the given \a rectangle with the \a color specified.-
6987-
6988 \since 4.5-
6989*/-
6990void QPainter::fillRect(const QRectF &r, const QColor &color)-
6991{-
6992 Q_D(QPainter);-
6993-
6994 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
6995 return;
never executed: return;
0
6996-
6997 if (d->extended) {
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6998 d->extended->fillRect(r, color);-
6999 return;
never executed: return;
0
7000 }-
7001-
7002 fillRect(r, QBrush(color));-
7003}
never executed: end of block
0
7004-
7005/*!-
7006 \fn void QPainter::fillRect(int x, int y, int width, int height, const QBrush &brush)-
7007-
7008 \overload-
7009-
7010 Fills the rectangle beginning at (\a{x}, \a{y}) with the given \a-
7011 width and \a height, using the given \a brush.-
7012*/-
7013-
7014/*!-
7015 \fn void QPainter::fillRect(int x, int y, int width, int height, const QColor &color)-
7016-
7017 \overload-
7018-
7019 Fills the rectangle beginning at (\a{x}, \a{y}) with the given \a-
7020 width and \a height, using the given \a color.-
7021-
7022 \since 4.5-
7023*/-
7024-
7025/*!-
7026 \fn void QPainter::fillRect(int x, int y, int width, int height, Qt::GlobalColor color)-
7027-
7028 \overload-
7029-
7030 Fills the rectangle beginning at (\a{x}, \a{y}) with the given \a-
7031 width and \a height, using the given \a color.-
7032-
7033 \since 4.5-
7034*/-
7035-
7036/*!-
7037 \fn void QPainter::fillRect(const QRect &rectangle, Qt::GlobalColor color);-
7038-
7039 \overload-
7040-
7041 Fills the given \a rectangle with the specified \a color.-
7042-
7043 \since 4.5-
7044*/-
7045-
7046/*!-
7047 \fn void QPainter::fillRect(const QRectF &rectangle, Qt::GlobalColor color);-
7048-
7049 \overload-
7050-
7051 Fills the given \a rectangle with the specified \a color.-
7052-
7053 \since 4.5-
7054*/-
7055-
7056/*!-
7057 Sets the given render \a hint on the painter if \a on is true;-
7058 otherwise clears the render hint.-
7059-
7060 \sa setRenderHints(), renderHints(), {QPainter#Rendering-
7061 Quality}{Rendering Quality}-
7062*/-
7063void QPainter::setRenderHint(RenderHint hint, bool on)-
7064{-
7065#ifdef QT_DEBUG_DRAW-
7066 if (qt_show_painter_debug_output)-
7067 printf("QPainter::setRenderHint: hint=%x, %s\n", hint, on ? "on" : "off");-
7068#endif-
7069-
7070#ifndef QT_NO_DEBUG-
7071 static const bool antialiasingDisabled = qEnvironmentVariableIntValue("QT_NO_ANTIALIASING");-
7072 if (hint == QPainter::Antialiasing && antialiasingDisabled)
hint == QPainter::AntialiasingDescription
TRUEnever evaluated
FALSEnever evaluated
antialiasingDisabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
7073 return;
never executed: return;
0
7074#endif-
7075-
7076 setRenderHints(hint, on);-
7077}
never executed: end of block
0
7078-
7079/*!-
7080 \since 4.2-
7081-
7082 Sets the given render \a hints on the painter if \a on is true;-
7083 otherwise clears the render hints.-
7084-
7085 \sa setRenderHint(), renderHints(), {QPainter#Rendering-
7086 Quality}{Rendering Quality}-
7087*/-
7088-
7089void QPainter::setRenderHints(RenderHints hints, bool on)-
7090{-
7091 Q_D(QPainter);-
7092-
7093 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
7094 qWarning("QPainter::setRenderHint: Painter must be active to set rendering hints");-
7095 return;
never executed: return;
0
7096 }-
7097-
7098 if (on)
onDescription
TRUEnever evaluated
FALSEnever evaluated
0
7099 d->state->renderHints |= hints;
never executed: d->state->renderHints |= hints;
0
7100 else-
7101 d->state->renderHints &= ~hints;
never executed: d->state->renderHints &= ~hints;
0
7102-
7103 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7104 d->extended->renderHintsChanged();
never executed: d->extended->renderHintsChanged();
0
7105 else-
7106 d->state->dirtyFlags |= QPaintEngine::DirtyHints;
never executed: d->state->dirtyFlags |= QPaintEngine::DirtyHints;
0
7107}-
7108-
7109/*!-
7110 Returns a flag that specifies the rendering hints that are set for-
7111 this painter.-
7112-
7113 \sa testRenderHint(), {QPainter#Rendering Quality}{Rendering Quality}-
7114*/-
7115QPainter::RenderHints QPainter::renderHints() const-
7116{-
7117 Q_D(const QPainter);-
7118-
7119 if (!d->engine)
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
7120 return 0;
never executed: return 0;
0
7121-
7122 return d->state->renderHints;
never executed: return d->state->renderHints;
0
7123}-
7124-
7125/*!-
7126 \fn bool QPainter::testRenderHint(RenderHint hint) const-
7127 \since 4.3-
7128-
7129 Returns \c true if \a hint is set; otherwise returns \c false.-
7130-
7131 \sa renderHints(), setRenderHint()-
7132*/-
7133-
7134/*!-
7135 Returns \c true if view transformation is enabled; otherwise returns-
7136 false.-
7137-
7138 \sa setViewTransformEnabled(), worldTransform()-
7139*/-
7140-
7141bool QPainter::viewTransformEnabled() const-
7142{-
7143 Q_D(const QPainter);-
7144 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
7145 qWarning("QPainter::viewTransformEnabled: Painter not active");-
7146 return false;
never executed: return false;
0
7147 }-
7148 return d->state->VxF;
never executed: return d->state->VxF;
0
7149}-
7150-
7151/*!-
7152 \fn void QPainter::setWindow(const QRect &rectangle)-
7153-
7154 Sets the painter's window to the given \a rectangle, and enables-
7155 view transformations.-
7156-
7157 The window rectangle is part of the view transformation. The-
7158 window specifies the logical coordinate system. Its sister, the-
7159 viewport(), specifies the device coordinate system.-
7160-
7161 The default window rectangle is the same as the device's-
7162 rectangle.-
7163-
7164 \sa window(), viewTransformEnabled(), {Coordinate-
7165 System#Window-Viewport Conversion}{Window-Viewport Conversion}-
7166*/-
7167-
7168/*!-
7169 \fn void QPainter::setWindow(int x, int y, int width, int height)-
7170 \overload-
7171-
7172 Sets the painter's window to the rectangle beginning at (\a x, \a-
7173 y) and the given \a width and \a height.-
7174*/-
7175-
7176void QPainter::setWindow(const QRect &r)-
7177{-
7178#ifdef QT_DEBUG_DRAW-
7179 if (qt_show_painter_debug_output)-
7180 printf("QPainter::setWindow(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height());-
7181#endif-
7182-
7183 Q_D(QPainter);-
7184-
7185 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
7186 qWarning("QPainter::setWindow: Painter not active");-
7187 return;
never executed: return;
0
7188 }-
7189-
7190 d->state->wx = r.x();-
7191 d->state->wy = r.y();-
7192 d->state->ww = r.width();-
7193 d->state->wh = r.height();-
7194-
7195 d->state->VxF = true;-
7196 d->updateMatrix();-
7197}
never executed: end of block
0
7198-
7199/*!-
7200 Returns the window rectangle.-
7201-
7202 \sa setWindow(), setViewTransformEnabled()-
7203*/-
7204-
7205QRect QPainter::window() const-
7206{-
7207 Q_D(const QPainter);-
7208 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
7209 qWarning("QPainter::window: Painter not active");-
7210 return QRect();
never executed: return QRect();
0
7211 }-
7212 return QRect(d->state->wx, d->state->wy, d->state->ww, d->state->wh);
never executed: return QRect(d->state->wx, d->state->wy, d->state->ww, d->state->wh);
0
7213}-
7214-
7215/*!-
7216 \fn void QPainter::setViewport(const QRect &rectangle)-
7217-
7218 Sets the painter's viewport rectangle to the given \a rectangle,-
7219 and enables view transformations.-
7220-
7221 The viewport rectangle is part of the view transformation. The-
7222 viewport specifies the device coordinate system. Its sister, the-
7223 window(), specifies the logical coordinate system.-
7224-
7225 The default viewport rectangle is the same as the device's-
7226 rectangle.-
7227-
7228 \sa viewport(), viewTransformEnabled(), {Coordinate-
7229 System#Window-Viewport Conversion}{Window-Viewport Conversion}-
7230*/-
7231-
7232/*!-
7233 \fn void QPainter::setViewport(int x, int y, int width, int height)-
7234 \overload-
7235-
7236 Sets the painter's viewport rectangle to be the rectangle-
7237 beginning at (\a x, \a y) with the given \a width and \a height.-
7238*/-
7239-
7240void QPainter::setViewport(const QRect &r)-
7241{-
7242#ifdef QT_DEBUG_DRAW-
7243 if (qt_show_painter_debug_output)-
7244 printf("QPainter::setViewport(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height());-
7245#endif-
7246-
7247 Q_D(QPainter);-
7248-
7249 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
7250 qWarning("QPainter::setViewport: Painter not active");-
7251 return;
never executed: return;
0
7252 }-
7253-
7254 d->state->vx = r.x();-
7255 d->state->vy = r.y();-
7256 d->state->vw = r.width();-
7257 d->state->vh = r.height();-
7258-
7259 d->state->VxF = true;-
7260 d->updateMatrix();-
7261}
never executed: end of block
0
7262-
7263/*!-
7264 Returns the viewport rectangle.-
7265-
7266 \sa setViewport(), setViewTransformEnabled()-
7267*/-
7268-
7269QRect QPainter::viewport() const-
7270{-
7271 Q_D(const QPainter);-
7272 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
7273 qWarning("QPainter::viewport: Painter not active");-
7274 return QRect();
never executed: return QRect();
0
7275 }-
7276 return QRect(d->state->vx, d->state->vy, d->state->vw, d->state->vh);
never executed: return QRect(d->state->vx, d->state->vy, d->state->vw, d->state->vh);
0
7277}-
7278-
7279/*!-
7280 Enables view transformations if \a enable is true, or disables-
7281 view transformations if \a enable is false.-
7282-
7283 \sa viewTransformEnabled(), {Coordinate System#Window-Viewport-
7284 Conversion}{Window-Viewport Conversion}-
7285*/-
7286-
7287void QPainter::setViewTransformEnabled(bool enable)-
7288{-
7289#ifdef QT_DEBUG_DRAW-
7290 if (qt_show_painter_debug_output)-
7291 printf("QPainter::setViewTransformEnabled(), enable=%d\n", enable);-
7292#endif-
7293-
7294 Q_D(QPainter);-
7295-
7296 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
7297 qWarning("QPainter::setViewTransformEnabled: Painter not active");-
7298 return;
never executed: return;
0
7299 }-
7300-
7301 if (enable == d->state->VxF)
enable == d->state->VxFDescription
TRUEnever evaluated
FALSEnever evaluated
0
7302 return;
never executed: return;
0
7303-
7304 d->state->VxF = enable;-
7305 d->updateMatrix();-
7306}
never executed: end of block
0
7307-
7308/*!-
7309 \threadsafe-
7310-
7311 \obsolete-
7312-
7313 Please use QWidget::render() instead.-
7314-
7315 Redirects all paint commands for the given paint \a device, to the-
7316 \a replacement device. The optional point \a offset defines an-
7317 offset within the source device.-
7318-
7319 The redirection will not be effective until the begin() function-
7320 has been called; make sure to call end() for the given \a-
7321 device's painter (if any) before redirecting. Call-
7322 restoreRedirected() to restore the previous redirection.-
7323-
7324 \warning Making use of redirections in the QPainter API implies-
7325 that QPainter::begin() and QPaintDevice destructors need to hold-
7326 a mutex for a short period. This can impact performance. Use of-
7327 QWidget::render is strongly encouraged.-
7328-
7329 \sa redirected(), restoreRedirected()-
7330*/-
7331void QPainter::setRedirected(const QPaintDevice *device,-
7332 QPaintDevice *replacement,-
7333 const QPoint &offset)-
7334{-
7335 Q_ASSERT(device != 0);-
7336 Q_UNUSED(device)-
7337 Q_UNUSED(replacement)-
7338 Q_UNUSED(offset)-
7339 qWarning("QPainter::setRedirected(): ignoring call to deprecated function, use QWidget::render() instead");-
7340}
never executed: end of block
0
7341-
7342/*!-
7343 \threadsafe-
7344-
7345 \obsolete-
7346-
7347 Using QWidget::render() obsoletes the use of this function.-
7348-
7349 Restores the previous redirection for the given \a device after a-
7350 call to setRedirected().-
7351-
7352 \warning Making use of redirections in the QPainter API implies-
7353 that QPainter::begin() and QPaintDevice destructors need to hold-
7354 a mutex for a short period. This can impact performance. Use of-
7355 QWidget::render is strongly encouraged.-
7356-
7357 \sa redirected()-
7358 */-
7359void QPainter::restoreRedirected(const QPaintDevice *device)-
7360{-
7361 Q_UNUSED(device)-
7362 qWarning("QPainter::restoreRedirected(): ignoring call to deprecated function, use QWidget::render() instead");-
7363}
never executed: end of block
0
7364-
7365/*!-
7366 \threadsafe-
7367-
7368 \obsolete-
7369-
7370 Using QWidget::render() obsoletes the use of this function.-
7371-
7372 Returns the replacement for given \a device. The optional out-
7373 parameter \a offset returns the offset within the replaced device.-
7374-
7375 \warning Making use of redirections in the QPainter API implies-
7376 that QPainter::begin() and QPaintDevice destructors need to hold-
7377 a mutex for a short period. This can impact performance. Use of-
7378 QWidget::render is strongly encouraged.-
7379-
7380 \sa setRedirected(), restoreRedirected()-
7381*/-
7382QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)-
7383{-
7384 Q_UNUSED(device)-
7385 Q_UNUSED(offset)-
7386 return 0;
never executed: return 0;
0
7387}-
7388-
7389void qt_format_text(const QFont &fnt, const QRectF &_r,-
7390 int tf, const QString& str, QRectF *brect,-
7391 int tabstops, int *ta, int tabarraylen,-
7392 QPainter *painter)-
7393{-
7394 qt_format_text(fnt, _r,-
7395 tf, 0, str, brect,-
7396 tabstops, ta, tabarraylen,-
7397 painter);-
7398}
never executed: end of block
0
7399void qt_format_text(const QFont &fnt, const QRectF &_r,-
7400 int tf, const QTextOption *option, const QString& str, QRectF *brect,-
7401 int tabstops, int *ta, int tabarraylen,-
7402 QPainter *painter)-
7403{-
7404-
7405 Q_ASSERT( !((tf & ~Qt::TextDontPrint)!=0 && option!=0) ); // we either have an option or flags-
7406-
7407 if (option) {
optionDescription
TRUEnever evaluated
FALSEnever evaluated
0
7408 tf |= option->alignment();-
7409 if (option->wrapMode() != QTextOption::NoWrap)
option->wrapMo...Option::NoWrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
7410 tf |= Qt::TextWordWrap;
never executed: tf |= Qt::TextWordWrap;
0
7411-
7412 if (option->flags() & QTextOption::IncludeTrailingSpaces)
option->flags(...TrailingSpacesDescription
TRUEnever evaluated
FALSEnever evaluated
0
7413 tf |= Qt::TextIncludeTrailingSpaces;
never executed: tf |= Qt::TextIncludeTrailingSpaces;
0
7414-
7415 if (option->tabStop() >= 0 || !option->tabArray().isEmpty())
option->tabStop() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
!option->tabArray().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
7416 tf |= Qt::TextExpandTabs;
never executed: tf |= Qt::TextExpandTabs;
0
7417 }
never executed: end of block
0
7418-
7419 // we need to copy r here to protect against the case (&r == brect).-
7420 QRectF r(_r);-
7421-
7422 bool dontclip = (tf & Qt::TextDontClip);-
7423 bool wordwrap = (tf & Qt::TextWordWrap) || (tf & Qt::TextWrapAnywhere);
(tf & Qt::TextWordWrap)Description
TRUEnever evaluated
FALSEnever evaluated
(tf & Qt::TextWrapAnywhere)Description
TRUEnever evaluated
FALSEnever evaluated
0
7424 bool singleline = (tf & Qt::TextSingleLine);-
7425 bool showmnemonic = (tf & Qt::TextShowMnemonic);-
7426 bool hidemnmemonic = (tf & Qt::TextHideMnemonic);-
7427-
7428 Qt::LayoutDirection layout_direction;-
7429 if (tf & Qt::TextForceLeftToRight)
tf & Qt::TextForceLeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
7430 layout_direction = Qt::LeftToRight;
never executed: layout_direction = Qt::LeftToRight;
0
7431 else if (tf & Qt::TextForceRightToLeft)
tf & Qt::TextForceRightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
7432 layout_direction = Qt::RightToLeft;
never executed: layout_direction = Qt::RightToLeft;
0
7433 else if (option)
optionDescription
TRUEnever evaluated
FALSEnever evaluated
0
7434 layout_direction = option->textDirection();
never executed: layout_direction = option->textDirection();
0
7435 else if (painter)
painterDescription
TRUEnever evaluated
FALSEnever evaluated
0
7436 layout_direction = painter->layoutDirection();
never executed: layout_direction = painter->layoutDirection();
0
7437 else-
7438 layout_direction = Qt::LeftToRight;
never executed: layout_direction = Qt::LeftToRight;
0
7439-
7440 tf = QGuiApplicationPrivate::visualAlignment(layout_direction, QFlag(tf));-
7441-
7442 bool isRightToLeft = layout_direction == Qt::RightToLeft;-
7443 bool expandtabs = ((tf & Qt::TextExpandTabs) &&
(tf & Qt::TextExpandTabs)Description
TRUEnever evaluated
FALSEnever evaluated
0
7444 (((tf & Qt::AlignLeft) && !isRightToLeft) ||
(tf & Qt::AlignLeft)Description
TRUEnever evaluated
FALSEnever evaluated
!isRightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
7445 ((tf & Qt::AlignRight) && isRightToLeft)));
(tf & Qt::AlignRight)Description
TRUEnever evaluated
FALSEnever evaluated
isRightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
7446-
7447 if (!painter)
!painterDescription
TRUEnever evaluated
FALSEnever evaluated
0
7448 tf |= Qt::TextDontPrint;
never executed: tf |= Qt::TextDontPrint;
0
7449-
7450 uint maxUnderlines = 0;-
7451-
7452 QFontMetricsF fm(fnt);-
7453 QString text = str;-
7454 int offset = 0;-
7455start_lengthVariant:
code before this statement never executed: start_lengthVariant:
0
7456 bool hasMoreLengthVariants = false;-
7457 // compatible behaviour to the old implementation. Replace-
7458 // tabs by spaces-
7459 int old_offset = offset;-
7460 for (; offset < text.length(); offset++) {
offset < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
7461 QChar chr = text.at(offset);-
7462 if (chr == QLatin1Char('\r') || (singleline && chr == QLatin1Char('\n'))) {
chr == QLatin1Char('\r')Description
TRUEnever evaluated
FALSEnever evaluated
singlelineDescription
TRUEnever evaluated
FALSEnever evaluated
chr == QLatin1Char('\n')Description
TRUEnever evaluated
FALSEnever evaluated
0
7463 text[offset] = QLatin1Char(' ');-
7464 } else if (chr == QLatin1Char('\n')) {
never executed: end of block
chr == QLatin1Char('\n')Description
TRUEnever evaluated
FALSEnever evaluated
0
7465 text[offset] = QChar::LineSeparator;-
7466 } else if (chr == QLatin1Char('&')) {
never executed: end of block
chr == QLatin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
0
7467 ++maxUnderlines;-
7468 } else if (chr == QLatin1Char('\t')) {
never executed: end of block
chr == QLatin1Char('\t')Description
TRUEnever evaluated
FALSEnever evaluated
0
7469 if (!expandtabs) {
!expandtabsDescription
TRUEnever evaluated
FALSEnever evaluated
0
7470 text[offset] = QLatin1Char(' ');-
7471 } else if (!tabarraylen && !tabstops) {
never executed: end of block
!tabarraylenDescription
TRUEnever evaluated
FALSEnever evaluated
!tabstopsDescription
TRUEnever evaluated
FALSEnever evaluated
0
7472 tabstops = qRound(fm.width(QLatin1Char('x'))*8);-
7473 }
never executed: end of block
0
7474 } else if (chr == QChar(ushort(0x9c))) {
never executed: end of block
chr == QChar(ushort(0x9c))Description
TRUEnever evaluated
FALSEnever evaluated
0
7475 // string with multiple length variants-
7476 hasMoreLengthVariants = true;-
7477 break;
never executed: break;
0
7478 }-
7479 }
never executed: end of block
0
7480-
7481 QVector<QTextLayout::FormatRange> underlineFormats;-
7482 int length = offset - old_offset;-
7483 if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) {
hidemnmemonicDescription
TRUEnever evaluated
FALSEnever evaluated
showmnemonicDescription
TRUEnever evaluated
FALSEnever evaluated
maxUnderlines > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
7484 QChar *cout = text.data() + old_offset;-
7485 QChar *cout0 = cout;-
7486 QChar *cin = cout;-
7487 int l = length;-
7488 while (l) {
lDescription
TRUEnever evaluated
FALSEnever evaluated
0
7489 if (*cin == QLatin1Char('&')) {
*cin == QLatin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
0
7490 ++cin;-
7491 --length;-
7492 --l;-
7493 if (!l)
!lDescription
TRUEnever evaluated
FALSEnever evaluated
0
7494 break;
never executed: break;
0
7495 if (*cin != QLatin1Char('&') && !hidemnmemonic && !(tf & Qt::TextDontPrint)) {
*cin != QLatin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
!hidemnmemonicDescription
TRUEnever evaluated
FALSEnever evaluated
!(tf & Qt::TextDontPrint)Description
TRUEnever evaluated
FALSEnever evaluated
0
7496 QTextLayout::FormatRange range;-
7497 range.start = cout - cout0;-
7498 range.length = 1;-
7499 range.format.setFontUnderline(true);-
7500 underlineFormats.append(range);-
7501 }
never executed: end of block
0
7502#ifdef Q_OS_MAC-
7503 } else if (hidemnmemonic && *cin == QLatin1Char('(') && l >= 4 &&-
7504 cin[1] == QLatin1Char('&') && cin[2] != QLatin1Char('&') &&-
7505 cin[3] == QLatin1Char(')')) {-
7506 int n = 0;-
7507 while ((cout - n) > cout0 && (cout - n - 1)->isSpace())-
7508 ++n;-
7509 cout -= n;-
7510 cin += 4;-
7511 length -= n + 4;-
7512 l -= 4;-
7513 continue;-
7514#endif //Q_OS_MAC-
7515 }
never executed: end of block
0
7516 *cout = *cin;-
7517 ++cout;-
7518 ++cin;-
7519 --l;-
7520 }
never executed: end of block
0
7521 }
never executed: end of block
0
7522-
7523 qreal height = 0;-
7524 qreal width = 0;-
7525-
7526 QString finalText = text.mid(old_offset, length);-
7527 QStackTextEngine engine(finalText, fnt);-
7528 if (option) {
optionDescription
TRUEnever evaluated
FALSEnever evaluated
0
7529 engine.option = *option;-
7530 }
never executed: end of block
0
7531-
7532 if (engine.option.tabStop() < 0 && tabstops > 0)
engine.option.tabStop() < 0Description
TRUEnever evaluated
FALSEnever evaluated
tabstops > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
7533 engine.option.setTabStop(tabstops);
never executed: engine.option.setTabStop(tabstops);
0
7534-
7535 if (engine.option.tabs().isEmpty() && ta) {
engine.option.tabs().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
taDescription
TRUEnever evaluated
FALSEnever evaluated
0
7536 QList<qreal> tabs;-
7537 tabs.reserve(tabarraylen);-
7538 for (int i = 0; i < tabarraylen; i++)
i < tabarraylenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7539 tabs.append(qreal(ta[i]));
never executed: tabs.append(qreal(ta[i]));
0
7540 engine.option.setTabArray(tabs);-
7541 }
never executed: end of block
0
7542-
7543 engine.option.setTextDirection(layout_direction);-
7544 if (tf & Qt::AlignJustify)
tf & Qt::AlignJustifyDescription
TRUEnever evaluated
FALSEnever evaluated
0
7545 engine.option.setAlignment(Qt::AlignJustify);
never executed: engine.option.setAlignment(Qt::AlignJustify);
0
7546 else-
7547 engine.option.setAlignment(Qt::AlignLeft); // do not do alignment twice
never executed: engine.option.setAlignment(Qt::AlignLeft);
0
7548-
7549 if (!option && (tf & Qt::TextWrapAnywhere))
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
(tf & Qt::TextWrapAnywhere)Description
TRUEnever evaluated
FALSEnever evaluated
0
7550 engine.option.setWrapMode(QTextOption::WrapAnywhere);
never executed: engine.option.setWrapMode(QTextOption::WrapAnywhere);
0
7551-
7552 if (tf & Qt::TextJustificationForced)
tf & Qt::TextJ...ficationForcedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7553 engine.forceJustification = true;
never executed: engine.forceJustification = true;
0
7554 QTextLayout textLayout(&engine);-
7555 textLayout.setCacheEnabled(true);-
7556 textLayout.setFormats(underlineFormats);-
7557-
7558 if (finalText.isEmpty()) {
finalText.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
7559 height = fm.height();-
7560 width = 0;-
7561 tf |= Qt::TextDontPrint;-
7562 } else {
never executed: end of block
0
7563 qreal lineWidth = 0x01000000;-
7564 if (wordwrap || (tf & Qt::TextJustificationForced))
wordwrapDescription
TRUEnever evaluated
FALSEnever evaluated
(tf & Qt::Text...icationForced)Description
TRUEnever evaluated
FALSEnever evaluated
0
7565 lineWidth = qMax<qreal>(0, r.width());
never executed: lineWidth = qMax<qreal>(0, r.width());
0
7566 if(!wordwrap)
!wordwrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
7567 tf |= Qt::TextIncludeTrailingSpaces;
never executed: tf |= Qt::TextIncludeTrailingSpaces;
0
7568 textLayout.engine()->ignoreBidi = bool(tf & Qt::TextDontPrint);-
7569 textLayout.beginLayout();-
7570-
7571 qreal leading = fm.leading();-
7572 height = -leading;-
7573-
7574 while (1) {-
7575 QTextLine l = textLayout.createLine();-
7576 if (!l.isValid())
!l.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
7577 break;
never executed: break;
0
7578-
7579 l.setLineWidth(lineWidth);-
7580 height += leading;-
7581-
7582 // Make sure lines are positioned on whole pixels-
7583 height = qCeil(height);-
7584 l.setPosition(QPointF(0., height));-
7585 height += textLayout.engine()->lines[l.lineNumber()].height().toReal();-
7586 width = qMax(width, l.naturalTextWidth());-
7587 if (!dontclip && !brect && height >= r.height())
!dontclipDescription
TRUEnever evaluated
FALSEnever evaluated
!brectDescription
TRUEnever evaluated
FALSEnever evaluated
height >= r.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
7588 break;
never executed: break;
0
7589 }
never executed: end of block
0
7590 textLayout.endLayout();-
7591 }
never executed: end of block
0
7592-
7593 qreal yoff = 0;-
7594 qreal xoff = 0;-
7595 if (tf & Qt::AlignBottom)
tf & Qt::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
7596 yoff = r.height() - height;
never executed: yoff = r.height() - height;
0
7597 else if (tf & Qt::AlignVCenter)
tf & Qt::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
7598 yoff = (r.height() - height)/2;
never executed: yoff = (r.height() - height)/2;
0
7599-
7600 if (tf & Qt::AlignRight)
tf & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
7601 xoff = r.width() - width;
never executed: xoff = r.width() - width;
0
7602 else if (tf & Qt::AlignHCenter)
tf & Qt::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
7603 xoff = (r.width() - width)/2;
never executed: xoff = (r.width() - width)/2;
0
7604-
7605 QRectF bounds = QRectF(r.x() + xoff, r.y() + yoff, width, height);-
7606-
7607 if (hasMoreLengthVariants && !(tf & Qt::TextLongestVariant) && !r.contains(bounds)) {
hasMoreLengthVariantsDescription
TRUEnever evaluated
FALSEnever evaluated
!(tf & Qt::TextLongestVariant)Description
TRUEnever evaluated
FALSEnever evaluated
!r.contains(bounds)Description
TRUEnever evaluated
FALSEnever evaluated
0
7608 offset++;-
7609 goto start_lengthVariant;
never executed: goto start_lengthVariant;
0
7610 }-
7611 if (brect)
brectDescription
TRUEnever evaluated
FALSEnever evaluated
0
7612 *brect = bounds;
never executed: *brect = bounds;
0
7613-
7614 if (!(tf & Qt::TextDontPrint)) {
!(tf & Qt::TextDontPrint)Description
TRUEnever evaluated
FALSEnever evaluated
0
7615 bool restore = false;-
7616 if (!dontclip && !r.contains(bounds)) {
!dontclipDescription
TRUEnever evaluated
FALSEnever evaluated
!r.contains(bounds)Description
TRUEnever evaluated
FALSEnever evaluated
0
7617 restore = true;-
7618 painter->save();-
7619 painter->setClipRect(r, Qt::IntersectClip);-
7620 }
never executed: end of block
0
7621-
7622 for (int i = 0; i < textLayout.lineCount(); i++) {
i < textLayout.lineCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
7623 QTextLine line = textLayout.lineAt(i);-
7624 QTextEngine *eng = textLayout.engine();-
7625 eng->enableDelayDecorations();-
7626-
7627 qreal advance = line.horizontalAdvance();-
7628 xoff = 0;-
7629 if (tf & Qt::AlignRight) {
tf & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
7630 xoff = r.width() - advance --
7631 eng->leadingSpaceWidth(eng->lines[line.lineNumber()]).toReal();-
7632 }
never executed: end of block
0
7633 else if (tf & Qt::AlignHCenter)
tf & Qt::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
7634 xoff = (r.width() - advance) / 2;
never executed: xoff = (r.width() - advance) / 2;
0
7635-
7636 line.draw(painter, QPointF(r.x() + xoff, r.y() + yoff));-
7637 eng->drawDecorations(painter);-
7638 }
never executed: end of block
0
7639-
7640 if (restore) {
restoreDescription
TRUEnever evaluated
FALSEnever evaluated
0
7641 painter->restore();-
7642 }
never executed: end of block
0
7643 }
never executed: end of block
0
7644}
never executed: end of block
0
7645-
7646/*!-
7647 Sets the layout direction used by the painter when drawing text,-
7648 to the specified \a direction.-
7649-
7650 The default is Qt::LayoutDirectionAuto, which will implicitly determine the-
7651 direction from the text drawn.-
7652-
7653 \sa QTextOption::setTextDirection(), layoutDirection(), drawText(), {QPainter#Settings}{Settings}-
7654*/-
7655void QPainter::setLayoutDirection(Qt::LayoutDirection direction)-
7656{-
7657 Q_D(QPainter);-
7658 if (d->state)
d->stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
7659 d->state->layoutDirection = direction;
never executed: d->state->layoutDirection = direction;
0
7660}
never executed: end of block
0
7661-
7662/*!-
7663 Returns the layout direction used by the painter when drawing text.-
7664-
7665 \sa QTextOption::textDirection(), setLayoutDirection(), drawText(), {QPainter#Settings}{Settings}-
7666*/-
7667Qt::LayoutDirection QPainter::layoutDirection() const-
7668{-
7669 Q_D(const QPainter);-
7670 return d->state ? d->state->layoutDirection : Qt::LayoutDirectionAuto;
never executed: return d->state ? d->state->layoutDirection : Qt::LayoutDirectionAuto;
0
7671}-
7672-
7673QPainterState::QPainterState(const QPainterState *s)-
7674 : brushOrigin(s->brushOrigin), font(s->font), deviceFont(s->deviceFont),-
7675 pen(s->pen), brush(s->brush), bgBrush(s->bgBrush),-
7676 clipRegion(s->clipRegion), clipPath(s->clipPath),-
7677 clipOperation(s->clipOperation),-
7678 renderHints(s->renderHints), clipInfo(s->clipInfo),-
7679 worldMatrix(s->worldMatrix), matrix(s->matrix), redirectionMatrix(s->redirectionMatrix),-
7680 wx(s->wx), wy(s->wy), ww(s->ww), wh(s->wh),-
7681 vx(s->vx), vy(s->vy), vw(s->vw), vh(s->vh),-
7682 opacity(s->opacity), WxF(s->WxF), VxF(s->VxF),-
7683 clipEnabled(s->clipEnabled), bgMode(s->bgMode), painter(s->painter),-
7684 layoutDirection(s->layoutDirection),-
7685 composition_mode(s->composition_mode),-
7686 emulationSpecifier(s->emulationSpecifier), changeFlags(0)-
7687{-
7688 dirtyFlags = s->dirtyFlags;-
7689}
never executed: end of block
0
7690-
7691QPainterState::QPainterState()-
7692 : brushOrigin(0, 0), bgBrush(Qt::white), clipOperation(Qt::NoClip),-
7693 renderHints(0),-
7694 wx(0), wy(0), ww(0), wh(0), vx(0), vy(0), vw(0), vh(0),-
7695 opacity(1), WxF(false), VxF(false), clipEnabled(true),-
7696 bgMode(Qt::TransparentMode), painter(0),-
7697 layoutDirection(QGuiApplication::layoutDirection()),-
7698 composition_mode(QPainter::CompositionMode_SourceOver),-
7699 emulationSpecifier(0), changeFlags(0)-
7700{-
7701 dirtyFlags = 0;-
7702}
never executed: end of block
0
7703-
7704QPainterState::~QPainterState()-
7705{-
7706}-
7707-
7708void QPainterState::init(QPainter *p) {-
7709 bgBrush = Qt::white;-
7710 bgMode = Qt::TransparentMode;-
7711 WxF = false;-
7712 VxF = false;-
7713 clipEnabled = true;-
7714 wx = wy = ww = wh = 0;-
7715 vx = vy = vw = vh = 0;-
7716 painter = p;-
7717 pen = QPen();-
7718 brushOrigin = QPointF(0, 0);-
7719 brush = QBrush();-
7720 font = deviceFont = QFont();-
7721 clipRegion = QRegion();-
7722 clipPath = QPainterPath();-
7723 clipOperation = Qt::NoClip;-
7724 clipInfo.clear();-
7725 worldMatrix.reset();-
7726 matrix.reset();-
7727 layoutDirection = QGuiApplication::layoutDirection();-
7728 composition_mode = QPainter::CompositionMode_SourceOver;-
7729 emulationSpecifier = 0;-
7730 dirtyFlags = 0;-
7731 changeFlags = 0;-
7732 renderHints = 0;-
7733 opacity = 1;-
7734}
never executed: end of block
0
7735-
7736/*!-
7737 \fn void QPainter::drawImage(const QRectF &target, const QImage &image, const QRectF &source,-
7738 Qt::ImageConversionFlags flags)-
7739-
7740 Draws the rectangular portion \a source of the given \a image-
7741 into the \a target rectangle in the paint device.-
7742-
7743 \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree.-
7744 \note See \l{Drawing High Resolution Versions of Pixmaps and Images} on how this is affected-
7745 by QImage::devicePixelRatio().-
7746-
7747 If the image needs to be modified to fit in a lower-resolution-
7748 result (e.g. converting from 32-bit to 8-bit), use the \a flags to-
7749 specify how you would prefer this to happen.-
7750-
7751 \table 100%-
7752 \row-
7753 \li-
7754 \snippet code/src_gui_painting_qpainter.cpp 20-
7755 \endtable-
7756-
7757 \sa drawPixmap(), QImage::devicePixelRatio()-
7758*/-
7759-
7760/*!-
7761 \fn void QPainter::drawImage(const QRect &target, const QImage &image, const QRect &source,-
7762 Qt::ImageConversionFlags flags)-
7763 \overload-
7764-
7765 Draws the rectangular portion \a source of the given \a image-
7766 into the \a target rectangle in the paint device.-
7767-
7768 \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree.-
7769*/-
7770-
7771/*!-
7772 \fn void QPainter::drawImage(const QPointF &point, const QImage &image)-
7773-
7774 \overload-
7775-
7776 Draws the given \a image at the given \a point.-
7777*/-
7778-
7779/*!-
7780 \fn void QPainter::drawImage(const QPoint &point, const QImage &image)-
7781-
7782 \overload-
7783-
7784 Draws the given \a image at the given \a point.-
7785*/-
7786-
7787/*!-
7788 \fn void QPainter::drawImage(const QPointF &point, const QImage &image, const QRectF &source,-
7789 Qt::ImageConversionFlags flags = 0)-
7790-
7791 \overload-
7792-
7793 Draws the rectangular portion \a source of the given \a image with-
7794 its origin at the given \a point.-
7795*/-
7796-
7797/*!-
7798 \fn void QPainter::drawImage(const QPoint &point, const QImage &image, const QRect &source,-
7799 Qt::ImageConversionFlags flags = 0)-
7800 \overload-
7801-
7802 Draws the rectangular portion \a source of the given \a image with-
7803 its origin at the given \a point.-
7804*/-
7805-
7806/*!-
7807 \fn void QPainter::drawImage(const QRectF &rectangle, const QImage &image)-
7808-
7809 \overload-
7810-
7811 Draws the given \a image into the given \a rectangle.-
7812-
7813 \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree.-
7814*/-
7815-
7816/*!-
7817 \fn void QPainter::drawImage(const QRect &rectangle, const QImage &image)-
7818-
7819 \overload-
7820-
7821 Draws the given \a image into the given \a rectangle.-
7822-
7823 \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree.-
7824*/-
7825-
7826/*!-
7827 \fn void QPainter::drawImage(int x, int y, const QImage &image,-
7828 int sx, int sy, int sw, int sh,-
7829 Qt::ImageConversionFlags flags)-
7830 \overload-
7831-
7832 Draws an image at (\a{x}, \a{y}) by copying a part of \a image into-
7833 the paint device.-
7834-
7835 (\a{x}, \a{y}) specifies the top-left point in the paint device that is-
7836 to be drawn onto. (\a{sx}, \a{sy}) specifies the top-left point in \a-
7837 image that is to be drawn. The default is (0, 0).-
7838-
7839 (\a{sw}, \a{sh}) specifies the size of the image that is to be drawn.-
7840 The default, (0, 0) (and negative) means all the way to the-
7841 bottom-right of the image.-
7842*/-
7843-
7844/*!-
7845 \class QPaintEngineState-
7846 \since 4.1-
7847 \inmodule QtGui-
7848-
7849 \brief The QPaintEngineState class provides information about the-
7850 active paint engine's current state.-
7851 \reentrant-
7852-
7853 QPaintEngineState records which properties that have changed since-
7854 the last time the paint engine was updated, as well as their-
7855 current value.-
7856-
7857 Which properties that have changed can at any time be retrieved-
7858 using the state() function. This function returns an instance of-
7859 the QPaintEngine::DirtyFlags type which stores an OR combination-
7860 of QPaintEngine::DirtyFlag values. The QPaintEngine::DirtyFlag-
7861 enum defines whether a property has changed since the last update-
7862 or not.-
7863-
7864 If a property is marked with a dirty flag, its current value can-
7865 be retrieved using the corresponding get function:-
7866-
7867 \target GetFunction-
7868-
7869 \table-
7870 \header \li Property Flag \li Current Property Value-
7871 \row \li QPaintEngine::DirtyBackground \li backgroundBrush()-
7872 \row \li QPaintEngine::DirtyBackgroundMode \li backgroundMode()-
7873 \row \li QPaintEngine::DirtyBrush \li brush()-
7874 \row \li QPaintEngine::DirtyBrushOrigin \li brushOrigin()-
7875 \row \li QPaintEngine::DirtyClipRegion \e or QPaintEngine::DirtyClipPath-
7876 \li clipOperation()-
7877 \row \li QPaintEngine::DirtyClipPath \li clipPath()-
7878 \row \li QPaintEngine::DirtyClipRegion \li clipRegion()-
7879 \row \li QPaintEngine::DirtyCompositionMode \li compositionMode()-
7880 \row \li QPaintEngine::DirtyFont \li font()-
7881 \row \li QPaintEngine::DirtyTransform \li transform()-
7882 \row \li QPaintEngine::DirtyClipEnabled \li isClipEnabled()-
7883 \row \li QPaintEngine::DirtyPen \li pen()-
7884 \row \li QPaintEngine::DirtyHints \li renderHints()-
7885 \endtable-
7886-
7887 The QPaintEngineState class also provide the painter() function-
7888 which returns a pointer to the painter that is currently updating-
7889 the paint engine.-
7890-
7891 An instance of this class, representing the current state of the-
7892 active paint engine, is passed as argument to the-
7893 QPaintEngine::updateState() function. The only situation in which-
7894 you will have to use this class directly is when implementing your-
7895 own paint engine.-
7896-
7897 \sa QPaintEngine-
7898*/-
7899-
7900-
7901/*!-
7902 \fn QPaintEngine::DirtyFlags QPaintEngineState::state() const-
7903-
7904 Returns a combination of flags identifying the set of properties-
7905 that need to be updated when updating the paint engine's state-
7906 (i.e. during a call to the QPaintEngine::updateState() function).-
7907-
7908 \sa QPaintEngine::updateState()-
7909*/-
7910-
7911-
7912/*!-
7913 Returns the pen in the current paint engine state.-
7914-
7915 This variable should only be used when the state() returns a-
7916 combination which includes the QPaintEngine::DirtyPen flag.-
7917-
7918 \sa state(), QPaintEngine::updateState()-
7919*/-
7920-
7921QPen QPaintEngineState::pen() const-
7922{-
7923 return static_cast<const QPainterState *>(this)->pen;
never executed: return static_cast<const QPainterState *>(this)->pen;
0
7924}-
7925-
7926/*!-
7927 Returns the brush in the current paint engine state.-
7928-
7929 This variable should only be used when the state() returns a-
7930 combination which includes the QPaintEngine::DirtyBrush flag.-
7931-
7932 \sa state(), QPaintEngine::updateState()-
7933*/-
7934-
7935QBrush QPaintEngineState::brush() const-
7936{-
7937 return static_cast<const QPainterState *>(this)->brush;
never executed: return static_cast<const QPainterState *>(this)->brush;
0
7938}-
7939-
7940/*!-
7941 Returns the brush origin in the current paint engine state.-
7942-
7943 This variable should only be used when the state() returns a-
7944 combination which includes the QPaintEngine::DirtyBrushOrigin flag.-
7945-
7946 \sa state(), QPaintEngine::updateState()-
7947*/-
7948-
7949QPointF QPaintEngineState::brushOrigin() const-
7950{-
7951 return static_cast<const QPainterState *>(this)->brushOrigin;
never executed: return static_cast<const QPainterState *>(this)->brushOrigin;
0
7952}-
7953-
7954/*!-
7955 Returns the background brush in the current paint engine state.-
7956-
7957 This variable should only be used when the state() returns a-
7958 combination which includes the QPaintEngine::DirtyBackground flag.-
7959-
7960 \sa state(), QPaintEngine::updateState()-
7961*/-
7962-
7963QBrush QPaintEngineState::backgroundBrush() const-
7964{-
7965 return static_cast<const QPainterState *>(this)->bgBrush;
never executed: return static_cast<const QPainterState *>(this)->bgBrush;
0
7966}-
7967-
7968/*!-
7969 Returns the background mode in the current paint engine-
7970 state.-
7971-
7972 This variable should only be used when the state() returns a-
7973 combination which includes the QPaintEngine::DirtyBackgroundMode flag.-
7974-
7975 \sa state(), QPaintEngine::updateState()-
7976*/-
7977-
7978Qt::BGMode QPaintEngineState::backgroundMode() const-
7979{-
7980 return static_cast<const QPainterState *>(this)->bgMode;
never executed: return static_cast<const QPainterState *>(this)->bgMode;
0
7981}-
7982-
7983/*!-
7984 Returns the font in the current paint engine-
7985 state.-
7986-
7987 This variable should only be used when the state() returns a-
7988 combination which includes the QPaintEngine::DirtyFont flag.-
7989-
7990 \sa state(), QPaintEngine::updateState()-
7991*/-
7992-
7993QFont QPaintEngineState::font() const-
7994{-
7995 return static_cast<const QPainterState *>(this)->font;
never executed: return static_cast<const QPainterState *>(this)->font;
0
7996}-
7997-
7998/*!-
7999 \since 4.2-
8000 \obsolete-
8001-
8002 Returns the matrix in the current paint engine-
8003 state.-
8004-
8005 \note It is advisable to use transform() instead of this function to-
8006 preserve the properties of perspective transformations.-
8007-
8008 This variable should only be used when the state() returns a-
8009 combination which includes the QPaintEngine::DirtyTransform flag.-
8010-
8011 \sa state(), QPaintEngine::updateState()-
8012*/-
8013-
8014QMatrix QPaintEngineState::matrix() const-
8015{-
8016 const QPainterState *st = static_cast<const QPainterState *>(this);-
8017-
8018 return st->matrix.toAffine();
never executed: return st->matrix.toAffine();
0
8019}-
8020-
8021/*!-
8022 \since 4.3-
8023-
8024 Returns the matrix in the current paint engine state.-
8025-
8026 This variable should only be used when the state() returns a-
8027 combination which includes the QPaintEngine::DirtyTransform flag.-
8028-
8029 \sa state(), QPaintEngine::updateState()-
8030*/-
8031-
8032-
8033QTransform QPaintEngineState::transform() const-
8034{-
8035 const QPainterState *st = static_cast<const QPainterState *>(this);-
8036-
8037 return st->matrix;
never executed: return st->matrix;
0
8038}-
8039-
8040-
8041/*!-
8042 Returns the clip operation in the current paint engine-
8043 state.-
8044-
8045 This variable should only be used when the state() returns a-
8046 combination which includes either the QPaintEngine::DirtyClipPath-
8047 or the QPaintEngine::DirtyClipRegion flag.-
8048-
8049 \sa state(), QPaintEngine::updateState()-
8050*/-
8051-
8052Qt::ClipOperation QPaintEngineState::clipOperation() const-
8053{-
8054 return static_cast<const QPainterState *>(this)->clipOperation;
never executed: return static_cast<const QPainterState *>(this)->clipOperation;
0
8055}-
8056-
8057/*!-
8058 \since 4.3-
8059-
8060 Returns whether the coordinate of the fill have been specified-
8061 as bounded by the current rendering operation and have to be-
8062 resolved (about the currently rendered primitive).-
8063*/-
8064bool QPaintEngineState::brushNeedsResolving() const-
8065{-
8066 const QBrush &brush = static_cast<const QPainterState *>(this)->brush;-
8067 return needsResolving(brush);
never executed: return needsResolving(brush);
0
8068}-
8069-
8070-
8071/*!-
8072 \since 4.3-
8073-
8074 Returns whether the coordinate of the stroke have been specified-
8075 as bounded by the current rendering operation and have to be-
8076 resolved (about the currently rendered primitive).-
8077*/-
8078bool QPaintEngineState::penNeedsResolving() const-
8079{-
8080 const QPen &pen = static_cast<const QPainterState *>(this)->pen;-
8081 return needsResolving(pen.brush());
never executed: return needsResolving(pen.brush());
0
8082}-
8083-
8084/*!-
8085 Returns the clip region in the current paint engine state.-
8086-
8087 This variable should only be used when the state() returns a-
8088 combination which includes the QPaintEngine::DirtyClipRegion flag.-
8089-
8090 \sa state(), QPaintEngine::updateState()-
8091*/-
8092-
8093QRegion QPaintEngineState::clipRegion() const-
8094{-
8095 return static_cast<const QPainterState *>(this)->clipRegion;
never executed: return static_cast<const QPainterState *>(this)->clipRegion;
0
8096}-
8097-
8098/*!-
8099 Returns the clip path in the current paint engine state.-
8100-
8101 This variable should only be used when the state() returns a-
8102 combination which includes the QPaintEngine::DirtyClipPath flag.-
8103-
8104 \sa state(), QPaintEngine::updateState()-
8105*/-
8106-
8107QPainterPath QPaintEngineState::clipPath() const-
8108{-
8109 return static_cast<const QPainterState *>(this)->clipPath;
never executed: return static_cast<const QPainterState *>(this)->clipPath;
0
8110}-
8111-
8112/*!-
8113 Returns whether clipping is enabled or not in the current paint-
8114 engine state.-
8115-
8116 This variable should only be used when the state() returns a-
8117 combination which includes the QPaintEngine::DirtyClipEnabled-
8118 flag.-
8119-
8120 \sa state(), QPaintEngine::updateState()-
8121*/-
8122-
8123bool QPaintEngineState::isClipEnabled() const-
8124{-
8125 return static_cast<const QPainterState *>(this)->clipEnabled;
never executed: return static_cast<const QPainterState *>(this)->clipEnabled;
0
8126}-
8127-
8128/*!-
8129 Returns the render hints in the current paint engine state.-
8130-
8131 This variable should only be used when the state() returns a-
8132 combination which includes the QPaintEngine::DirtyHints-
8133 flag.-
8134-
8135 \sa state(), QPaintEngine::updateState()-
8136*/-
8137-
8138QPainter::RenderHints QPaintEngineState::renderHints() const-
8139{-
8140 return static_cast<const QPainterState *>(this)->renderHints;
never executed: return static_cast<const QPainterState *>(this)->renderHints;
0
8141}-
8142-
8143/*!-
8144 Returns the composition mode in the current paint engine state.-
8145-
8146 This variable should only be used when the state() returns a-
8147 combination which includes the QPaintEngine::DirtyCompositionMode-
8148 flag.-
8149-
8150 \sa state(), QPaintEngine::updateState()-
8151*/-
8152-
8153QPainter::CompositionMode QPaintEngineState::compositionMode() const-
8154{-
8155 return static_cast<const QPainterState *>(this)->composition_mode;
never executed: return static_cast<const QPainterState *>(this)->composition_mode;
0
8156}-
8157-
8158-
8159/*!-
8160 Returns a pointer to the painter currently updating the paint-
8161 engine.-
8162*/-
8163-
8164QPainter *QPaintEngineState::painter() const-
8165{-
8166 return static_cast<const QPainterState *>(this)->painter;
never executed: return static_cast<const QPainterState *>(this)->painter;
0
8167}-
8168-
8169-
8170/*!-
8171 \since 4.2-
8172-
8173 Returns the opacity in the current paint engine state.-
8174*/-
8175-
8176qreal QPaintEngineState::opacity() const-
8177{-
8178 return static_cast<const QPainterState *>(this)->opacity;
never executed: return static_cast<const QPainterState *>(this)->opacity;
0
8179}-
8180-
8181/*!-
8182 \since 4.3-
8183-
8184 Sets the world transformation matrix.-
8185 If \a combine is true, the specified \a transform is combined with-
8186 the current matrix; otherwise it replaces the current matrix.-
8187-
8188 \sa transform(), setWorldTransform()-
8189*/-
8190-
8191void QPainter::setTransform(const QTransform &transform, bool combine )-
8192{-
8193 setWorldTransform(transform, combine);-
8194}
never executed: end of block
0
8195-
8196/*!-
8197 Returns the world transformation matrix.-
8198-
8199 \sa worldTransform()-
8200*/-
8201-
8202const QTransform & QPainter::transform() const-
8203{-
8204 return worldTransform();
never executed: return worldTransform();
0
8205}-
8206-
8207-
8208/*!-
8209 Returns the matrix that transforms from logical coordinates to-
8210 device coordinates of the platform dependent paint device.-
8211-
8212 This function is \e only needed when using platform painting-
8213 commands on the platform dependent handle (Qt::HANDLE), and the-
8214 platform does not do transformations nativly.-
8215-
8216 The QPaintEngine::PaintEngineFeature enum can be queried to-
8217 determine whether the platform performs the transformations or-
8218 not.-
8219-
8220 \sa worldTransform(), QPaintEngine::hasFeature(),-
8221*/-
8222-
8223const QTransform & QPainter::deviceTransform() const-
8224{-
8225 Q_D(const QPainter);-
8226 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
8227 qWarning("QPainter::deviceTransform: Painter not active");-
8228 return d->fakeState()->transform;
never executed: return d->fakeState()->transform;
0
8229 }-
8230 return d->state->matrix;
never executed: return d->state->matrix;
0
8231}-
8232-
8233-
8234/*!-
8235 Resets any transformations that were made using translate(),-
8236 scale(), shear(), rotate(), setWorldTransform(), setViewport()-
8237 and setWindow().-
8238-
8239 \sa {Coordinate Transformations}-
8240*/-
8241-
8242void QPainter::resetTransform()-
8243{-
8244 Q_D(QPainter);-
8245#ifdef QT_DEBUG_DRAW-
8246 if (qt_show_painter_debug_output)-
8247 printf("QPainter::resetMatrix()\n");-
8248#endif-
8249 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
8250 qWarning("QPainter::resetMatrix: Painter not active");-
8251 return;
never executed: return;
0
8252 }-
8253-
8254 d->state->wx = d->state->wy = d->state->vx = d->state->vy = 0; // default view origins-
8255 d->state->ww = d->state->vw = d->device->metric(QPaintDevice::PdmWidth);-
8256 d->state->wh = d->state->vh = d->device->metric(QPaintDevice::PdmHeight);-
8257 d->state->worldMatrix = QTransform();-
8258 setMatrixEnabled(false);-
8259 setViewTransformEnabled(false);-
8260 if (d->extended)
d->extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
8261 d->extended->transformChanged();
never executed: d->extended->transformChanged();
0
8262 else-
8263 d->state->dirtyFlags |= QPaintEngine::DirtyTransform;
never executed: d->state->dirtyFlags |= QPaintEngine::DirtyTransform;
0
8264}-
8265-
8266/*!-
8267 Sets the world transformation matrix.-
8268 If \a combine is true, the specified \a matrix is combined with the current matrix;-
8269 otherwise it replaces the current matrix.-
8270-
8271 \sa transform(), setTransform()-
8272*/-
8273-
8274void QPainter::setWorldTransform(const QTransform &matrix, bool combine )-
8275{-
8276 Q_D(QPainter);-
8277-
8278 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
8279 qWarning("QPainter::setWorldTransform: Painter not active");-
8280 return;
never executed: return;
0
8281 }-
8282-
8283 if (combine)
combineDescription
TRUEnever evaluated
FALSEnever evaluated
0
8284 d->state->worldMatrix = matrix * d->state->worldMatrix; // combines
never executed: d->state->worldMatrix = matrix * d->state->worldMatrix;
0
8285 else-
8286 d->state->worldMatrix = matrix; // set new matrix
never executed: d->state->worldMatrix = matrix;
0
8287-
8288 d->state->WxF = true;-
8289 d->updateMatrix();-
8290}
never executed: end of block
0
8291-
8292/*!-
8293 Returns the world transformation matrix.-
8294*/-
8295-
8296const QTransform & QPainter::worldTransform() const-
8297{-
8298 Q_D(const QPainter);-
8299 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
8300 qWarning("QPainter::worldTransform: Painter not active");-
8301 return d->fakeState()->transform;
never executed: return d->fakeState()->transform;
0
8302 }-
8303 return d->state->worldMatrix;
never executed: return d->state->worldMatrix;
0
8304}-
8305-
8306/*!-
8307 Returns the transformation matrix combining the current-
8308 window/viewport and world transformation.-
8309-
8310 \sa setWorldTransform(), setWindow(), setViewport()-
8311*/-
8312-
8313QTransform QPainter::combinedTransform() const-
8314{-
8315 Q_D(const QPainter);-
8316 if (!d->engine) {
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
8317 qWarning("QPainter::combinedTransform: Painter not active");-
8318 return QTransform();
never executed: return QTransform();
0
8319 }-
8320 return d->state->worldMatrix * d->viewTransform() * d->hidpiScaleTransform();
never executed: return d->state->worldMatrix * d->viewTransform() * d->hidpiScaleTransform();
0
8321}-
8322-
8323/*!-
8324 \since 4.7-
8325-
8326 This function is used to draw \a pixmap, or a sub-rectangle of \a pixmap,-
8327 at multiple positions with different scale, rotation and opacity. \a-
8328 fragments is an array of \a fragmentCount elements specifying the-
8329 parameters used to draw each pixmap fragment. The \a hints-
8330 parameter can be used to pass in drawing hints.-
8331-
8332 This function is potentially faster than multiple calls to drawPixmap(),-
8333 since the backend can optimize state changes.-
8334-
8335 \sa QPainter::PixmapFragment, QPainter::PixmapFragmentHint-
8336*/-
8337-
8338void QPainter::drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount,-
8339 const QPixmap &pixmap, PixmapFragmentHints hints)-
8340{-
8341 Q_D(QPainter);-
8342-
8343 if (!d->engine || pixmap.isNull())
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8344 return;
never executed: return;
0
8345-
8346#ifndef QT_NO_DEBUG-
8347 for (int i = 0; i < fragmentCount; ++i) {
i < fragmentCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
8348 QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop,-
8349 fragments[i].width, fragments[i].height);-
8350 if (!(QRectF(pixmap.rect()).contains(sourceRect)))
!(QRectF(pixma...s(sourceRect))Description
TRUEnever evaluated
FALSEnever evaluated
0
8351 qWarning("QPainter::drawPixmapFragments - the source rect is not contained by the pixmap's rectangle");
never executed: QMessageLogger(__FILE__, 8351, __PRETTY_FUNCTION__).warning("QPainter::drawPixmapFragments - the source rect is not contained by the pixmap's rectangle");
0
8352 }
never executed: end of block
0
8353#endif-
8354-
8355 if (d->engine->isExtended()) {
d->engine->isExtended()Description
TRUEnever evaluated
FALSEnever evaluated
0
8356 d->extended->drawPixmapFragments(fragments, fragmentCount, pixmap, hints);-
8357 } else {
never executed: end of block
0
8358 qreal oldOpacity = opacity();-
8359 QTransform oldTransform = transform();-
8360-
8361 for (int i = 0; i < fragmentCount; ++i) {
i < fragmentCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
8362 QTransform transform = oldTransform;-
8363 qreal xOffset = 0;-
8364 qreal yOffset = 0;-
8365 if (fragments[i].rotation == 0) {
fragments[i].rotation == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
8366 xOffset = fragments[i].x;-
8367 yOffset = fragments[i].y;-
8368 } else {
never executed: end of block
0
8369 transform.translate(fragments[i].x, fragments[i].y);-
8370 transform.rotate(fragments[i].rotation);-
8371 }
never executed: end of block
0
8372 setOpacity(oldOpacity * fragments[i].opacity);-
8373 setTransform(transform);-
8374-
8375 qreal w = fragments[i].scaleX * fragments[i].width;-
8376 qreal h = fragments[i].scaleY * fragments[i].height;-
8377 QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop,-
8378 fragments[i].width, fragments[i].height);-
8379 drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, sourceRect);-
8380 }
never executed: end of block
0
8381-
8382 setOpacity(oldOpacity);-
8383 setTransform(oldTransform);-
8384 }
never executed: end of block
0
8385}-
8386-
8387/*!-
8388 \since 4.7-
8389 \class QPainter::PixmapFragment-
8390 \inmodule QtGui-
8391-
8392 \brief This class is used in conjunction with the-
8393 QPainter::drawPixmapFragments() function to specify how a pixmap, or-
8394 sub-rect of a pixmap, is drawn.-
8395-
8396 The \a sourceLeft, \a sourceTop, \a width and \a height variables are used-
8397 as a source rectangle within the pixmap passed into the-
8398 QPainter::drawPixmapFragments() function. The variables \a x, \a y, \a-
8399 width and \a height are used to calculate the target rectangle that is-
8400 drawn. \a x and \a y denotes the center of the target rectangle. The \a-
8401 width and \a height in the target rectangle is scaled by the \a scaleX and-
8402 \a scaleY values. The resulting target rectangle is then rotated \a-
8403 rotation degrees around the \a x, \a y center point.-
8404-
8405 \sa QPainter::drawPixmapFragments()-
8406*/-
8407-
8408/*!-
8409 \since 4.7-
8410-
8411 This is a convenience function that returns a QPainter::PixmapFragment that is-
8412 initialized with the \a pos, \a sourceRect, \a scaleX, \a scaleY, \a-
8413 rotation, \a opacity parameters.-
8414*/-
8415-
8416QPainter::PixmapFragment QPainter::PixmapFragment::create(const QPointF &pos, const QRectF &sourceRect,-
8417 qreal scaleX, qreal scaleY, qreal rotation,-
8418 qreal opacity)-
8419{-
8420 PixmapFragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(),-
8421 sourceRect.height(), scaleX, scaleY, rotation, opacity};-
8422 return fragment;
never executed: return fragment;
0
8423}-
8424-
8425/*!-
8426 \variable QPainter::PixmapFragment::x-
8427 \brief the x coordinate of center point in the target rectangle.-
8428*/-
8429-
8430/*!-
8431 \variable QPainter::PixmapFragment::y-
8432 \brief the y coordinate of the center point in the target rectangle.-
8433*/-
8434-
8435/*!-
8436 \variable QPainter::PixmapFragment::sourceLeft-
8437 \brief the left coordinate of the source rectangle.-
8438*/-
8439-
8440/*!-
8441 \variable QPainter::PixmapFragment::sourceTop-
8442 \brief the top coordinate of the source rectangle.-
8443*/-
8444-
8445/*!-
8446 \variable QPainter::PixmapFragment::width-
8447-
8448 \brief the width of the source rectangle and is used to calculate the width-
8449 of the target rectangle.-
8450*/-
8451-
8452/*!-
8453 \variable QPainter::PixmapFragment::height-
8454-
8455 \brief the height of the source rectangle and is used to calculate the-
8456 height of the target rectangle.-
8457*/-
8458-
8459/*!-
8460 \variable QPainter::PixmapFragment::scaleX-
8461 \brief the horizontal scale of the target rectangle.-
8462*/-
8463-
8464/*!-
8465 \variable QPainter::PixmapFragment::scaleY-
8466 \brief the vertical scale of the target rectangle.-
8467*/-
8468-
8469/*!-
8470 \variable QPainter::PixmapFragment::rotation-
8471-
8472 \brief the rotation of the target rectangle in degrees. The target-
8473 rectangle is rotated after it has been scaled.-
8474*/-
8475-
8476/*!-
8477 \variable QPainter::PixmapFragment::opacity-
8478-
8479 \brief the opacity of the target rectangle, where 0.0 is fully transparent-
8480 and 1.0 is fully opaque.-
8481*/-
8482-
8483/*!-
8484 \since 4.7-
8485-
8486 \enum QPainter::PixmapFragmentHint-
8487-
8488 \value OpaqueHint Indicates that the pixmap fragments to be drawn are-
8489 opaque. Opaque fragments are potentially faster to draw.-
8490-
8491 \sa QPainter::drawPixmapFragments(), QPainter::PixmapFragment-
8492*/-
8493-
8494void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation)-
8495{-
8496 p->draw_helper(path, operation);-
8497}
never executed: end of block
0
8498-
8499QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9