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