Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | extern QPixmap qt_pixmapForBrush(int style, bool invert); | - |
8 | | - |
9 | void qt_format_text(const QFont &font, | - |
10 | const QRectF &_r, int tf, const QTextOption *option, const QString& str, QRectF *brect, | - |
11 | int tabstops, int* tabarray, int tabarraylen, | - |
12 | QPainter *painter); | - |
13 | static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextEngine *textEngine, | - |
14 | QTextCharFormat::UnderlineStyle underlineStyle, | - |
15 | QTextItem::RenderFlags flags, qreal width, | - |
16 | const QTextCharFormat &charFormat); | - |
17 | | - |
18 | __attribute__((visibility("default"))) void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray, | - |
19 | const QFixedPoint *positions, int glyphCount, | - |
20 | QFontEngine *fontEngine, const QFont &font, | - |
21 | const QTextCharFormat &charFormat); | - |
22 | | - |
23 | static inline QGradient::CoordinateMode coordinateMode(const QBrush &brush) | - |
24 | { | - |
25 | switch (brush.style()) { | - |
26 | case Qt::LinearGradientPattern: | - |
27 | case Qt::RadialGradientPattern: | - |
28 | case Qt::ConicalGradientPattern: | - |
29 | return brush.gradient()->coordinateMode(); | - |
30 | default: | - |
31 | ; | - |
32 | } | - |
33 | return QGradient::LogicalMode; | - |
34 | } | - |
35 | | - |
36 | extern bool qHasPixmapTexture(const QBrush &); | - |
37 | | - |
38 | static inline bool is_brush_transparent(const QBrush &brush) { | - |
39 | Qt::BrushStyle s = brush.style(); | - |
40 | if (s != Qt::TexturePattern) | - |
41 | return s >= Qt::Dense1Pattern && s <= Qt::DiagCrossPattern; | - |
42 | if (qHasPixmapTexture(brush)) | - |
43 | return brush.texture().isQBitmap() || brush.texture().hasAlphaChannel(); | - |
44 | else { | - |
45 | const QImage texture = brush.textureImage(); | - |
46 | return texture.hasAlphaChannel() || (texture.depth() == 1 && texture.colorCount() == 0); | - |
47 | } | - |
48 | } | - |
49 | | - |
50 | static inline bool is_pen_transparent(const QPen &pen) { | - |
51 | return pen.style() > Qt::SolidLine || is_brush_transparent(pen.brush()); | - |
52 | } | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | static inline uint line_emulation(uint emulation) | - |
58 | { | - |
59 | return emulation & (QPaintEngine::PrimitiveTransform | - |
60 | | QPaintEngine::AlphaBlend | - |
61 | | QPaintEngine::Antialiasing | - |
62 | | QPaintEngine::BrushStroke | - |
63 | | QPaintEngine::ConstantOpacity | - |
64 | | 0x10000000 | - |
65 | | QPaintEngine::ObjectBoundingModeGradients | - |
66 | | 0x40000000); | - |
67 | } | - |
68 | | - |
69 | | - |
70 | static bool qt_painter_thread_test(int devType, int engineType, const char *what) | - |
71 | { | - |
72 | const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); | - |
73 | switch (devType) { | - |
74 | case QInternal::Image: | - |
75 | case QInternal::Printer: | - |
76 | case QInternal::Picture: | - |
77 | | - |
78 | break; | - |
79 | default: | - |
80 | if (QThread::currentThread() != (static_cast<QGuiApplication *>(QCoreApplication::instance()))->thread() | - |
81 | | - |
82 | && (devType != QInternal::Pixmap || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedPixmaps)) | - |
83 | | - |
84 | && (devType != QInternal::OpenGL || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedOpenGL)) | - |
85 | | - |
86 | && (devType != QInternal::Widget || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedOpenGL) | - |
87 | || (engineType != QPaintEngine::OpenGL && engineType != QPaintEngine::OpenGL2))) { | - |
88 | QMessageLogger(__FILE__, 163169, __PRETTY_FUNCTION__).warning("QPainter: It is not safe to use %s outside the GUI thread", what); | - |
89 | return false; | - |
90 | } | - |
91 | break; | - |
92 | } | - |
93 | return true; | - |
94 | } | - |
95 | | - |
96 | | - |
97 | void QPainterPrivate::checkEmulation() | - |
98 | { | - |
99 | ((!(extended)) ? qt_assert("extended",__FILE__,174180) : qt_noop()); | - |
100 | bool doEmulation = false; | - |
101 | if (state->bgMode == Qt::OpaqueMode) | - |
102 | doEmulation = true; | - |
103 | | - |
104 | const QGradient *bg = state->brush.gradient(); | - |
105 | if (bg && bg->coordinateMode() > QGradient::LogicalMode) | - |
106 | doEmulation = true; | - |
107 | | - |
108 | const QGradient *pg = qpen_brush(state->pen).gradient(); | - |
109 | if (pg && pg->coordinateMode() > QGradient::LogicalMode) | - |
110 | doEmulation = true; | - |
111 | | - |
112 | if (doEmulation && extended->flags() & QPaintEngineEx::DoNotEmulate) | - |
113 | return; | - |
114 | | - |
115 | if (doEmulation) { | - |
116 | if (extended != emulationEngine) { | - |
117 | if (!emulationEngine) | - |
118 | emulationEngine = new QEmulationPaintEngine(extended); | - |
119 | extended = emulationEngine; | - |
120 | extended->setState(state); | - |
121 | } | - |
122 | } else if (emulationEngine == extended) { | - |
123 | extended = emulationEngine->real_engine; | - |
124 | } | - |
125 | } | - |
126 | | - |
127 | | - |
128 | QPainterPrivate::~QPainterPrivate() | - |
129 | { | - |
130 | delete emulationEngine; | - |
131 | qDeleteAll(states); | - |
132 | delete dummyState; | - |
133 | } | - |
134 | | - |
135 | | - |
136 | QTransform QPainterPrivate::viewTransform() const | - |
137 | { | - |
138 | if (state->VxF) { | - |
139 | qreal scaleW = qreal(state->vw)/qreal(state->ww); | - |
140 | qreal scaleH = qreal(state->vh)/qreal(state->wh); | - |
141 | return QTransform(scaleW, 0, 0, scaleH, | - |
142 | state->vx - state->wx*scaleW, state->vy - state->wy*scaleH); | - |
143 | } | - |
144 | return QTransform(); | - |
145 | } | - |
146 | | - |
147 | qreal QPainterPrivate::effectiveDevicePixelRatio() const | - |
148 | { | - |
149 | | - |
150 | if (device->devType() == QInternal::Printer) | - |
151 | return qreal(1); | - |
152 | | - |
153 | return qMax(qreal(1), device->devicePixelRatioF()); | - |
154 | } | - |
155 | | - |
156 | QTransform QPainterPrivate::hidpiScaleTransform() const | - |
157 | { | - |
158 | const qreal devicePixelRatio = effectiveDevicePixelRatio(); | - |
159 | return QTransform::fromScale(devicePixelRatio, devicePixelRatio); | - |
160 | } | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev) | - |
167 | { | - |
168 | ((!(q)) ? qt_assert("q",__FILE__,243249) : qt_noop()); | - |
169 | ((!(pdev)) ? qt_assert("pdev",__FILE__,244250) : qt_noop()); | - |
170 | | - |
171 | QPainter *sp = pdev->sharedPainter(); | - |
172 | if (!sp) | - |
173 | return false; | - |
174 | | - |
175 | | - |
176 | | - |
177 | sp->save(); | - |
178 | if (!sp->d_ptr->d_ptrs) { | - |
179 | | - |
180 | | - |
181 | | - |
182 | sp->d_ptr->d_ptrs_size = 4; | - |
183 | sp->d_ptr->d_ptrs = (QPainterPrivate **)malloc(4 * sizeof(QPainterPrivate *)); | - |
184 | do {if(!(sp->d_ptr->d_ptrs))qt_check_pointer(__FILE__,259265);} while (0); | - |
185 | } else if (sp->d_ptr->refcount - 1 == sp->d_ptr->d_ptrs_size) { | - |
186 | | - |
187 | sp->d_ptr->d_ptrs_size <<= 1; | - |
188 | const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *); | - |
189 | sp->d_ptr->d_ptrs = q_check_ptr((QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize)); | - |
190 | } | - |
191 | sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data(); | - |
192 | q->d_ptr.take(); | - |
193 | q->d_ptr.reset(sp->d_ptr.data()); | - |
194 | | - |
195 | ((!(q->d_ptr->state)) ? qt_assert("q->d_ptr->state",__FILE__,270276) : qt_noop()); | - |
196 | | - |
197 | | - |
198 | q->initFrom(pdev); | - |
199 | QPoint offset; | - |
200 | pdev->redirected(&offset); | - |
201 | offset += q->d_ptr->engine->coordinateOffset(); | - |
202 | | - |
203 | | - |
204 | q->d_ptr->state->ww = q->d_ptr->state->vw = pdev->width(); | - |
205 | q->d_ptr->state->wh = q->d_ptr->state->vh = pdev->height(); | - |
206 | | - |
207 | | - |
208 | if (q->d_ptr->state->WxF) { | - |
209 | q->d_ptr->state->redirectionMatrix = q->d_ptr->state->matrix; | - |
210 | q->d_ptr->state->redirectionMatrix *= q->d_ptr->hidpiScaleTransform().inverted(); | - |
211 | q->d_ptr->state->redirectionMatrix.translate(-offset.x(), -offset.y()); | - |
212 | q->d_ptr->state->worldMatrix = QTransform(); | - |
213 | q->d_ptr->state->WxF = false; | - |
214 | } else { | - |
215 | q->d_ptr->state->redirectionMatrix = QTransform::fromTranslate(-offset.x(), -offset.y()); | - |
216 | } | - |
217 | q->d_ptr->updateMatrix(); | - |
218 | | - |
219 | QPaintEnginePrivate *enginePrivate = q->d_ptr->engine->d_func(); | - |
220 | if (enginePrivate->currentClipDevice == pdev) { | - |
221 | enginePrivate->systemStateChanged(); | - |
222 | return true; | - |
223 | } | - |
224 | | - |
225 | | - |
226 | enginePrivate->currentClipDevice = pdev; | - |
227 | enginePrivate->setSystemTransform(q->d_ptr->state->matrix); | - |
228 | return true; | - |
229 | } | - |
230 | | - |
231 | void QPainterPrivate::detachPainterPrivate(QPainter *q) | - |
232 | { | - |
233 | ((!(refcount > 1)) ? qt_assert("refcount > 1",__FILE__,308314) : qt_noop()); | - |
234 | ((!(q)) ? qt_assert("q",__FILE__,309315) : qt_noop()); | - |
235 | | - |
236 | QPainterPrivate *original = d_ptrs[--refcount - 1]; | - |
237 | if (inDestructor) { | - |
238 | inDestructor = false; | - |
239 | if (original) | - |
240 | original->inDestructor = true; | - |
241 | } else if (!original) { | - |
242 | original = new QPainterPrivate(q); | - |
243 | } | - |
244 | | - |
245 | d_ptrs[refcount - 1] = 0; | - |
246 | q->restore(); | - |
247 | q->d_ptr.take(); | - |
248 | q->d_ptr.reset(original); | - |
249 | | - |
250 | if (emulationEngine) { | - |
251 | extended = emulationEngine->real_engine; | - |
252 | delete emulationEngine; | - |
253 | emulationEngine = 0; | - |
254 | } | - |
255 | } | - |
256 | | - |
257 | | - |
258 | void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperation op) | - |
259 | { | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - |
266 | if (originalPath.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
267 | return; never executed: return; | 0 |
268 | | - |
269 | QPaintEngine::PaintEngineFeatures gradientStretch = | - |
270 | QPaintEngine::PaintEngineFeatures(0x10000000 | - |
271 | | QPaintEngine::ObjectBoundingModeGradients); | - |
272 | | - |
273 | const bool mustEmulateObjectBoundingModeGradients = extendedTRUE | never evaluated | FALSE | never evaluated |
| 0 |
274 | || ((TRUE | never evaluated | FALSE | never evaluated |
state->emulationSpecifier & QPaintEngine::ObjectBoundingModeGradients)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
275 | && !engine->hasFeature(QPaintEngine::PatternTransform)TRUE | never evaluated | FALSE | never evaluated |
); | 0 |
276 | | - |
277 | if (!(state->emulationSpecifier & ~gradientStretch)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
278 | && !mustEmulateObjectBoundingModeGradientsTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
279 | drawStretchedGradient(originalPath, op); | - |
280 | return; never executed: return; | 0 |
281 | } else if (state->emulationSpecifier & 0x40000000TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
282 | drawOpaqueBackground(originalPath, op); | - |
283 | return; never executed: return; | 0 |
284 | } | - |
285 | | - |
286 | QPainter * const q = q_func(); | - |
287 | | - |
288 | qreal strokeOffsetX = 0, strokeOffsetY = 0; | - |
289 | | - |
290 | QPainterPath path = originalPath * state->matrix; | - |
291 | QRectF pathBounds = path.boundingRect(); | - |
292 | QRectF strokeBounds; | - |
293 | bool doStroke = (TRUE | never evaluated | FALSE | never evaluated |
op & StrokeDraw)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
state->pen.style() != Qt::NoPen)TRUE | never evaluated | FALSE | never evaluated |
; | 0 |
294 | if (doStrokeTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
295 | qreal penWidth = state->pen.widthF(); | - |
296 | if (penWidth == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
297 | strokeOffsetX = 1; | - |
298 | strokeOffsetY = 1; | - |
299 | } never executed: end of block else { | 0 |
300 | | - |
301 | if (state->matrix.type() > QTransform::TxScaleTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
302 | QPainterPathStroker stroker; | - |
303 | stroker.setWidth(penWidth); | - |
304 | stroker.setJoinStyle(state->pen.joinStyle()); | - |
305 | stroker.setCapStyle(state->pen.capStyle()); | - |
306 | QPainterPath stroke = stroker.createStroke(originalPath); | - |
307 | strokeBounds = (stroke * state->matrix).boundingRect(); | - |
308 | } never executed: end of block else { | 0 |
309 | strokeOffsetX = qAbs(penWidth * state->matrix.m11() / 2.0); | - |
310 | strokeOffsetY = qAbs(penWidth * state->matrix.m22() / 2.0); | - |
311 | } never executed: end of block | 0 |
312 | } | - |
313 | } | - |
314 | | - |
315 | QRect absPathRect; | - |
316 | if (!strokeBounds.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
317 | absPathRect = strokeBounds.intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect(); | - |
318 | } never executed: end of block else { | 0 |
319 | absPathRect = pathBounds.adjusted(-strokeOffsetX, -strokeOffsetY, strokeOffsetX, strokeOffsetY) | - |
320 | .intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect(); | - |
321 | } never executed: end of block | 0 |
322 | | - |
323 | if (q->hasClipping()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
324 | bool hasPerspectiveTransform = false; | - |
325 | for (int i = 0; i < state->clipInfo.size(); ++i) {const QPainterClipInfo &info =: qAsConst(state->clipInfo.at(i);)) { | - |
326 | if (info.matrix.type() == QTransform::TxProjectTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
327 | hasPerspectiveTransform = true; | - |
328 | break; never executed: break; | 0 |
329 | } | - |
330 | } never executed: end of block | 0 |
331 | | - |
332 | if (!hasPerspectiveTransformTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
338 | | - |
339 | bool old_txinv = txinv; | - |
340 | QTransform old_invMatrix = invMatrix; | - |
341 | txinv = true; | - |
342 | invMatrix = QTransform(); | - |
343 | QPainterPath clipPath = q->clipPath(); | - |
344 | QRectF r = clipPath.boundingRect().intersected(absPathRect); | - |
345 | absPathRect = r.toAlignedRect(); | - |
346 | txinv = old_txinv; | - |
347 | invMatrix = old_invMatrix; | - |
348 | } never executed: end of block | 0 |
349 | } never executed: end of block | 0 |
350 | | - |
351 | | - |
352 | | - |
353 | | - |
354 | | - |
355 | | - |
356 | | - |
357 | if (absPathRect.width() <= 0TRUE | never evaluated | FALSE | never evaluated |
|| absPathRect.height() <= 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
358 | return; never executed: return; | 0 |
359 | | - |
360 | QImage image(absPathRect.width(), absPathRect.height(), QImage::Format_ARGB32_Premultiplied); | - |
361 | image.fill(0); | - |
362 | | - |
363 | QPainter p(&image); | - |
364 | | - |
365 | p.d_ptr->helper_device = helper_device; | - |
366 | | - |
367 | p.setOpacity(state->opacity); | - |
368 | p.translate(-absPathRect.x(), -absPathRect.y()); | - |
369 | p.setTransform(state->matrix, true); | - |
370 | p.setPen(doStroke ? state->pen : QPen(Qt::NoPen)); | - |
371 | p.setBrush((op & FillDraw) ? state->brush : QBrush(Qt::NoBrush)); | - |
372 | p.setBackground(state->bgBrush); | - |
373 | p.setBackgroundMode(state->bgMode); | - |
374 | p.setBrushOrigin(state->brushOrigin); | - |
375 | | - |
376 | p.setRenderHint(QPainter::Antialiasing, state->renderHints & QPainter::Antialiasing); | - |
377 | p.setRenderHint(QPainter::SmoothPixmapTransform, | - |
378 | state->renderHints & QPainter::SmoothPixmapTransform); | - |
379 | | - |
380 | p.drawPath(originalPath); | - |
381 | | - |
382 | | - |
383 | static bool do_fallback_overlay = !qEnvironmentVariableIsEmpty("QT_PAINT_FALLBACK_OVERLAY"); | - |
384 | if (do_fallback_overlayTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
385 | QImage block(8, 8, QImage::Format_ARGB32_Premultiplied); | - |
386 | QPainter pt(&block); | - |
387 | pt.fillRect(0, 0, 8, 8, QColor(196, 0, 196)); | - |
388 | pt.drawLine(0, 0, 8, 8); | - |
389 | pt.end(); | - |
390 | p.resetTransform(); | - |
391 | p.setCompositionMode(QPainter::CompositionMode_SourceAtop); | - |
392 | p.setOpacity(0.5); | - |
393 | p.fillRect(0, 0, image.width(), image.height(), QBrush(block)); | - |
394 | } never executed: end of block | 0 |
395 | | - |
396 | | - |
397 | p.end(); | - |
398 | | - |
399 | q->save(); | - |
400 | state->matrix = QTransform(); | - |
401 | if (extendedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
402 | extended->transformChanged(); | - |
403 | } never executed: end of block else { | 0 |
404 | state->dirtyFlags |= QPaintEngine::DirtyTransform; | - |
405 | updateState(state); | - |
406 | } never executed: end of block | 0 |
407 | engine->drawImage(absPathRect, | - |
408 | image, | - |
409 | QRectF(0, 0, absPathRect.width(), absPathRect.height()), | - |
410 | Qt::OrderedDither | Qt::OrderedAlphaDither); | - |
411 | q->restore(); | - |
412 | } never executed: end of block | 0 |
413 | | - |
414 | void QPainterPrivate::drawOpaqueBackground(const QPainterPath &path, DrawOperation op) | - |
415 | { | - |
416 | QPainter * const q = q_func(); | - |
417 | | - |
418 | q->setBackgroundMode(Qt::TransparentMode); | - |
419 | | - |
420 | if (op & FillDraw && state->brush.style() != Qt::NoBrush) { | - |
421 | q->fillPath(path, state->bgBrush.color()); | - |
422 | q->fillPath(path, state->brush); | - |
423 | } | - |
424 | | - |
425 | if (op & StrokeDraw && state->pen.style() != Qt::NoPen) { | - |
426 | q->strokePath(path, QPen(state->bgBrush.color(), state->pen.width())); | - |
427 | q->strokePath(path, state->pen); | - |
428 | } | - |
429 | | - |
430 | q->setBackgroundMode(Qt::OpaqueMode); | - |
431 | } | - |
432 | | - |
433 | static inline QBrush stretchGradientToUserSpace(const QBrush &brush, const QRectF &boundingRect) | - |
434 | { | - |
435 | ((!(brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern)) ? qt_assert("brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern", | - |
436 | __FILE__ | - |
437 | , | - |
438 | 512517 | - |
439 | ) : qt_noop()) | - |
440 | ; | - |
441 | | - |
442 | QTransform gradientToUser(boundingRect.width(), 0, 0, boundingRect.height(), | - |
443 | boundingRect.x(), boundingRect.y()); | - |
444 | | - |
445 | QGradient g = *brush.gradient(); | - |
446 | g.setCoordinateMode(QGradient::LogicalMode); | - |
447 | | - |
448 | QBrush b(g); | - |
449 | b.setTransform(gradientToUser * b.transform()); | - |
450 | return b; | - |
451 | } | - |
452 | | - |
453 | void QPainterPrivate::drawStretchedGradient(const QPainterPath &path, DrawOperation op) | - |
454 | { | - |
455 | QPainter * const q = q_func(); | - |
456 | | - |
457 | const qreal sw = helper_device->width(); | - |
458 | const qreal sh = helper_device->height(); | - |
459 | | - |
460 | bool changedPen = false; | - |
461 | bool changedBrush = false; | - |
462 | bool needsFill = false; | - |
463 | | - |
464 | const QPen pen = state->pen; | - |
465 | const QBrush brush = state->brush; | - |
466 | | - |
467 | const QGradient::CoordinateMode penMode = coordinateMode(pen.brush()); | - |
468 | const QGradient::CoordinateMode brushMode = coordinateMode(brush); | - |
469 | | - |
470 | QRectF boundingRect; | - |
471 | | - |
472 | | - |
473 | if ((op & FillDraw) && brush.style() != Qt::NoBrush) { | - |
474 | if (brushMode == QGradient::StretchToDeviceMode) { | - |
475 | q->setPen(Qt::NoPen); | - |
476 | changedPen = pen.style() != Qt::NoPen; | - |
477 | q->scale(sw, sh); | - |
478 | updateState(state); | - |
479 | | - |
480 | const qreal isw = 1.0 / sw; | - |
481 | const qreal ish = 1.0 / sh; | - |
482 | QTransform inv(isw, 0, 0, ish, 0, 0); | - |
483 | engine->drawPath(path * inv); | - |
484 | q->scale(isw, ish); | - |
485 | } else { | - |
486 | needsFill = true; | - |
487 | | - |
488 | if (brushMode == QGradient::ObjectBoundingMode) { | - |
489 | ((!(engine->hasFeature(QPaintEngine::PatternTransform))) ? qt_assert("engine->hasFeature(QPaintEngine::PatternTransform)",__FILE__,561566) : qt_noop()); | - |
490 | boundingRect = path.boundingRect(); | - |
491 | q->setBrush(stretchGradientToUserSpace(brush, boundingRect)); | - |
492 | changedBrush = true; | - |
493 | } | - |
494 | } | - |
495 | } | - |
496 | | - |
497 | if ((op & StrokeDraw) && pen.style() != Qt::NoPen) { | - |
498 | | - |
499 | if (penMode == QGradient::StretchToDeviceMode) { | - |
500 | q->setPen(Qt::NoPen); | - |
501 | changedPen = true; | - |
502 | | - |
503 | if (needsFill) { | - |
504 | updateState(state); | - |
505 | engine->drawPath(path); | - |
506 | } | - |
507 | | - |
508 | q->scale(sw, sh); | - |
509 | q->setBrush(pen.brush()); | - |
510 | changedBrush = true; | - |
511 | updateState(state); | - |
512 | | - |
513 | QPainterPathStroker stroker; | - |
514 | stroker.setDashPattern(pen.style()); | - |
515 | stroker.setWidth(pen.widthF()); | - |
516 | stroker.setJoinStyle(pen.joinStyle()); | - |
517 | stroker.setCapStyle(pen.capStyle()); | - |
518 | stroker.setMiterLimit(pen.miterLimit()); | - |
519 | QPainterPath stroke = stroker.createStroke(path); | - |
520 | | - |
521 | const qreal isw = 1.0 / sw; | - |
522 | const qreal ish = 1.0 / sh; | - |
523 | QTransform inv(isw, 0, 0, ish, 0, 0); | - |
524 | engine->drawPath(stroke * inv); | - |
525 | q->scale(isw, ish); | - |
526 | } else { | - |
527 | if (!needsFill && brush.style() != Qt::NoBrush) { | - |
528 | q->setBrush(Qt::NoBrush); | - |
529 | changedBrush = true; | - |
530 | } | - |
531 | | - |
532 | if (penMode == QGradient::ObjectBoundingMode) { | - |
533 | ((!(engine->hasFeature(QPaintEngine::PatternTransform))) ? qt_assert("engine->hasFeature(QPaintEngine::PatternTransform)",__FILE__,605610) : qt_noop()); | - |
534 | | - |
535 | | - |
536 | if (!needsFill || brushMode != QGradient::ObjectBoundingMode) | - |
537 | boundingRect = path.boundingRect(); | - |
538 | | - |
539 | QPen p = pen; | - |
540 | p.setBrush(stretchGradientToUserSpace(pen.brush(), boundingRect)); | - |
541 | q->setPen(p); | - |
542 | changedPen = true; | - |
543 | } else if (changedPen) { | - |
544 | q->setPen(pen); | - |
545 | changedPen = false; | - |
546 | } | - |
547 | | - |
548 | updateState(state); | - |
549 | engine->drawPath(path); | - |
550 | } | - |
551 | } else if (needsFill) { | - |
552 | if (pen.style() != Qt::NoPen) { | - |
553 | q->setPen(Qt::NoPen); | - |
554 | changedPen = true; | - |
555 | } | - |
556 | | - |
557 | updateState(state); | - |
558 | engine->drawPath(path); | - |
559 | } | - |
560 | | - |
561 | if (changedPen) | - |
562 | q->setPen(pen); | - |
563 | if (changedBrush) | - |
564 | q->setBrush(brush); | - |
565 | } | - |
566 | | - |
567 | | - |
568 | void QPainterPrivate::updateMatrix() | - |
569 | { | - |
570 | state->matrix = state->WxF ? state->worldMatrix : QTransform(); | - |
571 | if (state->VxF) | - |
572 | state->matrix *= viewTransform(); | - |
573 | | - |
574 | txinv = false; | - |
575 | state->matrix *= state->redirectionMatrix; | - |
576 | if (extended) | - |
577 | extended->transformChanged(); | - |
578 | else | - |
579 | state->dirtyFlags |= QPaintEngine::DirtyTransform; | - |
580 | | - |
581 | state->matrix *= hidpiScaleTransform(); | - |
582 | | - |
583 | | - |
584 | | - |
585 | } | - |
586 | | - |
587 | | - |
588 | void QPainterPrivate::updateInvMatrix() | - |
589 | { | - |
590 | ((!(txinv == false)) ? qt_assert("txinv == false",__FILE__,662667) : qt_noop()); | - |
591 | txinv = true; | - |
592 | invMatrix = state->matrix.inverted(); | - |
593 | } | - |
594 | | - |
595 | extern bool qt_isExtendedRadialGradient(const QBrush &brush); | - |
596 | | - |
597 | void QPainterPrivate::updateEmulationSpecifier(QPainterState *s) | - |
598 | { | - |
599 | bool alpha = false; | - |
600 | bool linearGradient = false; | - |
601 | bool radialGradient = false; | - |
602 | bool extendedRadialGradient = false; | - |
603 | bool conicalGradient = false; | - |
604 | bool patternBrush = false; | - |
605 | bool xform = false; | - |
606 | bool complexXform = false; | - |
607 | | - |
608 | bool skip = true; | - |
609 | | - |
610 | | - |
611 | | - |
612 | if (s->state() & (QPaintEngine::DirtyPen | QPaintEngine::DirtyBrush | QPaintEngine::DirtyHints)) { | - |
613 | | - |
614 | if (!s->pen.isSolid() && !engine->hasFeature(QPaintEngine::BrushStroke)) | - |
615 | s->emulationSpecifier |= QPaintEngine::BrushStroke; | - |
616 | else | - |
617 | s->emulationSpecifier &= ~QPaintEngine::BrushStroke; | - |
618 | | - |
619 | skip = false; | - |
620 | | - |
621 | QBrush penBrush = (qpen_style(s->pen) == Qt::NoPen) ? QBrush(Qt::NoBrush) : qpen_brush(s->pen); | - |
622 | Qt::BrushStyle brushStyle = qbrush_style(s->brush); | - |
623 | Qt::BrushStyle penBrushStyle = qbrush_style(penBrush); | - |
624 | alpha = (penBrushStyle != Qt::NoBrush | - |
625 | && (penBrushStyle < Qt::LinearGradientPattern && penBrush.color().alpha() != 255) | - |
626 | && !penBrush.isOpaque()) | - |
627 | || (brushStyle != Qt::NoBrush | - |
628 | && (brushStyle < Qt::LinearGradientPattern && s->brush.color().alpha() != 255) | - |
629 | && !s->brush.isOpaque()); | - |
630 | linearGradient = ((penBrushStyle == Qt::LinearGradientPattern) || | - |
631 | (brushStyle == Qt::LinearGradientPattern)); | - |
632 | radialGradient = ((penBrushStyle == Qt::RadialGradientPattern) || | - |
633 | (brushStyle == Qt::RadialGradientPattern)); | - |
634 | extendedRadialGradient = radialGradient && (qt_isExtendedRadialGradient(penBrush) || qt_isExtendedRadialGradient(s->brush)); | - |
635 | conicalGradient = ((penBrushStyle == Qt::ConicalGradientPattern) || | - |
636 | (brushStyle == Qt::ConicalGradientPattern)); | - |
637 | patternBrush = (((penBrushStyle > Qt::SolidPattern | - |
638 | && penBrushStyle < Qt::LinearGradientPattern) | - |
639 | || penBrushStyle == Qt::TexturePattern) || | - |
640 | ((brushStyle > Qt::SolidPattern | - |
641 | && brushStyle < Qt::LinearGradientPattern) | - |
642 | || brushStyle == Qt::TexturePattern)); | - |
643 | | - |
644 | bool penTextureAlpha = false; | - |
645 | if (penBrush.style() == Qt::TexturePattern) | - |
646 | penTextureAlpha = qHasPixmapTexture(penBrush) | - |
647 | ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() | - |
648 | : penBrush.textureImage().hasAlphaChannel(); | - |
649 | bool brushTextureAlpha = false; | - |
650 | if (s->brush.style() == Qt::TexturePattern) { | - |
651 | brushTextureAlpha = qHasPixmapTexture(s->brush) | - |
652 | ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha() | - |
653 | : s->brush.textureImage().hasAlphaChannel(); | - |
654 | } | - |
655 | if (((penBrush.style() == Qt::TexturePattern && penTextureAlpha) | - |
656 | || (s->brush.style() == Qt::TexturePattern && brushTextureAlpha)) | - |
657 | && !engine->hasFeature(QPaintEngine::MaskedBrush)) | - |
658 | s->emulationSpecifier |= QPaintEngine::MaskedBrush; | - |
659 | else | - |
660 | s->emulationSpecifier &= ~QPaintEngine::MaskedBrush; | - |
661 | } | - |
662 | | - |
663 | if (s->state() & (QPaintEngine::DirtyHints | - |
664 | | QPaintEngine::DirtyOpacity | - |
665 | | QPaintEngine::DirtyBackgroundMode)) { | - |
666 | skip = false; | - |
667 | } | - |
668 | | - |
669 | if (skip) | - |
670 | return; | - |
671 | if (s->state() & QPaintEngine::DirtyTransform) { | - |
672 | xform = !s->matrix.isIdentity(); | - |
673 | complexXform = !s->matrix.isAffine(); | - |
674 | } else if (s->matrix.type() >= QTransform::TxTranslate) { | - |
675 | xform = true; | - |
676 | complexXform = !s->matrix.isAffine(); | - |
677 | } | - |
678 | | - |
679 | const bool brushXform = (s->brush.transform().type() != QTransform::TxNone); | - |
680 | const bool penXform = (s->pen.brush().transform().type() != QTransform::TxNone); | - |
681 | | - |
682 | const bool patternXform = patternBrush && (xform || brushXform || penXform); | - |
683 | | - |
684 | | - |
685 | if (alpha && !engine->hasFeature(QPaintEngine::AlphaBlend)) | - |
686 | s->emulationSpecifier |= QPaintEngine::AlphaBlend; | - |
687 | else | - |
688 | s->emulationSpecifier &= ~QPaintEngine::AlphaBlend; | - |
689 | | - |
690 | | - |
691 | if (linearGradient && !engine->hasFeature(QPaintEngine::LinearGradientFill)) | - |
692 | s->emulationSpecifier |= QPaintEngine::LinearGradientFill; | - |
693 | else | - |
694 | s->emulationSpecifier &= ~QPaintEngine::LinearGradientFill; | - |
695 | | - |
696 | | - |
697 | if (extendedRadialGradient || (radialGradient && !engine->hasFeature(QPaintEngine::RadialGradientFill))) | - |
698 | s->emulationSpecifier |= QPaintEngine::RadialGradientFill; | - |
699 | else | - |
700 | s->emulationSpecifier &= ~QPaintEngine::RadialGradientFill; | - |
701 | | - |
702 | | - |
703 | if (conicalGradient && !engine->hasFeature(QPaintEngine::ConicalGradientFill)) | - |
704 | s->emulationSpecifier |= QPaintEngine::ConicalGradientFill; | - |
705 | else | - |
706 | s->emulationSpecifier &= ~QPaintEngine::ConicalGradientFill; | - |
707 | | - |
708 | | - |
709 | if (patternBrush && !engine->hasFeature(QPaintEngine::PatternBrush)) | - |
710 | s->emulationSpecifier |= QPaintEngine::PatternBrush; | - |
711 | else | - |
712 | s->emulationSpecifier &= ~QPaintEngine::PatternBrush; | - |
713 | | - |
714 | | - |
715 | if (patternXform && !engine->hasFeature(QPaintEngine::PatternTransform)) | - |
716 | s->emulationSpecifier |= QPaintEngine::PatternTransform; | - |
717 | else | - |
718 | s->emulationSpecifier &= ~QPaintEngine::PatternTransform; | - |
719 | | - |
720 | | - |
721 | if (xform && !engine->hasFeature(QPaintEngine::PrimitiveTransform)) | - |
722 | s->emulationSpecifier |= QPaintEngine::PrimitiveTransform; | - |
723 | else | - |
724 | s->emulationSpecifier &= ~QPaintEngine::PrimitiveTransform; | - |
725 | | - |
726 | | - |
727 | if (complexXform && !engine->hasFeature(QPaintEngine::PerspectiveTransform)) | - |
728 | s->emulationSpecifier |= QPaintEngine::PerspectiveTransform; | - |
729 | else | - |
730 | s->emulationSpecifier &= ~QPaintEngine::PerspectiveTransform; | - |
731 | | - |
732 | | - |
733 | if (state->opacity != 1 && !engine->hasFeature(QPaintEngine::ConstantOpacity)) | - |
734 | s->emulationSpecifier |= QPaintEngine::ConstantOpacity; | - |
735 | else | - |
736 | s->emulationSpecifier &= ~QPaintEngine::ConstantOpacity; | - |
737 | | - |
738 | bool gradientStretch = false; | - |
739 | bool objectBoundingMode = false; | - |
740 | if (linearGradient || conicalGradient || radialGradient) { | - |
741 | QGradient::CoordinateMode brushMode = coordinateMode(s->brush); | - |
742 | QGradient::CoordinateMode penMode = coordinateMode(s->pen.brush()); | - |
743 | | - |
744 | gradientStretch |= (brushMode == QGradient::StretchToDeviceMode); | - |
745 | gradientStretch |= (penMode == QGradient::StretchToDeviceMode); | - |
746 | | - |
747 | objectBoundingMode |= (brushMode == QGradient::ObjectBoundingMode); | - |
748 | objectBoundingMode |= (penMode == QGradient::ObjectBoundingMode); | - |
749 | } | - |
750 | if (gradientStretch) | - |
751 | s->emulationSpecifier |= 0x10000000; | - |
752 | else | - |
753 | s->emulationSpecifier &= ~0x10000000; | - |
754 | | - |
755 | if (objectBoundingMode && !engine->hasFeature(QPaintEngine::ObjectBoundingModeGradients)) | - |
756 | s->emulationSpecifier |= QPaintEngine::ObjectBoundingModeGradients; | - |
757 | else | - |
758 | s->emulationSpecifier &= ~QPaintEngine::ObjectBoundingModeGradients; | - |
759 | | - |
760 | | - |
761 | if (s->bgMode == Qt::OpaqueMode && | - |
762 | (is_pen_transparent(s->pen) || is_brush_transparent(s->brush))) | - |
763 | s->emulationSpecifier |= 0x40000000; | - |
764 | else | - |
765 | s->emulationSpecifier &= ~0x40000000; | - |
766 | } | - |
767 | | - |
768 | void QPainterPrivate::updateStateImpl(QPainterState *newState) | - |
769 | { | - |
770 | | - |
771 | if (!engine->state) { | - |
772 | engine->state = newState; | - |
773 | engine->setDirty(QPaintEngine::AllDirty); | - |
774 | } | - |
775 | | - |
776 | if (engine->state->painter() != newState->painter) | - |
777 | | - |
778 | engine->setDirty(QPaintEngine::AllDirty); | - |
779 | | - |
780 | | - |
781 | else if (engine->state != newState) | - |
782 | newState->dirtyFlags |= QPaintEngine::DirtyFlags(static_cast<QPainterState *>(engine->state)->changeFlags); | - |
783 | | - |
784 | | - |
785 | else | - |
786 | newState->changeFlags |= newState->dirtyFlags; | - |
787 | | - |
788 | updateEmulationSpecifier(newState); | - |
789 | | - |
790 | | - |
791 | newState->dirtyFlags &= ~(QPaintEngine::DirtyBackgroundMode | - |
792 | | QPaintEngine::DirtyBackground); | - |
793 | | - |
794 | engine->state = newState; | - |
795 | engine->updateState(*newState); | - |
796 | engine->clearDirty(QPaintEngine::AllDirty); | - |
797 | | - |
798 | } | - |
799 | | - |
800 | void QPainterPrivate::updateState(QPainterState *newState) | - |
801 | { | - |
802 | | - |
803 | if (!newState) { | - |
804 | engine->state = newState; | - |
805 | } else if (newState->state() || engine->state!=newState) { | - |
806 | updateStateImpl(newState); | - |
807 | } | - |
808 | } | - |
809 | QPainter::QPainter() | - |
810 | : d_ptr(new QPainterPrivate(this)) | - |
811 | { | - |
812 | } | - |
813 | QPainter::QPainter(QPaintDevice *pd) | - |
814 | : d_ptr(0) | - |
815 | { | - |
816 | ((!(pd != 0)) ? qt_assert("pd != 0",__FILE__,14681473) : qt_noop()); | - |
817 | if (!QPainterPrivate::attachPainterPrivate(this, pd)) { | - |
818 | d_ptr.reset(new QPainterPrivate(this)); | - |
819 | begin(pd); | - |
820 | } | - |
821 | ((!(d_ptr)) ? qt_assert("d_ptr",__FILE__,14731478) : qt_noop()); | - |
822 | } | - |
823 | | - |
824 | | - |
825 | | - |
826 | | - |
827 | QPainter::~QPainter() | - |
828 | { | - |
829 | d_ptr->inDestructor = true; | - |
830 | if (true) { | - |
831 | if (isActive()) | - |
832 | end(); | - |
833 | else if (d_ptr->refcount > 1) | - |
834 | d_ptr->detachPainterPrivate(this); | - |
835 | } else { dead code: { } | - |
836 | | - |
837 | } dead code: { } | - |
838 | if (d_ptr) { | - |
839 | | - |
840 | ((!(d_ptr->inDestructor)) ? qt_assert("d_ptr->inDestructor",__FILE__,14921497) : qt_noop()); | - |
841 | d_ptr->inDestructor = false; | - |
842 | ((!(d_ptr->refcount == 1)) ? qt_assert("d_ptr->refcount == 1",__FILE__,14941499) : qt_noop()); | - |
843 | if (d_ptr->d_ptrs) | - |
844 | free(d_ptr->d_ptrs); | - |
845 | } | - |
846 | } | - |
847 | QPaintDevice *QPainter::device() const | - |
848 | { | - |
849 | const QPainterPrivate * const d = d_func(); | - |
850 | if (isActive() && d->engine->d_func()->currentClipDevice) | - |
851 | return d->engine->d_func()->currentClipDevice; | - |
852 | return d->original_device; | - |
853 | } | - |
854 | bool QPainter::isActive() const | - |
855 | { | - |
856 | const QPainterPrivate * const d = d_func(); | - |
857 | return d->engine; | - |
858 | } | - |
859 | void QPainter::initFrom(const QPaintDevice *device) | - |
860 | { | - |
861 | ((!(device)) ? qt_assert_x("QPainter::initFrom(const QPaintDevice *device)", "QPaintDevice cannot be 0",__FILE__,15381543) : qt_noop()); | - |
862 | QPainterPrivate * const d = d_func(); | - |
863 | if (!d->engine) { | - |
864 | QMessageLogger(__FILE__, 15411546, __PRETTY_FUNCTION__).warning("QPainter::initFrom: Painter not active, aborted"); | - |
865 | return; | - |
866 | } | - |
867 | | - |
868 | device->initPainter(this); | - |
869 | | - |
870 | if (d->extended) { | - |
871 | d->extended->penChanged(); | - |
872 | } else if (d->engine) { | - |
873 | d->engine->setDirty(QPaintEngine::DirtyPen); | - |
874 | d->engine->setDirty(QPaintEngine::DirtyBrush); | - |
875 | d->engine->setDirty(QPaintEngine::DirtyFont); | - |
876 | } | - |
877 | } | - |
878 | void QPainter::save() | - |
879 | { | - |
880 | | - |
881 | | - |
882 | | - |
883 | | - |
884 | QPainterPrivate * const d = d_func(); | - |
885 | if (!d->engine) { | - |
886 | QMessageLogger(__FILE__, 15731578, __PRETTY_FUNCTION__).warning("QPainter::save: Painter not active"); | - |
887 | return; | - |
888 | } | - |
889 | | - |
890 | if (d->extended) { | - |
891 | d->state = d->extended->createState(d->states.back()); | - |
892 | d->extended->setState(d->state); | - |
893 | } else { | - |
894 | d->updateState(d->state); | - |
895 | d->state = new QPainterState(d->states.back()); | - |
896 | d->engine->state = d->state; | - |
897 | } | - |
898 | d->states.push_back(d->state); | - |
899 | } | - |
900 | void QPainter::restore() | - |
901 | { | - |
902 | | - |
903 | | - |
904 | | - |
905 | | - |
906 | QPainterPrivate * const d = d_func(); | - |
907 | if (d->states.size()<=1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
908 | QMessageLogger(__FILE__, 16031608, __PRETTY_FUNCTION__).warning("QPainter::restore: Unbalanced save/restore"); | - |
909 | return; never executed: return; | 0 |
910 | } else if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
911 | QMessageLogger(__FILE__, 16061611, __PRETTY_FUNCTION__).warning("QPainter::restore: Painter not active"); | - |
912 | return; never executed: return; | 0 |
913 | } | - |
914 | | - |
915 | QPainterState *tmp = d->state; | - |
916 | d->states.pop_back(); | - |
917 | d->state = d->states.back(); | - |
918 | d->txinv = false; | - |
919 | | - |
920 | if (d->extendedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
921 | d->checkEmulation(); | - |
922 | d->extended->setState(d->state); | - |
923 | delete tmp; | - |
924 | return; never executed: return; | 0 |
925 | } | - |
926 | | - |
927 | | - |
928 | | - |
929 | if (!d->state->clipInfo.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
930 | && (TRUE | never evaluated | FALSE | never evaluated |
tmp->changeFlags & (QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipPath))TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
931 | | - |
932 | tmp->dirtyFlags = QPaintEngine::DirtyClipPath; | - |
933 | tmp->clipOperation = Qt::NoClip; | - |
934 | tmp->clipPath = QPainterPath(); | - |
935 | d->engine->updateState(*tmp); | - |
936 | | - |
937 | for (int i=0; i<d->state->clipInfo.size(); ++i) {const QPainterClipInfo &info =: qAsConst(d->state->clipInfo.at(i);)) { | - |
938 | tmp->matrix = info.matrix; | - |
939 | tmp->matrix *= d->state->redirectionMatrix; | - |
940 | tmp->clipOperation = info.operation; | - |
941 | if (info.clipType == QPainterClipInfo::RectClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
942 | tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform; | - |
943 | tmp->clipRegion = info.rect; | - |
944 | } never executed: end of block else if (info.clipType == QPainterClipInfo::RegionClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
945 | tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform; | - |
946 | tmp->clipRegion = info.region; | - |
947 | } never executed: end of block else { | 0 |
948 | tmp->dirtyFlags = QPaintEngine::DirtyClipPath | QPaintEngine::DirtyTransform; | - |
949 | tmp->clipPath = info.path; | - |
950 | } never executed: end of block | 0 |
951 | d->engine->updateState(*tmp); | - |
952 | } never executed: end of block | 0 |
953 | | - |
954 | | - |
955 | | - |
956 | d->state->dirtyFlags &= ~(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion); | - |
957 | tmp->changeFlags &= ~uint(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion); | - |
958 | tmp->changeFlags |= QPaintEngine::DirtyTransform; | - |
959 | } never executed: end of block | 0 |
960 | | - |
961 | d->updateState(d->state); | - |
962 | delete tmp; | - |
963 | } never executed: end of block | 0 |
964 | static inline void qt_cleanup_painter_state(QPainterPrivate *d) | - |
965 | { | - |
966 | d->states.clear(); | - |
967 | delete d->state; | - |
968 | d->state = 0; | - |
969 | d->engine = 0; | - |
970 | d->device = 0; | - |
971 | } | - |
972 | | - |
973 | bool QPainter::begin(QPaintDevice *pd) | - |
974 | { | - |
975 | ((!(pd)) ? qt_assert("pd",__FILE__,17001704) : qt_noop()); | - |
976 | | - |
977 | if (pd->painters > 0) { | - |
978 | QMessageLogger(__FILE__, 17031707, __PRETTY_FUNCTION__).warning("QPainter::begin: A paint device can only be painted by one painter at a time."); | - |
979 | return false; | - |
980 | } | - |
981 | | - |
982 | if (d_ptr->engine) { | - |
983 | QMessageLogger(__FILE__, 17081712, __PRETTY_FUNCTION__).warning("QPainter::begin: Painter already active"); | - |
984 | return false; | - |
985 | } | - |
986 | | - |
987 | if (QPainterPrivate::attachPainterPrivate(this, pd)) | - |
988 | return true; | - |
989 | | - |
990 | QPainterPrivate * const d = d_func(); | - |
991 | | - |
992 | d->helper_device = pd; | - |
993 | d->original_device = pd; | - |
994 | | - |
995 | QPoint redirectionOffset; | - |
996 | QPaintDevice *rpd = pd->redirected(&redirectionOffset); | - |
997 | if (rpd) | - |
998 | pd = rpd; | - |
999 | | - |
1000 | | - |
1001 | | - |
1002 | | - |
1003 | | - |
1004 | | - |
1005 | if (pd->devType() == QInternal::Pixmap) | - |
1006 | static_cast<QPixmap *>(pd)->detach(); | - |
1007 | else if (pd->devType() == QInternal::Image) | - |
1008 | static_cast<QImage *>(pd)->detach(); | - |
1009 | | - |
1010 | d->engine = pd->paintEngine(); | - |
1011 | | - |
1012 | if (!d->engine) { | - |
1013 | QMessageLogger(__FILE__, 17381742, __PRETTY_FUNCTION__).warning("QPainter::begin: Paint device returned engine == 0, type: %d", pd->devType()); | - |
1014 | return false; | - |
1015 | } | - |
1016 | | - |
1017 | d->device = pd; | - |
1018 | | - |
1019 | d->extended = d->engine->isExtended() ? static_cast<QPaintEngineEx *>(d->engine) : 0; | - |
1020 | if (d->emulationEngine) | - |
1021 | d->emulationEngine->real_engine = d->extended; | - |
1022 | | - |
1023 | | - |
1024 | ((!(!d->state)) ? qt_assert("!d->state",__FILE__,17491753) : qt_noop()); | - |
1025 | d->state = d->extended ? d->extended->createState(0) : new QPainterState; | - |
1026 | d->state->painter = this; | - |
1027 | d->states.push_back(d->state); | - |
1028 | | - |
1029 | d->state->redirectionMatrix.translate(-redirectionOffset.x(), -redirectionOffset.y()); | - |
1030 | d->state->brushOrigin = QPointF(); | - |
1031 | | - |
1032 | | - |
1033 | if (d->extended) | - |
1034 | d->extended->setState(d->state); | - |
1035 | else | - |
1036 | d->engine->state = d->state; | - |
1037 | | - |
1038 | switch (pd->devType()) { | - |
1039 | case QInternal::Pixmap: | - |
1040 | { | - |
1041 | QPixmap *pm = static_cast<QPixmap *>(pd); | - |
1042 | ((!(pm)) ? qt_assert("pm",__FILE__,17671771) : qt_noop()); | - |
1043 | if (pm->isNull()) { | - |
1044 | QMessageLogger(__FILE__, 17691773, __PRETTY_FUNCTION__).warning("QPainter::begin: Cannot paint on a null pixmap"); | - |
1045 | qt_cleanup_painter_state(d); | - |
1046 | return false; | - |
1047 | } | - |
1048 | | - |
1049 | if (pm->depth() == 1) { | - |
1050 | d->state->pen = QPen(Qt::color1); | - |
1051 | d->state->brush = QBrush(Qt::color0); | - |
1052 | } | - |
1053 | break; | - |
1054 | } | - |
1055 | case QInternal::Image: | - |
1056 | { | - |
1057 | QImage *img = static_cast<QImage *>(pd); | - |
1058 | ((!(img)) ? qt_assert("img",__FILE__,17831787) : qt_noop()); | - |
1059 | if (img->isNull()) { | - |
1060 | QMessageLogger(__FILE__, 17851789, __PRETTY_FUNCTION__).warning("QPainter::begin: Cannot paint on a null image"); | - |
1061 | qt_cleanup_painter_state(d); | - |
1062 | return false; | - |
1063 | } else if (img->format() == QImage::Format_Indexed8) { | - |
1064 | | - |
1065 | QMessageLogger(__FILE__, 17901794, __PRETTY_FUNCTION__).warning("QPainter::begin: Cannot paint on an image with the QImage::Format_Indexed8 format"); | - |
1066 | qt_cleanup_painter_state(d); | - |
1067 | return false; | - |
1068 | } | - |
1069 | if (img->depth() == 1) { | - |
1070 | d->state->pen = QPen(Qt::color1); | - |
1071 | d->state->brush = QBrush(Qt::color0); | - |
1072 | } | - |
1073 | break; | - |
1074 | } | - |
1075 | default: | - |
1076 | break; | - |
1077 | } | - |
1078 | if (d->state->ww == 0) | - |
1079 | d->state->ww = d->state->wh = d->state->vw = d->state->vh = 1024; | - |
1080 | | - |
1081 | d->engine->setPaintDevice(pd); | - |
1082 | | - |
1083 | bool begun = d->engine->begin(pd); | - |
1084 | if (!begun) { | - |
1085 | QMessageLogger(__FILE__, 18101814, __PRETTY_FUNCTION__).warning("QPainter::begin(): Returned false"); | - |
1086 | if (d->engine->isActive()) { | - |
1087 | end(); | - |
1088 | } else { | - |
1089 | qt_cleanup_painter_state(d); | - |
1090 | } | - |
1091 | return false; | - |
1092 | } else { | - |
1093 | d->engine->setActive(begun); | - |
1094 | } | - |
1095 | | - |
1096 | | - |
1097 | | - |
1098 | if (d->original_device->devType() == QInternal::Widget) { | - |
1099 | initFrom(d->original_device); | - |
1100 | } else { | - |
1101 | d->state->layoutDirection = Qt::LayoutDirectionAuto; | - |
1102 | | - |
1103 | d->state->deviceFont = d->state->font = QFont(d->state->deviceFont, device()); | - |
1104 | } | - |
1105 | | - |
1106 | QRect systemRect = d->engine->systemRect(); | - |
1107 | if (!systemRect.isEmpty()) { | - |
1108 | d->state->ww = d->state->vw = systemRect.width(); | - |
1109 | d->state->wh = d->state->vh = systemRect.height(); | - |
1110 | } else { | - |
1111 | d->state->ww = d->state->vw = pd->metric(QPaintDevice::PdmWidth); | - |
1112 | d->state->wh = d->state->vh = pd->metric(QPaintDevice::PdmHeight); | - |
1113 | } | - |
1114 | | - |
1115 | const QPoint coordinateOffset = d->engine->coordinateOffset(); | - |
1116 | d->state->redirectionMatrix.translate(-coordinateOffset.x(), -coordinateOffset.y()); | - |
1117 | | - |
1118 | ((!(d->engine->isActive())) ? qt_assert("d->engine->isActive()",__FILE__,18431847) : qt_noop()); | - |
1119 | | - |
1120 | if (!d->state->redirectionMatrix.isIdentity() || d->effectiveDevicePixelRatio() > 1) | - |
1121 | d->updateMatrix(); | - |
1122 | | - |
1123 | ((!(d->engine->isActive())) ? qt_assert("d->engine->isActive()",__FILE__,18481852) : qt_noop()); | - |
1124 | d->state->renderHints = QPainter::TextAntialiasing; | - |
1125 | ++d->device->painters; | - |
1126 | | - |
1127 | d->state->emulationSpecifier = 0; | - |
1128 | | - |
1129 | return true; | - |
1130 | } | - |
1131 | bool QPainter::end() | - |
1132 | { | - |
1133 | | - |
1134 | | - |
1135 | | - |
1136 | | - |
1137 | QPainterPrivate * const d = d_func(); | - |
1138 | | - |
1139 | if (!d->engine) { | - |
1140 | QMessageLogger(__FILE__, 18761880, __PRETTY_FUNCTION__).warning("QPainter::end: Painter not active, aborted"); | - |
1141 | qt_cleanup_painter_state(d); | - |
1142 | return false; | - |
1143 | } | - |
1144 | | - |
1145 | if (d->refcount > 1) { | - |
1146 | d->detachPainterPrivate(this); | - |
1147 | return true; | - |
1148 | } | - |
1149 | | - |
1150 | bool ended = true; | - |
1151 | | - |
1152 | if (d->engine->isActive()) { | - |
1153 | ended = d->engine->end(); | - |
1154 | d->updateState(0); | - |
1155 | | - |
1156 | --d->device->painters; | - |
1157 | if (d->device->painters == 0) { | - |
1158 | d->engine->setPaintDevice(0); | - |
1159 | d->engine->setActive(false); | - |
1160 | } | - |
1161 | } | - |
1162 | | - |
1163 | if (d->states.size() > 1) { | - |
1164 | QMessageLogger(__FILE__, 19001904, __PRETTY_FUNCTION__).warning("QPainter::end: Painter ended with %d saved states", | - |
1165 | d->states.size()); | - |
1166 | } | - |
1167 | | - |
1168 | if (d->engine->autoDestruct()) { | - |
1169 | delete d->engine; | - |
1170 | } | - |
1171 | | - |
1172 | if (d->emulationEngine) { | - |
1173 | delete d->emulationEngine; | - |
1174 | d->emulationEngine = 0; | - |
1175 | } | - |
1176 | | - |
1177 | if (d->extended) { | - |
1178 | d->extended = 0; | - |
1179 | } | - |
1180 | | - |
1181 | qt_cleanup_painter_state(d); | - |
1182 | | - |
1183 | return ended; | - |
1184 | } | - |
1185 | QPaintEngine *QPainter::paintEngine() const | - |
1186 | { | - |
1187 | const QPainterPrivate * const d = d_func(); | - |
1188 | return d->engine; | - |
1189 | } | - |
1190 | void QPainter::beginNativePainting() | - |
1191 | { | - |
1192 | QPainterPrivate * const d = d_func(); | - |
1193 | if (!d->engine) { | - |
1194 | QMessageLogger(__FILE__, 19711975, __PRETTY_FUNCTION__).warning("QPainter::beginNativePainting: Painter not active"); | - |
1195 | return; | - |
1196 | } | - |
1197 | | - |
1198 | if (d->extended) | - |
1199 | d->extended->beginNativePainting(); | - |
1200 | } | - |
1201 | void QPainter::endNativePainting() | - |
1202 | { | - |
1203 | const QPainterPrivate * const d = d_func(); | - |
1204 | if (!d->engine) { | - |
1205 | QMessageLogger(__FILE__, 19921996, __PRETTY_FUNCTION__).warning("QPainter::beginNativePainting: Painter not active"); | - |
1206 | return; | - |
1207 | } | - |
1208 | | - |
1209 | if (d->extended) | - |
1210 | d->extended->endNativePainting(); | - |
1211 | else | - |
1212 | d->engine->syncState(); | - |
1213 | } | - |
1214 | QFontMetrics QPainter::fontMetrics() const | - |
1215 | { | - |
1216 | const QPainterPrivate * const d = d_func(); | - |
1217 | if (!d->engine) { | - |
1218 | QMessageLogger(__FILE__, 20132017, __PRETTY_FUNCTION__).warning("QPainter::fontMetrics: Painter not active"); | - |
1219 | return QFontMetrics(QFont()); | - |
1220 | } | - |
1221 | return QFontMetrics(d->state->font); | - |
1222 | } | - |
1223 | QFontInfo QPainter::fontInfo() const | - |
1224 | { | - |
1225 | const QPainterPrivate * const d = d_func(); | - |
1226 | if (!d->engine) { | - |
1227 | QMessageLogger(__FILE__, 20312035, __PRETTY_FUNCTION__).warning("QPainter::fontInfo: Painter not active"); | - |
1228 | return QFontInfo(QFont()); | - |
1229 | } | - |
1230 | return QFontInfo(d->state->font); | - |
1231 | } | - |
1232 | qreal QPainter::opacity() const | - |
1233 | { | - |
1234 | const QPainterPrivate * const d = d_func(); | - |
1235 | if (!d->engine) { | - |
1236 | QMessageLogger(__FILE__, 20482052, __PRETTY_FUNCTION__).warning("QPainter::opacity: Painter not active"); | - |
1237 | return 1.0; | - |
1238 | } | - |
1239 | return d->state->opacity; | - |
1240 | } | - |
1241 | void QPainter::setOpacity(qreal opacity) | - |
1242 | { | - |
1243 | QPainterPrivate * const d = d_func(); | - |
1244 | | - |
1245 | if (!d->engine) { | - |
1246 | QMessageLogger(__FILE__, 20702074, __PRETTY_FUNCTION__).warning("QPainter::setOpacity: Painter not active"); | - |
1247 | return; | - |
1248 | } | - |
1249 | | - |
1250 | opacity = qMin(qreal(1), qMax(qreal(0), opacity)); | - |
1251 | | - |
1252 | if (opacity == d->state->opacity) | - |
1253 | return; | - |
1254 | | - |
1255 | d->state->opacity = opacity; | - |
1256 | | - |
1257 | if (d->extended) | - |
1258 | d->extended->opacityChanged(); | - |
1259 | else | - |
1260 | d->state->dirtyFlags |= QPaintEngine::DirtyOpacity; | - |
1261 | } | - |
1262 | QPoint QPainter::brushOrigin() const | - |
1263 | { | - |
1264 | const QPainterPrivate * const d = d_func(); | - |
1265 | if (!d->engine) { | - |
1266 | QMessageLogger(__FILE__, 20982102, __PRETTY_FUNCTION__).warning("QPainter::brushOrigin: Painter not active"); | - |
1267 | return QPoint(); | - |
1268 | } | - |
1269 | return QPointF(d->state->brushOrigin).toPoint(); | - |
1270 | } | - |
1271 | void QPainter::setBrushOrigin(const QPointF &p) | - |
1272 | { | - |
1273 | QPainterPrivate * const d = d_func(); | - |
1274 | | - |
1275 | | - |
1276 | | - |
1277 | | - |
1278 | | - |
1279 | if (!d->engine) { | - |
1280 | QMessageLogger(__FILE__, 21312135, __PRETTY_FUNCTION__).warning("QPainter::setBrushOrigin: Painter not active"); | - |
1281 | return; | - |
1282 | } | - |
1283 | | - |
1284 | d->state->brushOrigin = p; | - |
1285 | | - |
1286 | if (d->extended) { | - |
1287 | d->extended->brushOriginChanged(); | - |
1288 | return; | - |
1289 | } | - |
1290 | | - |
1291 | d->state->dirtyFlags |= QPaintEngine::DirtyBrushOrigin; | - |
1292 | } | - |
1293 | void QPainter::setCompositionMode(CompositionMode mode) | - |
1294 | { | - |
1295 | QPainterPrivate * const d = d_func(); | - |
1296 | if (!d->engine) { | - |
1297 | QMessageLogger(__FILE__, 23572361, __PRETTY_FUNCTION__).warning("QPainter::setCompositionMode: Painter not active"); | - |
1298 | return; | - |
1299 | } | - |
1300 | if (d->state->composition_mode == mode) | - |
1301 | return; | - |
1302 | if (d->extended) { | - |
1303 | d->state->composition_mode = mode; | - |
1304 | d->extended->compositionModeChanged(); | - |
1305 | return; | - |
1306 | } | - |
1307 | | - |
1308 | if (mode >= QPainter::RasterOp_SourceOrDestination) { | - |
1309 | if (!d->engine->hasFeature(QPaintEngine::RasterOpModes)) { | - |
1310 | QMessageLogger(__FILE__, 23702374, __PRETTY_FUNCTION__).warning("QPainter::setCompositionMode: " | - |
1311 | "Raster operation modes not supported on device"); | - |
1312 | return; | - |
1313 | } | - |
1314 | } else if (mode >= QPainter::CompositionMode_Plus) { | - |
1315 | if (!d->engine->hasFeature(QPaintEngine::BlendModes)) { | - |
1316 | QMessageLogger(__FILE__, 23762380, __PRETTY_FUNCTION__).warning("QPainter::setCompositionMode: " | - |
1317 | "Blend modes not supported on device"); | - |
1318 | return; | - |
1319 | } | - |
1320 | } else if (!d->engine->hasFeature(QPaintEngine::PorterDuff)) { | - |
1321 | if (mode != CompositionMode_Source && mode != CompositionMode_SourceOver) { | - |
1322 | QMessageLogger(__FILE__, 23822386, __PRETTY_FUNCTION__).warning("QPainter::setCompositionMode: " | - |
1323 | "PorterDuff modes not supported on device"); | - |
1324 | return; | - |
1325 | } | - |
1326 | } | - |
1327 | | - |
1328 | d->state->composition_mode = mode; | - |
1329 | d->state->dirtyFlags |= QPaintEngine::DirtyCompositionMode; | - |
1330 | } | - |
1331 | | - |
1332 | | - |
1333 | | - |
1334 | | - |
1335 | | - |
1336 | | - |
1337 | QPainter::CompositionMode QPainter::compositionMode() const | - |
1338 | { | - |
1339 | const QPainterPrivate * const d = d_func(); | - |
1340 | if (!d->engine) { | - |
1341 | QMessageLogger(__FILE__, 24012405, __PRETTY_FUNCTION__).warning("QPainter::compositionMode: Painter not active"); | - |
1342 | return QPainter::CompositionMode_SourceOver; | - |
1343 | } | - |
1344 | return d->state->composition_mode; | - |
1345 | } | - |
1346 | | - |
1347 | | - |
1348 | | - |
1349 | | - |
1350 | | - |
1351 | | - |
1352 | | - |
1353 | const QBrush &QPainter::background() const | - |
1354 | { | - |
1355 | const QPainterPrivate * const d = d_func(); | - |
1356 | if (!d->engine) { | - |
1357 | QMessageLogger(__FILE__, 24172421, __PRETTY_FUNCTION__).warning("QPainter::background: Painter not active"); | - |
1358 | return d->fakeState()->brush; | - |
1359 | } | - |
1360 | return d->state->bgBrush; | - |
1361 | } | - |
1362 | bool QPainter::hasClipping() const | - |
1363 | { | - |
1364 | const QPainterPrivate * const d = d_func(); | - |
1365 | if (!d->engine) { | - |
1366 | QMessageLogger(__FILE__, 24342438, __PRETTY_FUNCTION__).warning("QPainter::hasClipping: Painter not active"); | - |
1367 | return false; | - |
1368 | } | - |
1369 | return d->state->clipEnabled && d->state->clipOperation != Qt::NoClip; | - |
1370 | } | - |
1371 | void QPainter::setClipping(bool enable) | - |
1372 | { | - |
1373 | QPainterPrivate * const d = d_func(); | - |
1374 | | - |
1375 | | - |
1376 | | - |
1377 | | - |
1378 | | - |
1379 | | - |
1380 | if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1381 | QMessageLogger(__FILE__, 24582462, __PRETTY_FUNCTION__).warning("QPainter::setClipping: Painter not active, state will be reset by begin"); | - |
1382 | return; never executed: return; | 0 |
1383 | } | - |
1384 | | - |
1385 | if (hasClipping() == enableTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1386 | return; never executed: return; | 0 |
1387 | | - |
1388 | | - |
1389 | if (enableTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1390 | && (d->state->clipInfo.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
|| d->state->clipInfo.lastconstLast().operation == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
1391 | return; never executed: return; | 0 |
1392 | d->state->clipEnabled = enable; | - |
1393 | | - |
1394 | if (d->extendedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1395 | d->extended->clipEnabledChanged(); | - |
1396 | return; never executed: return; | 0 |
1397 | } | - |
1398 | | - |
1399 | d->state->dirtyFlags |= QPaintEngine::DirtyClipEnabled; | - |
1400 | d->updateState(d->state); | - |
1401 | } never executed: end of block | 0 |
1402 | QRegion QPainter::clipRegion() const | - |
1403 | { | - |
1404 | const QPainterPrivate * const d = d_func(); | - |
1405 | if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1406 | QMessageLogger(__FILE__, 24972501, __PRETTY_FUNCTION__).warning("QPainter::clipRegion: Painter not active"); | - |
1407 | return never executed: return QRegion(); QRegion();never executed: return QRegion(); | 0 |
1408 | } | - |
1409 | | - |
1410 | QRegion region; | - |
1411 | bool lastWasNothing = true; | - |
1412 | | - |
1413 | if (!d->txinvTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1414 | const_cast< never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); QPainter *>(this)->d_ptr->updateInvMatrix();never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); | 0 |
1415 | | - |
1416 | | - |
1417 | for (int i=0; i<d->state->clipInfo.size(); ++i) {const QPainterClipInfo &info =: qAsConst(d->state->clipInfo.at(i);)) { | - |
1418 | switch (info.clipType) { | - |
1419 | | - |
1420 | case never executed: case QPainterClipInfo::RegionClip: QPainterClipInfo::RegionClip:never executed: case QPainterClipInfo::RegionClip: { | 0 |
1421 | QTransform matrix = (info.matrix * d->invMatrix); | - |
1422 | if (lastWasNothingTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1423 | region = info.region * matrix; | - |
1424 | lastWasNothing = false; | - |
1425 | continue; never executed: continue; | 0 |
1426 | } | - |
1427 | if (info.operation == Qt::IntersectClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1428 | region &= info.region * matrix; never executed: region &= info.region * matrix; | 0 |
1429 | else if (info.operation == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1430 | lastWasNothing = true; | - |
1431 | region = QRegion(); | - |
1432 | } never executed: end of block else | 0 |
1433 | region = info.region * matrix; never executed: region = info.region * matrix; | 0 |
1434 | break; never executed: break; | 0 |
1435 | } | - |
1436 | | - |
1437 | case never executed: case QPainterClipInfo::PathClip: QPainterClipInfo::PathClip:never executed: case QPainterClipInfo::PathClip: { | 0 |
1438 | QTransform matrix = (info.matrix * d->invMatrix); | - |
1439 | if (lastWasNothingTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1440 | region = QRegion((info.path * matrix).toFillPolygon().toPolygon(), | - |
1441 | info.path.fillRule()); | - |
1442 | lastWasNothing = false; | - |
1443 | continue; never executed: continue; | 0 |
1444 | } | - |
1445 | if (info.operation == Qt::IntersectClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1446 | region &= QRegion((info.path * matrix).toFillPolygon().toPolygon(), | - |
1447 | info.path.fillRule()); | - |
1448 | } never executed: end of block else if (info.operation == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1449 | lastWasNothing = true; | - |
1450 | region = QRegion(); | - |
1451 | } never executed: end of block else { | 0 |
1452 | region = QRegion((info.path * matrix).toFillPolygon().toPolygon(), | - |
1453 | info.path.fillRule()); | - |
1454 | } never executed: end of block | 0 |
1455 | break; never executed: break; | 0 |
1456 | } | - |
1457 | | - |
1458 | case never executed: case QPainterClipInfo::RectClip: QPainterClipInfo::RectClip:never executed: case QPainterClipInfo::RectClip: { | 0 |
1459 | QTransform matrix = (info.matrix * d->invMatrix); | - |
1460 | if (lastWasNothingTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1461 | region = QRegion(info.rect) * matrix; | - |
1462 | lastWasNothing = false; | - |
1463 | continue; never executed: continue; | 0 |
1464 | } | - |
1465 | if (info.operation == Qt::IntersectClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1466 | | - |
1467 | if (matrix.type() <= QTransform::TxScaleTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1468 | region &= matrix.mapRect(info.rect); never executed: region &= matrix.mapRect(info.rect); | 0 |
1469 | else | - |
1470 | region &= matrix.map(QRegion(info.rect)); never executed: region &= matrix.map(QRegion(info.rect)); | 0 |
1471 | } else if (info.operation == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1472 | lastWasNothing = true; | - |
1473 | region = QRegion(); | - |
1474 | } never executed: end of block else { | 0 |
1475 | region = QRegion(info.rect) * matrix; | - |
1476 | } never executed: end of block | 0 |
1477 | break; never executed: break; | 0 |
1478 | } | - |
1479 | | - |
1480 | case never executed: case QPainterClipInfo::RectFClip: QPainterClipInfo::RectFClip:never executed: case QPainterClipInfo::RectFClip: { | 0 |
1481 | QTransform matrix = (info.matrix * d->invMatrix); | - |
1482 | if (lastWasNothingTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1483 | region = QRegion(info.rectf.toRect()) * matrix; | - |
1484 | lastWasNothing = false; | - |
1485 | continue; never executed: continue; | 0 |
1486 | } | - |
1487 | if (info.operation == Qt::IntersectClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1488 | | - |
1489 | if (matrix.type() <= QTransform::TxScaleTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1490 | region &= matrix.mapRect(info.rectf.toRect()); never executed: region &= matrix.mapRect(info.rectf.toRect()); | 0 |
1491 | else | - |
1492 | region &= matrix.map(QRegion(info.rectf.toRect())); never executed: region &= matrix.map(QRegion(info.rectf.toRect())); | 0 |
1493 | } else if (info.operation == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1494 | lastWasNothing = true; | - |
1495 | region = QRegion(); | - |
1496 | } never executed: end of block else { | 0 |
1497 | region = QRegion(info.rectf.toRect()) * matrix; | - |
1498 | } never executed: end of block | 0 |
1499 | break; never executed: break; | 0 |
1500 | } | - |
1501 | } | - |
1502 | } never executed: end of block | 0 |
1503 | | - |
1504 | return never executed: return region; region;never executed: return region; | 0 |
1505 | } | - |
1506 | | - |
1507 | extern QPainterPath qt_regionToPath(const QRegion ®ion); | - |
1508 | QPainterPath QPainter::clipPath() const | - |
1509 | { | - |
1510 | const QPainterPrivate * const d = d_func(); | - |
1511 | | - |
1512 | | - |
1513 | | - |
1514 | if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1515 | QMessageLogger(__FILE__, 26182621, __PRETTY_FUNCTION__).warning("QPainter::clipPath: Painter not active"); | - |
1516 | return never executed: return QPainterPath(); QPainterPath();never executed: return QPainterPath(); | 0 |
1517 | } | - |
1518 | | - |
1519 | | - |
1520 | if (d->state->clipInfo.size() == 0)isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1521 | return never executed: return QPainterPath(); QPainterPath();never executed: return QPainterPath(); | 0 |
1522 | } else { | - |
1523 | | - |
1524 | | - |
1525 | if (!d->txinvTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1526 | const_cast< never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); QPainter *>(this)->d_ptr->updateInvMatrix();never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); | 0 |
1527 | | - |
1528 | | - |
1529 | if (d->state->clipInfo.size() == 1TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1530 | && d->state->clipInfo.at(0).clipType == QPainterClipInfo::PathClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1531 | QTransform matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix); | - |
1532 | return never executed: return d->state->clipInfo.at(0).path * matrix; d->state->clipInfo.at(0).path * matrix;never executed: return d->state->clipInfo.at(0).path * matrix; | 0 |
1533 | | - |
1534 | } else if (d->state->clipInfo.size() == 1TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1535 | && d->state->clipInfo.at(0).clipType == QPainterClipInfo::RectClipTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1536 | QTransform matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix); | - |
1537 | QPainterPath path; | - |
1538 | path.addRect(d->state->clipInfo.at(0).rect); | - |
1539 | return never executed: return path * matrix; path * matrix;never executed: return path * matrix; | 0 |
1540 | } else { | - |
1541 | | - |
1542 | return never executed: return qt_regionToPath(clipRegion()); qt_regionToPath(clipRegion());never executed: return qt_regionToPath(clipRegion()); | 0 |
1543 | } | - |
1544 | } | - |
1545 | } | - |
1546 | QRectF QPainter::clipBoundingRect() const | - |
1547 | { | - |
1548 | const QPainterPrivate * const d = d_func(); | - |
1549 | | - |
1550 | if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1551 | QMessageLogger(__FILE__, 26672670, __PRETTY_FUNCTION__).warning("QPainter::clipBoundingRect: Painter not active"); | - |
1552 | return never executed: return QRectF(); QRectF();never executed: return QRectF(); | 0 |
1553 | } | - |
1554 | | - |
1555 | | - |
1556 | | - |
1557 | | - |
1558 | QRectF bounds; | - |
1559 | for (int ibool first = 0true; | - |
1560 | i<for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo.size(); ++i))) { | - |
1561 | QRectF r; | - |
1562 | | - |
1563 | const QPainterClipInfo &info = d->state->clipInfo.at(i);if (info.clipType == QPainterClipInfo::RectClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1564 | r = info.rect; never executed: r = info.rect; | 0 |
1565 | else if (info.clipType == QPainterClipInfo::RectFClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1566 | r = info.rectf; never executed: r = info.rectf; | 0 |
1567 | else if (info.clipType == QPainterClipInfo::RegionClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1568 | r = info.region.boundingRect(); never executed: r = info.region.boundingRect(); | 0 |
1569 | else | - |
1570 | r = info.path.boundingRect(); never executed: r = info.path.boundingRect(); | 0 |
1571 | | - |
1572 | r = info.matrix.mapRect(r); | - |
1573 | | - |
1574 | if (i == 0firstTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1575 | bounds = r; never executed: bounds = r; | 0 |
1576 | else if (info.operation == Qt::IntersectClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1577 | bounds &= r; never executed: bounds &= r; | 0 |
1578 | first = false; | - |
1579 | } never executed: end of block | 0 |
1580 | | - |
1581 | | - |
1582 | | - |
1583 | | - |
1584 | if (!d->txinvTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1585 | const_cast< never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); QPainter *>(this)->d_ptr->updateInvMatrix();never executed: const_cast<QPainter *>(this)->d_ptr->updateInvMatrix(); | 0 |
1586 | | - |
1587 | return never executed: return d->invMatrix.mapRect(bounds); d->invMatrix.mapRect(bounds);never executed: return d->invMatrix.mapRect(bounds); | 0 |
1588 | } | - |
1589 | void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op) | - |
1590 | { | - |
1591 | QPainterPrivate * const d = d_func(); | - |
1592 | | - |
1593 | if (d->extendedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1594 | if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1595 | QMessageLogger(__FILE__, 27232727, __PRETTY_FUNCTION__).warning("QPainter::setClipRect: Painter not active"); | - |
1596 | return; never executed: return; | 0 |
1597 | } | - |
1598 | bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture); | - |
1599 | if (simplifyClipOpTRUE | never evaluated | FALSE | never evaluated |
&& (!d->state->clipEnabledTRUE | never evaluated | FALSE | never evaluated |
&& op != Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
1600 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
1601 | | - |
1602 | qreal right = rect.x() + rect.width(); | - |
1603 | qreal bottom = rect.y() + rect.height(); | - |
1604 | qreal pts[] = { rect.x(), rect.y(), | - |
1605 | right, rect.y(), | - |
1606 | right, bottom, | - |
1607 | rect.x(), bottom }; | - |
1608 | QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); | - |
1609 | d->state->clipEnabled = true; | - |
1610 | d->extended->clip(vp, op); | - |
1611 | if (op == Qt::ReplaceClipTRUE | never evaluated | FALSE | never evaluated |
|| op == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1612 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
1613 | d->state->clipInfo<<.append(QPainterClipInfo(rect, op, d->state->matrix);)); | - |
1614 | d->state->clipOperation = op; | - |
1615 | return; never executed: return; | 0 |
1616 | } | - |
1617 | | - |
1618 | if (qreal(int(rect.top())) == rect.top()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1619 | && qreal(int(rect.bottom())) == rect.bottom()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1620 | && qreal(int(rect.left())) == rect.left()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1621 | && qreal(int(rect.right())) == rect.right()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1622 | { | - |
1623 | setClipRect(rect.toRect(), op); | - |
1624 | return; never executed: return; | 0 |
1625 | } | - |
1626 | | - |
1627 | if (rect.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1628 | setClipRegion(QRegion(), op); | - |
1629 | return; never executed: return; | 0 |
1630 | } | - |
1631 | | - |
1632 | QPainterPath path; | - |
1633 | path.addRect(rect); | - |
1634 | setClipPath(path, op); | - |
1635 | } never executed: end of block | 0 |
1636 | void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) | - |
1637 | { | - |
1638 | QPainterPrivate * const d = d_func(); | - |
1639 | | - |
1640 | if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1641 | QMessageLogger(__FILE__, 27772781, __PRETTY_FUNCTION__).warning("QPainter::setClipRect: Painter not active"); | - |
1642 | return; never executed: return; | 0 |
1643 | } | - |
1644 | bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture); | - |
1645 | | - |
1646 | if (simplifyClipOpTRUE | never evaluated | FALSE | never evaluated |
&& (!d->state->clipEnabledTRUE | never evaluated | FALSE | never evaluated |
&& op != Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
1647 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
1648 | | - |
1649 | if (d->extendedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1650 | d->state->clipEnabled = true; | - |
1651 | d->extended->clip(rect, op); | - |
1652 | if (op == Qt::ReplaceClipTRUE | never evaluated | FALSE | never evaluated |
|| op == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1653 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
1654 | d->state->clipInfo<<.append(QPainterClipInfo(rect, op, d->state->matrix);)); | - |
1655 | d->state->clipOperation = op; | - |
1656 | return; never executed: return; | 0 |
1657 | } | - |
1658 | | - |
1659 | if (simplifyClipOpTRUE | never evaluated | FALSE | never evaluated |
&& d->state->clipOperation == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
&& op == Qt::IntersectClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1660 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
1661 | | - |
1662 | d->state->clipRegion = rect; | - |
1663 | d->state->clipOperation = op; | - |
1664 | if (op == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
|| op == Qt::ReplaceClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1665 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
1666 | d->state->clipInfo<<.append(QPainterClipInfo(rect, op, d->state->matrix);)); | - |
1667 | d->state->clipEnabled = true; | - |
1668 | d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled; | - |
1669 | d->updateState(d->state); | - |
1670 | } never executed: end of block | 0 |
1671 | void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) | - |
1672 | { | - |
1673 | QPainterPrivate * const d = d_func(); | - |
1674 | | - |
1675 | | - |
1676 | | - |
1677 | | - |
1678 | | - |
1679 | | - |
1680 | if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1681 | QMessageLogger(__FILE__, 28362840, __PRETTY_FUNCTION__).warning("QPainter::setClipRegion: Painter not active"); | - |
1682 | return; never executed: return; | 0 |
1683 | } | - |
1684 | bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture); | - |
1685 | | - |
1686 | if (simplifyClipOpTRUE | never evaluated | FALSE | never evaluated |
&& (!d->state->clipEnabledTRUE | never evaluated | FALSE | never evaluated |
&& op != Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
1687 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
1688 | | - |
1689 | if (d->extendedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1690 | d->state->clipEnabled = true; | - |
1691 | d->extended->clip(r, op); | - |
1692 | if (op == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
|| op == Qt::ReplaceClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1693 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
1694 | d->state->clipInfo<<.append(QPainterClipInfo(r, op, d->state->matrix);)); | - |
1695 | d->state->clipOperation = op; | - |
1696 | return; never executed: return; | 0 |
1697 | } | - |
1698 | | - |
1699 | if (simplifyClipOpTRUE | never evaluated | FALSE | never evaluated |
&& d->state->clipOperation == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
&& op == Qt::IntersectClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1700 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
1701 | | - |
1702 | d->state->clipRegion = r; | - |
1703 | d->state->clipOperation = op; | - |
1704 | if (op == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
|| op == Qt::ReplaceClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1705 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
1706 | d->state->clipInfo<<.append(QPainterClipInfo(r, op, d->state->matrix);)); | - |
1707 | d->state->clipEnabled = true; | - |
1708 | d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled; | - |
1709 | d->updateState(d->state); | - |
1710 | } never executed: end of block | 0 |
1711 | void QPainter::setWorldMatrix(const QMatrix &matrix, bool combine) | - |
1712 | { | - |
1713 | setWorldTransform(QTransform(matrix), combine); | - |
1714 | } | - |
1715 | const QMatrix &QPainter::worldMatrix() const | - |
1716 | { | - |
1717 | const QPainterPrivate * const d = d_func(); | - |
1718 | if (!d->engine) { | - |
1719 | QMessageLogger(__FILE__, 29322936, __PRETTY_FUNCTION__).warning("QPainter::worldMatrix: Painter not active"); | - |
1720 | return d->fakeState()->transform.toAffine(); | - |
1721 | } | - |
1722 | return d->state->worldMatrix.toAffine(); | - |
1723 | } | - |
1724 | void QPainter::setMatrix(const QMatrix &matrix, bool combine) | - |
1725 | { | - |
1726 | setWorldTransform(QTransform(matrix), combine); | - |
1727 | } | - |
1728 | const QMatrix &QPainter::matrix() const | - |
1729 | { | - |
1730 | return worldMatrix(); | - |
1731 | } | - |
1732 | QMatrix QPainter::combinedMatrix() const | - |
1733 | { | - |
1734 | return combinedTransform().toAffine(); | - |
1735 | } | - |
1736 | const QMatrix &QPainter::deviceMatrix() const | - |
1737 | { | - |
1738 | const QPainterPrivate * const d = d_func(); | - |
1739 | if (!d->engine) { | - |
1740 | QMessageLogger(__FILE__, 30063010, __PRETTY_FUNCTION__).warning("QPainter::deviceMatrix: Painter not active"); | - |
1741 | return d->fakeState()->transform.toAffine(); | - |
1742 | } | - |
1743 | return d->state->matrix.toAffine(); | - |
1744 | } | - |
1745 | void QPainter::resetMatrix() | - |
1746 | { | - |
1747 | resetTransform(); | - |
1748 | } | - |
1749 | void QPainter::setWorldMatrixEnabled(bool enable) | - |
1750 | { | - |
1751 | QPainterPrivate * const d = d_func(); | - |
1752 | | - |
1753 | | - |
1754 | | - |
1755 | | - |
1756 | | - |
1757 | if (!d->engine) { | - |
1758 | QMessageLogger(__FILE__, 30523056, __PRETTY_FUNCTION__).warning("QPainter::setMatrixEnabled: Painter not active"); | - |
1759 | return; | - |
1760 | } | - |
1761 | if (enable == d->state->WxF) | - |
1762 | return; | - |
1763 | | - |
1764 | d->state->WxF = enable; | - |
1765 | d->updateMatrix(); | - |
1766 | } | - |
1767 | bool QPainter::worldMatrixEnabled() const | - |
1768 | { | - |
1769 | const QPainterPrivate * const d = d_func(); | - |
1770 | if (!d->engine) { | - |
1771 | QMessageLogger(__FILE__, 30753079, __PRETTY_FUNCTION__).warning("QPainter::worldMatrixEnabled: Painter not active"); | - |
1772 | return false; | - |
1773 | } | - |
1774 | return d->state->WxF; | - |
1775 | } | - |
1776 | void QPainter::setMatrixEnabled(bool enable) | - |
1777 | { | - |
1778 | setWorldMatrixEnabled(enable); | - |
1779 | } | - |
1780 | bool QPainter::matrixEnabled() const | - |
1781 | { | - |
1782 | return worldMatrixEnabled(); | - |
1783 | } | - |
1784 | | - |
1785 | | - |
1786 | | - |
1787 | | - |
1788 | | - |
1789 | | - |
1790 | | - |
1791 | void QPainter::scale(qreal sx, qreal sy) | - |
1792 | { | - |
1793 | | - |
1794 | | - |
1795 | | - |
1796 | | - |
1797 | QPainterPrivate * const d = d_func(); | - |
1798 | if (!d->engine) { | - |
1799 | QMessageLogger(__FILE__, 31213125, __PRETTY_FUNCTION__).warning("QPainter::scale: Painter not active"); | - |
1800 | return; | - |
1801 | } | - |
1802 | | - |
1803 | d->state->worldMatrix.scale(sx,sy); | - |
1804 | d->state->WxF = true; | - |
1805 | d->updateMatrix(); | - |
1806 | } | - |
1807 | | - |
1808 | | - |
1809 | | - |
1810 | | - |
1811 | | - |
1812 | | - |
1813 | | - |
1814 | void QPainter::shear(qreal sh, qreal sv) | - |
1815 | { | - |
1816 | | - |
1817 | | - |
1818 | | - |
1819 | | - |
1820 | QPainterPrivate * const d = d_func(); | - |
1821 | if (!d->engine) { | - |
1822 | QMessageLogger(__FILE__, 31443148, __PRETTY_FUNCTION__).warning("QPainter::shear: Painter not active"); | - |
1823 | return; | - |
1824 | } | - |
1825 | | - |
1826 | d->state->worldMatrix.shear(sh, sv); | - |
1827 | d->state->WxF = true; | - |
1828 | d->updateMatrix(); | - |
1829 | } | - |
1830 | void QPainter::rotate(qreal a) | - |
1831 | { | - |
1832 | | - |
1833 | | - |
1834 | | - |
1835 | | - |
1836 | QPainterPrivate * const d = d_func(); | - |
1837 | if (!d->engine) { | - |
1838 | QMessageLogger(__FILE__, 31693173, __PRETTY_FUNCTION__).warning("QPainter::rotate: Painter not active"); | - |
1839 | return; | - |
1840 | } | - |
1841 | | - |
1842 | d->state->worldMatrix.rotate(a); | - |
1843 | d->state->WxF = true; | - |
1844 | d->updateMatrix(); | - |
1845 | } | - |
1846 | | - |
1847 | | - |
1848 | | - |
1849 | | - |
1850 | | - |
1851 | | - |
1852 | | - |
1853 | void QPainter::translate(const QPointF &offset) | - |
1854 | { | - |
1855 | qreal dx = offset.x(); | - |
1856 | qreal dy = offset.y(); | - |
1857 | | - |
1858 | | - |
1859 | | - |
1860 | | - |
1861 | QPainterPrivate * const d = d_func(); | - |
1862 | if (!d->engine) { | - |
1863 | QMessageLogger(__FILE__, 31943198, __PRETTY_FUNCTION__).warning("QPainter::translate: Painter not active"); | - |
1864 | return; | - |
1865 | } | - |
1866 | | - |
1867 | d->state->worldMatrix.translate(dx, dy); | - |
1868 | d->state->WxF = true; | - |
1869 | d->updateMatrix(); | - |
1870 | } | - |
1871 | void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) | - |
1872 | { | - |
1873 | | - |
1874 | | - |
1875 | | - |
1876 | | - |
1877 | | - |
1878 | | - |
1879 | | - |
1880 | QPainterPrivate * const d = d_func(); | - |
1881 | | - |
1882 | if (!d->engineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1883 | QMessageLogger(__FILE__, 32413245, __PRETTY_FUNCTION__).warning("QPainter::setClipPath: Painter not active"); | - |
1884 | return; never executed: return; | 0 |
1885 | } | - |
1886 | | - |
1887 | if ((!d->state->clipEnabledTRUE | never evaluated | FALSE | never evaluated |
&& op != Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
1888 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
1889 | | - |
1890 | if (d->extendedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1891 | d->state->clipEnabled = true; | - |
1892 | d->extended->clip(path, op); | - |
1893 | if (op == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
|| op == Qt::ReplaceClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1894 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
1895 | d->state->clipInfo<<.append(QPainterClipInfo(path, op, d->state->matrix);)); | - |
1896 | d->state->clipOperation = op; | - |
1897 | return; never executed: return; | 0 |
1898 | } | - |
1899 | | - |
1900 | if (d->state->clipOperation == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
&& op == Qt::IntersectClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1901 | op = Qt::ReplaceClip; never executed: op = Qt::ReplaceClip; | 0 |
1902 | | - |
1903 | d->state->clipPath = path; | - |
1904 | d->state->clipOperation = op; | - |
1905 | if (op == Qt::NoClipTRUE | never evaluated | FALSE | never evaluated |
|| op == Qt::ReplaceClipTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1906 | d->state->clipInfo.clear(); never executed: d->state->clipInfo.clear(); | 0 |
1907 | d->state->clipInfo<<.append(QPainterClipInfo(path, op, d->state->matrix);)); | - |
1908 | d->state->clipEnabled = true; | - |
1909 | d->state->dirtyFlags |= QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipEnabled; | - |
1910 | d->updateState(d->state); | - |
1911 | } never executed: end of block | 0 |
1912 | | - |
1913 | | - |
1914 | | - |
1915 | | - |
1916 | | - |
1917 | | - |
1918 | | - |
1919 | void QPainter::strokePath(const QPainterPath &path, const QPen &pen) | - |
1920 | { | - |
1921 | QPainterPrivate * const d = d_func(); | - |
1922 | | - |
1923 | if (!d->engine) { | - |
1924 | QMessageLogger(__FILE__, 32823286, __PRETTY_FUNCTION__).warning("QPainter::strokePath: Painter not active"); | - |
1925 | return; | - |
1926 | } | - |
1927 | | - |
1928 | if (path.isEmpty()) | - |
1929 | return; | - |
1930 | | - |
1931 | if (d->extended) { | - |
1932 | const QGradient *g = qpen_brush(pen).gradient(); | - |
1933 | if (!g || g->coordinateMode() == QGradient::LogicalMode) { | - |
1934 | d->extended->stroke(qtVectorPathForPath(path), pen); | - |
1935 | return; | - |
1936 | } | - |
1937 | } | - |
1938 | | - |
1939 | QBrush oldBrush = d->state->brush; | - |
1940 | QPen oldPen = d->state->pen; | - |
1941 | | - |
1942 | setPen(pen); | - |
1943 | setBrush(Qt::NoBrush); | - |
1944 | | - |
1945 | drawPath(path); | - |
1946 | | - |
1947 | | - |
1948 | setPen(oldPen); | - |
1949 | setBrush(oldBrush); | - |
1950 | } | - |
1951 | void QPainter::fillPath(const QPainterPath &path, const QBrush &brush) | - |
1952 | { | - |
1953 | QPainterPrivate * const d = d_func(); | - |
1954 | | - |
1955 | if (!d->engine) { | - |
1956 | QMessageLogger(__FILE__, 33253329, __PRETTY_FUNCTION__).warning("QPainter::fillPath: Painter not active"); | - |
1957 | return; | - |
1958 | } | - |
1959 | | - |
1960 | if (path.isEmpty()) | - |
1961 | return; | - |
1962 | | - |
1963 | if (d->extended) { | - |
1964 | const QGradient *g = brush.gradient(); | - |
1965 | if (!g || g->coordinateMode() == QGradient::LogicalMode) { | - |
1966 | d->extended->fill(qtVectorPathForPath(path), brush); | - |
1967 | return; | - |
1968 | } | - |
1969 | } | - |
1970 | | - |
1971 | QBrush oldBrush = d->state->brush; | - |
1972 | QPen oldPen = d->state->pen; | - |
1973 | | - |
1974 | setPen(Qt::NoPen); | - |
1975 | setBrush(brush); | - |
1976 | | - |
1977 | drawPath(path); | - |
1978 | | - |
1979 | | - |
1980 | setPen(oldPen); | - |
1981 | setBrush(oldBrush); | - |
1982 | } | - |
1983 | void QPainter::drawPath(const QPainterPath &path) | - |
1984 | { | - |
1985 | QPainterPrivate * const d = d_func(); | - |
1986 | | - |
1987 | if (!d->engine) { | - |
1988 | QMessageLogger(__FILE__, 33803384, __PRETTY_FUNCTION__).warning("QPainter::drawPath: Painter not active"); | - |
1989 | return; | - |
1990 | } | - |
1991 | | - |
1992 | if (d->extended) { | - |
1993 | d->extended->drawPath(path); | - |
1994 | return; | - |
1995 | } | - |
1996 | d->updateState(d->state); | - |
1997 | | - |
1998 | if (d->engine->hasFeature(QPaintEngine::PainterPaths) && d->state->emulationSpecifier == 0) { | - |
1999 | d->engine->drawPath(path); | - |
2000 | } else { | - |
2001 | d->draw_helper(path); | - |
2002 | } | - |
2003 | } | - |
2004 | void QPainter::drawRects(const QRectF *rects, int rectCount) | - |
2005 | { | - |
2006 | | - |
2007 | | - |
2008 | | - |
2009 | | - |
2010 | QPainterPrivate * const d = d_func(); | - |
2011 | | - |
2012 | if (!d->engine) { | - |
2013 | QMessageLogger(__FILE__, 34923496, __PRETTY_FUNCTION__).warning("QPainter::drawRects: Painter not active"); | - |
2014 | return; | - |
2015 | } | - |
2016 | | - |
2017 | if (rectCount <= 0) | - |
2018 | return; | - |
2019 | | - |
2020 | if (d->extended) { | - |
2021 | d->extended->drawRects(rects, rectCount); | - |
2022 | return; | - |
2023 | } | - |
2024 | | - |
2025 | d->updateState(d->state); | - |
2026 | | - |
2027 | if (!d->state->emulationSpecifier) { | - |
2028 | d->engine->drawRects(rects, rectCount); | - |
2029 | return; | - |
2030 | } | - |
2031 | | - |
2032 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | - |
2033 | && d->state->matrix.type() == QTransform::TxTranslate) { | - |
2034 | for (int i=0; i<rectCount; ++i) { | - |
2035 | QRectF r(rects[i].x() + d->state->matrix.dx(), | - |
2036 | rects[i].y() + d->state->matrix.dy(), | - |
2037 | rects[i].width(), | - |
2038 | rects[i].height()); | - |
2039 | d->engine->drawRects(&r, 1); | - |
2040 | } | - |
2041 | } else { | - |
2042 | if (d->state->brushNeedsResolving() || d->state->penNeedsResolving()) { | - |
2043 | for (int i=0; i<rectCount; ++i) { | - |
2044 | QPainterPath rectPath; | - |
2045 | rectPath.addRect(rects[i]); | - |
2046 | d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); | - |
2047 | } | - |
2048 | } else { | - |
2049 | QPainterPath rectPath; | - |
2050 | for (int i=0; i<rectCount; ++i) | - |
2051 | rectPath.addRect(rects[i]); | - |
2052 | d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); | - |
2053 | } | - |
2054 | } | - |
2055 | } | - |
2056 | void QPainter::drawRects(const QRect *rects, int rectCount) | - |
2057 | { | - |
2058 | | - |
2059 | | - |
2060 | | - |
2061 | | - |
2062 | QPainterPrivate * const d = d_func(); | - |
2063 | | - |
2064 | if (!d->engine) { | - |
2065 | QMessageLogger(__FILE__, 35523556, __PRETTY_FUNCTION__).warning("QPainter::drawRects: Painter not active"); | - |
2066 | return; | - |
2067 | } | - |
2068 | | - |
2069 | if (rectCount <= 0) | - |
2070 | return; | - |
2071 | | - |
2072 | if (d->extended) { | - |
2073 | d->extended->drawRects(rects, rectCount); | - |
2074 | return; | - |
2075 | } | - |
2076 | | - |
2077 | d->updateState(d->state); | - |
2078 | | - |
2079 | if (!d->state->emulationSpecifier) { | - |
2080 | d->engine->drawRects(rects, rectCount); | - |
2081 | return; | - |
2082 | } | - |
2083 | | - |
2084 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | - |
2085 | && d->state->matrix.type() == QTransform::TxTranslate) { | - |
2086 | for (int i=0; i<rectCount; ++i) { | - |
2087 | QRectF r(rects[i].x() + d->state->matrix.dx(), | - |
2088 | rects[i].y() + d->state->matrix.dy(), | - |
2089 | rects[i].width(), | - |
2090 | rects[i].height()); | - |
2091 | | - |
2092 | d->engine->drawRects(&r, 1); | - |
2093 | } | - |
2094 | } else { | - |
2095 | if (d->state->brushNeedsResolving() || d->state->penNeedsResolving()) { | - |
2096 | for (int i=0; i<rectCount; ++i) { | - |
2097 | QPainterPath rectPath; | - |
2098 | rectPath.addRect(rects[i]); | - |
2099 | d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); | - |
2100 | } | - |
2101 | } else { | - |
2102 | QPainterPath rectPath; | - |
2103 | for (int i=0; i<rectCount; ++i) | - |
2104 | rectPath.addRect(rects[i]); | - |
2105 | | - |
2106 | d->draw_helper(rectPath, QPainterPrivate::StrokeAndFillDraw); | - |
2107 | } | - |
2108 | } | - |
2109 | } | - |
2110 | void QPainter::drawPoints(const QPointF *points, int pointCount) | - |
2111 | { | - |
2112 | | - |
2113 | | - |
2114 | | - |
2115 | | - |
2116 | QPainterPrivate * const d = d_func(); | - |
2117 | | - |
2118 | if (!d->engine) { | - |
2119 | QMessageLogger(__FILE__, 36523656, __PRETTY_FUNCTION__).warning("QPainter::drawPoints: Painter not active"); | - |
2120 | return; | - |
2121 | } | - |
2122 | | - |
2123 | if (pointCount <= 0) | - |
2124 | return; | - |
2125 | | - |
2126 | if (d->extended) { | - |
2127 | d->extended->drawPoints(points, pointCount); | - |
2128 | return; | - |
2129 | } | - |
2130 | | - |
2131 | d->updateState(d->state); | - |
2132 | | - |
2133 | if (!d->state->emulationSpecifier) { | - |
2134 | d->engine->drawPoints(points, pointCount); | - |
2135 | return; | - |
2136 | } | - |
2137 | | - |
2138 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | - |
2139 | && d->state->matrix.type() == QTransform::TxTranslate) { | - |
2140 | | - |
2141 | for (int i=0; i<pointCount; ++i) { | - |
2142 | QPointF pt(points[i].x() + d->state->matrix.dx(), | - |
2143 | points[i].y() + d->state->matrix.dy()); | - |
2144 | d->engine->drawPoints(&pt, 1); | - |
2145 | } | - |
2146 | } else { | - |
2147 | QPen pen = d->state->pen; | - |
2148 | bool flat_pen = pen.capStyle() == Qt::FlatCap; | - |
2149 | if (flat_pen) { | - |
2150 | save(); | - |
2151 | pen.setCapStyle(Qt::SquareCap); | - |
2152 | setPen(pen); | - |
2153 | } | - |
2154 | QPainterPath path; | - |
2155 | for (int i=0; i<pointCount; ++i) { | - |
2156 | path.moveTo(points[i].x(), points[i].y()); | - |
2157 | path.lineTo(points[i].x() + 0.0001, points[i].y()); | - |
2158 | } | - |
2159 | d->draw_helper(path, QPainterPrivate::StrokeDraw); | - |
2160 | if (flat_pen) | - |
2161 | restore(); | - |
2162 | } | - |
2163 | } | - |
2164 | void QPainter::drawPoints(const QPoint *points, int pointCount) | - |
2165 | { | - |
2166 | | - |
2167 | | - |
2168 | | - |
2169 | | - |
2170 | QPainterPrivate * const d = d_func(); | - |
2171 | | - |
2172 | if (!d->engine) { | - |
2173 | QMessageLogger(__FILE__, 37143718, __PRETTY_FUNCTION__).warning("QPainter::drawPoints: Painter not active"); | - |
2174 | return; | - |
2175 | } | - |
2176 | | - |
2177 | if (pointCount <= 0) | - |
2178 | return; | - |
2179 | | - |
2180 | if (d->extended) { | - |
2181 | d->extended->drawPoints(points, pointCount); | - |
2182 | return; | - |
2183 | } | - |
2184 | | - |
2185 | d->updateState(d->state); | - |
2186 | | - |
2187 | if (!d->state->emulationSpecifier) { | - |
2188 | d->engine->drawPoints(points, pointCount); | - |
2189 | return; | - |
2190 | } | - |
2191 | | - |
2192 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | - |
2193 | && d->state->matrix.type() == QTransform::TxTranslate) { | - |
2194 | | - |
2195 | for (int i=0; i<pointCount; ++i) { | - |
2196 | QPointF pt(points[i].x() + d->state->matrix.dx(), | - |
2197 | points[i].y() + d->state->matrix.dy()); | - |
2198 | d->engine->drawPoints(&pt, 1); | - |
2199 | } | - |
2200 | } else { | - |
2201 | QPen pen = d->state->pen; | - |
2202 | bool flat_pen = (pen.capStyle() == Qt::FlatCap); | - |
2203 | if (flat_pen) { | - |
2204 | save(); | - |
2205 | pen.setCapStyle(Qt::SquareCap); | - |
2206 | setPen(pen); | - |
2207 | } | - |
2208 | QPainterPath path; | - |
2209 | for (int i=0; i<pointCount; ++i) { | - |
2210 | path.moveTo(points[i].x(), points[i].y()); | - |
2211 | path.lineTo(points[i].x() + 0.0001, points[i].y()); | - |
2212 | } | - |
2213 | d->draw_helper(path, QPainterPrivate::StrokeDraw); | - |
2214 | if (flat_pen) | - |
2215 | restore(); | - |
2216 | } | - |
2217 | } | - |
2218 | void QPainter::setBackgroundMode(Qt::BGMode mode) | - |
2219 | { | - |
2220 | | - |
2221 | | - |
2222 | | - |
2223 | | - |
2224 | | - |
2225 | QPainterPrivate * const d = d_func(); | - |
2226 | if (!d->engine) { | - |
2227 | QMessageLogger(__FILE__, 37993803, __PRETTY_FUNCTION__).warning("QPainter::setBackgroundMode: Painter not active"); | - |
2228 | return; | - |
2229 | } | - |
2230 | if (d->state->bgMode == mode) | - |
2231 | return; | - |
2232 | | - |
2233 | d->state->bgMode = mode; | - |
2234 | if (d->extended) { | - |
2235 | d->checkEmulation(); | - |
2236 | } else { | - |
2237 | d->state->dirtyFlags |= QPaintEngine::DirtyBackgroundMode; | - |
2238 | } | - |
2239 | } | - |
2240 | | - |
2241 | | - |
2242 | | - |
2243 | | - |
2244 | | - |
2245 | | - |
2246 | Qt::BGMode QPainter::backgroundMode() const | - |
2247 | { | - |
2248 | const QPainterPrivate * const d = d_func(); | - |
2249 | if (!d->engine) { | - |
2250 | QMessageLogger(__FILE__, 38223826, __PRETTY_FUNCTION__).warning("QPainter::backgroundMode: Painter not active"); | - |
2251 | return Qt::TransparentMode; | - |
2252 | } | - |
2253 | return d->state->bgMode; | - |
2254 | } | - |
2255 | void QPainter::setPen(const QColor &color) | - |
2256 | { | - |
2257 | | - |
2258 | | - |
2259 | | - |
2260 | | - |
2261 | QPainterPrivate * const d = d_func(); | - |
2262 | if (!d->engine) { | - |
2263 | QMessageLogger(__FILE__, 38443848, __PRETTY_FUNCTION__).warning("QPainter::setPen: Painter not active"); | - |
2264 | return; | - |
2265 | } | - |
2266 | | - |
2267 | QPen pen(color.isValid() ? color : QColor(Qt::black)); | - |
2268 | | - |
2269 | if (d->state->pen == pen) | - |
2270 | return; | - |
2271 | | - |
2272 | d->state->pen = pen; | - |
2273 | if (d->extended) | - |
2274 | d->extended->penChanged(); | - |
2275 | else | - |
2276 | d->state->dirtyFlags |= QPaintEngine::DirtyPen; | - |
2277 | } | - |
2278 | void QPainter::setPen(const QPen &pen) | - |
2279 | { | - |
2280 | | - |
2281 | | - |
2282 | | - |
2283 | | - |
2284 | | - |
2285 | | - |
2286 | QPainterPrivate * const d = d_func(); | - |
2287 | if (!d->engine) { | - |
2288 | QMessageLogger(__FILE__, 38793883, __PRETTY_FUNCTION__).warning("QPainter::setPen: Painter not active"); | - |
2289 | return; | - |
2290 | } | - |
2291 | | - |
2292 | if (d->state->pen == pen) | - |
2293 | return; | - |
2294 | | - |
2295 | d->state->pen = pen; | - |
2296 | | - |
2297 | if (d->extended) { | - |
2298 | d->checkEmulation(); | - |
2299 | d->extended->penChanged(); | - |
2300 | return; | - |
2301 | } | - |
2302 | | - |
2303 | d->state->dirtyFlags |= QPaintEngine::DirtyPen; | - |
2304 | } | - |
2305 | void QPainter::setPen(Qt::PenStyle style) | - |
2306 | { | - |
2307 | QPainterPrivate * const d = d_func(); | - |
2308 | if (!d->engine) { | - |
2309 | QMessageLogger(__FILE__, 39083912, __PRETTY_FUNCTION__).warning("QPainter::setPen: Painter not active"); | - |
2310 | return; | - |
2311 | } | - |
2312 | | - |
2313 | QPen pen = QPen(style); | - |
2314 | | - |
2315 | if (d->state->pen == pen) | - |
2316 | return; | - |
2317 | | - |
2318 | d->state->pen = pen; | - |
2319 | | - |
2320 | if (d->extended) | - |
2321 | d->extended->penChanged(); | - |
2322 | else | - |
2323 | d->state->dirtyFlags |= QPaintEngine::DirtyPen; | - |
2324 | | - |
2325 | } | - |
2326 | | - |
2327 | | - |
2328 | | - |
2329 | | - |
2330 | | - |
2331 | | - |
2332 | | - |
2333 | const QPen &QPainter::pen() const | - |
2334 | { | - |
2335 | const QPainterPrivate * const d = d_func(); | - |
2336 | if (!d->engine) { | - |
2337 | QMessageLogger(__FILE__, 39363940, __PRETTY_FUNCTION__).warning("QPainter::pen: Painter not active"); | - |
2338 | return d->fakeState()->pen; | - |
2339 | } | - |
2340 | return d->state->pen; | - |
2341 | } | - |
2342 | void QPainter::setBrush(const QBrush &brush) | - |
2343 | { | - |
2344 | | - |
2345 | | - |
2346 | | - |
2347 | | - |
2348 | QPainterPrivate * const d = d_func(); | - |
2349 | if (!d->engine) { | - |
2350 | QMessageLogger(__FILE__, 39593963, __PRETTY_FUNCTION__).warning("QPainter::setBrush: Painter not active"); | - |
2351 | return; | - |
2352 | } | - |
2353 | | - |
2354 | if (d->state->brush.d == brush.d) | - |
2355 | return; | - |
2356 | | - |
2357 | if (d->extended) { | - |
2358 | d->state->brush = brush; | - |
2359 | d->checkEmulation(); | - |
2360 | d->extended->brushChanged(); | - |
2361 | return; | - |
2362 | } | - |
2363 | | - |
2364 | d->state->brush = brush; | - |
2365 | d->state->dirtyFlags |= QPaintEngine::DirtyBrush; | - |
2366 | } | - |
2367 | void QPainter::setBrush(Qt::BrushStyle style) | - |
2368 | { | - |
2369 | QPainterPrivate * const d = d_func(); | - |
2370 | if (!d->engine) { | - |
2371 | QMessageLogger(__FILE__, 39893993, __PRETTY_FUNCTION__).warning("QPainter::setBrush: Painter not active"); | - |
2372 | return; | - |
2373 | } | - |
2374 | if (d->state->brush.style() == style && | - |
2375 | (style == Qt::NoBrush | - |
2376 | || (style == Qt::SolidPattern && d->state->brush.color() == QColor(0, 0, 0)))) | - |
2377 | return; | - |
2378 | d->state->brush = QBrush(Qt::black, style); | - |
2379 | if (d->extended) | - |
2380 | d->extended->brushChanged(); | - |
2381 | else | - |
2382 | d->state->dirtyFlags |= QPaintEngine::DirtyBrush; | - |
2383 | } | - |
2384 | | - |
2385 | | - |
2386 | | - |
2387 | | - |
2388 | | - |
2389 | | - |
2390 | | - |
2391 | const QBrush &QPainter::brush() const | - |
2392 | { | - |
2393 | const QPainterPrivate * const d = d_func(); | - |
2394 | if (!d->engine) { | - |
2395 | QMessageLogger(__FILE__, 40134017, __PRETTY_FUNCTION__).warning("QPainter::brush: Painter not active"); | - |
2396 | return d->fakeState()->brush; | - |
2397 | } | - |
2398 | return d->state->brush; | - |
2399 | } | - |
2400 | void QPainter::setBackground(const QBrush &bg) | - |
2401 | { | - |
2402 | | - |
2403 | | - |
2404 | | - |
2405 | | - |
2406 | | - |
2407 | QPainterPrivate * const d = d_func(); | - |
2408 | if (!d->engine) { | - |
2409 | QMessageLogger(__FILE__, 40414045, __PRETTY_FUNCTION__).warning("QPainter::setBackground: Painter not active"); | - |
2410 | return; | - |
2411 | } | - |
2412 | d->state->bgBrush = bg; | - |
2413 | if (!d->extended) | - |
2414 | d->state->dirtyFlags |= QPaintEngine::DirtyBackground; | - |
2415 | } | - |
2416 | void QPainter::setFont(const QFont &font) | - |
2417 | { | - |
2418 | QPainterPrivate * const d = d_func(); | - |
2419 | | - |
2420 | | - |
2421 | | - |
2422 | | - |
2423 | | - |
2424 | | - |
2425 | if (!d->engine) { | - |
2426 | QMessageLogger(__FILE__, 40724076, __PRETTY_FUNCTION__).warning("QPainter::setFont: Painter not active"); | - |
2427 | return; | - |
2428 | } | - |
2429 | | - |
2430 | d->state->font = QFont(font.resolve(d->state->deviceFont), device()); | - |
2431 | if (!d->extended) | - |
2432 | d->state->dirtyFlags |= QPaintEngine::DirtyFont; | - |
2433 | } | - |
2434 | | - |
2435 | | - |
2436 | | - |
2437 | | - |
2438 | | - |
2439 | | - |
2440 | const QFont &QPainter::font() const | - |
2441 | { | - |
2442 | const QPainterPrivate * const d = d_func(); | - |
2443 | if (!d->engine) { | - |
2444 | QMessageLogger(__FILE__, 40904094, __PRETTY_FUNCTION__).warning("QPainter::font: Painter not active"); | - |
2445 | return d->fakeState()->font; | - |
2446 | } | - |
2447 | return d->state->font; | - |
2448 | } | - |
2449 | void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode) | - |
2450 | { | - |
2451 | | - |
2452 | | - |
2453 | | - |
2454 | | - |
2455 | QPainterPrivate * const d = d_func(); | - |
2456 | | - |
2457 | if (!d->engine) | - |
2458 | return; | - |
2459 | | - |
2460 | if (xRadius <= 0 || yRadius <= 0) { | - |
2461 | drawRect(rect); | - |
2462 | return; | - |
2463 | } | - |
2464 | | - |
2465 | if (d->extended) { | - |
2466 | d->extended->drawRoundedRect(rect, xRadius, yRadius, mode); | - |
2467 | return; | - |
2468 | } | - |
2469 | | - |
2470 | QPainterPath path; | - |
2471 | path.addRoundedRect(rect, xRadius, yRadius, mode); | - |
2472 | drawPath(path); | - |
2473 | } | - |
2474 | void QPainter::drawRoundRect(const QRectF &r, int xRnd, int yRnd) | - |
2475 | { | - |
2476 | drawRoundedRect(r, xRnd, yRnd, Qt::RelativeSize); | - |
2477 | } | - |
2478 | void QPainter::drawEllipse(const QRectF &r) | - |
2479 | { | - |
2480 | | - |
2481 | | - |
2482 | | - |
2483 | | - |
2484 | QPainterPrivate * const d = d_func(); | - |
2485 | | - |
2486 | if (!d->engine) | - |
2487 | return; | - |
2488 | | - |
2489 | QRectF rect(r.normalized()); | - |
2490 | | - |
2491 | if (d->extended) { | - |
2492 | d->extended->drawEllipse(rect); | - |
2493 | return; | - |
2494 | } | - |
2495 | | - |
2496 | d->updateState(d->state); | - |
2497 | if (d->state->emulationSpecifier) { | - |
2498 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | - |
2499 | && d->state->matrix.type() == QTransform::TxTranslate) { | - |
2500 | rect.translate(QPointF(d->state->matrix.dx(), d->state->matrix.dy())); | - |
2501 | } else { | - |
2502 | QPainterPath path; | - |
2503 | path.addEllipse(rect); | - |
2504 | d->draw_helper(path, QPainterPrivate::StrokeAndFillDraw); | - |
2505 | return; | - |
2506 | } | - |
2507 | } | - |
2508 | | - |
2509 | d->engine->drawEllipse(rect); | - |
2510 | } | - |
2511 | void QPainter::drawEllipse(const QRect &r) | - |
2512 | { | - |
2513 | | - |
2514 | | - |
2515 | | - |
2516 | | - |
2517 | QPainterPrivate * const d = d_func(); | - |
2518 | | - |
2519 | if (!d->engine) | - |
2520 | return; | - |
2521 | | - |
2522 | QRect rect(r.normalized()); | - |
2523 | | - |
2524 | if (d->extended) { | - |
2525 | d->extended->drawEllipse(rect); | - |
2526 | return; | - |
2527 | } | - |
2528 | | - |
2529 | d->updateState(d->state); | - |
2530 | | - |
2531 | if (d->state->emulationSpecifier) { | - |
2532 | if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform | - |
2533 | && d->state->matrix.type() == QTransform::TxTranslate) { | - |
2534 | rect.translate(QPoint(qRound(d->state->matrix.dx()), qRound(d->state->matrix.dy()))); | - |
2535 | } else { | - |
2536 | QPainterPath path; | - |
2537 | path.addEllipse(rect); | - |
2538 | d->draw_helper(path, QPainterPrivate::StrokeAndFillDraw); | - |
2539 | return; | - |
2540 | } | - |
2541 | } | - |
2542 | | - |
2543 | d->engine->drawEllipse(rect); | - |
2544 | } | - |
2545 | void QPainter::drawArc(const QRectF &r, int a, int alen) | - |
2546 | { | - |
2547 | | - |
2548 | | - |
2549 | | - |
2550 | | - |
2551 | | - |
2552 | QPainterPrivate * const d = d_func(); | - |
2553 | | - |
2554 | if (!d->engine) | - |
2555 | return; | - |
2556 | | - |
2557 | QRectF rect = r.normalized(); | - |
2558 | | - |
2559 | QPainterPath path; | - |
2560 | path.arcMoveTo(rect, a/16.0); | - |
2561 | path.arcTo(rect, a/16.0, alen/16.0); | - |
2562 | strokePath(path, d->state->pen); | - |
2563 | } | - |
2564 | void QPainter::drawPie(const QRectF &r, int a, int alen) | - |
2565 | { | - |
2566 | | - |
2567 | | - |
2568 | | - |
2569 | | - |
2570 | | - |
2571 | QPainterPrivate * const d = d_func(); | - |
2572 | | - |
2573 | if (!d->engine) | - |
2574 | return; | - |
2575 | | - |
2576 | if (a > (360*16)) { | - |
2577 | a = a % (360*16); | - |
2578 | } else if (a < 0) { | - |
2579 | a = a % (360*16); | - |
2580 | if (a < 0) a += (360*16); | - |
2581 | } | - |
2582 | | - |
2583 | QRectF rect = r.normalized(); | - |
2584 | | - |
2585 | QPainterPath path; | - |
2586 | path.moveTo(rect.center()); | - |
2587 | path.arcTo(rect.x(), rect.y(), rect.width(), rect.height(), a/16.0, alen/16.0); | - |
2588 | path.closeSubpath(); | - |
2589 | drawPath(path); | - |
2590 | | - |
2591 | } | - |
2592 | void QPainter::drawChord(const QRectF &r, int a, int alen) | - |
2593 | { | - |
2594 | | - |
2595 | | - |
2596 | | - |
2597 | | - |
2598 | | - |
2599 | QPainterPrivate * const d = d_func(); | - |
2600 | | - |
2601 | if (!d->engine) | - |
2602 | return; | - |
2603 | | - |
2604 | QRectF rect = r.normalized(); | - |
2605 | | - |
2606 | QPainterPath path; | - |
2607 | path.arcMoveTo(rect, a/16.0); | - |
2608 | path.arcTo(rect, a/16.0, alen/16.0); | - |
2609 | path.closeSubpath(); | - |
2610 | drawPath(path); | - |
2611 | } | - |
2612 | void QPainter::drawLines(const QLineF *lines, int lineCount) | - |
2613 | { | - |
2614 | | - |
2615 | | - |
2616 | | - |
2617 | | - |
2618 | | - |
2619 | QPainterPrivate * const d = d_func(); | - |
2620 | | - |
2621 | if (!d->engine || lineCount < 1) | - |
2622 | return; | - |
2623 | | - |
2624 | if (d->extended) { | - |
2625 | d->extended->drawLines(lines, lineCount); | - |
2626 | return; | - |
2627 | } | - |
2628 | | - |
2629 | d->updateState(d->state); | - |
2630 | | - |
2631 | uint lineEmulation = line_emulation(d->state->emulationSpecifier); | - |
2632 | | - |
2633 | if (lineEmulation) { | - |
2634 | if (lineEmulation == QPaintEngine::PrimitiveTransform | - |
2635 | && d->state->matrix.type() == QTransform::TxTranslate) { | - |
2636 | for (int i = 0; i < lineCount; ++i) { | - |
2637 | QLineF line = lines[i]; | - |
2638 | line.translate(d->state->matrix.dx(), d->state->matrix.dy()); | - |
2639 | d->engine->drawLines(&line, 1); | - |
2640 | } | - |
2641 | } else { | - |
2642 | QPainterPath linePath; | - |
2643 | for (int i = 0; i < lineCount; ++i) { | - |
2644 | linePath.moveTo(lines[i].p1()); | - |
2645 | linePath.lineTo(lines[i].p2()); | - |
2646 | } | - |
2647 | d->draw_helper(linePath, QPainterPrivate::StrokeDraw); | - |
2648 | } | - |
2649 | return; | - |
2650 | } | - |
2651 | d->engine->drawLines(lines, lineCount); | - |
2652 | } | - |
2653 | void QPainter::drawLines(const QLine *lines, int lineCount) | - |
2654 | { | - |
2655 | | - |
2656 | | - |
2657 | | - |
2658 | | - |
2659 | | - |
2660 | QPainterPrivate * const d = d_func(); | - |
2661 | | - |
2662 | if (!d->engine || lineCount < 1) | - |
2663 | return; | - |
2664 | | - |
2665 | if (d->extended) { | - |
2666 | d->extended->drawLines(lines, lineCount); | - |
2667 | return; | - |
2668 | } | - |
2669 | | - |
2670 | d->updateState(d->state); | - |
2671 | | - |
2672 | uint lineEmulation = line_emulation(d->state->emulationSpecifier); | - |
2673 | | - |
2674 | if (lineEmulation) { | - |
2675 | if (lineEmulation == QPaintEngine::PrimitiveTransform | - |
2676 | && d->state->matrix.type() == QTransform::TxTranslate) { | - |
2677 | for (int i = 0; i < lineCount; ++i) { | - |
2678 | QLineF line = lines[i]; | - |
2679 | line.translate(d->state->matrix.dx(), d->state->matrix.dy()); | - |
2680 | d->engine->drawLines(&line, 1); | - |
2681 | } | - |
2682 | } else { | - |
2683 | QPainterPath linePath; | - |
2684 | for (int i = 0; i < lineCount; ++i) { | - |
2685 | linePath.moveTo(lines[i].p1()); | - |
2686 | linePath.lineTo(lines[i].p2()); | - |
2687 | } | - |
2688 | d->draw_helper(linePath, QPainterPrivate::StrokeDraw); | - |
2689 | } | - |
2690 | return; | - |
2691 | } | - |
2692 | d->engine->drawLines(lines, lineCount); | - |
2693 | } | - |
2694 | void QPainter::drawLines(const QPointF *pointPairs, int lineCount) | - |
2695 | { | - |
2696 | ((!(sizeof(QLineF) == 2*sizeof(QPointF))) ? qt_assert("sizeof(QLineF) == 2*sizeof(QPointF)",__FILE__,46264630) : qt_noop()); | - |
2697 | | - |
2698 | drawLines((const QLineF*)pointPairs, lineCount); | - |
2699 | } | - |
2700 | | - |
2701 | | - |
2702 | | - |
2703 | | - |
2704 | | - |
2705 | | - |
2706 | | - |
2707 | void QPainter::drawLines(const QPoint *pointPairs, int lineCount) | - |
2708 | { | - |
2709 | ((!(sizeof(QLine) == 2*sizeof(QPoint))) ? qt_assert("sizeof(QLine) == 2*sizeof(QPoint)",__FILE__,46394643) : qt_noop()); | - |
2710 | | - |
2711 | drawLines((const QLine*)pointPairs, lineCount); | - |
2712 | } | - |
2713 | void QPainter::drawPolyline(const QPointF *points, int pointCount) | - |
2714 | { | - |
2715 | | - |
2716 | | - |
2717 | | - |
2718 | | - |
2719 | QPainterPrivate * const d = d_func(); | - |
2720 | | - |
2721 | if (!d->engine || pointCount < 2) | - |
2722 | return; | - |
2723 | | - |
2724 | if (d->extended) { | - |
2725 | d->extended->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); | - |
2726 | return; | - |
2727 | } | - |
2728 | | - |
2729 | d->updateState(d->state); | - |
2730 | | - |
2731 | uint lineEmulation = line_emulation(d->state->emulationSpecifier); | - |
2732 | | - |
2733 | if (lineEmulation) { | - |
2734 | | - |
2735 | | - |
2736 | | - |
2737 | | - |
2738 | QPainterPath polylinePath(points[0]); | - |
2739 | for (int i=1; i<pointCount; ++i) | - |
2740 | polylinePath.lineTo(points[i]); | - |
2741 | d->draw_helper(polylinePath, QPainterPrivate::StrokeDraw); | - |
2742 | | - |
2743 | } else { | - |
2744 | d->engine->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); | - |
2745 | } | - |
2746 | } | - |
2747 | | - |
2748 | | - |
2749 | | - |
2750 | | - |
2751 | | - |
2752 | | - |
2753 | | - |
2754 | void QPainter::drawPolyline(const QPoint *points, int pointCount) | - |
2755 | { | - |
2756 | | - |
2757 | | - |
2758 | | - |
2759 | | - |
2760 | QPainterPrivate * const d = d_func(); | - |
2761 | | - |
2762 | if (!d->engine || pointCount < 2) | - |
2763 | return; | - |
2764 | | - |
2765 | if (d->extended) { | - |
2766 | d->extended->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); | - |
2767 | return; | - |
2768 | } | - |
2769 | | - |
2770 | d->updateState(d->state); | - |
2771 | | - |
2772 | uint lineEmulation = line_emulation(d->state->emulationSpecifier); | - |
2773 | | - |
2774 | if (lineEmulation) { | - |
2775 | | - |
2776 | | - |
2777 | | - |
2778 | | - |
2779 | QPainterPath polylinePath(points[0]); | - |
2780 | for (int i=1; i<pointCount; ++i) | - |
2781 | polylinePath.lineTo(points[i]); | - |
2782 | d->draw_helper(polylinePath, QPainterPrivate::StrokeDraw); | - |
2783 | | - |
2784 | } else { | - |
2785 | d->engine->drawPolygon(points, pointCount, QPaintEngine::PolylineMode); | - |
2786 | } | - |
2787 | } | - |
2788 | void QPainter::drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule) | - |
2789 | { | - |
2790 | | - |
2791 | | - |
2792 | | - |
2793 | | - |
2794 | | - |
2795 | QPainterPrivate * const d = d_func(); | - |
2796 | | - |
2797 | if (!d->engine || pointCount < 2) | - |
2798 | return; | - |
2799 | | - |
2800 | if (d->extended) { | - |
2801 | d->extended->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); | - |
2802 | return; | - |
2803 | } | - |
2804 | | - |
2805 | d->updateState(d->state); | - |
2806 | | - |
2807 | uint emulationSpecifier = d->state->emulationSpecifier; | - |
2808 | | - |
2809 | if (emulationSpecifier) { | - |
2810 | QPainterPath polygonPath(points[0]); | - |
2811 | for (int i=1; i<pointCount; ++i) | - |
2812 | polygonPath.lineTo(points[i]); | - |
2813 | polygonPath.closeSubpath(); | - |
2814 | polygonPath.setFillRule(fillRule); | - |
2815 | d->draw_helper(polygonPath); | - |
2816 | return; | - |
2817 | } | - |
2818 | | - |
2819 | d->engine->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); | - |
2820 | } | - |
2821 | | - |
2822 | | - |
2823 | | - |
2824 | | - |
2825 | | - |
2826 | | - |
2827 | void QPainter::drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fillRule) | - |
2828 | { | - |
2829 | | - |
2830 | | - |
2831 | | - |
2832 | | - |
2833 | | - |
2834 | QPainterPrivate * const d = d_func(); | - |
2835 | | - |
2836 | if (!d->engine || pointCount < 2) | - |
2837 | return; | - |
2838 | | - |
2839 | if (d->extended) { | - |
2840 | d->extended->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); | - |
2841 | return; | - |
2842 | } | - |
2843 | | - |
2844 | d->updateState(d->state); | - |
2845 | | - |
2846 | uint emulationSpecifier = d->state->emulationSpecifier; | - |
2847 | | - |
2848 | if (emulationSpecifier) { | - |
2849 | QPainterPath polygonPath(points[0]); | - |
2850 | for (int i=1; i<pointCount; ++i) | - |
2851 | polygonPath.lineTo(points[i]); | - |
2852 | polygonPath.closeSubpath(); | - |
2853 | polygonPath.setFillRule(fillRule); | - |
2854 | d->draw_helper(polygonPath); | - |
2855 | return; | - |
2856 | } | - |
2857 | | - |
2858 | d->engine->drawPolygon(points, pointCount, QPaintEngine::PolygonDrawMode(fillRule)); | - |
2859 | } | - |
2860 | void QPainter::drawConvexPolygon(const QPoint *points, int pointCount) | - |
2861 | { | - |
2862 | | - |
2863 | | - |
2864 | | - |
2865 | | - |
2866 | | - |
2867 | QPainterPrivate * const d = d_func(); | - |
2868 | | - |
2869 | if (!d->engine || pointCount < 2) | - |
2870 | return; | - |
2871 | | - |
2872 | if (d->extended) { | - |
2873 | d->extended->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); | - |
2874 | return; | - |
2875 | } | - |
2876 | | - |
2877 | d->updateState(d->state); | - |
2878 | | - |
2879 | uint emulationSpecifier = d->state->emulationSpecifier; | - |
2880 | | - |
2881 | if (emulationSpecifier) { | - |
2882 | QPainterPath polygonPath(points[0]); | - |
2883 | for (int i=1; i<pointCount; ++i) | - |
2884 | polygonPath.lineTo(points[i]); | - |
2885 | polygonPath.closeSubpath(); | - |
2886 | polygonPath.setFillRule(Qt::WindingFill); | - |
2887 | d->draw_helper(polygonPath); | - |
2888 | return; | - |
2889 | } | - |
2890 | | - |
2891 | d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); | - |
2892 | } | - |
2893 | | - |
2894 | void QPainter::drawConvexPolygon(const QPointF *points, int pointCount) | - |
2895 | { | - |
2896 | | - |
2897 | | - |
2898 | | - |
2899 | | - |
2900 | | - |
2901 | QPainterPrivate * const d = d_func(); | - |
2902 | | - |
2903 | if (!d->engine || pointCount < 2) | - |
2904 | return; | - |
2905 | | - |
2906 | if (d->extended) { | - |
2907 | d->extended->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); | - |
2908 | return; | - |
2909 | } | - |
2910 | | - |
2911 | d->updateState(d->state); | - |
2912 | | - |
2913 | uint emulationSpecifier = d->state->emulationSpecifier; | - |
2914 | | - |
2915 | if (emulationSpecifier) { | - |
2916 | QPainterPath polygonPath(points[0]); | - |
2917 | for (int i=1; i<pointCount; ++i) | - |
2918 | polygonPath.lineTo(points[i]); | - |
2919 | polygonPath.closeSubpath(); | - |
2920 | polygonPath.setFillRule(Qt::WindingFill); | - |
2921 | d->draw_helper(polygonPath); | - |
2922 | return; | - |
2923 | } | - |
2924 | | - |
2925 | d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); | - |
2926 | } | - |
2927 | | - |
2928 | static inline QPointF roundInDeviceCoordinates(const QPointF &p, const QTransform &m) | - |
2929 | { | - |
2930 | return m.inverted().map(QPointF(m.map(p).toPoint())); | - |
2931 | } | - |
2932 | void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) | - |
2933 | { | - |
2934 | | - |
2935 | | - |
2936 | | - |
2937 | | - |
2938 | | - |
2939 | | - |
2940 | | - |
2941 | QPainterPrivate * const d = d_func(); | - |
2942 | | - |
2943 | if (!d->engine || pm.isNull()) | - |
2944 | return; | - |
2945 | | - |
2946 | | - |
2947 | qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawPixmap()"); | - |
2948 | | - |
2949 | | - |
2950 | if (d->extended) { | - |
2951 | d->extended->drawPixmap(p, pm); | - |
2952 | return; | - |
2953 | } | - |
2954 | | - |
2955 | qreal x = p.x(); | - |
2956 | qreal y = p.y(); | - |
2957 | | - |
2958 | int w = pm.width(); | - |
2959 | int h = pm.height(); | - |
2960 | | - |
2961 | if (w <= 0) | - |
2962 | return; | - |
2963 | | - |
2964 | | - |
2965 | if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap()) { | - |
2966 | fillRect(QRectF(x, y, w, h), d->state->bgBrush.color()); | - |
2967 | } | - |
2968 | | - |
2969 | d->updateState(d->state); | - |
2970 | | - |
2971 | if ((d->state->matrix.type() > QTransform::TxTranslate | - |
2972 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) | - |
2973 | || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform)) | - |
2974 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) | - |
2975 | { | - |
2976 | save(); | - |
2977 | | - |
2978 | | - |
2979 | if (d->state->matrix.type() <= QTransform::TxScale) { | - |
2980 | const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); | - |
2981 | x = p.x(); | - |
2982 | y = p.y(); | - |
2983 | } | - |
2984 | translate(x, y); | - |
2985 | setBackgroundMode(Qt::TransparentMode); | - |
2986 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
2987 | QBrush brush(d->state->pen.color(), pm); | - |
2988 | setBrush(brush); | - |
2989 | setPen(Qt::NoPen); | - |
2990 | setBrushOrigin(QPointF(0, 0)); | - |
2991 | | - |
2992 | drawRect(pm.rect()); | - |
2993 | restore(); | - |
2994 | } else { | - |
2995 | if (!d->engine->hasFeature(QPaintEngine::PixmapTransform)) { | - |
2996 | x += d->state->matrix.dx(); | - |
2997 | y += d->state->matrix.dy(); | - |
2998 | } | - |
2999 | qreal scale = pm.devicePixelRatio(); | - |
3000 | d->engine->drawPixmap(QRectF(x, y, w / scale, h / scale), pm, QRectF(0, 0, w, h)); | - |
3001 | } | - |
3002 | } | - |
3003 | | - |
3004 | void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) | - |
3005 | { | - |
3006 | QPainterPrivate * const d = d_func(); | - |
3007 | if (!d->engine || pm.isNull()) | - |
3008 | return; | - |
3009 | | - |
3010 | qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawPixmap()"); | - |
3011 | | - |
3012 | | - |
3013 | qreal x = r.x(); | - |
3014 | qreal y = r.y(); | - |
3015 | qreal w = r.width(); | - |
3016 | qreal h = r.height(); | - |
3017 | qreal sx = sr.x(); | - |
3018 | qreal sy = sr.y(); | - |
3019 | qreal sw = sr.width(); | - |
3020 | qreal sh = sr.height(); | - |
3021 | | - |
3022 | | - |
3023 | | - |
3024 | | - |
3025 | const qreal pmscale = pm.devicePixelRatio(); | - |
3026 | | - |
3027 | | - |
3028 | if (sw <= 0) | - |
3029 | sw = pm.width() - sx; | - |
3030 | | - |
3031 | if (sh <= 0) | - |
3032 | sh = pm.height() - sy; | - |
3033 | | - |
3034 | if (w < 0) | - |
3035 | w = sw / pmscale; | - |
3036 | if (h < 0) | - |
3037 | h = sh / pmscale; | - |
3038 | | - |
3039 | if (sx < 0) { | - |
3040 | qreal w_ratio = sx * w/sw; | - |
3041 | x -= w_ratio; | - |
3042 | w += w_ratio; | - |
3043 | sw += sx; | - |
3044 | sx = 0; | - |
3045 | } | - |
3046 | | - |
3047 | if (sy < 0) { | - |
3048 | qreal h_ratio = sy * h/sh; | - |
3049 | y -= h_ratio; | - |
3050 | h += h_ratio; | - |
3051 | sh += sy; | - |
3052 | sy = 0; | - |
3053 | } | - |
3054 | | - |
3055 | if (sw + sx > pm.width()) { | - |
3056 | qreal delta = sw - (pm.width() - sx); | - |
3057 | qreal w_ratio = delta * w/sw; | - |
3058 | sw -= delta; | - |
3059 | w -= w_ratio; | - |
3060 | } | - |
3061 | | - |
3062 | if (sh + sy > pm.height()) { | - |
3063 | qreal delta = sh - (pm.height() - sy); | - |
3064 | qreal h_ratio = delta * h/sh; | - |
3065 | sh -= delta; | - |
3066 | h -= h_ratio; | - |
3067 | } | - |
3068 | | - |
3069 | if (w == 0 || h == 0 || sw <= 0 || sh <= 0) | - |
3070 | return; | - |
3071 | | - |
3072 | if (d->extended) { | - |
3073 | d->extended->drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh)); | - |
3074 | return; | - |
3075 | } | - |
3076 | | - |
3077 | | - |
3078 | if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap()) | - |
3079 | fillRect(QRectF(x, y, w, h), d->state->bgBrush.color()); | - |
3080 | | - |
3081 | d->updateState(d->state); | - |
3082 | | - |
3083 | if ((d->state->matrix.type() > QTransform::TxTranslate | - |
3084 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) | - |
3085 | || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform)) | - |
3086 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity)) | - |
3087 | || ((sw != w || sh != h) && !d->engine->hasFeature(QPaintEngine::PixmapTransform))) | - |
3088 | { | - |
3089 | save(); | - |
3090 | | - |
3091 | | - |
3092 | if (d->state->matrix.type() <= QTransform::TxScale) { | - |
3093 | const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); | - |
3094 | x = p.x(); | - |
3095 | y = p.y(); | - |
3096 | } | - |
3097 | | - |
3098 | if (d->state->matrix.type() <= QTransform::TxTranslate && sw == w && sh == h) { | - |
3099 | sx = qRound(sx); | - |
3100 | sy = qRound(sy); | - |
3101 | sw = qRound(sw); | - |
3102 | sh = qRound(sh); | - |
3103 | } | - |
3104 | | - |
3105 | translate(x, y); | - |
3106 | scale(w / sw, h / sh); | - |
3107 | setBackgroundMode(Qt::TransparentMode); | - |
3108 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
3109 | QBrush brush; | - |
3110 | | - |
3111 | if (sw == pm.width() && sh == pm.height()) | - |
3112 | brush = QBrush(d->state->pen.color(), pm); | - |
3113 | else | - |
3114 | brush = QBrush(d->state->pen.color(), pm.copy(sx, sy, sw, sh)); | - |
3115 | | - |
3116 | setBrush(brush); | - |
3117 | setPen(Qt::NoPen); | - |
3118 | | - |
3119 | drawRect(QRectF(0, 0, sw, sh)); | - |
3120 | restore(); | - |
3121 | } else { | - |
3122 | if (!d->engine->hasFeature(QPaintEngine::PixmapTransform)) { | - |
3123 | x += d->state->matrix.dx(); | - |
3124 | y += d->state->matrix.dy(); | - |
3125 | } | - |
3126 | d->engine->drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh)); | - |
3127 | } | - |
3128 | } | - |
3129 | void QPainter::drawImage(const QPointF &p, const QImage &image) | - |
3130 | { | - |
3131 | QPainterPrivate * const d = d_func(); | - |
3132 | | - |
3133 | if (!d->engine || image.isNull()) | - |
3134 | return; | - |
3135 | | - |
3136 | if (d->extended) { | - |
3137 | d->extended->drawImage(p, image); | - |
3138 | return; | - |
3139 | } | - |
3140 | | - |
3141 | qreal x = p.x(); | - |
3142 | qreal y = p.y(); | - |
3143 | | - |
3144 | int w = image.width(); | - |
3145 | int h = image.height(); | - |
3146 | qreal scale = image.devicePixelRatio(); | - |
3147 | | - |
3148 | d->updateState(d->state); | - |
3149 | | - |
3150 | if (((d->state->matrix.type() > QTransform::TxTranslate) | - |
3151 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) | - |
3152 | || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform)) | - |
3153 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) | - |
3154 | { | - |
3155 | save(); | - |
3156 | | - |
3157 | | - |
3158 | if (d->state->matrix.type() <= QTransform::TxScale) { | - |
3159 | const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); | - |
3160 | x = p.x(); | - |
3161 | y = p.y(); | - |
3162 | } | - |
3163 | translate(x, y); | - |
3164 | setBackgroundMode(Qt::TransparentMode); | - |
3165 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
3166 | QBrush brush(image); | - |
3167 | setBrush(brush); | - |
3168 | setPen(Qt::NoPen); | - |
3169 | setBrushOrigin(QPointF(0, 0)); | - |
3170 | drawRect(QRect(QPoint(0, 0), image.size() / scale)); | - |
3171 | restore(); | - |
3172 | return; | - |
3173 | } | - |
3174 | | - |
3175 | if (d->state->matrix.type() == QTransform::TxTranslate | - |
3176 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) { | - |
3177 | x += d->state->matrix.dx(); | - |
3178 | y += d->state->matrix.dy(); | - |
3179 | } | - |
3180 | | - |
3181 | d->engine->drawImage(QRectF(x, y, w / scale, h / scale), image, QRectF(0, 0, w, h), Qt::AutoColor); | - |
3182 | } | - |
3183 | | - |
3184 | void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, | - |
3185 | Qt::ImageConversionFlags flags) | - |
3186 | { | - |
3187 | QPainterPrivate * const d = d_func(); | - |
3188 | | - |
3189 | if (!d->engine || image.isNull()) | - |
3190 | return; | - |
3191 | | - |
3192 | qreal x = targetRect.x(); | - |
3193 | qreal y = targetRect.y(); | - |
3194 | qreal w = targetRect.width(); | - |
3195 | qreal h = targetRect.height(); | - |
3196 | qreal sx = sourceRect.x(); | - |
3197 | qreal sy = sourceRect.y(); | - |
3198 | qreal sw = sourceRect.width(); | - |
3199 | qreal sh = sourceRect.height(); | - |
3200 | qreal imageScale = image.devicePixelRatio(); | - |
3201 | | - |
3202 | | - |
3203 | if (sw <= 0) | - |
3204 | sw = image.width() - sx; | - |
3205 | | - |
3206 | if (sh <= 0) | - |
3207 | sh = image.height() - sy; | - |
3208 | | - |
3209 | if (w < 0) | - |
3210 | w = sw / imageScale; | - |
3211 | if (h < 0) | - |
3212 | h = sh / imageScale; | - |
3213 | | - |
3214 | if (sx < 0) { | - |
3215 | qreal w_ratio = sx * w/sw; | - |
3216 | x -= w_ratio; | - |
3217 | w += w_ratio; | - |
3218 | sw += sx; | - |
3219 | sx = 0; | - |
3220 | } | - |
3221 | | - |
3222 | if (sy < 0) { | - |
3223 | qreal h_ratio = sy * h/sh; | - |
3224 | y -= h_ratio; | - |
3225 | h += h_ratio; | - |
3226 | sh += sy; | - |
3227 | sy = 0; | - |
3228 | } | - |
3229 | | - |
3230 | if (sw + sx > image.width()) { | - |
3231 | qreal delta = sw - (image.width() - sx); | - |
3232 | qreal w_ratio = delta * w/sw; | - |
3233 | sw -= delta; | - |
3234 | w -= w_ratio; | - |
3235 | } | - |
3236 | | - |
3237 | if (sh + sy > image.height()) { | - |
3238 | qreal delta = sh - (image.height() - sy); | - |
3239 | qreal h_ratio = delta * h/sh; | - |
3240 | sh -= delta; | - |
3241 | h -= h_ratio; | - |
3242 | } | - |
3243 | | - |
3244 | if (w == 0 || h == 0 || sw <= 0 || sh <= 0) | - |
3245 | return; | - |
3246 | | - |
3247 | if (d->extended) { | - |
3248 | d->extended->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags); | - |
3249 | return; | - |
3250 | } | - |
3251 | | - |
3252 | d->updateState(d->state); | - |
3253 | | - |
3254 | if (((d->state->matrix.type() > QTransform::TxTranslate || (sw != w || sh != h)) | - |
3255 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) | - |
3256 | || (!d->state->matrix.isAffine() && !d->engine->hasFeature(QPaintEngine::PerspectiveTransform)) | - |
3257 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) | - |
3258 | { | - |
3259 | save(); | - |
3260 | | - |
3261 | | - |
3262 | if (d->state->matrix.type() <= QTransform::TxScale) { | - |
3263 | const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); | - |
3264 | x = p.x(); | - |
3265 | y = p.y(); | - |
3266 | } | - |
3267 | | - |
3268 | if (d->state->matrix.type() <= QTransform::TxTranslate && sw == w && sh == h) { | - |
3269 | sx = qRound(sx); | - |
3270 | sy = qRound(sy); | - |
3271 | sw = qRound(sw); | - |
3272 | sh = qRound(sh); | - |
3273 | } | - |
3274 | translate(x, y); | - |
3275 | scale(w / sw, h / sh); | - |
3276 | setBackgroundMode(Qt::TransparentMode); | - |
3277 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
3278 | QBrush brush(image); | - |
3279 | setBrush(brush); | - |
3280 | setPen(Qt::NoPen); | - |
3281 | setBrushOrigin(QPointF(-sx, -sy)); | - |
3282 | | - |
3283 | drawRect(QRectF(0, 0, sw, sh)); | - |
3284 | restore(); | - |
3285 | return; | - |
3286 | } | - |
3287 | | - |
3288 | if (d->state->matrix.type() == QTransform::TxTranslate | - |
3289 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) { | - |
3290 | x += d->state->matrix.dx(); | - |
3291 | y += d->state->matrix.dy(); | - |
3292 | } | - |
3293 | | - |
3294 | d->engine->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags); | - |
3295 | } | - |
3296 | void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun) | - |
3297 | { | - |
3298 | QPainterPrivate * const d = d_func(); | - |
3299 | | - |
3300 | if (!d->engine) { | - |
3301 | QMessageLogger(__FILE__, 55395543, __PRETTY_FUNCTION__).warning("QPainter::drawGlyphRun: Painter not active"); | - |
3302 | return; | - |
3303 | } | - |
3304 | | - |
3305 | QRawFont font = glyphRun.rawFont(); | - |
3306 | if (!font.isValid()) | - |
3307 | return; | - |
3308 | | - |
3309 | QGlyphRunPrivate *glyphRun_d = QGlyphRunPrivate::get(glyphRun); | - |
3310 | | - |
3311 | const quint32 *glyphIndexes = glyphRun_d->glyphIndexData; | - |
3312 | const QPointF *glyphPositions = glyphRun_d->glyphPositionData; | - |
3313 | | - |
3314 | int count = qMin(glyphRun_d->glyphIndexDataSize, glyphRun_d->glyphPositionDataSize); | - |
3315 | QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count); | - |
3316 | | - |
3317 | QRawFontPrivate *fontD = QRawFontPrivate::get(font); | - |
3318 | bool engineRequiresPretransformedGlyphPositions = d->extended | - |
3319 | ? d->extended->requiresPretransformedGlyphPositions(fontD->fontEngine, d->state->matrix) | - |
3320 | : d->engine->type() != QPaintEngine::CoreGraphics && !d->state->matrix.isAffine(); | - |
3321 | | - |
3322 | for (int i=0; i<count; ++i) { | - |
3323 | QPointF processedPosition = position + glyphPositions[i]; | - |
3324 | if (engineRequiresPretransformedGlyphPositions) | - |
3325 | processedPosition = d->state->transform().map(processedPosition); | - |
3326 | fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition); | - |
3327 | } | - |
3328 | | - |
3329 | d->drawGlyphs(glyphIndexes, fixedPointPositions.data(), count, fontD->fontEngine, | - |
3330 | glyphRun.overline(), glyphRun.underline(), glyphRun.strikeOut()); | - |
3331 | } | - |
3332 | | - |
3333 | void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positions, | - |
3334 | int glyphCount, | - |
3335 | QFontEngine *fontEngine, bool overline, bool underline, | - |
3336 | bool strikeOut) | - |
3337 | { | - |
3338 | QPainter * const q = q_func(); | - |
3339 | | - |
3340 | updateState(state); | - |
3341 | | - |
3342 | QFixed leftMost; | - |
3343 | QFixed rightMost; | - |
3344 | QFixed baseLine; | - |
3345 | for (int i=0; i<glyphCount; ++i) { | - |
3346 | glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]); | - |
3347 | if (i == 0 || leftMost > positions[i].x) | - |
3348 | leftMost = positions[i].x; | - |
3349 | | - |
3350 | | - |
3351 | | - |
3352 | | - |
3353 | if (i == 0 || baseLine < positions[i].y) | - |
3354 | baseLine = positions[i].y; | - |
3355 | | - |
3356 | | - |
3357 | if (i == 0 || rightMost < positions[i].x + gm.xoff) | - |
3358 | rightMost = positions[i].x + gm.xoff; | - |
3359 | } | - |
3360 | | - |
3361 | QFixed width = rightMost - leftMost; | - |
3362 | | - |
3363 | if (extended != 0 && state->matrix.isAffine()) { | - |
3364 | QStaticTextItem staticTextItem; | - |
3365 | staticTextItem.color = state->pen.color(); | - |
3366 | staticTextItem.font = state->font; | - |
3367 | staticTextItem.setFontEngine(fontEngine); | - |
3368 | staticTextItem.numGlyphs = glyphCount; | - |
3369 | staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray)); | - |
3370 | staticTextItem.glyphPositions = positions; | - |
3371 | | - |
3372 | staticTextItem.usesRawFont = true; | - |
3373 | | - |
3374 | extended->drawStaticTextItem(&staticTextItem); | - |
3375 | } else { | - |
3376 | QTextItemInt textItem; | - |
3377 | textItem.fontEngine = fontEngine; | - |
3378 | | - |
3379 | QVarLengthArray<QFixed, 128> advances(glyphCount); | - |
3380 | QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount); | - |
3381 | QVarLengthArray<QGlyphAttributes, 128> glyphAttributes(glyphCount); | - |
3382 | memset(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(QGlyphAttributes)); | - |
3383 | memset(advances.data(), 0, advances.size() * sizeof(QFixed)); | - |
3384 | memset(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification)); | - |
3385 | | - |
3386 | textItem.glyphs.numGlyphs = glyphCount; | - |
3387 | textItem.glyphs.glyphs = const_cast<glyph_t *>(glyphArray); | - |
3388 | textItem.glyphs.offsets = positions; | - |
3389 | textItem.glyphs.advances = advances.data(); | - |
3390 | textItem.glyphs.justifications = glyphJustifications.data(); | - |
3391 | textItem.glyphs.attributes = glyphAttributes.data(); | - |
3392 | | - |
3393 | engine->drawTextItem(QPointF(0, 0), textItem); | - |
3394 | } | - |
3395 | | - |
3396 | QTextItemInt::RenderFlags flags; | - |
3397 | if (underline) | - |
3398 | flags |= QTextItemInt::Underline; | - |
3399 | if (overline) | - |
3400 | flags |= QTextItemInt::Overline; | - |
3401 | if (strikeOut) | - |
3402 | flags |= QTextItemInt::StrikeOut; | - |
3403 | | - |
3404 | drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()), | - |
3405 | fontEngine, | - |
3406 | 0, | - |
3407 | (underline | - |
3408 | ? QTextCharFormat::SingleUnderline | - |
3409 | : QTextCharFormat::NoUnderline), | - |
3410 | flags, width.toReal(), QTextCharFormat()); | - |
3411 | } | - |
3412 | void QPainter::drawText(const QPointF &p, const QString &str) | - |
3413 | { | - |
3414 | drawText(p, str, 0, 0); | - |
3415 | } | - |
3416 | void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText) | - |
3417 | { | - |
3418 | QPainterPrivate * const d = d_func(); | - |
3419 | if (!d->engine || staticText.text().isEmpty() || pen().style() == Qt::NoPen) | - |
3420 | return; | - |
3421 | | - |
3422 | QStaticTextPrivate *staticText_d = | - |
3423 | const_cast<QStaticTextPrivate *>(QStaticTextPrivate::get(&staticText)); | - |
3424 | | - |
3425 | if (font() != staticText_d->font) { | - |
3426 | staticText_d->font = font(); | - |
3427 | staticText_d->needsRelayout = true; | - |
3428 | } | - |
3429 | | - |
3430 | QFontEngine *fe = staticText_d->font.d->engineForScript(QChar::Script_Common); | - |
3431 | if (fe->type() == QFontEngine::Multi) | - |
3432 | fe = static_cast<QFontEngineMulti *>(fe)->engine(0); | - |
3433 | | - |
3434 | | - |
3435 | | - |
3436 | | - |
3437 | if (d->extended == 0 | - |
3438 | || !d->state->matrix.isAffine() | - |
3439 | || !fe->supportsTransformation(d->state->matrix)) { | - |
3440 | staticText_d->paintText(topLeftPosition, this); | - |
3441 | return; | - |
3442 | } | - |
3443 | | - |
3444 | bool engineRequiresPretransform = d->extended->requiresPretransformedGlyphPositions(fe, d->state->matrix); | - |
3445 | if (staticText_d->untransformedCoordinates && engineRequiresPretransform) { | - |
3446 | | - |
3447 | | - |
3448 | staticText_d->untransformedCoordinates = false; | - |
3449 | staticText_d->needsRelayout = true; | - |
3450 | } else if (!staticText_d->untransformedCoordinates && !engineRequiresPretransform) { | - |
3451 | | - |
3452 | | - |
3453 | staticText_d->untransformedCoordinates = true; | - |
3454 | staticText_d->needsRelayout = true; | - |
3455 | } | - |
3456 | | - |
3457 | | - |
3458 | | - |
3459 | QPointF transformedPosition = topLeftPosition; | - |
3460 | if (!staticText_d->untransformedCoordinates) | - |
3461 | transformedPosition = transformedPosition * d->state->matrix; | - |
3462 | QTransform oldMatrix; | - |
3463 | | - |
3464 | | - |
3465 | | - |
3466 | if (d->state->matrix.isTranslating() && !staticText_d->untransformedCoordinates) { | - |
3467 | qreal m11 = d->state->matrix.m11(); | - |
3468 | qreal m12 = d->state->matrix.m12(); | - |
3469 | qreal m13 = d->state->matrix.m13(); | - |
3470 | qreal m21 = d->state->matrix.m21(); | - |
3471 | qreal m22 = d->state->matrix.m22(); | - |
3472 | qreal m23 = d->state->matrix.m23(); | - |
3473 | qreal m33 = d->state->matrix.m33(); | - |
3474 | | - |
3475 | oldMatrix = d->state->matrix; | - |
3476 | d->state->matrix.setMatrix(m11, m12, m13, | - |
3477 | m21, m22, m23, | - |
3478 | 0.0, 0.0, m33); | - |
3479 | } | - |
3480 | | - |
3481 | | - |
3482 | | - |
3483 | bool staticTextNeedsReinit = staticText_d->needsRelayout; | - |
3484 | if (!staticText_d->untransformedCoordinates && staticText_d->matrix != d->state->matrix) { | - |
3485 | staticText_d->matrix = d->state->matrix; | - |
3486 | staticTextNeedsReinit = true; | - |
3487 | } | - |
3488 | | - |
3489 | | - |
3490 | if (staticTextNeedsReinit) | - |
3491 | staticText_d->init(); | - |
3492 | | - |
3493 | if (transformedPosition != staticText_d->position) { | - |
3494 | QFixed fx = QFixed::fromReal(transformedPosition.x()); | - |
3495 | QFixed fy = QFixed::fromReal(transformedPosition.y()); | - |
3496 | QFixed oldX = QFixed::fromReal(staticText_d->position.x()); | - |
3497 | QFixed oldY = QFixed::fromReal(staticText_d->position.y()); | - |
3498 | for (int item=0; item<staticText_d->itemCount;++item) { | - |
3499 | QStaticTextItem *textItem = staticText_d->items + item; | - |
3500 | for (int i=0; i<textItem->numGlyphs; ++i) { | - |
3501 | textItem->glyphPositions[i].x += fx - oldX; | - |
3502 | textItem->glyphPositions[i].y += fy - oldY; | - |
3503 | } | - |
3504 | textItem->userDataNeedsUpdate = true; | - |
3505 | } | - |
3506 | | - |
3507 | staticText_d->position = transformedPosition; | - |
3508 | } | - |
3509 | | - |
3510 | QPen oldPen = d->state->pen; | - |
3511 | QColor currentColor = oldPen.color(); | - |
3512 | for (int i=0; i<staticText_d->itemCount; ++i) { | - |
3513 | QStaticTextItem *item = staticText_d->items + i; | - |
3514 | if (item->color.isValid() && currentColor != item->color) { | - |
3515 | setPen(item->color); | - |
3516 | currentColor = item->color; | - |
3517 | } | - |
3518 | d->extended->drawStaticTextItem(item); | - |
3519 | | - |
3520 | qt_draw_decoration_for_glyphs(this, item->glyphs, item->glyphPositions, | - |
3521 | item->numGlyphs, item->fontEngine(), staticText_d->font, | - |
3522 | QTextCharFormat()); | - |
3523 | } | - |
3524 | if (currentColor != oldPen.color()) | - |
3525 | setPen(oldPen); | - |
3526 | | - |
3527 | if (!staticText_d->untransformedCoordinates && oldMatrix.isTranslating()) | - |
3528 | d->state->matrix = oldMatrix; | - |
3529 | } | - |
3530 | | - |
3531 | | - |
3532 | | - |
3533 | | - |
3534 | void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justificationPadding) | - |
3535 | { | - |
3536 | | - |
3537 | | - |
3538 | | - |
3539 | | - |
3540 | | - |
3541 | QPainterPrivate * const d = d_func(); | - |
3542 | | - |
3543 | if (!d->engine || str.isEmpty() || pen().style() == Qt::NoPen) | - |
3544 | return; | - |
3545 | | - |
3546 | if (tf & Qt::TextBypassShaping) { | - |
3547 | | - |
3548 | int len = str.length(); | - |
3549 | int numGlyphs = len; | - |
3550 | QVarLengthGlyphLayoutArray glyphs(len); | - |
3551 | QFontEngine *fontEngine = d->state->font.d->engineForScript(QChar::Script_Common); | - |
3552 | if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) | - |
3553 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,58565860) : qt_noop()); __builtin_unreachable(); } while (0); | - |
3554 | | - |
3555 | QTextItemInt gf(glyphs, &d->state->font, str.data(), len, fontEngine); | - |
3556 | drawTextItem(p, gf); | - |
3557 | return; | - |
3558 | } | - |
3559 | | - |
3560 | QStackTextEngine engine(str, d->state->font); | - |
3561 | engine.option.setTextDirection(d->state->layoutDirection); | - |
3562 | if (tf & (Qt::TextForceLeftToRight|Qt::TextForceRightToLeft)) { | - |
3563 | engine.ignoreBidi = true; | - |
3564 | engine.option.setTextDirection((tf & Qt::TextForceLeftToRight) ? Qt::LeftToRight : Qt::RightToLeft); | - |
3565 | } | - |
3566 | engine.itemize(); | - |
3567 | QScriptLine line; | - |
3568 | line.length = str.length(); | - |
3569 | engine.shapeLine(line); | - |
3570 | | - |
3571 | int nItems = engine.layoutData->items.size(); | - |
3572 | QVarLengthArray<int> visualOrder(nItems); | - |
3573 | QVarLengthArray<uchar> levels(nItems); | - |
3574 | for (int i = 0; i < nItems; ++i) | - |
3575 | levels[i] = engine.layoutData->items[i].analysis.bidiLevel; | - |
3576 | QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); | - |
3577 | | - |
3578 | if (justificationPadding > 0) { | - |
3579 | engine.option.setAlignment(Qt::AlignJustify); | - |
3580 | engine.forceJustification = true; | - |
3581 | | - |
3582 | line.width = justificationPadding; | - |
3583 | engine.justify(line); | - |
3584 | } | - |
3585 | QFixed x = QFixed::fromReal(p.x()); | - |
3586 | | - |
3587 | for (int i = 0; i < nItems; ++i) { | - |
3588 | int item = visualOrder[i]; | - |
3589 | const QScriptItem &si = engine.layoutData->items.at(item); | - |
3590 | if (si.analysis.flags >= QScriptAnalysis::TabOrObject) { | - |
3591 | x += si.width; | - |
3592 | continue; | - |
3593 | } | - |
3594 | QFont f = engine.font(si); | - |
3595 | QTextItemInt gf(si, &f); | - |
3596 | gf.glyphs = engine.shapedGlyphs(&si); | - |
3597 | gf.chars = engine.layoutData->string.unicode() + si.position; | - |
3598 | gf.num_chars = engine.length(item); | - |
3599 | if (engine.forceJustification) { | - |
3600 | for (int j=0; j<gf.glyphs.numGlyphs; ++j) | - |
3601 | gf.width += gf.glyphs.effectiveAdvance(j); | - |
3602 | } else { | - |
3603 | gf.width = si.width; | - |
3604 | } | - |
3605 | gf.logClusters = engine.logClusters(&si); | - |
3606 | | - |
3607 | drawTextItem(QPointF(x.toReal(), p.y()), gf); | - |
3608 | | - |
3609 | x += gf.width; | - |
3610 | } | - |
3611 | } | - |
3612 | | - |
3613 | void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br) | - |
3614 | { | - |
3615 | | - |
3616 | | - |
3617 | | - |
3618 | | - |
3619 | | - |
3620 | | - |
3621 | QPainterPrivate * const d = d_func(); | - |
3622 | | - |
3623 | if (!d->engine || str.length() == 0 || pen().style() == Qt::NoPen) | - |
3624 | return; | - |
3625 | | - |
3626 | if (!d->extended) | - |
3627 | d->updateState(d->state); | - |
3628 | | - |
3629 | QRectF bounds; | - |
3630 | qt_format_text(d->state->font, r, flags, 0, str, br ? &bounds : 0, 0, 0, 0, this); | - |
3631 | if (br) | - |
3632 | *br = bounds.toAlignedRect(); | - |
3633 | } | - |
3634 | void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF *br) | - |
3635 | { | - |
3636 | | - |
3637 | | - |
3638 | | - |
3639 | | - |
3640 | | - |
3641 | | - |
3642 | QPainterPrivate * const d = d_func(); | - |
3643 | | - |
3644 | if (!d->engine || str.length() == 0 || pen().style() == Qt::NoPen) | - |
3645 | return; | - |
3646 | | - |
3647 | if (!d->extended) | - |
3648 | d->updateState(d->state); | - |
3649 | | - |
3650 | qt_format_text(d->state->font, r, flags, 0, str, br, 0, 0, 0, this); | - |
3651 | } | - |
3652 | void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption &o) | - |
3653 | { | - |
3654 | | - |
3655 | | - |
3656 | | - |
3657 | | - |
3658 | | - |
3659 | | - |
3660 | QPainterPrivate * const d = d_func(); | - |
3661 | | - |
3662 | if (!d->engine || text.length() == 0 || pen().style() == Qt::NoPen) | - |
3663 | return; | - |
3664 | | - |
3665 | if (!d->extended) | - |
3666 | d->updateState(d->state); | - |
3667 | | - |
3668 | qt_format_text(d->state->font, r, 0, &o, text, 0, 0, 0, 0, this); | - |
3669 | } | - |
3670 | static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen) | - |
3671 | { | - |
3672 | const qreal radiusBase = qMax(qreal(1), maxRadius); | - |
3673 | | - |
3674 | QString key = QLatin1String("WaveUnderline-") | - |
3675 | % pen.color().name() | - |
3676 | % HexString<qreal>(radiusBase) | - |
3677 | % HexString<qreal>(pen.widthF()); | - |
3678 | | - |
3679 | QPixmap pixmap; | - |
3680 | if (QPixmapCache::find(key, pixmap)) | - |
3681 | return pixmap; | - |
3682 | | - |
3683 | const qreal halfPeriod = qMax(qreal(2), qreal(radiusBase * 1.61803399)); | - |
3684 | const int width = qCeil(100 / (2 * halfPeriod)) * (2 * halfPeriod); | - |
3685 | const qreal radius = qFloor(radiusBase * 2) / 2.; | - |
3686 | | - |
3687 | QPainterPath path; | - |
3688 | | - |
3689 | qreal xs = 0; | - |
3690 | qreal ys = radius; | - |
3691 | | - |
3692 | while (xs < width) { | - |
3693 | xs += halfPeriod; | - |
3694 | ys = -ys; | - |
3695 | path.quadTo(xs - halfPeriod / 2, ys, xs, 0); | - |
3696 | } | - |
3697 | | - |
3698 | pixmap = QPixmap(width, radius * 2); | - |
3699 | pixmap.fill(Qt::transparent); | - |
3700 | { | - |
3701 | QPen wavePen = pen; | - |
3702 | wavePen.setCapStyle(Qt::SquareCap); | - |
3703 | | - |
3704 | | - |
3705 | | - |
3706 | const qreal maxPenWidth = .8 * radius; | - |
3707 | if (wavePen.widthF() > maxPenWidth) | - |
3708 | wavePen.setWidthF(maxPenWidth); | - |
3709 | | - |
3710 | QPainter imgPainter(&pixmap); | - |
3711 | imgPainter.setPen(wavePen); | - |
3712 | imgPainter.setRenderHint(QPainter::Antialiasing); | - |
3713 | imgPainter.translate(0, radius); | - |
3714 | imgPainter.drawPath(path); | - |
3715 | } | - |
3716 | | - |
3717 | QPixmapCache::insert(key, pixmap); | - |
3718 | | - |
3719 | return pixmap; | - |
3720 | } | - |
3721 | | - |
3722 | static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextEngine *textEngine, | - |
3723 | QTextCharFormat::UnderlineStyle underlineStyle, | - |
3724 | QTextItem::RenderFlags flags, qreal width, | - |
3725 | const QTextCharFormat &charFormat) | - |
3726 | { | - |
3727 | if (underlineStyle == QTextCharFormat::NoUnderline | - |
3728 | && !(flags & (QTextItem::StrikeOut | QTextItem::Overline))) | - |
3729 | return; | - |
3730 | | - |
3731 | const QPen oldPen = painter->pen(); | - |
3732 | const QBrush oldBrush = painter->brush(); | - |
3733 | painter->setBrush(Qt::NoBrush); | - |
3734 | QPen pen = oldPen; | - |
3735 | pen.setStyle(Qt::SolidLine); | - |
3736 | pen.setWidthF(fe->lineThickness().toReal()); | - |
3737 | pen.setCapStyle(Qt::FlatCap); | - |
3738 | | - |
3739 | QLineF line(qFloor(pos.x()), pos.y(), qFloor(pos.x() + width), pos.y()); | - |
3740 | | - |
3741 | bool wasCompatiblePainting = painter->renderHints() | - |
3742 | & QPainter::Qt4CompatiblePainting; | - |
3743 | | - |
3744 | if (wasCompatiblePainting) | - |
3745 | painter->setRenderHint(QPainter::Qt4CompatiblePainting, false); | - |
3746 | | - |
3747 | const qreal underlineOffset = fe->underlinePosition().toReal(); | - |
3748 | | - |
3749 | if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { | - |
3750 | QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); | - |
3751 | if (theme) | - |
3752 | underlineStyle = QTextCharFormat::UnderlineStyle(theme->themeHint(QPlatformTheme::SpellCheckUnderlineStyle).toInt()); | - |
3753 | } | - |
3754 | | - |
3755 | if (underlineStyle == QTextCharFormat::WaveUnderline) { | - |
3756 | painter->save(); | - |
3757 | painter->translate(0, pos.y() + 1); | - |
3758 | qreal maxHeight = fe->descent().toReal() - qreal(1); | - |
3759 | | - |
3760 | QColor uc = charFormat.underlineColor(); | - |
3761 | if (uc.isValid()) | - |
3762 | pen.setColor(uc); | - |
3763 | | - |
3764 | | - |
3765 | const QPixmap wave = generateWavyPixmap(qMin(qMax(underlineOffset, pen.widthF()), maxHeight / qreal(2.)), pen); | - |
3766 | const int descent = qFloor(maxHeight); | - |
3767 | | - |
3768 | painter->setBrushOrigin(painter->brushOrigin().x(), 0); | - |
3769 | painter->fillRect(pos.x(), 0, qCeil(width), qMin(wave.height(), descent), wave); | - |
3770 | painter->restore(); | - |
3771 | } else if (underlineStyle != QTextCharFormat::NoUnderline) { | - |
3772 | | - |
3773 | | - |
3774 | qreal adjustedUnderlineOffset = std::ceil(underlineOffset) + 0.5; | - |
3775 | if (underlineOffset <= fe->descent().toReal()) | - |
3776 | adjustedUnderlineOffset = qMin(adjustedUnderlineOffset, fe->descent().toReal() - qreal(0.5)); | - |
3777 | const qreal underlinePos = pos.y() + adjustedUnderlineOffset; | - |
3778 | QColor uc = charFormat.underlineColor(); | - |
3779 | if (uc.isValid()) | - |
3780 | pen.setColor(uc); | - |
3781 | | - |
3782 | pen.setStyle((Qt::PenStyle)(underlineStyle)); | - |
3783 | painter->setPen(pen); | - |
3784 | QLineF underline(line.x1(), underlinePos, line.x2(), underlinePos); | - |
3785 | if (textEngine) | - |
3786 | textEngine->addUnderline(painter, underline); | - |
3787 | else | - |
3788 | painter->drawLine(underline); | - |
3789 | } | - |
3790 | | - |
3791 | pen.setStyle(Qt::SolidLine); | - |
3792 | pen.setColor(oldPen.color()); | - |
3793 | | - |
3794 | if (flags & QTextItem::StrikeOut) { | - |
3795 | QLineF strikeOutLine = line; | - |
3796 | strikeOutLine.translate(0., - fe->ascent().toReal() / 3.); | - |
3797 | painter->setPen(pen); | - |
3798 | if (textEngine) | - |
3799 | textEngine->addStrikeOut(painter, strikeOutLine); | - |
3800 | else | - |
3801 | painter->drawLine(strikeOutLine); | - |
3802 | } | - |
3803 | | - |
3804 | if (flags & QTextItem::Overline) { | - |
3805 | QLineF overline = line; | - |
3806 | overline.translate(0., - fe->ascent().toReal()); | - |
3807 | painter->setPen(pen); | - |
3808 | if (textEngine) | - |
3809 | textEngine->addOverline(painter, overline); | - |
3810 | else | - |
3811 | painter->drawLine(overline); | - |
3812 | } | - |
3813 | | - |
3814 | painter->setPen(oldPen); | - |
3815 | painter->setBrush(oldBrush); | - |
3816 | | - |
3817 | if (wasCompatiblePainting) | - |
3818 | painter->setRenderHint(QPainter::Qt4CompatiblePainting); | - |
3819 | } | - |
3820 | | - |
3821 | __attribute__((visibility("default"))) void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray, | - |
3822 | const QFixedPoint *positions, int glyphCount, | - |
3823 | QFontEngine *fontEngine, const QFont &font, | - |
3824 | const QTextCharFormat &charFormat) | - |
3825 | { | - |
3826 | if (!(font.underline() || font.strikeOut() || font.overline())) | - |
3827 | return; | - |
3828 | | - |
3829 | QFixed leftMost; | - |
3830 | QFixed rightMost; | - |
3831 | QFixed baseLine; | - |
3832 | for (int i=0; i<glyphCount; ++i) { | - |
3833 | glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]); | - |
3834 | if (i == 0 || leftMost > positions[i].x) | - |
3835 | leftMost = positions[i].x; | - |
3836 | | - |
3837 | | - |
3838 | | - |
3839 | | - |
3840 | if (i == 0 || baseLine < positions[i].y) | - |
3841 | baseLine = positions[i].y; | - |
3842 | | - |
3843 | | - |
3844 | if (i == 0 || rightMost < positions[i].x + gm.xoff) | - |
3845 | rightMost = positions[i].x + gm.xoff; | - |
3846 | } | - |
3847 | | - |
3848 | QFixed width = rightMost - leftMost; | - |
3849 | QTextItem::RenderFlags flags = 0; | - |
3850 | | - |
3851 | if (font.underline()) | - |
3852 | flags |= QTextItem::Underline; | - |
3853 | if (font.overline()) | - |
3854 | flags |= QTextItem::Overline; | - |
3855 | if (font.strikeOut()) | - |
3856 | flags |= QTextItem::StrikeOut; | - |
3857 | | - |
3858 | drawTextItemDecoration(painter, QPointF(leftMost.toReal(), baseLine.toReal()), | - |
3859 | fontEngine, | - |
3860 | 0, | - |
3861 | font.underline() ? QTextCharFormat::SingleUnderline | - |
3862 | : QTextCharFormat::NoUnderline, flags, | - |
3863 | width.toReal(), charFormat); | - |
3864 | } | - |
3865 | | - |
3866 | void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti) | - |
3867 | { | - |
3868 | QPainterPrivate * const d = d_func(); | - |
3869 | | - |
3870 | d->drawTextItem(p, ti, static_cast<QTextEngine *>(0)); | - |
3871 | } | - |
3872 | | - |
3873 | void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QTextEngine *textEngine) | - |
3874 | { | - |
3875 | | - |
3876 | | - |
3877 | | - |
3878 | | - |
3879 | | - |
3880 | | - |
3881 | QPainter * const q = q_func(); | - |
3882 | | - |
3883 | if (!engine) | - |
3884 | return; | - |
3885 | | - |
3886 | QTextItemInt &ti = const_cast<QTextItemInt &>(static_cast<const QTextItemInt &>(_ti)); | - |
3887 | | - |
3888 | if (!extended && state->bgMode == Qt::OpaqueMode) { | - |
3889 | QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent).toReal()); | - |
3890 | q->fillRect(rect, state->bgBrush); | - |
3891 | } | - |
3892 | | - |
3893 | if (q->pen().style() == Qt::NoPen) | - |
3894 | return; | - |
3895 | | - |
3896 | const QPainter::RenderHints oldRenderHints = state->renderHints; | - |
3897 | if (!(state->renderHints & QPainter::Antialiasing) && state->matrix.type() >= QTransform::TxScale) { | - |
3898 | | - |
3899 | | - |
3900 | | - |
3901 | bool aa = true; | - |
3902 | const QTransform &m = state->matrix; | - |
3903 | if (state->matrix.type() < QTransform::TxShear) { | - |
3904 | bool isPlain90DegreeRotation = | - |
3905 | (qFuzzyIsNull(m.m11()) | - |
3906 | && qFuzzyIsNull(m.m12() - qreal(1)) | - |
3907 | && qFuzzyIsNull(m.m21() + qreal(1)) | - |
3908 | && qFuzzyIsNull(m.m22()) | - |
3909 | ) | - |
3910 | || | - |
3911 | (qFuzzyIsNull(m.m11() + qreal(1)) | - |
3912 | && qFuzzyIsNull(m.m12()) | - |
3913 | && qFuzzyIsNull(m.m21()) | - |
3914 | && qFuzzyIsNull(m.m22() + qreal(1)) | - |
3915 | ) | - |
3916 | || | - |
3917 | (qFuzzyIsNull(m.m11()) | - |
3918 | && qFuzzyIsNull(m.m12() + qreal(1)) | - |
3919 | && qFuzzyIsNull(m.m21() - qreal(1)) | - |
3920 | && qFuzzyIsNull(m.m22()) | - |
3921 | ) | - |
3922 | ; | - |
3923 | aa = !isPlain90DegreeRotation; | - |
3924 | } | - |
3925 | if (aa) | - |
3926 | q->setRenderHint(QPainter::Antialiasing, true); | - |
3927 | } | - |
3928 | | - |
3929 | if (!extended) | - |
3930 | updateState(state); | - |
3931 | | - |
3932 | if (!ti.glyphs.numGlyphs) { | - |
3933 | | - |
3934 | } else if (ti.fontEngine->type() == QFontEngine::Multi) { | - |
3935 | QFontEngineMulti *multi = static_cast<QFontEngineMulti *>(ti.fontEngine); | - |
3936 | | - |
3937 | const QGlyphLayout &glyphs = ti.glyphs; | - |
3938 | int which = glyphs.glyphs[0] >> 24; | - |
3939 | | - |
3940 | qreal x = p.x(); | - |
3941 | qreal y = p.y(); | - |
3942 | | - |
3943 | bool rtl = ti.flags & QTextItem::RightToLeft; | - |
3944 | if (rtl) | - |
3945 | x += ti.width.toReal(); | - |
3946 | | - |
3947 | int start = 0; | - |
3948 | int end, i; | - |
3949 | for (end = 0; end < ti.glyphs.numGlyphs; ++end) { | - |
3950 | const int e = glyphs.glyphs[end] >> 24; | - |
3951 | if (e == which) | - |
3952 | continue; | - |
3953 | | - |
3954 | | - |
3955 | multi->ensureEngineAt(which); | - |
3956 | QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); | - |
3957 | ti2.width = 0; | - |
3958 | | - |
3959 | for (i = start; i < end; ++i) { | - |
3960 | glyphs.glyphs[i] = glyphs.glyphs[i] & 0xffffff; | - |
3961 | ti2.width += ti.glyphs.effectiveAdvance(i); | - |
3962 | } | - |
3963 | | - |
3964 | if (rtl) | - |
3965 | x -= ti2.width.toReal(); | - |
3966 | | - |
3967 | if (extended) | - |
3968 | extended->drawTextItem(QPointF(x, y), ti2); | - |
3969 | else | - |
3970 | engine->drawTextItem(QPointF(x, y), ti2); | - |
3971 | | - |
3972 | if (!rtl) | - |
3973 | x += ti2.width.toReal(); | - |
3974 | | - |
3975 | | - |
3976 | const int hi = which << 24; | - |
3977 | for (i = start; i < end; ++i) { | - |
3978 | glyphs.glyphs[i] = hi | glyphs.glyphs[i]; | - |
3979 | } | - |
3980 | | - |
3981 | | - |
3982 | start = end; | - |
3983 | which = e; | - |
3984 | } | - |
3985 | | - |
3986 | multi->ensureEngineAt(which); | - |
3987 | QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); | - |
3988 | ti2.width = 0; | - |
3989 | | - |
3990 | for (i = start; i < end; ++i) { | - |
3991 | glyphs.glyphs[i] = glyphs.glyphs[i] & 0xffffff; | - |
3992 | ti2.width += ti.glyphs.effectiveAdvance(i); | - |
3993 | } | - |
3994 | | - |
3995 | if (rtl) | - |
3996 | x -= ti2.width.toReal(); | - |
3997 | | - |
3998 | if (extended) | - |
3999 | extended->drawTextItem(QPointF(x, y), ti2); | - |
4000 | else | - |
4001 | engine->drawTextItem(QPointF(x,y), ti2); | - |
4002 | | - |
4003 | | - |
4004 | const int hi = which << 24; | - |
4005 | for (i = start; i < end; ++i) | - |
4006 | glyphs.glyphs[i] = hi | glyphs.glyphs[i]; | - |
4007 | | - |
4008 | } else { | - |
4009 | if (extended) | - |
4010 | extended->drawTextItem(p, ti); | - |
4011 | else | - |
4012 | engine->drawTextItem(p, ti); | - |
4013 | } | - |
4014 | drawTextItemDecoration(q, p, ti.fontEngine, textEngine, ti.underlineStyle, | - |
4015 | ti.flags, ti.width.toReal(), ti.charFormat); | - |
4016 | | - |
4017 | if (state->renderHints != oldRenderHints) { | - |
4018 | state->renderHints = oldRenderHints; | - |
4019 | if (extended) | - |
4020 | extended->renderHintsChanged(); | - |
4021 | else | - |
4022 | state->dirtyFlags |= QPaintEngine::DirtyHints; | - |
4023 | } | - |
4024 | } | - |
4025 | QRect QPainter::boundingRect(const QRect &rect, int flags, const QString &str) | - |
4026 | { | - |
4027 | if (str.isEmpty()) | - |
4028 | return QRect(rect.x(),rect.y(), 0,0); | - |
4029 | QRect brect; | - |
4030 | drawText(rect, flags | Qt::TextDontPrint, str, &brect); | - |
4031 | return brect; | - |
4032 | } | - |
4033 | | - |
4034 | | - |
4035 | | - |
4036 | QRectF QPainter::boundingRect(const QRectF &rect, int flags, const QString &str) | - |
4037 | { | - |
4038 | if (str.isEmpty()) | - |
4039 | return QRectF(rect.x(),rect.y(), 0,0); | - |
4040 | QRectF brect; | - |
4041 | drawText(rect, flags | Qt::TextDontPrint, str, &brect); | - |
4042 | return brect; | - |
4043 | } | - |
4044 | QRectF QPainter::boundingRect(const QRectF &r, const QString &text, const QTextOption &o) | - |
4045 | { | - |
4046 | QPainterPrivate * const d = d_func(); | - |
4047 | | - |
4048 | if (!d->engine || text.length() == 0) | - |
4049 | return QRectF(r.x(),r.y(), 0,0); | - |
4050 | | - |
4051 | QRectF br; | - |
4052 | qt_format_text(d->state->font, r, Qt::TextDontPrint, &o, text, &br, 0, 0, 0, this); | - |
4053 | return br; | - |
4054 | } | - |
4055 | void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &sp) | - |
4056 | { | - |
4057 | QPainterPrivate * const d = d_func(); | - |
4058 | if (!d->engine || pixmap.isNull() || r.isEmpty()) | - |
4059 | return; | - |
4060 | | - |
4061 | | - |
4062 | qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawTiledPixmap()"); | - |
4063 | | - |
4064 | | - |
4065 | qreal sw = pixmap.width(); | - |
4066 | qreal sh = pixmap.height(); | - |
4067 | qreal sx = sp.x(); | - |
4068 | qreal sy = sp.y(); | - |
4069 | if (sx < 0) | - |
4070 | sx = qRound(sw) - qRound(-sx) % qRound(sw); | - |
4071 | else | - |
4072 | sx = qRound(sx) % qRound(sw); | - |
4073 | if (sy < 0) | - |
4074 | sy = qRound(sh) - -qRound(sy) % qRound(sh); | - |
4075 | else | - |
4076 | sy = qRound(sy) % qRound(sh); | - |
4077 | | - |
4078 | | - |
4079 | if (d->extended) { | - |
4080 | d->extended->drawTiledPixmap(r, pixmap, QPointF(sx, sy)); | - |
4081 | return; | - |
4082 | } | - |
4083 | | - |
4084 | if (d->state->bgMode == Qt::OpaqueMode && pixmap.isQBitmap()) | - |
4085 | fillRect(r, d->state->bgBrush); | - |
4086 | | - |
4087 | d->updateState(d->state); | - |
4088 | if ((d->state->matrix.type() > QTransform::TxTranslate | - |
4089 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) | - |
4090 | || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) | - |
4091 | { | - |
4092 | save(); | - |
4093 | setBackgroundMode(Qt::TransparentMode); | - |
4094 | setRenderHint(Antialiasing, renderHints() & SmoothPixmapTransform); | - |
4095 | setBrush(QBrush(d->state->pen.color(), pixmap)); | - |
4096 | setPen(Qt::NoPen); | - |
4097 | | - |
4098 | | - |
4099 | | - |
4100 | if (d->state->matrix.type() <= QTransform::TxScale) { | - |
4101 | const QPointF p = roundInDeviceCoordinates(r.topLeft(), d->state->matrix); | - |
4102 | | - |
4103 | if (d->state->matrix.type() <= QTransform::TxTranslate) { | - |
4104 | sx = qRound(sx); | - |
4105 | sy = qRound(sy); | - |
4106 | } | - |
4107 | | - |
4108 | setBrushOrigin(QPointF(r.x()-sx, r.y()-sy)); | - |
4109 | drawRect(QRectF(p, r.size())); | - |
4110 | } else { | - |
4111 | setBrushOrigin(QPointF(r.x()-sx, r.y()-sy)); | - |
4112 | drawRect(r); | - |
4113 | } | - |
4114 | restore(); | - |
4115 | return; | - |
4116 | } | - |
4117 | | - |
4118 | qreal x = r.x(); | - |
4119 | qreal y = r.y(); | - |
4120 | if (d->state->matrix.type() == QTransform::TxTranslate | - |
4121 | && !d->engine->hasFeature(QPaintEngine::PixmapTransform)) { | - |
4122 | x += d->state->matrix.dx(); | - |
4123 | y += d->state->matrix.dy(); | - |
4124 | } | - |
4125 | | - |
4126 | d->engine->drawTiledPixmap(QRectF(x, y, r.width(), r.height()), pixmap, QPointF(sx, sy)); | - |
4127 | } | - |
4128 | void QPainter::drawPicture(const QPointF &p, const QPicture &picture) | - |
4129 | { | - |
4130 | QPainterPrivate * const d = d_func(); | - |
4131 | | - |
4132 | if (!d->engine) | - |
4133 | return; | - |
4134 | | - |
4135 | if (!d->extended) | - |
4136 | d->updateState(d->state); | - |
4137 | | - |
4138 | save(); | - |
4139 | translate(p); | - |
4140 | const_cast<QPicture *>(&picture)->play(this); | - |
4141 | restore(); | - |
4142 | } | - |
4143 | void QPainter::eraseRect(const QRectF &r) | - |
4144 | { | - |
4145 | QPainterPrivate * const d = d_func(); | - |
4146 | | - |
4147 | fillRect(r, d->state->bgBrush); | - |
4148 | } | - |
4149 | | - |
4150 | static inline bool needsResolving(const QBrush &brush) | - |
4151 | { | - |
4152 | Qt::BrushStyle s = brush.style(); | - |
4153 | return ((s == Qt::LinearGradientPattern || s == Qt::RadialGradientPattern || | - |
4154 | s == Qt::ConicalGradientPattern) && | - |
4155 | brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode); | - |
4156 | } | - |
4157 | void QPainter::fillRect(const QRectF &r, const QBrush &brush) | - |
4158 | { | - |
4159 | QPainterPrivate * const d = d_func(); | - |
4160 | | - |
4161 | if (!d->engine) | - |
4162 | return; | - |
4163 | | - |
4164 | if (d->extended) { | - |
4165 | const QGradient *g = brush.gradient(); | - |
4166 | if (!g || g->coordinateMode() == QGradient::LogicalMode) { | - |
4167 | d->extended->fillRect(r, brush); | - |
4168 | return; | - |
4169 | } | - |
4170 | } | - |
4171 | | - |
4172 | QPen oldPen = pen(); | - |
4173 | QBrush oldBrush = this->brush(); | - |
4174 | setPen(Qt::NoPen); | - |
4175 | if (brush.style() == Qt::SolidPattern) { | - |
4176 | d->colorBrush.setStyle(Qt::SolidPattern); | - |
4177 | d->colorBrush.setColor(brush.color()); | - |
4178 | setBrush(d->colorBrush); | - |
4179 | } else { | - |
4180 | setBrush(brush); | - |
4181 | } | - |
4182 | | - |
4183 | drawRect(r); | - |
4184 | setBrush(oldBrush); | - |
4185 | setPen(oldPen); | - |
4186 | } | - |
4187 | void QPainter::fillRect(const QRect &r, const QBrush &brush) | - |
4188 | { | - |
4189 | QPainterPrivate * const d = d_func(); | - |
4190 | | - |
4191 | if (!d->engine) | - |
4192 | return; | - |
4193 | | - |
4194 | if (d->extended) { | - |
4195 | const QGradient *g = brush.gradient(); | - |
4196 | if (!g || g->coordinateMode() == QGradient::LogicalMode) { | - |
4197 | d->extended->fillRect(r, brush); | - |
4198 | return; | - |
4199 | } | - |
4200 | } | - |
4201 | | - |
4202 | QPen oldPen = pen(); | - |
4203 | QBrush oldBrush = this->brush(); | - |
4204 | setPen(Qt::NoPen); | - |
4205 | if (brush.style() == Qt::SolidPattern) { | - |
4206 | d->colorBrush.setStyle(Qt::SolidPattern); | - |
4207 | d->colorBrush.setColor(brush.color()); | - |
4208 | setBrush(d->colorBrush); | - |
4209 | } else { | - |
4210 | setBrush(brush); | - |
4211 | } | - |
4212 | | - |
4213 | drawRect(r); | - |
4214 | setBrush(oldBrush); | - |
4215 | setPen(oldPen); | - |
4216 | } | - |
4217 | void QPainter::fillRect(const QRect &r, const QColor &color) | - |
4218 | { | - |
4219 | QPainterPrivate * const d = d_func(); | - |
4220 | | - |
4221 | if (!d->engine) | - |
4222 | return; | - |
4223 | | - |
4224 | if (d->extended) { | - |
4225 | d->extended->fillRect(r, color); | - |
4226 | return; | - |
4227 | } | - |
4228 | | - |
4229 | fillRect(r, QBrush(color)); | - |
4230 | } | - |
4231 | void QPainter::fillRect(const QRectF &r, const QColor &color) | - |
4232 | { | - |
4233 | QPainterPrivate * const d = d_func(); | - |
4234 | | - |
4235 | if (!d->engine) | - |
4236 | return; | - |
4237 | | - |
4238 | if (d->extended) { | - |
4239 | d->extended->fillRect(r, color); | - |
4240 | return; | - |
4241 | } | - |
4242 | | - |
4243 | fillRect(r, QBrush(color)); | - |
4244 | } | - |
4245 | void QPainter::setRenderHint(RenderHint hint, bool on) | - |
4246 | { | - |
4247 | | - |
4248 | | - |
4249 | | - |
4250 | | - |
4251 | | - |
4252 | | - |
4253 | static const bool antialiasingDisabled = qEnvironmentVariableIntValue("QT_NO_ANTIALIASING"); | - |
4254 | if (hint == QPainter::Antialiasing && antialiasingDisabled) | - |
4255 | return; | - |
4256 | | - |
4257 | | - |
4258 | setRenderHints(hint, on); | - |
4259 | } | - |
4260 | void QPainter::setRenderHints(RenderHints hints, bool on) | - |
4261 | { | - |
4262 | QPainterPrivate * const d = d_func(); | - |
4263 | | - |
4264 | if (!d->engine) { | - |
4265 | QMessageLogger(__FILE__, 70907094, __PRETTY_FUNCTION__).warning("QPainter::setRenderHint: Painter must be active to set rendering hints"); | - |
4266 | return; | - |
4267 | } | - |
4268 | | - |
4269 | if (on) | - |
4270 | d->state->renderHints |= hints; | - |
4271 | else | - |
4272 | d->state->renderHints &= ~hints; | - |
4273 | | - |
4274 | if (d->extended) | - |
4275 | d->extended->renderHintsChanged(); | - |
4276 | else | - |
4277 | d->state->dirtyFlags |= QPaintEngine::DirtyHints; | - |
4278 | } | - |
4279 | | - |
4280 | | - |
4281 | | - |
4282 | | - |
4283 | | - |
4284 | | - |
4285 | | - |
4286 | QPainter::RenderHints QPainter::renderHints() const | - |
4287 | { | - |
4288 | const QPainterPrivate * const d = d_func(); | - |
4289 | | - |
4290 | if (!d->engine) | - |
4291 | return 0; | - |
4292 | | - |
4293 | return d->state->renderHints; | - |
4294 | } | - |
4295 | bool QPainter::viewTransformEnabled() const | - |
4296 | { | - |
4297 | const QPainterPrivate * const d = d_func(); | - |
4298 | if (!d->engine) { | - |
4299 | QMessageLogger(__FILE__, 71417145, __PRETTY_FUNCTION__).warning("QPainter::viewTransformEnabled: Painter not active"); | - |
4300 | return false; | - |
4301 | } | - |
4302 | return d->state->VxF; | - |
4303 | } | - |
4304 | void QPainter::setWindow(const QRect &r) | - |
4305 | { | - |
4306 | | - |
4307 | | - |
4308 | | - |
4309 | | - |
4310 | | - |
4311 | QPainterPrivate * const d = d_func(); | - |
4312 | | - |
4313 | if (!d->engine) { | - |
4314 | QMessageLogger(__FILE__, 71827186, __PRETTY_FUNCTION__).warning("QPainter::setWindow: Painter not active"); | - |
4315 | return; | - |
4316 | } | - |
4317 | | - |
4318 | d->state->wx = r.x(); | - |
4319 | d->state->wy = r.y(); | - |
4320 | d->state->ww = r.width(); | - |
4321 | d->state->wh = r.height(); | - |
4322 | | - |
4323 | d->state->VxF = true; | - |
4324 | d->updateMatrix(); | - |
4325 | } | - |
4326 | | - |
4327 | | - |
4328 | | - |
4329 | | - |
4330 | | - |
4331 | | - |
4332 | | - |
4333 | QRect QPainter::window() const | - |
4334 | { | - |
4335 | const QPainterPrivate * const d = d_func(); | - |
4336 | if (!d->engine) { | - |
4337 | QMessageLogger(__FILE__, 72057209, __PRETTY_FUNCTION__).warning("QPainter::window: Painter not active"); | - |
4338 | return QRect(); | - |
4339 | } | - |
4340 | return QRect(d->state->wx, d->state->wy, d->state->ww, d->state->wh); | - |
4341 | } | - |
4342 | void QPainter::setViewport(const QRect &r) | - |
4343 | { | - |
4344 | | - |
4345 | | - |
4346 | | - |
4347 | | - |
4348 | | - |
4349 | QPainterPrivate * const d = d_func(); | - |
4350 | | - |
4351 | if (!d->engine) { | - |
4352 | QMessageLogger(__FILE__, 72467250, __PRETTY_FUNCTION__).warning("QPainter::setViewport: Painter not active"); | - |
4353 | return; | - |
4354 | } | - |
4355 | | - |
4356 | d->state->vx = r.x(); | - |
4357 | d->state->vy = r.y(); | - |
4358 | d->state->vw = r.width(); | - |
4359 | d->state->vh = r.height(); | - |
4360 | | - |
4361 | d->state->VxF = true; | - |
4362 | d->updateMatrix(); | - |
4363 | } | - |
4364 | | - |
4365 | | - |
4366 | | - |
4367 | | - |
4368 | | - |
4369 | | - |
4370 | | - |
4371 | QRect QPainter::viewport() const | - |
4372 | { | - |
4373 | const QPainterPrivate * const d = d_func(); | - |
4374 | if (!d->engine) { | - |
4375 | QMessageLogger(__FILE__, 72697273, __PRETTY_FUNCTION__).warning("QPainter::viewport: Painter not active"); | - |
4376 | return QRect(); | - |
4377 | } | - |
4378 | return QRect(d->state->vx, d->state->vy, d->state->vw, d->state->vh); | - |
4379 | } | - |
4380 | void QPainter::setViewTransformEnabled(bool enable) | - |
4381 | { | - |
4382 | | - |
4383 | | - |
4384 | | - |
4385 | | - |
4386 | | - |
4387 | QPainterPrivate * const d = d_func(); | - |
4388 | | - |
4389 | if (!d->engine) { | - |
4390 | QMessageLogger(__FILE__, 72937297, __PRETTY_FUNCTION__).warning("QPainter::setViewTransformEnabled: Painter not active"); | - |
4391 | return; | - |
4392 | } | - |
4393 | | - |
4394 | if (enable == d->state->VxF) | - |
4395 | return; | - |
4396 | | - |
4397 | d->state->VxF = enable; | - |
4398 | d->updateMatrix(); | - |
4399 | } | - |
4400 | void QPainter::setRedirected(const QPaintDevice *device, | - |
4401 | QPaintDevice *replacement, | - |
4402 | const QPoint &offset) | - |
4403 | { | - |
4404 | ((!(device != 0)) ? qt_assert("device != 0",__FILE__,73317335) : qt_noop()); | - |
4405 | (void)device; | - |
4406 | (void)replacement; | - |
4407 | (void)offset; | - |
4408 | QMessageLogger(__FILE__, 73357339, __PRETTY_FUNCTION__).warning("QPainter::setRedirected(): ignoring call to deprecated function, use QWidget::render() instead"); | - |
4409 | } | - |
4410 | void QPainter::restoreRedirected(const QPaintDevice *device) | - |
4411 | { | - |
4412 | (void)device; | - |
4413 | QMessageLogger(__FILE__, 73587362, __PRETTY_FUNCTION__).warning("QPainter::restoreRedirected(): ignoring call to deprecated function, use QWidget::render() instead"); | - |
4414 | } | - |
4415 | QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) | - |
4416 | { | - |
4417 | (void)device; | - |
4418 | (void)offset; | - |
4419 | return 0; | - |
4420 | } | - |
4421 | | - |
4422 | void qt_format_text(const QFont &fnt, const QRectF &_r, | - |
4423 | int tf, const QString& str, QRectF *brect, | - |
4424 | int tabstops, int *ta, int tabarraylen, | - |
4425 | QPainter *painter) | - |
4426 | { | - |
4427 | qt_format_text(fnt, _r, | - |
4428 | tf, 0, str, brect, | - |
4429 | tabstops, ta, tabarraylen, | - |
4430 | painter); | - |
4431 | } | - |
4432 | void qt_format_text(const QFont &fnt, const QRectF &_r, | - |
4433 | int tf, const QTextOption *option, const QString& str, QRectF *brect, | - |
4434 | int tabstops, int *ta, int tabarraylen, | - |
4435 | QPainter *painter) | - |
4436 | { | - |
4437 | | - |
4438 | ((!(!((tf & ~Qt::TextDontPrint)!=0 && option!=0))) ? qt_assert("!((tf & ~Qt::TextDontPrint)!=0 && option!=0)",__FILE__,74017405) : qt_noop()); | - |
4439 | | - |
4440 | if (optionTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4441 | tf |= option->alignment(); | - |
4442 | if (option->wrapMode() != QTextOption::NoWrapTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4443 | tf |= Qt::TextWordWrap; never executed: tf |= Qt::TextWordWrap; | 0 |
4444 | | - |
4445 | if (option->flags() & QTextOption::IncludeTrailingSpacesTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4446 | tf |= Qt::TextIncludeTrailingSpaces; never executed: tf |= Qt::TextIncludeTrailingSpaces; | 0 |
4447 | | - |
4448 | if (option->tabStop() >= 0TRUE | never evaluated | FALSE | never evaluated |
|| !option->tabArray().isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4449 | tf |= Qt::TextExpandTabs; never executed: tf |= Qt::TextExpandTabs; | 0 |
4450 | } never executed: end of block | 0 |
4451 | | - |
4452 | | - |
4453 | QRectF r(_r); | - |
4454 | | - |
4455 | bool dontclip = (tf & Qt::TextDontClip); | - |
4456 | bool wordwrap = (TRUE | never evaluated | FALSE | never evaluated |
tf & Qt::TextWordWrap)TRUE | never evaluated | FALSE | never evaluated |
|| (TRUE | never evaluated | FALSE | never evaluated |
tf & Qt::TextWrapAnywhere)TRUE | never evaluated | FALSE | never evaluated |
; | 0 |
4457 | bool singleline = (tf & Qt::TextSingleLine); | - |
4458 | bool showmnemonic = (tf & Qt::TextShowMnemonic); | - |
4459 | bool hidemnmemonic = (tf & Qt::TextHideMnemonic); | - |
4460 | | - |
4461 | Qt::LayoutDirection layout_direction; | - |
4462 | if (tf & Qt::TextForceLeftToRightTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4463 | layout_direction = Qt::LeftToRight; never executed: layout_direction = Qt::LeftToRight; | 0 |
4464 | else if (tf & Qt::TextForceRightToLeftTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4465 | layout_direction = Qt::RightToLeft; never executed: layout_direction = Qt::RightToLeft; | 0 |
4466 | else if (optionTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4467 | layout_direction = option->textDirection(); never executed: layout_direction = option->textDirection(); | 0 |
4468 | else if (painterTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4469 | layout_direction = painter->layoutDirection(); never executed: layout_direction = painter->layoutDirection(); | 0 |
4470 | else | - |
4471 | layout_direction = Qt::LeftToRight; never executed: layout_direction = Qt::LeftToRight; | 0 |
4472 | | - |
4473 | tf = QGuiApplicationPrivate::visualAlignment(layout_direction, QFlag(tf)); | - |
4474 | | - |
4475 | bool isRightToLeft = layout_direction == Qt::RightToLeft; | - |
4476 | bool expandtabs = ((TRUE | never evaluated | FALSE | never evaluated |
tf & Qt::TextExpandTabs)TRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
4477 | (((TRUE | never evaluated | FALSE | never evaluated |
tf & Qt::AlignLeft)TRUE | never evaluated | FALSE | never evaluated |
&& !isRightToLeftTRUE | never evaluated | FALSE | never evaluated |
) || | 0 |
4478 | ((TRUE | never evaluated | FALSE | never evaluated |
tf & Qt::AlignRight)TRUE | never evaluated | FALSE | never evaluated |
&& isRightToLeftTRUE | never evaluated | FALSE | never evaluated |
))); | 0 |
4479 | | - |
4480 | if (!painterTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4481 | tf |= Qt::TextDontPrint; never executed: tf |= Qt::TextDontPrint; | 0 |
4482 | | - |
4483 | uint maxUnderlines = 0; | - |
4484 | | - |
4485 | QFontMetricsF fm(fnt); | - |
4486 | QString text = str; | - |
4487 | int offset = 0; | - |
4488 | start_lengthVariant: code before this statement never executed: start_lengthVariant: | 0 |
4489 | bool hasMoreLengthVariants = false; | - |
4490 | | - |
4491 | | - |
4492 | int old_offset = offset; | - |
4493 | for (; offset < text.length()TRUE | never evaluated | FALSE | never evaluated |
; offset++) { | 0 |
4494 | QChar chr = text.at(offset); | - |
4495 | if (chr == QLatin1Char('\r')TRUE | never evaluated | FALSE | never evaluated |
|| (singlelineTRUE | never evaluated | FALSE | never evaluated |
&& chr == QLatin1Char('\n')TRUE | never evaluated | FALSE | never evaluated |
)) { | 0 |
4496 | text[offset] = QLatin1Char(' '); | - |
4497 | } never executed: end of block else if (chr == QLatin1Char('\n')TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4498 | text[offset] = QChar::LineSeparator; | - |
4499 | } never executed: end of block else if (chr == QLatin1Char('&')TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4500 | ++maxUnderlines; | - |
4501 | } never executed: end of block else if (chr == QLatin1Char('\t')TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4502 | if (!expandtabsTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4503 | text[offset] = QLatin1Char(' '); | - |
4504 | } never executed: end of block else if (!tabarraylenTRUE | never evaluated | FALSE | never evaluated |
&& !tabstopsTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4505 | tabstops = qRound(fm.width(QLatin1Char('x'))*8); | - |
4506 | } never executed: end of block | 0 |
4507 | } never executed: end of block else if (chr == QChar(ushort(0x9c))TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4508 | | - |
4509 | hasMoreLengthVariants = true; | - |
4510 | break; never executed: break; | 0 |
4511 | } | - |
4512 | } never executed: end of block | 0 |
4513 | | - |
4514 | QVector<QTextLayout::FormatRange> underlineFormats; | - |
4515 | int length = offset - old_offset; | - |
4516 | if ((hidemnmemonicTRUE | never evaluated | FALSE | never evaluated |
|| showmnemonicTRUE | never evaluated | FALSE | never evaluated |
) && maxUnderlines > 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4517 | QChar *cout = text.data() + old_offset; | - |
4518 | QChar *cout0 = cout; | - |
4519 | QChar *cin = cout; | - |
4520 | int l = length; | - |
4521 | while (lTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4522 | if (*TRUE | never evaluated | FALSE | never evaluated |
cin == QLatin1Char('&')TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4523 | ++cin; | - |
4524 | --length; | - |
4525 | --l; | - |
4526 | if (!lTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4527 | break; never executed: break; | 0 |
4528 | if (*TRUE | never evaluated | FALSE | never evaluated |
cin != QLatin1Char('&')TRUE | never evaluated | FALSE | never evaluated |
&& !hidemnmemonicTRUE | never evaluated | FALSE | never evaluated |
&& !(tf & Qt::TextDontPrint)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4529 | QTextLayout::FormatRange range; | - |
4530 | range.start = cout - cout0; | - |
4531 | range.length = 1; | - |
4532 | range.format.setFontUnderline(true); | - |
4533 | underlineFormats.append(range); | - |
4534 | } never executed: end of block | 0 |
4535 | } never executed: end of block | 0 |
4536 | *cout = *cin; | - |
4537 | ++cout; | - |
4538 | ++cin; | - |
4539 | --l; | - |
4540 | } never executed: end of block | 0 |
4541 | } never executed: end of block | 0 |
4542 | | - |
4543 | qreal height = 0; | - |
4544 | qreal width = 0; | - |
4545 | | - |
4546 | QString finalText = text.mid(old_offset, length); | - |
4547 | QStackTextEngine engine(finalText, fnt); | - |
4548 | if (optionTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4549 | engine.option = *option; | - |
4550 | } never executed: end of block | 0 |
4551 | | - |
4552 | if (engine.option.tabStop() < 0TRUE | never evaluated | FALSE | never evaluated |
&& tabstops > 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4553 | engine.option.setTabStop(tabstops); never executed: engine.option.setTabStop(tabstops); | 0 |
4554 | | - |
4555 | if (engine.option.tabs().isEmpty()TRUE | never evaluated | FALSE | never evaluated |
&& taTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4556 | QList<qreal> tabs; | - |
4557 | tabs.reserve(tabarraylen); | - |
4558 | for (int i = 0; i < tabarraylenTRUE | never evaluated | FALSE | never evaluated |
; i++) | 0 |
4559 | tabs.append(qreal(ta[i])); never executed: tabs.append(qreal(ta[i])); | 0 |
4560 | engine.option.setTabArray(tabs); | - |
4561 | } never executed: end of block | 0 |
4562 | | - |
4563 | engine.option.setTextDirection(layout_direction); | - |
4564 | if (tf & Qt::AlignJustifyTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4565 | engine.option.setAlignment(Qt::AlignJustify); never executed: engine.option.setAlignment(Qt::AlignJustify); | 0 |
4566 | else | - |
4567 | engine.option.setAlignment(Qt::AlignLeft); never executed: engine.option.setAlignment(Qt::AlignLeft); | 0 |
4568 | | - |
4569 | if (!optionTRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
tf & Qt::TextWrapAnywhere)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4570 | engine.option.setWrapMode(QTextOption::WrapAnywhere); never executed: engine.option.setWrapMode(QTextOption::WrapAnywhere); | 0 |
4571 | | - |
4572 | if (tf & Qt::TextJustificationForcedTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4573 | engine.forceJustification = true; never executed: engine.forceJustification = true; | 0 |
4574 | QTextLayout textLayout(&engine); | - |
4575 | textLayout.setCacheEnabled(true); | - |
4576 | textLayout.setFormats(underlineFormats); | - |
4577 | | - |
4578 | if (finalText.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4579 | height = fm.height(); | - |
4580 | width = 0; | - |
4581 | tf |= Qt::TextDontPrint; | - |
4582 | } never executed: end of block else { | 0 |
4583 | qreal lineWidth = 0x01000000; | - |
4584 | if (wordwrapTRUE | never evaluated | FALSE | never evaluated |
|| (TRUE | never evaluated | FALSE | never evaluated |
tf & Qt::TextJustificationForced)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4585 | lineWidth = qMax<qreal>(0, r.width()); never executed: lineWidth = qMax<qreal>(0, r.width()); | 0 |
4586 | if(!wordwrapTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4587 | tf |= Qt::TextIncludeTrailingSpaces; never executed: tf |= Qt::TextIncludeTrailingSpaces; | 0 |
4588 | textLayout.engine()->ignoreBidi = bool(tf & Qt::TextDontPrint); | - |
4589 | textLayout.beginLayout(); | - |
4590 | | - |
4591 | qreal leading = fm.leading(); | - |
4592 | height = -leading; | - |
4593 | | - |
4594 | while (1) { | - |
4595 | QTextLine l = textLayout.createLine(); | - |
4596 | if (!l.isValid()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4597 | break; never executed: break; | 0 |
4598 | | - |
4599 | l.setLineWidth(lineWidth); | - |
4600 | height += leading; | - |
4601 | | - |
4602 | | - |
4603 | height = qCeil(height); | - |
4604 | l.setPosition(QPointF(0., height)); | - |
4605 | height += textLayout.engine()->lines[l.lineNumber()].height().toReal(); | - |
4606 | width = qMax(width, l.naturalTextWidth()); | - |
4607 | if (!dontclipTRUE | never evaluated | FALSE | never evaluated |
&& !brectTRUE | never evaluated | FALSE | never evaluated |
&& height >= r.height()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4608 | break; never executed: break; | 0 |
4609 | } never executed: end of block | 0 |
4610 | textLayout.endLayout(); | - |
4611 | } never executed: end of block | 0 |
4612 | | - |
4613 | qreal yoff = 0; | - |
4614 | qreal xoff = 0; | - |
4615 | if (tf & Qt::AlignBottomTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4616 | yoff = r.height() - height; never executed: yoff = r.height() - height; | 0 |
4617 | else if (tf & Qt::AlignVCenterTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4618 | yoff = (r.height() - height)/2; never executed: yoff = (r.height() - height)/2; | 0 |
4619 | | - |
4620 | if (tf & Qt::AlignRightTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4621 | xoff = r.width() - width; never executed: xoff = r.width() - width; | 0 |
4622 | else if (tf & Qt::AlignHCenterTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4623 | xoff = (r.width() - width)/2; never executed: xoff = (r.width() - width)/2; | 0 |
4624 | | - |
4625 | QRectF bounds = QRectF(r.x() + xoff, r.y() + yoff, width, height); | - |
4626 | | - |
4627 | if (hasMoreLengthVariantsTRUE | never evaluated | FALSE | never evaluated |
&& !(tf & Qt::TextLongestVariant)TRUE | never evaluated | FALSE | never evaluated |
&& !r.contains(bounds)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4628 | offset++; | - |
4629 | goto never executed: goto start_lengthVariant; start_lengthVariant;never executed: goto start_lengthVariant; | 0 |
4630 | } | - |
4631 | if (brectTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4632 | * never executed: *brect = bounds; brect = bounds;never executed: *brect = bounds; | 0 |
4633 | | - |
4634 | if (!(tf & Qt::TextDontPrint)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4635 | bool restore = false; | - |
4636 | if (!dontclipTRUE | never evaluated | FALSE | never evaluated |
&& !r.contains(bounds)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4637 | restore = true; | - |
4638 | painter->save(); | - |
4639 | painter->setClipRect(r, Qt::IntersectClip); | - |
4640 | } never executed: end of block | 0 |
4641 | | - |
4642 | for (int i = 0; i < textLayout.lineCount()TRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
4643 | QTextLine line = textLayout.lineAt(i); | - |
4644 | QTextEngine *eng = textLayout.engine(); | - |
4645 | eng->enableDelayDecorations(); | - |
4646 | | - |
4647 | qreal advance = line.horizontalAdvance(); | - |
4648 | xoff = 0; | - |
4649 | if (tf & Qt::AlignRightTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4650 | xoff = r.width() - advance - | - |
4651 | eng->leadingSpaceWidth(eng->lines[line.lineNumber()]).toReal(); | - |
4652 | } never executed: end of block | 0 |
4653 | else if (tf & Qt::AlignHCenterTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
4654 | xoff = (r.width() - advance) / 2; never executed: xoff = (r.width() - advance) / 2; | 0 |
4655 | | - |
4656 | line.draw(painter, QPointF(r.x() + xoff, r.y() + yoff)); | - |
4657 | eng->drawDecorations(painter); | - |
4658 | } never executed: end of block | 0 |
4659 | | - |
4660 | if (restoreTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
4661 | painter->restore(); | - |
4662 | } never executed: end of block | 0 |
4663 | } never executed: end of block | 0 |
4664 | } never executed: end of block | 0 |
4665 | void QPainter::setLayoutDirection(Qt::LayoutDirection direction) | - |
4666 | { | - |
4667 | QPainterPrivate * const d = d_func(); | - |
4668 | if (d->state) | - |
4669 | d->state->layoutDirection = direction; | - |
4670 | } | - |
4671 | | - |
4672 | | - |
4673 | | - |
4674 | | - |
4675 | | - |
4676 | | - |
4677 | Qt::LayoutDirection QPainter::layoutDirection() const | - |
4678 | { | - |
4679 | const QPainterPrivate * const d = d_func(); | - |
4680 | return d->state ? d->state->layoutDirection : Qt::LayoutDirectionAuto; | - |
4681 | } | - |
4682 | | - |
4683 | QPainterState::QPainterState(const QPainterState *s) | - |
4684 | : brushOrigin(s->brushOrigin), font(s->font), deviceFont(s->deviceFont), | - |
4685 | pen(s->pen), brush(s->brush), bgBrush(s->bgBrush), | - |
4686 | clipRegion(s->clipRegion), clipPath(s->clipPath), | - |
4687 | clipOperation(s->clipOperation), | - |
4688 | renderHints(s->renderHints), clipInfo(s->clipInfo), | - |
4689 | worldMatrix(s->worldMatrix), matrix(s->matrix), redirectionMatrix(s->redirectionMatrix), | - |
4690 | wx(s->wx), wy(s->wy), ww(s->ww), wh(s->wh), | - |
4691 | vx(s->vx), vy(s->vy), vw(s->vw), vh(s->vh), | - |
4692 | opacity(s->opacity), WxF(s->WxF), VxF(s->VxF), | - |
4693 | clipEnabled(s->clipEnabled), bgMode(s->bgMode), painter(s->painter), | - |
4694 | layoutDirection(s->layoutDirection), | - |
4695 | composition_mode(s->composition_mode), | - |
4696 | emulationSpecifier(s->emulationSpecifier), changeFlags(0) | - |
4697 | { | - |
4698 | dirtyFlags = s->dirtyFlags; | - |
4699 | } | - |
4700 | | - |
4701 | QPainterState::QPainterState() | - |
4702 | : brushOrigin(0, 0), bgBrush(Qt::white), clipOperation(Qt::NoClip), | - |
4703 | renderHints(0), | - |
4704 | wx(0), wy(0), ww(0), wh(0), vx(0), vy(0), vw(0), vh(0), | - |
4705 | opacity(1), WxF(false), VxF(false), clipEnabled(true), | - |
4706 | bgMode(Qt::TransparentMode), painter(0), | - |
4707 | layoutDirection(QGuiApplication::layoutDirection()), | - |
4708 | composition_mode(QPainter::CompositionMode_SourceOver), | - |
4709 | emulationSpecifier(0), changeFlags(0) | - |
4710 | { | - |
4711 | dirtyFlags = 0; | - |
4712 | } | - |
4713 | | - |
4714 | QPainterState::~QPainterState() | - |
4715 | { | - |
4716 | } | - |
4717 | | - |
4718 | void QPainterState::init(QPainter *p) { | - |
4719 | bgBrush = Qt::white; | - |
4720 | bgMode = Qt::TransparentMode; | - |
4721 | WxF = false; | - |
4722 | VxF = false; | - |
4723 | clipEnabled = true; | - |
4724 | wx = wy = ww = wh = 0; | - |
4725 | vx = vy = vw = vh = 0; | - |
4726 | painter = p; | - |
4727 | pen = QPen(); | - |
4728 | brushOrigin = QPointF(0, 0); | - |
4729 | brush = QBrush(); | - |
4730 | font = deviceFont = QFont(); | - |
4731 | clipRegion = QRegion(); | - |
4732 | clipPath = QPainterPath(); | - |
4733 | clipOperation = Qt::NoClip; | - |
4734 | clipInfo.clear(); | - |
4735 | worldMatrix.reset(); | - |
4736 | matrix.reset(); | - |
4737 | layoutDirection = QGuiApplication::layoutDirection(); | - |
4738 | composition_mode = QPainter::CompositionMode_SourceOver; | - |
4739 | emulationSpecifier = 0; | - |
4740 | dirtyFlags = 0; | - |
4741 | changeFlags = 0; | - |
4742 | renderHints = 0; | - |
4743 | opacity = 1; | - |
4744 | } | - |
4745 | QPen QPaintEngineState::pen() const | - |
4746 | { | - |
4747 | return static_cast<const QPainterState *>(this)->pen; | - |
4748 | } | - |
4749 | QBrush QPaintEngineState::brush() const | - |
4750 | { | - |
4751 | return static_cast<const QPainterState *>(this)->brush; | - |
4752 | } | - |
4753 | QPointF QPaintEngineState::brushOrigin() const | - |
4754 | { | - |
4755 | return static_cast<const QPainterState *>(this)->brushOrigin; | - |
4756 | } | - |
4757 | QBrush QPaintEngineState::backgroundBrush() const | - |
4758 | { | - |
4759 | return static_cast<const QPainterState *>(this)->bgBrush; | - |
4760 | } | - |
4761 | Qt::BGMode QPaintEngineState::backgroundMode() const | - |
4762 | { | - |
4763 | return static_cast<const QPainterState *>(this)->bgMode; | - |
4764 | } | - |
4765 | QFont QPaintEngineState::font() const | - |
4766 | { | - |
4767 | return static_cast<const QPainterState *>(this)->font; | - |
4768 | } | - |
4769 | QMatrix QPaintEngineState::matrix() const | - |
4770 | { | - |
4771 | const QPainterState *st = static_cast<const QPainterState *>(this); | - |
4772 | | - |
4773 | return st->matrix.toAffine(); | - |
4774 | } | - |
4775 | QTransform QPaintEngineState::transform() const | - |
4776 | { | - |
4777 | const QPainterState *st = static_cast<const QPainterState *>(this); | - |
4778 | | - |
4779 | return st->matrix; | - |
4780 | } | - |
4781 | Qt::ClipOperation QPaintEngineState::clipOperation() const | - |
4782 | { | - |
4783 | return static_cast<const QPainterState *>(this)->clipOperation; | - |
4784 | } | - |
4785 | bool QPaintEngineState::brushNeedsResolving() const | - |
4786 | { | - |
4787 | const QBrush &brush = static_cast<const QPainterState *>(this)->brush; | - |
4788 | return needsResolving(brush); | - |
4789 | } | - |
4790 | bool QPaintEngineState::penNeedsResolving() const | - |
4791 | { | - |
4792 | const QPen &pen = static_cast<const QPainterState *>(this)->pen; | - |
4793 | return needsResolving(pen.brush()); | - |
4794 | } | - |
4795 | QRegion QPaintEngineState::clipRegion() const | - |
4796 | { | - |
4797 | return static_cast<const QPainterState *>(this)->clipRegion; | - |
4798 | } | - |
4799 | QPainterPath QPaintEngineState::clipPath() const | - |
4800 | { | - |
4801 | return static_cast<const QPainterState *>(this)->clipPath; | - |
4802 | } | - |
4803 | bool QPaintEngineState::isClipEnabled() const | - |
4804 | { | - |
4805 | return static_cast<const QPainterState *>(this)->clipEnabled; | - |
4806 | } | - |
4807 | QPainter::RenderHints QPaintEngineState::renderHints() const | - |
4808 | { | - |
4809 | return static_cast<const QPainterState *>(this)->renderHints; | - |
4810 | } | - |
4811 | QPainter::CompositionMode QPaintEngineState::compositionMode() const | - |
4812 | { | - |
4813 | return static_cast<const QPainterState *>(this)->composition_mode; | - |
4814 | } | - |
4815 | | - |
4816 | | - |
4817 | | - |
4818 | | - |
4819 | | - |
4820 | | - |
4821 | | - |
4822 | QPainter *QPaintEngineState::painter() const | - |
4823 | { | - |
4824 | return static_cast<const QPainterState *>(this)->painter; | - |
4825 | } | - |
4826 | qreal QPaintEngineState::opacity() const | - |
4827 | { | - |
4828 | return static_cast<const QPainterState *>(this)->opacity; | - |
4829 | } | - |
4830 | void QPainter::setTransform(const QTransform &transform, bool combine ) | - |
4831 | { | - |
4832 | setWorldTransform(transform, combine); | - |
4833 | } | - |
4834 | | - |
4835 | | - |
4836 | | - |
4837 | | - |
4838 | | - |
4839 | | - |
4840 | | - |
4841 | const QTransform & QPainter::transform() const | - |
4842 | { | - |
4843 | return worldTransform(); | - |
4844 | } | - |
4845 | const QTransform & QPainter::deviceTransform() const | - |
4846 | { | - |
4847 | const QPainterPrivate * const d = d_func(); | - |
4848 | if (!d->engine) { | - |
4849 | QMessageLogger(__FILE__, 82228227, __PRETTY_FUNCTION__).warning("QPainter::deviceTransform: Painter not active"); | - |
4850 | return d->fakeState()->transform; | - |
4851 | } | - |
4852 | return d->state->matrix; | - |
4853 | } | - |
4854 | void QPainter::resetTransform() | - |
4855 | { | - |
4856 | QPainterPrivate * const d = d_func(); | - |
4857 | | - |
4858 | | - |
4859 | | - |
4860 | | - |
4861 | if (!d->engine) { | - |
4862 | QMessageLogger(__FILE__, 82458250, __PRETTY_FUNCTION__).warning("QPainter::resetMatrix: Painter not active"); | - |
4863 | return; | - |
4864 | } | - |
4865 | | - |
4866 | d->state->wx = d->state->wy = d->state->vx = d->state->vy = 0; | - |
4867 | d->state->ww = d->state->vw = d->device->metric(QPaintDevice::PdmWidth); | - |
4868 | d->state->wh = d->state->vh = d->device->metric(QPaintDevice::PdmHeight); | - |
4869 | d->state->worldMatrix = QTransform(); | - |
4870 | setMatrixEnabled(false); | - |
4871 | setViewTransformEnabled(false); | - |
4872 | if (d->extended) | - |
4873 | d->extended->transformChanged(); | - |
4874 | else | - |
4875 | d->state->dirtyFlags |= QPaintEngine::DirtyTransform; | - |
4876 | } | - |
4877 | void QPainter::setWorldTransform(const QTransform &matrix, bool combine ) | - |
4878 | { | - |
4879 | QPainterPrivate * const d = d_func(); | - |
4880 | | - |
4881 | if (!d->engine) { | - |
4882 | QMessageLogger(__FILE__, 82748279, __PRETTY_FUNCTION__).warning("QPainter::setWorldTransform: Painter not active"); | - |
4883 | return; | - |
4884 | } | - |
4885 | | - |
4886 | if (combine) | - |
4887 | d->state->worldMatrix = matrix * d->state->worldMatrix; | - |
4888 | else | - |
4889 | d->state->worldMatrix = matrix; | - |
4890 | | - |
4891 | d->state->WxF = true; | - |
4892 | d->updateMatrix(); | - |
4893 | } | - |
4894 | | - |
4895 | | - |
4896 | | - |
4897 | | - |
4898 | | - |
4899 | const QTransform & QPainter::worldTransform() const | - |
4900 | { | - |
4901 | const QPainterPrivate * const d = d_func(); | - |
4902 | if (!d->engine) { | - |
4903 | QMessageLogger(__FILE__, 82958300, __PRETTY_FUNCTION__).warning("QPainter::worldTransform: Painter not active"); | - |
4904 | return d->fakeState()->transform; | - |
4905 | } | - |
4906 | return d->state->worldMatrix; | - |
4907 | } | - |
4908 | QTransform QPainter::combinedTransform() const | - |
4909 | { | - |
4910 | const QPainterPrivate * const d = d_func(); | - |
4911 | if (!d->engine) { | - |
4912 | QMessageLogger(__FILE__, 83128317, __PRETTY_FUNCTION__).warning("QPainter::combinedTransform: Painter not active"); | - |
4913 | return QTransform(); | - |
4914 | } | - |
4915 | return d->state->worldMatrix * d->viewTransform() * d->hidpiScaleTransform(); | - |
4916 | } | - |
4917 | void QPainter::drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount, | - |
4918 | const QPixmap &pixmap, PixmapFragmentHints hints) | - |
4919 | { | - |
4920 | QPainterPrivate * const d = d_func(); | - |
4921 | | - |
4922 | if (!d->engine || pixmap.isNull()) | - |
4923 | return; | - |
4924 | | - |
4925 | | - |
4926 | for (int i = 0; i < fragmentCount; ++i) { | - |
4927 | QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, | - |
4928 | fragments[i].width, fragments[i].height); | - |
4929 | if (!(QRectF(pixmap.rect()).contains(sourceRect))) | - |
4930 | QMessageLogger(__FILE__, 83468351, __PRETTY_FUNCTION__).warning("QPainter::drawPixmapFragments - the source rect is not contained by the pixmap's rectangle"); | - |
4931 | } | - |
4932 | | - |
4933 | | - |
4934 | if (d->engine->isExtended()) { | - |
4935 | d->extended->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); | - |
4936 | } else { | - |
4937 | qreal oldOpacity = opacity(); | - |
4938 | QTransform oldTransform = transform(); | - |
4939 | | - |
4940 | for (int i = 0; i < fragmentCount; ++i) { | - |
4941 | QTransform transform = oldTransform; | - |
4942 | qreal xOffset = 0; | - |
4943 | qreal yOffset = 0; | - |
4944 | if (fragments[i].rotation == 0) { | - |
4945 | xOffset = fragments[i].x; | - |
4946 | yOffset = fragments[i].y; | - |
4947 | } else { | - |
4948 | transform.translate(fragments[i].x, fragments[i].y); | - |
4949 | transform.rotate(fragments[i].rotation); | - |
4950 | } | - |
4951 | setOpacity(oldOpacity * fragments[i].opacity); | - |
4952 | setTransform(transform); | - |
4953 | | - |
4954 | qreal w = fragments[i].scaleX * fragments[i].width; | - |
4955 | qreal h = fragments[i].scaleY * fragments[i].height; | - |
4956 | QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, | - |
4957 | fragments[i].width, fragments[i].height); | - |
4958 | drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, sourceRect); | - |
4959 | } | - |
4960 | | - |
4961 | setOpacity(oldOpacity); | - |
4962 | setTransform(oldTransform); | - |
4963 | } | - |
4964 | } | - |
4965 | QPainter::PixmapFragment QPainter::PixmapFragment::create(const QPointF &pos, const QRectF &sourceRect, | - |
4966 | qreal scaleX, qreal scaleY, qreal rotation, | - |
4967 | qreal opacity) | - |
4968 | { | - |
4969 | PixmapFragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(), | - |
4970 | sourceRect.height(), scaleX, scaleY, rotation, opacity}; | - |
4971 | return fragment; | - |
4972 | } | - |
4973 | void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation) | - |
4974 | { | - |
4975 | p->draw_helper(path, operation); | - |
4976 | } | - |
4977 | | - |
4978 | | - |
| | |