27#include <qpa/qplatformtheme.h>
28#include <qpa/qplatformintegration.h>
30#include <private/qfontengine_p.h>
31#include <private/qpaintengine_p.h>
32#include <private/qemulationpaintengine_p.h>
33#include <private/qpainterpath_p.h>
34#include <private/qtextengine_p.h>
35#include <private/qpaintengine_raster_p.h>
36#include <private/qmath_p.h>
37#include <private/qstatictext_p.h>
38#include <private/qglyphrun_p.h>
39#include <private/qhexstring_p.h>
40#include <private/qguiapplication_p.h>
41#include <private/qrawfont_p.h>
42#include <private/qfont_p.h>
49static_assert(
sizeof(QScopedPointer<QPainterPrivate>) ==
sizeof(std::unique_ptr<QPainterPrivate>));
51#define QGradient_StretchToDevice 0x10000000
52#define QPaintEngine_OpaqueBackground 0x40000000
56bool qt_show_painter_debug_output =
true;
63 int tabstops,
int* tabarray,
int tabarraylen,
71 const QPointF &decorationPosition,
82 switch (
brush.style()) {
86 return brush.gradient()->coordinateMode();
100 return brush.texture().isQBitmap() ||
brush.texture().hasAlphaChannel();
145 qWarning(
"QPainter: It is not safe to use %s outside the GUI thread", what);
174 bool doEmulation =
false;
249 ++
sp->d_ptr->refcount;
250 sp->d_ptr->d_ptrs.push_back(
q->d_ptr.get());
252 q->d_ptr.reset(
sp->d_ptr.get());
257 q->d_ptr->initFrom(pdev);
260 offset +=
q->d_ptr->engine->coordinateOffset();
263 q->d_ptr->state->ww =
q->d_ptr->state->vw = pdev->
width();
264 q->d_ptr->state->wh =
q->d_ptr->state->vh = pdev->
height();
267 if (
q->d_ptr->state->WxF) {
268 q->d_ptr->state->redirectionMatrix =
q->d_ptr->state->matrix;
269 q->d_ptr->state->redirectionMatrix *=
q->d_ptr->hidpiScaleTransform().inverted();
270 q->d_ptr->state->redirectionMatrix.translate(-
offset.x(), -
offset.y());
272 q->d_ptr->state->WxF =
false;
276 q->d_ptr->updateMatrix();
302 }
else if (!original) {
308 q->d_ptr.reset(original);
320 if (qt_show_painter_debug_output) {
321 printf(
"QPainter::drawHelper\n");
328 QPaintEngine::PaintEngineFeatures gradientStretch =
332 const bool mustEmulateObjectBoundingModeGradients =
extended
336 if (!(
state->emulationSpecifier & ~gradientStretch)
337 && !mustEmulateObjectBoundingModeGradients) {
347 qreal strokeOffsetX = 0, strokeOffsetY = 0;
368 strokeOffsetX =
qAbs(penWidth *
state->matrix.m11() / 2.0);
369 strokeOffsetY =
qAbs(penWidth *
state->matrix.m22() / 2.0);
375 if (!strokeBounds.isEmpty()) {
378 absPathRect = pathBounds.
adjusted(-strokeOffsetX, -strokeOffsetY, strokeOffsetX, strokeOffsetY)
382 if (
q->hasClipping()) {
383 bool hasPerspectiveTransform =
false;
386 hasPerspectiveTransform =
true;
391 if (!hasPerspectiveTransform) {
398 bool old_txinv =
txinv;
416 if (absPathRect.width() <= 0 || absPathRect.height() <= 0)
426 p.setOpacity(
state->opacity);
427 p.translate(-absPathRect.x(), -absPathRect.y());
428 p.setTransform(
state->matrix,
true);
431 p.setBackground(
state->bgBrush);
432 p.setBackgroundMode(
state->bgMode);
433 p.setBrushOrigin(
state->brushOrigin);
439 p.drawPath(originalPath);
443 if (do_fallback_overlay) {
466 engine->drawImage(absPathRect,
468 QRectF(0, 0, absPathRect.width(), absPathRect.height()),
505 b.setTransform(
b.transform() * gradientToUser);
507 b.setTransform(gradientToUser *
b.transform());
518 bool changedPen =
false;
519 bool changedBrush =
false;
520 bool needsFill =
false;
538 const qreal isw = 1.0 / sw;
539 const qreal ish = 1.0 / sh;
579 const qreal isw = 1.0 / sw;
580 const qreal ish = 1.0 / sh;
582 engine->drawPath(stroke * inv);
601 }
else if (changedPen) {
609 }
else if (needsFill) {
658 bool linearGradient =
false;
659 bool radialGradient =
false;
660 bool extendedRadialGradient =
false;
661 bool conicalGradient =
false;
662 bool patternBrush =
false;
664 bool complexXform =
false;
684 && !penBrush.isOpaque())
686 && (brushStyle < Qt::LinearGradientPattern && s->
brush.color().alpha() != 255)
687 && !
s->brush.isOpaque());
702 bool penTextureAlpha =
false;
705 ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha()
706 : penBrush.textureImage().hasAlphaChannel();
707 bool brushTextureAlpha =
false;
710 ? (
s->brush.texture().depth() > 1) &&
s->brush.texture().hasAlpha()
711 :
s->brush.textureImage().hasAlphaChannel();
731 qDebug(
"QPainterPrivate::updateEmulationSpecifier, state=%p\n"
733 " - linearGradient: %d\n"
734 " - radialGradient: %d\n"
735 " - conicalGradient: %d\n"
736 " - patternBrush: %d\n"
745 uint(
s->renderHints),
752 complexXform = !
s->matrix.isAffine();
761 const bool patternXform = patternBrush && (
xform || brushXform || penXform);
817 bool gradientStretch =
false;
818 bool objectBoundingMode =
false;
819 if (linearGradient || conicalGradient || radialGradient) {
832 s->emulationSpecifier &= ~QGradient_StretchToDevice;
837 s->emulationSpecifier &=
~QPaintEngine::ObjectBoundingModeGradients;
844 s->emulationSpecifier &= ~QPaintEngine_OpaqueBackground;
1476 d_ptr->inDestructor =
true;
1480 else if (d_ptr->refcount > 1)
1481 d_ptr->detachPainterPrivate(
this);
1488 d_ptr->inDestructor =
false;
1503 if (
isActive() &&
d->engine->d_func()->currentClipDevice)
1504 return d->engine->d_func()->currentClipDevice;
1505 return d->original_device;
1518 return d->engine !=
nullptr;
1524 qWarning(
"QPainter::initFrom: Painter not active, aborted");
1551 if (qt_show_painter_debug_output)
1552 printf(
"QPainter::save()\n");
1556 qWarning(
"QPainter::save: Painter not active");
1560 std::unique_ptr<QPainterState> prev;
1564 std::unique_ptr<QPainterState>
next(
d->extended->createState(
d->state.get()));
1565 prev = std::exchange(
d->state, std::move(
next));
1566 d->extended->setState(
d->state.get());
1568 d->updateState(
d->state);
1569 prev = std::exchange(
d->state, std::make_unique<QPainterState>(
d->state.get()));
1570 d->engine->state =
d->state.get();
1572 d->savedStates.push(std::move(prev));
1585 if (qt_show_painter_debug_output)
1586 printf(
"QPainter::restore()\n");
1589 if (
d->savedStates.empty()) {
1590 qWarning(
"QPainter::restore: Unbalanced save/restore");
1592 }
else if (!
d->engine) {
1593 qWarning(
"QPainter::restore: Painter not active");
1597 const auto tmp = std::exchange(
d->state, std::move(
d->savedStates.top()));
1598 d->savedStates.pop();
1602 d->checkEmulation();
1603 d->extended->setState(
d->state.get());
1609 if (!
d->state->clipInfo.isEmpty()
1615 d->engine->updateState(*tmp);
1618 tmp->matrix =
info.matrix;
1619 tmp->clipOperation =
info.operation;
1622 tmp->clipRegion =
info.rect;
1625 tmp->clipRegion =
info.region;
1628 tmp->clipPath =
info.path;
1630 d->engine->updateState(*tmp);
1640 d->updateState(
d->state.get());
1673 d->savedStates.clear();
1675 d->engine =
nullptr;
1676 d->device =
nullptr;
1684 qWarning(
"QPainter::begin: A paint device can only be painted by one painter at a time.");
1688 if (d_ptr->engine) {
1689 qWarning(
"QPainter::begin: Painter already active");
1698 d->helper_device = pd;
1699 d->original_device = pd;
1701 QPoint redirectionOffset;
1707 if (qt_show_painter_debug_output)
1708 printf(
"QPainter::begin(), device=%p, type=%d\n", pd, pd->
devType());
1712 static_cast<QPixmap *
>(pd)->detach();
1719 qWarning(
"QPainter::begin: Paint device returned engine == 0, type: %d", pd->
devType());
1725 d->extended =
d->engine->isExtended() ?
static_cast<QPaintEngineEx *
>(
d->engine.get()) :
nullptr;
1726 if (
d->emulationEngine)
1727 d->emulationEngine->real_engine =
d->extended;
1731 d->state.reset(
d->extended ?
d->extended->createState(
nullptr) :
new QPainterState);
1732 d->state->painter =
this;
1734 d->state->redirectionMatrix.translate(-redirectionOffset.x(), -redirectionOffset.y());
1739 d->extended->setState(
d->state.get());
1741 d->engine->state =
d->state.get();
1749 qWarning(
"QPainter::begin: Cannot paint on a null pixmap");
1754 if (pm->
depth() == 1) {
1764 if (
img->isNull()) {
1765 qWarning(
"QPainter::begin: Cannot paint on a null image");
1771 qWarning() <<
"QPainter::begin: Cannot paint on an image with the"
1777 if (
img->depth() == 1) {
1786 if (
d->state->ww == 0)
1787 d->state->ww =
d->state->wh =
d->state->vw =
d->state->vh = 1024;
1789 d->engine->setPaintDevice(pd);
1791 bool begun =
d->engine->begin(pd);
1793 qWarning(
"QPainter::begin(): Returned false");
1794 if (
d->engine->isActive()) {
1801 d->engine->setActive(begun);
1807 d->initFrom(
d->original_device);
1811 d->state->deviceFont =
d->state->font =
QFont(
d->state->deviceFont,
device());
1814 QRect systemRect =
d->engine->systemRect();
1816 d->state->ww =
d->state->vw = systemRect.
width();
1817 d->state->wh =
d->state->vh = systemRect.
height();
1823 const QPoint coordinateOffset =
d->engine->coordinateOffset();
1824 d->state->redirectionMatrix.translate(-coordinateOffset.
x(), -coordinateOffset.
y());
1828 if (!
d->state->redirectionMatrix.isIdentity() || !
qFuzzyCompare(
d->effectiveDevicePixelRatio(),
qreal(1.0)))
1833 ++
d->device->painters;
1835 d->state->emulationSpecifier = 0;
1853 if (qt_show_painter_debug_output)
1854 printf(
"QPainter::end()\n");
1859 qWarning(
"QPainter::end: Painter not active, aborted");
1864 if (
d->refcount > 1) {
1865 d->detachPainterPrivate(
this);
1871 if (
d->engine->isActive()) {
1872 ended =
d->engine->end();
1873 d->updateState(
nullptr);
1875 --
d->device->painters;
1876 if (
d->device->painters == 0) {
1877 d->engine->setPaintDevice(
nullptr);
1878 d->engine->setActive(
false);
1882 if (
d->savedStates.size() > 0) {
1883 qWarning(
"QPainter::end: Painter ended with %d saved states",
int(
d->savedStates.size()));
1887 d->emulationEngine =
nullptr;
1888 d->extended =
nullptr;
1905 return d->engine.get();
1944 qWarning(
"QPainter::beginNativePainting: Painter not active");
1949 d->extended->beginNativePainting();
1965 qWarning(
"QPainter::beginNativePainting: Painter not active");
1970 d->extended->endNativePainting();
1972 d->engine->syncState();
1986 qWarning(
"QPainter::fontMetrics: Painter not active");
2004 qWarning(
"QPainter::fontInfo: Painter not active");
2021 qWarning(
"QPainter::opacity: Painter not active");
2024 return d->state->opacity;
2043 qWarning(
"QPainter::setOpacity: Painter not active");
2055 d->extended->opacityChanged();
2071 qWarning(
"QPainter::brushOrigin: Painter not active");
2099 if (qt_show_painter_debug_output)
2100 printf(
"QPainter::setBrushOrigin(), (%.2f,%.2f)\n",
p.x(),
p.y());
2104 qWarning(
"QPainter::setBrushOrigin: Painter not active");
2108 d->state->brushOrigin =
p;
2111 d->extended->brushOriginChanged();
2330 qWarning(
"QPainter::setCompositionMode: Painter not active");
2333 if (
d->state->composition_mode ==
mode)
2336 d->state->composition_mode =
mode;
2337 d->extended->compositionModeChanged();
2343 qWarning(
"QPainter::setCompositionMode: "
2344 "Raster operation modes not supported on device");
2349 qWarning(
"QPainter::setCompositionMode: "
2350 "Blend modes not supported on device");
2355 qWarning(
"QPainter::setCompositionMode: "
2356 "PorterDuff modes not supported on device");
2361 d->state->composition_mode =
mode;
2374 qWarning(
"QPainter::compositionMode: Painter not active");
2377 return d->state->composition_mode;
2390 qWarning(
"QPainter::background: Painter not active");
2391 return d->fakeState()->brush;
2393 return d->state->bgBrush;
2407 qWarning(
"QPainter::hasClipping: Painter not active");
2410 return d->state->clipEnabled &&
d->state->clipOperation !=
Qt::NoClip;
2425 if (qt_show_painter_debug_output)
2426 printf(
"QPainter::setClipping(), enable=%s, was=%s\n",
2431 qWarning(
"QPainter::setClipping: Painter not active, state will be reset by begin");
2440 && (
d->state->clipInfo.isEmpty() ||
d->state->clipInfo.constLast().operation ==
Qt::NoClip))
2442 d->state->clipEnabled =
enable;
2445 d->extended->clipEnabledChanged();
2450 d->updateState(
d->state);
2470 qWarning(
"QPainter::clipRegion: Painter not active");
2475 bool lastWasNothing =
true;
2478 const_cast<QPainter *
>(
this)->d_ptr->updateInvMatrix();
2482 switch (
info.clipType) {
2486 if (lastWasNothing) {
2488 lastWasNothing =
false;
2494 lastWasNothing =
true;
2503 if (lastWasNothing) {
2505 info.path.fillRule());
2506 lastWasNothing =
false;
2511 info.path.fillRule());
2513 lastWasNothing =
true;
2517 info.path.fillRule());
2524 if (lastWasNothing) {
2526 lastWasNothing =
false;
2536 lastWasNothing =
true;
2546 if (lastWasNothing) {
2548 lastWasNothing =
false;
2554 region &=
matrix.mapRect(
info.rectf.toRect());
2558 lastWasNothing =
true;
2590 qWarning(
"QPainter::clipPath: Painter not active");
2595 if (
d->state->clipInfo.isEmpty()) {
2601 const_cast<QPainter *
>(
this)->d_ptr->updateInvMatrix();
2604 if (
d->state->clipInfo.size() == 1
2607 return d->state->clipInfo.at(0).path *
matrix;
2609 }
else if (
d->state->clipInfo.size() == 1
2613 path.addRect(
d->state->clipInfo.at(0).rect);
2639 qWarning(
"QPainter::clipBoundingRect: Painter not active");
2656 r =
info.region.boundingRect();
2658 r =
info.path.boundingRect();
2660 r =
info.matrix.mapRect(
r);
2673 const_cast<QPainter *
>(
this)->d_ptr->updateInvMatrix();
2675 return d->invMatrix.mapRect(bounds);
2696 qWarning(
"QPainter::setClipRect: Painter not active");
2700 if (simplifyClipOp && (!
d->state->clipEnabled && op !=
Qt::NoClip))
2710 d->state->clipEnabled =
true;
2711 d->extended->clip(vp, op);
2713 d->state->clipInfo.clear();
2715 d->state->clipOperation = op;
2728 if (
rect.isEmpty()) {
2750 qWarning(
"QPainter::setClipRect: Painter not active");
2755 if (simplifyClipOp && (!
d->state->clipEnabled && op !=
Qt::NoClip))
2759 d->state->clipEnabled =
true;
2760 d->extended->clip(
rect, op);
2762 d->state->clipInfo.clear();
2764 d->state->clipOperation = op;
2771 d->state->clipRegion =
rect;
2772 d->state->clipOperation = op;
2774 d->state->clipInfo.clear();
2776 d->state->clipEnabled =
true;
2778 d->updateState(
d->state);
2804 if (qt_show_painter_debug_output)
2805 printf(
"QPainter::setClipRegion(), size=%d, [%d,%d,%d,%d]\n",
2809 qWarning(
"QPainter::setClipRegion: Painter not active");
2814 if (simplifyClipOp && (!
d->state->clipEnabled && op !=
Qt::NoClip))
2818 d->state->clipEnabled =
true;
2819 d->extended->clip(
r, op);
2821 d->state->clipInfo.clear();
2823 d->state->clipOperation = op;
2830 d->state->clipRegion =
r;
2831 d->state->clipOperation = op;
2833 d->state->clipInfo.clear();
2835 d->state->clipEnabled =
true;
2837 d->updateState(
d->state);
2855 if (qt_show_painter_debug_output)
2856 printf(
"QPainter::setMatrixEnabled(), enable=%d\n",
enable);
2860 qWarning(
"QPainter::setMatrixEnabled: Painter not active");
2883 qWarning(
"QPainter::worldMatrixEnabled: Painter not active");
2886 return d->state->WxF;
2898 if (qt_show_painter_debug_output)
2899 printf(
"QPainter::scale(), sx=%f, sy=%f\n", sx, sy);
2903 qWarning(
"QPainter::scale: Painter not active");
2907 d->state->worldMatrix.scale(sx,sy);
2908 d->state->WxF =
true;
2921 if (qt_show_painter_debug_output)
2922 printf(
"QPainter::shear(), sh=%f, sv=%f\n", sh, sv);
2926 qWarning(
"QPainter::shear: Painter not active");
2930 d->state->worldMatrix.shear(sh, sv);
2931 d->state->WxF =
true;
2946 if (qt_show_painter_debug_output)
2947 printf(
"QPainter::rotate(), angle=%f\n",
a);
2951 qWarning(
"QPainter::rotate: Painter not active");
2955 d->state->worldMatrix.rotate(
a);
2956 d->state->WxF =
true;
2971 if (qt_show_painter_debug_output)
2972 printf(
"QPainter::translate(), dx=%f, dy=%f\n", dx, dy);
2976 qWarning(
"QPainter::translate: Painter not active");
2980 d->state->worldMatrix.translate(dx, dy);
2981 d->state->WxF =
true;
3014 if (qt_show_painter_debug_output) {
3016 printf(
"QPainter::setClipPath(), size=%d, op=%d, bounds=[%.2f,%.2f,%.2f,%.2f]\n",
3017 path.elementCount(), op,
b.x(),
b.y(),
b.width(),
b.height());
3023 qWarning(
"QPainter::setClipPath: Painter not active");
3028 if (simplifyClipOp && (!
d->state->clipEnabled && op !=
Qt::NoClip))
3032 d->state->clipEnabled =
true;
3033 d->extended->clip(
path, op);
3035 d->state->clipInfo.clear();
3037 d->state->clipOperation = op;
3044 d->state->clipPath =
path;
3045 d->state->clipOperation = op;
3047 d->state->clipInfo.clear();
3049 d->state->clipEnabled =
true;
3051 d->updateState(
d->state);
3065 qWarning(
"QPainter::strokePath: Painter not active");
3077 QBrush oldBrush =
d->state->brush;
3078 QPen oldPen =
d->state->pen;
3105 qWarning(
"QPainter::fillPath: Painter not active");
3117 QBrush oldBrush =
d->state->brush;
3118 QPen oldPen =
d->state->pen;
3148 if (qt_show_painter_debug_output)
3149 printf(
"QPainter::drawPath(), size=%d, [%.2f,%.2f,%.2f,%.2f]\n",
3150 path.elementCount(),
3151 pathBounds.x(), pathBounds.y(), pathBounds.width(), pathBounds.height());
3157 qWarning(
"QPainter::drawPath: Painter not active");
3162 d->extended->drawPath(
path);
3165 d->updateState(
d->state);
3168 d->engine->drawPath(
path);
3170 d->draw_helper(
path);
3263 if (qt_show_painter_debug_output)
3264 printf(
"QPainter::drawRects(), count=%d\n", rectCount);
3269 qWarning(
"QPainter::drawRects: Painter not active");
3277 d->extended->drawRects(rects, rectCount);
3281 d->updateState(
d->state);
3283 if (!
d->state->emulationSpecifier) {
3284 d->engine->drawRects(rects, rectCount);
3290 for (
int i=0;
i<rectCount; ++
i) {
3291 QRectF r(rects[
i].
x() +
d->state->matrix.dx(),
3292 rects[
i].
y() +
d->state->matrix.dy(),
3295 d->engine->drawRects(&
r, 1);
3298 if (
d->state->brushNeedsResolving() ||
d->state->penNeedsResolving()) {
3299 for (
int i=0;
i<rectCount; ++
i) {
3306 for (
int i=0;
i<rectCount; ++
i)
3323 if (qt_show_painter_debug_output)
3324 printf(
"QPainter::drawRects(), count=%d\n", rectCount);
3329 qWarning(
"QPainter::drawRects: Painter not active");
3337 d->extended->drawRects(rects, rectCount);
3341 d->updateState(
d->state);
3343 if (!
d->state->emulationSpecifier) {
3344 d->engine->drawRects(rects, rectCount);
3350 for (
int i=0;
i<rectCount; ++
i) {
3351 QRectF r(rects[
i].
x() +
d->state->matrix.dx(),
3352 rects[
i].
y() +
d->state->matrix.dy(),
3356 d->engine->drawRects(&
r, 1);
3359 if (
d->state->brushNeedsResolving() ||
d->state->penNeedsResolving()) {
3360 for (
int i=0;
i<rectCount; ++
i) {
3367 for (
int i=0;
i<rectCount; ++
i)
3423 if (qt_show_painter_debug_output)
3424 printf(
"QPainter::drawPoints(), count=%d\n", pointCount);
3429 qWarning(
"QPainter::drawPoints: Painter not active");
3433 if (pointCount <= 0)
3437 d->extended->drawPoints(
points, pointCount);
3441 d->updateState(
d->state);
3443 if (!
d->state->emulationSpecifier) {
3444 d->engine->drawPoints(
points, pointCount);
3451 for (
int i=0;
i<pointCount; ++
i) {
3453 points[
i].y() +
d->state->matrix.dy());
3454 d->engine->drawPoints(&pt, 1);
3465 for (
int i=0;
i<pointCount; ++
i) {
3485 if (qt_show_painter_debug_output)
3486 printf(
"QPainter::drawPoints(), count=%d\n", pointCount);
3491 qWarning(
"QPainter::drawPoints: Painter not active");
3495 if (pointCount <= 0)
3499 d->extended->drawPoints(
points, pointCount);
3503 d->updateState(
d->state);
3505 if (!
d->state->emulationSpecifier) {
3506 d->engine->drawPoints(
points, pointCount);
3513 for (
int i=0;
i<pointCount; ++
i) {
3515 points[
i].y() +
d->state->matrix.dy());
3516 d->engine->drawPoints(&pt, 1);
3527 for (
int i=0;
i<pointCount; ++
i) {
3570 if (qt_show_painter_debug_output)
3571 printf(
"QPainter::setBackgroundMode(), mode=%d\n",
mode);
3576 qWarning(
"QPainter::setBackgroundMode: Painter not active");
3579 if (
d->state->bgMode ==
mode)
3582 d->state->bgMode =
mode;
3584 d->checkEmulation();
3599 qWarning(
"QPainter::backgroundMode: Painter not active");
3602 return d->state->bgMode;
3616 if (qt_show_painter_debug_output)
3617 printf(
"QPainter::setPen(), color=%04x\n",
color.rgb());
3621 qWarning(
"QPainter::setPen: Painter not active");
3627 if (
d->state->pen ==
pen)
3630 d->state->pen =
pen;
3632 d->extended->penChanged();
3650 if (qt_show_painter_debug_output)
3651 printf(
"QPainter::setPen(), color=%04x, (brushStyle=%d) style=%d, cap=%d, join=%d\n",
3656 qWarning(
"QPainter::setPen: Painter not active");
3660 if (
d->state->pen ==
pen)
3663 d->state->pen =
pen;
3666 d->checkEmulation();
3667 d->extended->penChanged();
3685 qWarning(
"QPainter::setPen: Painter not active");
3691 if (
d->state->pen ==
pen)
3694 d->state->pen =
pen;
3697 d->extended->penChanged();
3713 qWarning(
"QPainter::pen: Painter not active");
3714 return d->fakeState()->pen;
3716 return d->state->pen;
3731 if (qt_show_painter_debug_output)
3732 printf(
"QPainter::setBrush(), color=%04x, style=%d\n",
brush.color().rgb(),
brush.style());
3736 qWarning(
"QPainter::setBrush: Painter not active");
3740 if (
d->state->brush.d ==
brush.d)
3745 d->checkEmulation();
3746 d->extended->brushChanged();
3766 qWarning(
"QPainter::setBrush: Painter not active");
3769 if (
d->state->brush.style() == style &&
3775 d->extended->brushChanged();
3790 qWarning(
"QPainter::brush: Painter not active");
3791 return d->fakeState()->brush;
3793 return d->state->brush;
3812 if (qt_show_painter_debug_output)
3813 printf(
"QPainter::setBackground(), color=%04x, style=%d\n", bg.
color().
rgb(), bg.
style());
3818 qWarning(
"QPainter::setBackground: Painter not active");
3821 d->state->bgBrush = bg;
3844 if (qt_show_painter_debug_output)
3845 printf(
"QPainter::setFont(), family=%s, pointSize=%d\n",
font.
families().first().toLatin1().constData(),
font.
pointSize());
3849 qWarning(
"QPainter::setFont: Painter not active");
3867 qWarning(
"QPainter::font: Painter not active");
3868 return d->fakeState()->font;
3870 return d->state->font;
3900 if (qt_show_painter_debug_output)
3901 printf(
"QPainter::drawRoundedRect(), [%.2f,%.2f,%.2f,%.2f]\n",
rect.x(),
rect.y(),
rect.width(),
rect.height());
3906 qWarning(
"QPainter::drawRoundedRect: Painter not active");
3910 if (xRadius <= 0 || yRadius <= 0) {
3916 d->extended->drawRoundedRect(
rect, xRadius, yRadius,
mode);
3964 if (qt_show_painter_debug_output)
3965 printf(
"QPainter::drawEllipse(), [%.2f,%.2f,%.2f,%.2f]\n",
r.x(),
r.y(),
r.width(),
r.height());
3970 qWarning(
"QPainter::drawEllipse: Painter not active");
3977 d->extended->drawEllipse(
rect);
3981 d->updateState(
d->state);
3982 if (
d->state->emulationSpecifier) {
3985 rect.translate(
QPointF(
d->state->matrix.dx(),
d->state->matrix.dy()));
3994 d->engine->drawEllipse(
rect);
4007 if (qt_show_painter_debug_output)
4008 printf(
"QPainter::drawEllipse(), [%d,%d,%d,%d]\n",
r.x(),
r.y(),
r.width(),
r.height());
4013 qWarning(
"QPainter::drawEllipse: Painter not active");
4020 d->extended->drawEllipse(
rect);
4024 d->updateState(
d->state);
4026 if (
d->state->emulationSpecifier) {
4038 d->engine->drawEllipse(
rect);
4095 if (qt_show_painter_debug_output)
4096 printf(
"QPainter::drawArc(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n",
4097 r.x(),
r.y(),
r.width(),
r.height(),
a/16, alen/16);
4102 qWarning(
"QPainter::drawArc: Painter not active");
4159 if (qt_show_painter_debug_output)
4160 printf(
"QPainter::drawPie(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n",
4161 r.x(),
r.y(),
r.width(),
r.height(),
a/16, alen/16);
4166 qWarning(
"QPainter::drawPie: Painter not active");
4174 if (
a < 0)
a += (360*16);
4182 path.closeSubpath();
4230 if (qt_show_painter_debug_output)
4231 printf(
"QPainter::drawChord(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n",
4232 r.x(),
r.y(),
r.width(),
r.height(),
a/16, alen/16);
4237 qWarning(
"QPainter::drawChord: Painter not active");
4246 path.closeSubpath();
4279 if (qt_show_painter_debug_output)
4280 printf(
"QPainter::drawLines(), line count=%d\n", lineCount);
4285 if (!
d->engine || lineCount < 1)
4289 d->extended->drawLines(lines, lineCount);
4293 d->updateState(
d->state);
4297 if (lineEmulation) {
4300 for (
int i = 0;
i < lineCount; ++
i) {
4302 line.translate(
d->state->matrix.dx(),
d->state->matrix.dy());
4303 d->engine->drawLines(&
line, 1);
4307 for (
int i = 0;
i < lineCount; ++
i) {
4309 linePath.lineTo(lines[
i].
p2());
4315 d->engine->drawLines(lines, lineCount);
4328 if (qt_show_painter_debug_output)
4329 printf(
"QPainter::drawLine(), line count=%d\n", lineCount);
4334 if (!
d->engine || lineCount < 1)
4338 d->extended->drawLines(lines, lineCount);
4342 d->updateState(
d->state);
4346 if (lineEmulation) {
4349 for (
int i = 0;
i < lineCount; ++
i) {
4351 line.translate(
d->state->matrix.dx(),
d->state->matrix.dy());
4352 d->engine->drawLines(&
line, 1);
4356 for (
int i = 0;
i < lineCount; ++
i) {
4358 linePath.lineTo(lines[
i].
p2());
4364 d->engine->drawLines(lines, lineCount);
4447 if (qt_show_painter_debug_output)
4448 printf(
"QPainter::drawPolyline(), count=%d\n", pointCount);
4452 if (!
d->engine || pointCount < 2)
4460 d->updateState(
d->state);
4464 if (lineEmulation) {
4470 for (
int i=1;
i<pointCount; ++
i)
4471 polylinePath.lineTo(
points[
i]);
4488 if (qt_show_painter_debug_output)
4489 printf(
"QPainter::drawPolyline(), count=%d\n", pointCount);
4493 if (!
d->engine || pointCount < 2)
4501 d->updateState(
d->state);
4505 if (lineEmulation) {
4511 for (
int i=1;
i<pointCount; ++
i)
4512 polylinePath.lineTo(
points[
i]);
4563 if (qt_show_painter_debug_output)
4564 printf(
"QPainter::drawPolygon(), count=%d\n", pointCount);
4569 if (!
d->engine || pointCount < 2)
4577 d->updateState(
d->state);
4579 uint emulationSpecifier =
d->state->emulationSpecifier;
4581 if (emulationSpecifier) {
4583 for (
int i=1;
i<pointCount; ++
i)
4584 polygonPath.lineTo(
points[
i]);
4585 polygonPath.closeSubpath();
4586 polygonPath.setFillRule(fillRule);
4587 d->draw_helper(polygonPath);
4602 if (qt_show_painter_debug_output)
4603 printf(
"QPainter::drawPolygon(), count=%d\n", pointCount);
4608 if (!
d->engine || pointCount < 2)
4616 d->updateState(
d->state);
4618 uint emulationSpecifier =
d->state->emulationSpecifier;
4620 if (emulationSpecifier) {
4622 for (
int i=1;
i<pointCount; ++
i)
4623 polygonPath.lineTo(
points[
i]);
4624 polygonPath.closeSubpath();
4625 polygonPath.setFillRule(fillRule);
4626 d->draw_helper(polygonPath);
4701 if (qt_show_painter_debug_output)
4702 printf(
"QPainter::drawConvexPolygon(), count=%d\n", pointCount);
4707 if (!
d->engine || pointCount < 2)
4715 d->updateState(
d->state);
4717 uint emulationSpecifier =
d->state->emulationSpecifier;
4719 if (emulationSpecifier) {
4721 for (
int i=1;
i<pointCount; ++
i)
4722 polygonPath.lineTo(
points[
i]);
4723 polygonPath.closeSubpath();
4725 d->draw_helper(polygonPath);
4735 if (qt_show_painter_debug_output)
4736 printf(
"QPainter::drawConvexPolygon(), count=%d\n", pointCount);
4741 if (!
d->engine || pointCount < 2)
4749 d->updateState(
d->state);
4751 uint emulationSpecifier =
d->state->emulationSpecifier;
4753 if (emulationSpecifier) {
4755 for (
int i=1;
i<pointCount; ++
i)
4756 polygonPath.lineTo(
points[
i]);
4757 polygonPath.closeSubpath();
4759 d->draw_helper(polygonPath);
4768 return m.inverted().map(
QPointF(
m.map(
p).toPoint()));
4798#if defined QT_DEBUG_DRAW
4799 if (qt_show_painter_debug_output)
4800 printf(
"QPainter::drawPixmap(), p=[%.2f,%.2f], pix=[%d,%d]\n",
4807 if (!
d->engine || pm.
isNull())
4815 d->extended->drawPixmap(
p, pm);
4833 d->updateState(
d->state);
4860 x +=
d->state->matrix.dx();
4861 y +=
d->state->matrix.dy();
4870#if defined QT_DEBUG_DRAW
4871 if (qt_show_painter_debug_output)
4872 printf(
"QPainter::drawPixmap(), target=[%.2f,%.2f,%.2f,%.2f], pix=[%d,%d], source=[%.2f,%.2f,%.2f,%.2f]\n",
4873 r.x(),
r.y(),
r.width(),
r.height(),
4875 sr.x(), sr.y(), sr.width(), sr.height());
4879 if (!
d->engine || pm.
isNull())
4891 qreal sw = sr.width();
4892 qreal sh = sr.height();
4901 sw = pm.
width() - sx;
4912 qreal w_ratio = sx *
w/sw;
4920 qreal h_ratio = sy *
h/sh;
4927 if (sw + sx > pm.
width()) {
4929 qreal w_ratio = delta *
w/sw;
4934 if (sh + sy > pm.
height()) {
4936 qreal h_ratio = delta *
h/sh;
4941 if (
w == 0 ||
h == 0 || sw <= 0 || sh <= 0)
4953 d->updateState(
d->state);
4995 x +=
d->state->matrix.dx();
4996 y +=
d->state->matrix.dy();
5109 if (!
d->engine ||
image.isNull())
5113 d->extended->drawImage(
p,
image);
5124 d->updateState(
d->state);
5153 x +=
d->state->matrix.dx();
5154 y +=
d->state->matrix.dy();
5161 Qt::ImageConversionFlags
flags)
5165 if (!
d->engine ||
image.isNull())
5168 qreal x = targetRect.x();
5169 qreal y = targetRect.y();
5170 qreal w = targetRect.width();
5171 qreal h = targetRect.height();
5172 qreal sx = sourceRect.
x();
5173 qreal sy = sourceRect.
y();
5180 sw =
image.width() - sx;
5183 sh =
image.height() - sy;
5186 w = sw / imageScale;
5188 h = sh / imageScale;
5191 qreal w_ratio = sx *
w/sw;
5199 qreal h_ratio = sy *
h/sh;
5206 if (sw + sx >
image.width()) {
5208 qreal w_ratio = delta *
w/sw;
5213 if (sh + sy >
image.height()) {
5215 qreal h_ratio = delta *
h/sh;
5220 if (
w == 0 ||
h == 0 || sw <= 0 || sh <= 0)
5228 d->updateState(
d->state);
5266 x +=
d->state->matrix.dx();
5267 y +=
d->state->matrix.dy();
5284#if !defined(QT_NO_RAWFONT)
5290 qWarning(
"QPainter::drawGlyphRun: Painter not active");
5295 if (!
font.isValid())
5300 const quint32 *glyphIndexes = glyphRun_d->glyphIndexData;
5301 const QPointF *glyphPositions = glyphRun_d->glyphPositionData;
5303 int count =
qMin(glyphRun_d->glyphIndexDataSize, glyphRun_d->glyphPositionDataSize);
5304 QVarLengthArray<QFixedPoint, 128> fixedPointPositions(
count);
5307 bool engineRequiresPretransformedGlyphPositions =
d->extended
5308 ?
d->extended->requiresPretransformedGlyphPositions(fontD->fontEngine,
d->state->matrix)
5313 if (engineRequiresPretransformedGlyphPositions)
5314 processedPosition =
d->state->transform().map(processedPosition);
5318 d->drawGlyphs(engineRequiresPretransformedGlyphPositions
5322 fixedPointPositions.data(),
5346 staticTextItem.font =
state->font;
5347 staticTextItem.setFontEngine(fontEngine);
5348 staticTextItem.numGlyphs = glyphCount;
5349 staticTextItem.glyphs =
reinterpret_cast<glyph_t *
>(
const_cast<glyph_t *
>(glyphArray));
5350 staticTextItem.glyphPositions =
positions;
5352 staticTextItem.usesRawFont =
true;
5359 QVarLengthArray<QFixed, 128> advances(glyphCount);
5360 QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount);
5361 QVarLengthArray<QGlyphAttributes, 128> glyphAttributes(glyphCount);
5362 memset(glyphAttributes.data(), 0, glyphAttributes.size() *
sizeof(
QGlyphAttributes));
5363 memset(
static_cast<void *
>(advances.data()), 0, advances.size() *
sizeof(
QFixed));
5364 memset(
static_cast<void *
>(glyphJustifications.data()), 0, glyphJustifications.size() *
sizeof(
QGlyphJustification));
5366 textItem.glyphs.numGlyphs = glyphCount;
5367 textItem.glyphs.glyphs =
const_cast<glyph_t *
>(glyphArray);
5369 textItem.glyphs.advances = advances.data();
5370 textItem.glyphs.justifications = glyphJustifications.data();
5371 textItem.glyphs.attributes = glyphAttributes.data();
5458 if (!
d->engine || staticText.text().isEmpty() ||
pen().style() ==
Qt::NoPen)
5466 if (
font() != staticText_d->font ||
fp ==
nullptr || stfp ==
nullptr ||
fp->dpi != stfp->dpi) {
5467 staticText_d->font =
font();
5468 staticText_d->needsRelayout =
true;
5469 }
else if (stfp->engineData ==
nullptr || stfp->engineData->fontCacheId !=
QFontCache::instance()->id()) {
5470 staticText_d->needsRelayout =
true;
5473 QFontEngine *fe = staticText_d->font.d->engineForScript(QChar::Script_Common);
5480 if (
d->extended ==
nullptr
5481 || !
d->state->matrix.isAffine()
5482 || !fe->supportsTransformation(
d->state->matrix)) {
5483 staticText_d->paintText(topLeftPosition,
this,
pen().
color());
5487 bool engineRequiresPretransform =
d->extended->requiresPretransformedGlyphPositions(fe,
d->state->matrix);
5488 if (staticText_d->untransformedCoordinates && engineRequiresPretransform) {
5491 staticText_d->untransformedCoordinates =
false;
5492 staticText_d->needsRelayout =
true;
5493 }
else if (!staticText_d->untransformedCoordinates && !engineRequiresPretransform) {
5496 staticText_d->untransformedCoordinates =
true;
5497 staticText_d->needsRelayout =
true;
5502 QPointF transformedPosition = topLeftPosition;
5503 if (!staticText_d->untransformedCoordinates)
5504 transformedPosition = transformedPosition *
d->state->matrix;
5509 if (
d->state->matrix.isTranslating() && !staticText_d->untransformedCoordinates) {
5511 qreal m12 =
d->state->matrix.m12();
5512 qreal m13 =
d->state->matrix.m13();
5513 qreal m21 =
d->state->matrix.m21();
5514 qreal m22 =
d->state->matrix.m22();
5515 qreal m23 =
d->state->matrix.m23();
5516 qreal m33 =
d->state->matrix.m33();
5518 oldMatrix =
d->state->matrix;
5519 d->state->matrix.setMatrix(m11, m12, m13,
5526 bool staticTextNeedsReinit = staticText_d->needsRelayout;
5527 if (!staticText_d->untransformedCoordinates && staticText_d->matrix !=
d->state->matrix) {
5528 staticText_d->matrix =
d->state->matrix;
5529 staticTextNeedsReinit =
true;
5533 if (staticTextNeedsReinit)
5534 staticText_d->init();
5536 if (transformedPosition != staticText_d->position) {
5541 for (
int item=0;
item<staticText_d->itemCount;++
item) {
5543 for (
int i=0;
i<textItem->numGlyphs; ++
i) {
5544 textItem->glyphPositions[
i].
x += fx - oldX;
5545 textItem->glyphPositions[
i].y += fy - oldY;
5547 textItem->userDataNeedsUpdate =
true;
5550 staticText_d->position = transformedPosition;
5553 QPen oldPen =
d->state->pen;
5554 QColor currentColor = oldPen.color();
5555 static const QColor bodyIndicator(0, 0, 0, 0);
5556 for (
int i=0;
i<staticText_d->itemCount; ++
i) {
5558 if (
item->color.isValid() && currentColor !=
item->color
5559 &&
item->color != bodyIndicator) {
5561 currentColor =
item->color;
5562 }
else if (
item->color == bodyIndicator) {
5564 currentColor = oldPen.color();
5566 d->extended->drawStaticTextItem(
item);
5571 item->glyphPositions,
5574 staticText_d->font.underline(),
5575 staticText_d->font.overline(),
5576 staticText_d->font.strikeOut());
5578 if (currentColor != oldPen.color())
5581 if (!staticText_d->untransformedCoordinates && oldMatrix.isTranslating())
5582 d->state->matrix = oldMatrix;
5591 if (qt_show_painter_debug_output)
5601 engine.option.setTextDirection(
d->state->layoutDirection);
5603 engine.ignoreBidi =
true;
5611 int nItems =
engine.layoutData->items.size();
5612 QVarLengthArray<int> visualOrder(nItems);
5613 QVarLengthArray<uchar>
levels(nItems);
5614 for (
int i = 0;
i < nItems; ++
i)
5618 if (justificationPadding > 0) {
5620 engine.forceJustification =
true;
5622 line.width = justificationPadding;
5627 for (
int i = 0;
i < nItems; ++
i) {
5628 int item = visualOrder[
i];
5636 gf.glyphs =
engine.shapedGlyphs(&si);
5639 if (
engine.forceJustification) {
5640 for (
int j=0;
j<gf.glyphs.numGlyphs; ++
j)
5641 gf.width += gf.glyphs.effectiveAdvance(
j);
5643 gf.width = si.
width;
5645 gf.logClusters =
engine.logClusters(&si);
5656 if (qt_show_painter_debug_output)
5657 printf(
"QPainter::drawText(), r=[%d,%d,%d,%d], flags=%d, str='%s'\n",
5667 d->updateState(
d->state);
5743 if (qt_show_painter_debug_output)
5744 printf(
"QPainter::drawText(), r=[%.2f,%.2f,%.2f,%.2f], flags=%d, str='%s'\n",
5754 d->updateState(
d->state);
5862 if (qt_show_painter_debug_output)
5863 printf(
"QPainter::drawText(), r=[%.2f,%.2f,%.2f,%.2f], str='%s'\n",
5873 d->updateState(
d->state);
5919 % HexString<qreal>(radiusBase)
5920 % HexString<qreal>(pen.
widthF());
5927 const int width =
qCeil(100 / (2 * halfPeriod)) * (2 * halfPeriod);
5935 while (xs <
width) {
5938 path.quadTo(xs - halfPeriod / 2, ys, xs, 0);
5949 const qreal maxPenWidth = .8 * radius;
5950 if (wavePen.widthF() > maxPenWidth)
5951 wavePen.setWidthF(maxPenWidth);
5954 imgPainter.setPen(wavePen);
5956 imgPainter.translate(0, radius);
5957 imgPainter.drawPath(
path);
5979 pen.
setWidthF(fe->lineThickness().toReal());
5984 const qreal underlineOffset = fe->underlinePosition().toReal();
5997 qreal maxHeight = fe->descent().toReal() -
qreal(1);
6005 const int descent =
qFloor(maxHeight);
6013 qreal adjustedUnderlineOffset = std::ceil(underlineOffset) + 0.5;
6014 if (underlineOffset <= fe->descent().toReal())
6015 adjustedUnderlineOffset =
qMin(adjustedUnderlineOffset, fe->descent().toReal() -
qreal(0.5));
6016 const qreal underlinePos =
pos.y() + adjustedUnderlineOffset;
6023 QLineF underline(
line.x1(), underlinePos,
line.x2(), underlinePos);
6025 textEngine->addUnderline(
painter, underline);
6035 strikeOutLine.translate(0., - fe->ascent().toReal() / 3.);
6041 textEngine->addStrikeOut(
painter, strikeOutLine);
6048 overline.
translate(0., - fe->ascent().toReal());
6054 textEngine->addOverline(
painter, overline);
6064 const QPointF &decorationPosition,
6073 if (!underline && !overline && !strikeOut)
6076 QTextItem::RenderFlags
flags;
6107 d->drawTextItem(
p, ti,
static_cast<QTextEngine *
>(
nullptr));
6113 if (qt_show_painter_debug_output)
6114 printf(
"QPainter::drawTextItem(), pos=[%.f,%.f], str='%s'\n",
6126 QRectF rect(
p.x(),
p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent).toReal());
6133 const QPainter::RenderHints oldRenderHints =
state->renderHints;
6141 bool isPlain90DegreeRotation =
6160 aa = !isPlain90DegreeRotation;
6169 if (!ti.glyphs.numGlyphs) {
6171 ti.flags, ti.width.toReal(), ti.charFormat);
6176 int which = glyphs.
glyphs[0] >> 24;
6183 x += ti.width.toReal();
6187 for (
end = 0;
end < ti.glyphs.numGlyphs; ++
end) {
6199 ti2.width += ti.glyphs.effectiveAdvance(
i);
6203 x -= ti2.width.toReal();
6210 ti2.flags, ti2.width.toReal(), ti2.charFormat);
6213 x += ti2.width.toReal();
6216 const int hi = which << 24;
6232 ti2.width += ti.glyphs.effectiveAdvance(
i);
6236 x -= ti2.width.toReal();
6243 ti2.flags, ti2.width.toReal(), ti2.charFormat);
6246 const int hi = which << 24;
6256 ti.flags, ti.width.toReal(), ti.charFormat);
6259 if (
state->renderHints != oldRenderHints) {
6260 state->renderHints = oldRenderHints;
6394 if (qt_show_painter_debug_output)
6395 printf(
"QPainter::drawTiledPixmap(), target=[%.2f,%.2f,%.2f,%.2f], pix=[%d,%d], offset=[%.2f,%.2f]\n",
6396 r.x(),
r.y(),
r.width(),
r.height(),
6402 if (!
d->engine ||
pixmap.isNull() ||
r.isEmpty())
6431 d->updateState(
d->state);
6466 x +=
d->state->matrix.dx();
6467 y +=
d->state->matrix.dy();
6495#ifndef QT_NO_PICTURE
6526 qWarning(
"QPainter::drawPicture: Painter not active");
6531 d->updateState(
d->state);
6640 qWarning(
"QPainter::fillRect: Painter not active");
6645 d->extended->fillRect(
r,
brush);
6654 d->colorBrush.setColor(
brush.color());
6677 qWarning(
"QPainter::fillRect: Painter not active");
6682 d->extended->fillRect(
r,
brush);
6691 d->colorBrush.setColor(
brush.color());
6717 qWarning(
"QPainter::fillRect: Painter not active");
6722 d->extended->fillRect(
r,
color);
6746 d->extended->fillRect(
r,
color);
6845 if (qt_show_painter_debug_output)
6846 printf(
"QPainter::setRenderHint: hint=%x, %s\n",
hint, on ?
"on" :
"off");
6873 qWarning(
"QPainter::setRenderHint: Painter must be active to set rendering hints");
6878 d->state->renderHints |= hints;
6880 d->state->renderHints &= ~hints;
6883 d->extended->renderHintsChanged();
6901 return d->state->renderHints;
6924 qWarning(
"QPainter::viewTransformEnabled: Painter not active");
6927 return d->state->VxF;
6958 if (qt_show_painter_debug_output)
6959 printf(
"QPainter::setWindow(), [%d,%d,%d,%d]\n",
r.x(),
r.y(),
r.width(),
r.height());
6965 qWarning(
"QPainter::setWindow: Painter not active");
6969 d->state->wx =
r.x();
6970 d->state->wy =
r.y();
6971 d->state->ww =
r.width();
6972 d->state->wh =
r.height();
6974 d->state->VxF =
true;
6988 qWarning(
"QPainter::window: Painter not active");
6991 return QRect(
d->state->wx,
d->state->wy,
d->state->ww,
d->state->wh);
7022 if (qt_show_painter_debug_output)
7023 printf(
"QPainter::setViewport(), [%d,%d,%d,%d]\n",
r.x(),
r.y(),
r.width(),
r.height());
7029 qWarning(
"QPainter::setViewport: Painter not active");
7033 d->state->vx =
r.x();
7034 d->state->vy =
r.y();
7035 d->state->vw =
r.width();
7036 d->state->vh =
r.height();
7038 d->state->VxF =
true;
7052 qWarning(
"QPainter::viewport: Painter not active");
7055 return QRect(
d->state->vx,
d->state->vy,
d->state->vw,
d->state->vh);
7069 if (qt_show_painter_debug_output)
7070 printf(
"QPainter::setViewTransformEnabled(), enable=%d\n",
enable);
7076 qWarning(
"QPainter::setViewTransformEnabled: Painter not active");
7089 int tabstops,
int *ta,
int tabarraylen,
7093 tf,
nullptr,
str, brect,
7094 tabstops, ta, tabarraylen,
7099 int tabstops,
int *ta,
int tabarraylen,
7106 tf |=
option->alignment();
7113 if (
option->tabStopDistance() >= 0 || !
option->tabArray().isEmpty())
7148 uint maxUnderlines = 0;
7154 bool hasMoreLengthVariants =
false;
7160 if (chr == u
'\r' || (singleline && chr == u
'\n')) {
7162 }
else if (chr == u
'\n') {
7164 }
else if (chr == u
'&') {
7166 }
else if (chr == u
'\t') {
7169 }
else if (!tabarraylen && !tabstops) {
7170 tabstops =
qRound(fm.horizontalAdvance(u
'x')*8);
7172 }
else if (chr == u
'\x9c') {
7174 hasMoreLengthVariants =
true;
7179 QList<QTextLayout::FormatRange> underlineFormats;
7181 if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) {
7183 QChar *cout0 = cout;
7197 range.format.setFontUnderline(
true);
7198 underlineFormats.append(
range);
7201 }
else if (hidemnmemonic && *cin == u
'(' && l >= 4 &&
7202 cin[1] == u
'&' && cin[2] != u
'&' &&
7205 while ((cout -
n) > cout0 && (cout -
n - 1)->isSpace())
7230 if (
engine.option.tabStopDistance() < 0 && tabstops > 0)
7231 engine.option.setTabStopDistance(tabstops);
7233 if (
engine.option.tabs().isEmpty() && ta) {
7235 tabs.reserve(tabarraylen);
7236 for (
int i = 0;
i < tabarraylen;
i++)
7237 tabs.append(
qreal(ta[
i]));
7238 engine.option.setTabArray(tabs);
7251 engine.forceJustification =
true;
7256 if (finalText.isEmpty()) {
7261 qreal lineWidth = 0x01000000;
7263 lineWidth = qMax<qreal>(0,
r.width());
7268 qreal leading = fm.leading();
7295 yoff = (
r.height() -
height)/2;
7298 xoff =
r.width() -
width;
7300 xoff = (
r.width() -
width)/2;
7306 goto start_lengthVariant;
7312 bool restore =
false;
7313 if (!dontclip && !
r.contains(bounds)) {
7324 qreal advance =
line.horizontalAdvance();
7327 xoff =
r.width() - advance -
7331 xoff = (
r.width() - advance) / 2;
7371 : brushOrigin(
s->brushOrigin),
font(
s->
font), deviceFont(
s->deviceFont),
7373 clipRegion(
s->clipRegion), clipPath(
s->clipPath),
7374 clipOperation(
s->clipOperation),
7375 renderHints(
s->renderHints), clipInfo(
s->clipInfo),
7376 worldMatrix(
s->worldMatrix),
matrix(
s->
matrix), redirectionMatrix(
s->redirectionMatrix),
7377 wx(
s->wx), wy(
s->wy), ww(
s->ww), wh(
s->wh),
7378 vx(
s->vx), vy(
s->vy), vw(
s->vw), vh(
s->vh),
7379 opacity(
s->opacity), WxF(
s->WxF), VxF(
s->VxF),
7381 layoutDirection(
s->layoutDirection),
7382 composition_mode(
s->composition_mode),
7383 emulationSpecifier(
s->emulationSpecifier), changeFlags(0)
7389 : brushOrigin(0, 0), WxF(
false), VxF(
false), clipEnabled(true),
7792 return static_cast<const QPainterState *
>(
this)->clipEnabled;
7822 return static_cast<const QPainterState *
>(
this)->composition_mode;
7895 qWarning(
"QPainter::deviceTransform: Painter not active");
7896 return d->fakeState()->transform;
7898 return d->state->matrix;
7914 if (qt_show_painter_debug_output)
7915 printf(
"QPainter::resetMatrix()\n");
7918 qWarning(
"QPainter::resetMatrix: Painter not active");
7922 d->state->wx =
d->state->wy =
d->state->vx =
d->state->vy = 0;
7929 d->extended->transformChanged();
7947 qWarning(
"QPainter::setWorldTransform: Painter not active");
7952 d->state->worldMatrix =
matrix *
d->state->worldMatrix;
7954 d->state->worldMatrix =
matrix;
7956 d->state->WxF =
true;
7968 qWarning(
"QPainter::worldTransform: Painter not active");
7969 return d->fakeState()->transform;
7971 return d->state->worldMatrix;
7985 qWarning(
"QPainter::combinedTransform: Painter not active");
7988 return d->state->worldMatrix *
d->viewTransform() *
d->hidpiScaleTransform();
8011 if (!
d->engine ||
pixmap.isNull())
8015 for (
int i = 0;
i < fragmentCount; ++
i) {
8016 QRectF sourceRect(fragments[
i].sourceLeft, fragments[
i].sourceTop,
8019 qWarning(
"QPainter::drawPixmapFragments - the source rect is not contained by the pixmap's rectangle");
8023 if (
d->engine->isExtended()) {
8024 d->extended->drawPixmapFragments(fragments, fragmentCount,
pixmap, hints);
8029 for (
int i = 0;
i < fragmentCount; ++
i) {
8033 if (fragments[
i].rotation == 0) {
8034 xOffset = fragments[
i].
x;
8035 yOffset = fragments[
i].
y;
8045 QRectF sourceRect(fragments[
i].sourceLeft, fragments[
i].sourceTop,
8164 p->draw_helper(
path, operation);
8169#include "moc_qpainter.cpp"
IOBluetoothDevice * device
const QColor & color() const
Returns the brush color.
Qt::BrushStyle style() const
Returns the brush style.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
The QColor class provides colors based on RGB, HSV or CMYK values.
QRgb rgb() const noexcept
Returns the RGB value of the color.
QString name(NameFormat format=HexRgb) const
bool isValid() const noexcept
Returns true if the color is valid; otherwise returns false.
static QFontCache * instance()
void ensureEngineAt(int at)
QFontEngine * engine(int at) const
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)
\reentrant \inmodule QtGui
\reentrant \inmodule QtGui
static QFontPrivate * get(const QFont &font)
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
QStringList families() const
int pointSize() const
Returns the point size of the font.
static QGlyphRunPrivate * get(const QGlyphRun &glyphRun)
The QGlyphRun class provides direct access to the internal glyphs in a font.
bool overline() const
Returns true if this QGlyphRun should be painted with an overline decoration.
bool strikeOut() const
Returns true if this QGlyphRun should be painted with a strike out decoration.
QRawFont rawFont() const
Returns the font selected for this QGlyphRun object.
bool underline() const
Returns true if this QGlyphRun should be painted with an underline decoration.
CoordinateMode coordinateMode() const
qreal x() const
This convenience function is equivalent to calling pos().x().
static QPlatformIntegration * platformIntegration()
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
static QPlatformTheme * platformTheme()
Qt::LayoutDirection layoutDirection
the default layout direction for this application
@ Format_ARGB32_Premultiplied
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
void translate(const QPointF &p)
Translates this line by the given offset.
\inmodule QtCore\compares equality \compareswith equality QLineF \endcompareswith
qreal devicePixelRatio() const
virtual void initPainter(QPainter *painter) const
virtual int devType() const
virtual QPaintDevice * redirected(QPoint *offset) const
virtual QPainter * sharedPainter() const
virtual int metric(PaintDeviceMetric metric) const
virtual QPaintEngine * paintEngine() const =0
virtual void renderHintsChanged()=0
virtual void penChanged()=0
virtual uint flags() const
virtual void transformChanged()=0
virtual void setState(QPainterState *s)
virtual void drawStaticTextItem(QStaticTextItem *)
void setSystemTransform(const QTransform &xform)
QPaintDevice * currentClipDevice
virtual void systemStateChanged()
QTransform transform() const
QBrush backgroundBrush() const
Returns the background brush in the current paint engine state.
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
Qt::ClipOperation clipOperation() const
Returns the clip operation in the current paint engine state.
bool brushNeedsResolving() const
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
QPaintEngine::DirtyFlags dirtyFlags
QPainter * painter() const
Returns a pointer to the painter currently updating the paint engine.
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
QBrush brush() const
Returns the brush in the current paint engine state.
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
QFont font() const
Returns the font in the current paint engine state.
QPen pen() const
Returns the pen in the current paint engine state.
Qt::BGMode backgroundMode() const
Returns the background mode in the current paint engine state.
bool penNeedsResolving() const
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
@ ObjectBoundingModeGradients
QPaintEngineState * state
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
The QPainterPathStroker class is used to generate fillable outlines for a given painter path.
void setDashPattern(Qt::PenStyle)
Sets the dash pattern for the generated outlines to style.
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
void setMiterLimit(qreal length)
Sets the miter limit of the generated outlines to limit.
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision.
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation)
void updateEmulationSpecifier(QPainterState *s)
QPaintEngineEx * extended
QPaintDevice * helper_device
void initFrom(const QPaintDevice *device)
std::unique_ptr< QPaintEngine, QPaintEngineDestructor > engine
void updateState(QPainterState *state)
std::unique_ptr< QEmulationPaintEngine > emulationEngine
void draw_helper(const QPainterPath &path, DrawOperation operation=StrokeAndFillDraw)
QVarLengthArray< QPainterPrivate *, NDPtrs > d_ptrs
QPainterPrivate(QPainter *painter)
void drawTextItem(const QPointF &p, const QTextItem &_ti, QTextEngine *textEngine)
void drawStretchedGradient(const QPainterPath &path, DrawOperation operation)
QTransform hidpiScaleTransform() const
void detachPainterPrivate(QPainter *q)
QTransform viewTransform() const
qreal effectiveDevicePixelRatio() const
std::unique_ptr< QPainterState > state
void updateStateImpl(QPainterState *state)
static bool attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
void drawGlyphs(const QPointF &decorationPosition, const quint32 *glyphArray, QFixedPoint *positionArray, int glyphCount, QFontEngine *fontEngine, bool overline=false, bool underline=false, bool strikeOut=false)
QPainter::CompositionMode composition_mode
QList< QPainterClipInfo > clipInfo
QPainter::RenderHints renderHints
Qt::ClipOperation clipOperation
Qt::LayoutDirection layoutDirection
This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a ...
static PixmapFragment Q_GUI_EXPORT create(const QPointF &pos, const QRectF &sourceRect, qreal scaleX=1, qreal scaleY=1, qreal rotation=0, qreal opacity=1)
The QPainter class performs low-level painting on widgets and other paint devices.
const QBrush & background() const
Returns the current background brush.
CompositionMode compositionMode() const
Returns the current composition mode.
const QPen & pen() const
Returns the painter's current pen.
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
Qt::LayoutDirection layoutDirection() const
Returns the layout direction used by the painter when drawing text.
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
QPainter()
Constructs a painter.
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
void drawConvexPolygon(const QPointF *points, int pointCount)
Draws the convex polygon defined by the first pointCount points in the array points using the current...
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
void setWorldMatrixEnabled(bool enabled)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void drawPie(const QRectF &rect, int a, int alen)
Draws a pie defined by the given rectangle, startAngle and spanAngle.
void strokePath(const QPainterPath &path, const QPen &pen)
Draws the outline (strokes) the path path with the pen specified by pen.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, PixmapFragmentHints hints=PixmapFragmentHints())
void drawLine(const QLineF &line)
Draws a line defined by line.
void setViewport(const QRect &viewport)
Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun)
Draws the glyphs represented by glyphs at position.
QTransform combinedTransform() const
Returns the transformation matrix combining the current window/viewport and world transformation.
void drawTextItem(const QPointF &p, const QTextItem &ti)
void drawChord(const QRectF &rect, int a, int alen)
Draws the chord defined by the given rectangle, startAngle and spanAngle.
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false.
void setBrushOrigin(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount of the given rectangles using the current pen and brush.
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation.
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
const QFont & font() const
Returns the currently set font used for drawing text.
bool worldMatrixEnabled() const
void setLayoutDirection(Qt::LayoutDirection direction)
Sets the layout direction used by the painter when drawing text, to the specified direction.
~QPainter()
Destroys the painter.
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
void restore()
Restores the current painter state (pops a saved state off the stack).
void rotate(qreal a)
Rotates the coordinate system clockwise.
void scale(qreal sx, qreal sy)
Scales the coordinate system by ({sx}, {sy}).
const QTransform & worldTransform() const
Returns the world transformation matrix.
const QBrush & brush() const
Returns the painter's current brush.
void setOpacity(qreal opacity)
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
void beginNativePainting()
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void save()
Saves the current painter state (pushes the state onto a stack).
void setWorldTransform(const QTransform &matrix, bool combine=false)
Sets the world transformation matrix.
void shear(qreal sh, qreal sv)
Shears the coordinate system by ({sh}, {sv}).
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
void setFont(const QFont &f)
Sets the painter's font to the given font.
QRegion clipRegion() const
Returns the currently set clip region.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
Qt::BGMode backgroundMode() const
Returns the current background mode.
QPainterPath clipPath() const
Returns the current clip path in logical coordinates.
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen.
QRect viewport() const
Returns the viewport rectangle.
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
void eraseRect(const QRectF &)
Erases the area inside the given rectangle.
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
QPoint brushOrigin() const
Returns the currently set brush origin.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
RenderHint
Renderhints are used to specify flags to QPainter that may or may not be respected by any given engin...
void drawPicture(const QPointF &p, const QPicture &picture)
Replays the given picture at the given point.
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText)
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen's color.
bool viewTransformEnabled() const
Returns true if view transformation is enabled; otherwise returns false.
const QTransform & transform() const
Alias for worldTransform().
void resetTransform()
Resets any transformations that were made using translate(), scale(), shear(), rotate(),...
QRect window() const
Returns the window rectangle.
CompositionMode
Defines the modes supported for digital image compositing.
@ CompositionMode_SourceOver
@ CompositionMode_SourceAtop
@ RasterOp_SourceOrDestination
QRectF clipBoundingRect() const
Returns the bounding rectangle of the current clip if there is a clip; otherwise returns an empty rec...
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
void setViewTransformEnabled(bool enable)
Enables view transformations if enable is true, or disables view transformations if enable is false.
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void setRenderHints(RenderHints hints, bool on=true)
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
bool hasClipping() const
Returns true if clipping has been set; otherwise returns false.
void setWindow(const QRect &window)
Sets the painter's window to the given rectangle, and enables view transformations.
QFontInfo fontInfo() const
Returns the font info for the painter if the painter is active.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
void setTransform(const QTransform &transform, bool combine=false)
QRectF boundingRect(const QRectF &rect, int flags, const QString &text)
Returns the bounding rectangle of the text as it will appear when drawn inside the given rectangle wi...
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen's cap style to the given style.
qreal widthF() const
Returns the pen width with floating point precision.
void setStyle(Qt::PenStyle)
[0]
QColor color() const
Returns the color of this pen's brush.
void setWidthF(qreal width)
Sets the pen width to the given width in pixels with floating point precision.
Qt::PenCapStyle capStyle() const
Returns the pen's cap style.
void setColor(const QColor &color)
Sets the color of this pen's brush to the given color.
void setBrush(const QBrush &brush)
Sets the brush used to fill strokes generated with this pen to the given brush.
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
qreal miterLimit() const
Returns the miter limit of the pen.
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Qt::PenStyle style() const
Returns the pen style.
The QPicture class is a paint device that records and replays QPainter commands.
static bool find(const QString &key, QPixmap *pixmap)
Looks for a cached pixmap associated with the given key in the cache.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
int height() const
Returns the height of the pixmap.
int depth() const
Returns the depth of the pixmap.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
int width() const
Returns the width of the pixmap.
QPixmap copy(int x, int y, int width, int height) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRect rect() const
Returns the pixmap's enclosing rectangle.
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
bool isQBitmap() const
Returns true if this is a QBitmap; otherwise returns false.
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
static QRawFontPrivate * get(const QRawFont &font)
The QRawFont class provides access to a single physical instance of a font.
\inmodule QtCore\reentrant
QRect toAlignedRect() const noexcept
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
bool contains(const QRectF &r) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRectF normalized() const noexcept
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.
QRectF intersected(const QRectF &other) const noexcept
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr int height() const noexcept
Returns the height of the rectangle.
QRect intersected(const QRect &other) const noexcept
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
The QRegion class specifies a clip region for a painter.
static QStaticTextPrivate * get(const QStaticText *q)
The QStaticText class enables optimized drawing of text when the text and its layout is updated rarel...
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
QChar * data()
Returns a pointer to the data stored in the QString.
qsizetype length() const noexcept
Returns the number of characters in this string.
UnderlineStyle
This enum describes the different ways drawing underlined text.
QColor underlineColor() const
Returns the color used to draw underlines, overlines and strikeouts on the characters with this forma...
void enableDelayDecorations(bool enable=true)
QFixed leadingSpaceWidth(const QScriptLine &line)
void drawDecorations(QPainter *painter)
static void bidiReorder(int numRuns, const quint8 *levels, int *visualOrder)
QTextItemInt midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
void beginLayout()
Begins the layout process.
QTextEngine * engine() const
void setCacheEnabled(bool enable)
Enables caching of the complete layout information if enable is true; otherwise disables layout cachi...
void setFormats(const QList< FormatRange > &overrides)
int lineCount() const
Returns the number of lines in this text layout.
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
void endLayout()
Ends the layout process.
qreal naturalTextWidth() const
Returns the width of the line that is occupied by text.
void setPosition(const QPointF &pos)
Moves the line to position pos.
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
void setLineWidth(qreal width)
Lays out the line with the given width.
int lineNumber() const
Returns the position of the line in the text engine.
static QThread * currentThread()
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
@ TextJustificationForced
@ TextIncludeTrailingSpaces
bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush &brush)
Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush)
static const QCssKnownValue positions[NumKnownPositionModes - 1]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
static Q_CONSTINIT Qt::LayoutDirection layout_direction
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLenum GLuint GLintptr offset
GLfloat GLfloat GLfloat GLfloat h
GLuint GLenum GLenum transform
GLfixed GLfixed GLint GLint GLfixed points
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLfloat GLfloat GLfloat alpha
GLenum GLenum GLenum GLenum GLenum scale
static const QRectF boundingRect(const QPointF *points, int pointCount)
const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
bool qt_isExtendedRadialGradient(const QBrush &brush)
#define QPaintEngine_OpaqueBackground
static void qt_draw_decoration_for_glyphs(QPainter *painter, const QPointF &decorationPosition, const glyph_t *glyphArray, const QFixedPoint *positions, int glyphCount, QFontEngine *fontEngine, bool underline, bool overline, bool strikeOut)
static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextEngine *textEngine, QTextCharFormat::UnderlineStyle underlineStyle, QTextItem::RenderFlags flags, qreal width, const QTextCharFormat &charFormat)
static bool needsEmulation(const QBrush &brush)
static bool needsResolving(const QBrush &brush)
void qt_format_text(const QFont &font, const QRectF &_r, int tf, const QTextOption *option, const QString &str, QRectF *brect, int tabstops, int *tabarray, int tabarraylen, QPainter *painter)
static QPointF roundInDeviceCoordinates(const QPointF &p, const QTransform &m)
QPixmap qt_pixmapForBrush(int style, bool invert)
static bool is_brush_transparent(const QBrush &brush)
static QBrush stretchGradientToUserSpace(const QBrush &brush, const QRectF &boundingRect)
static bool qt_painter_thread_test(int devType, int engineType, const char *what)
static void qt_cleanup_painter_state(QPainterPrivate *d)
QPainterPath qt_regionToPath(const QRegion ®ion)
static QGradient::CoordinateMode coordinateMode(const QBrush &brush)
static uint line_emulation(uint emulation)
static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation)
#define QGradient_StretchToDevice
static bool is_pen_transparent(const QPen &pen)
bool qHasPixmapTexture(const QBrush &)
Qt::BrushStyle qbrush_style(const QBrush &b)
Qt::PenStyle qpen_style(const QPen &p)
QBrush qpen_brush(const QPen &p)
QT_BEGIN_NAMESPACE void qt_format_text(const QFont &fnt, const QRectF &_r, int tf, const QTextOption *opt, const QString &str, QRectF *brect, int tabstops, int *, int tabarraylen, QPainter *painter)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define qPrintable(string)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
static constexpr QFixedPoint fromPointF(const QPointF &p)
static constexpr QFixed fromReal(qreal r)
constexpr qreal toReal() const