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

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