diff options
author | Marc Mutz <[email protected]> | 2025-06-24 16:17:06 +0200 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2025-06-25 20:36:16 +0200 |
commit | 25f47a07833d1e3aaab89c017e931f5c8f23f147 (patch) | |
tree | 4d51a3c038b539447908d867e824960f9fdf36c5 | |
parent | d7a2e13df2773cf13968434b53a2dc7468decb63 (diff) |
QPainter: make qt_show_painter_debug_output constexpr
Nothing is modifying the variable, so make it constexpr (was: mutable)
and change all the if's into if-constexpr's.
While the compiler doesn't care unless QT_DEBUG_DRAW is defined, this
will prevent the next human reader from going on the same fruitless
hunt for a setter as yours truly.
Amends the start of the public history.
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ib2f8c0fcb2938ca3548b9452c4d8eb482e6ffbe5
Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r-- | src/gui/painting/qpainter.cpp | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index b868233d853..5013e96f740 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -53,7 +53,7 @@ static_assert(sizeof(QScopedPointer<QPainterPrivate>) == sizeof(std::unique_ptr< // #define QT_DEBUG_DRAW #ifdef QT_DEBUG_DRAW -bool qt_show_painter_debug_output = true; +constexpr bool qt_show_painter_debug_output = true; #endif extern QPixmap qt_pixmapForBrush(int style, bool invert); @@ -316,7 +316,7 @@ void QPainterPrivate::detachPainterPrivate(QPainter *q) void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperation op) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) { + if constexpr (qt_show_painter_debug_output) { printf("QPainter::drawHelper\n"); } #endif @@ -1546,7 +1546,7 @@ void QPainterPrivate::initFrom(const QPaintDevice *device) void QPainter::save() { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::save()\n"); #endif Q_D(QPainter); @@ -1580,7 +1580,7 @@ void QPainter::save() void QPainter::restore() { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::restore()\n"); #endif Q_D(QPainter); @@ -1702,7 +1702,7 @@ bool QPainter::begin(QPaintDevice *pd) pd = rpd; #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::begin(), device=%p, type=%d\n", pd, pd->devType()); #endif @@ -1848,7 +1848,7 @@ bool QPainter::begin(QPaintDevice *pd) bool QPainter::end() { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::end()\n"); #endif Q_D(QPainter); @@ -2112,7 +2112,7 @@ void QPainter::setBrushOrigin(const QPointF &p) { Q_D(QPainter); #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setBrushOrigin(), (%.2f,%.2f)\n", p.x(), p.y()); #endif @@ -2440,7 +2440,7 @@ void QPainter::setClipping(bool enable) { Q_D(QPainter); #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setClipping(), enable=%s, was=%s\n", enable ? "on" : "off", hasClipping() ? "on" : "off"); @@ -2819,7 +2819,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) Q_D(QPainter); #ifdef QT_DEBUG_DRAW QRect rect = r.boundingRect(); - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setClipRegion(), size=%d, [%d,%d,%d,%d]\n", r.rectCount(), rect.x(), rect.y(), rect.width(), rect.height()); #endif @@ -2870,7 +2870,7 @@ void QPainter::setWorldMatrixEnabled(bool enable) { Q_D(QPainter); #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setMatrixEnabled(), enable=%d\n", enable); #endif @@ -2913,7 +2913,7 @@ bool QPainter::worldMatrixEnabled() const void QPainter::scale(qreal sx, qreal sy) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::scale(), sx=%f, sy=%f\n", sx, sy); #endif Q_D(QPainter); @@ -2936,7 +2936,7 @@ void QPainter::scale(qreal sx, qreal sy) void QPainter::shear(qreal sh, qreal sv) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::shear(), sh=%f, sv=%f\n", sh, sv); #endif Q_D(QPainter); @@ -2961,7 +2961,7 @@ void QPainter::shear(qreal sh, qreal sv) void QPainter::rotate(qreal a) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::rotate(), angle=%f\n", a); #endif Q_D(QPainter); @@ -2986,7 +2986,7 @@ void QPainter::translate(const QPointF &offset) qreal dx = offset.x(); qreal dy = offset.y(); #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::translate(), dx=%f, dy=%f\n", dx, dy); #endif Q_D(QPainter); @@ -3029,7 +3029,7 @@ void QPainter::translate(const QPointF &offset) void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) { + if constexpr (qt_show_painter_debug_output) { QRectF b = path.boundingRect(); printf("QPainter::setClipPath(), size=%d, op=%d, bounds=[%.2f,%.2f,%.2f,%.2f]\n", path.elementCount(), op, b.x(), b.y(), b.width(), b.height()); @@ -3163,7 +3163,7 @@ void QPainter::drawPath(const QPainterPath &path) { #ifdef QT_DEBUG_DRAW QRectF pathBounds = path.boundingRect(); - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPath(), size=%d, [%.2f,%.2f,%.2f,%.2f]\n", path.elementCount(), pathBounds.x(), pathBounds.y(), pathBounds.width(), pathBounds.height()); @@ -3278,7 +3278,7 @@ void QPainter::drawPath(const QPainterPath &path) void QPainter::drawRects(const QRectF *rects, int rectCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawRects(), count=%d\n", rectCount); #endif Q_D(QPainter); @@ -3338,7 +3338,7 @@ void QPainter::drawRects(const QRectF *rects, int rectCount) void QPainter::drawRects(const QRect *rects, int rectCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawRects(), count=%d\n", rectCount); #endif Q_D(QPainter); @@ -3438,7 +3438,7 @@ void QPainter::drawRects(const QRect *rects, int rectCount) void QPainter::drawPoints(const QPointF *points, int pointCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPoints(), count=%d\n", pointCount); #endif Q_D(QPainter); @@ -3500,7 +3500,7 @@ void QPainter::drawPoints(const QPointF *points, int pointCount) void QPainter::drawPoints(const QPoint *points, int pointCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPoints(), count=%d\n", pointCount); #endif Q_D(QPainter); @@ -3585,7 +3585,7 @@ void QPainter::drawPoints(const QPoint *points, int pointCount) void QPainter::setBackgroundMode(Qt::BGMode mode) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setBackgroundMode(), mode=%d\n", mode); #endif @@ -3631,7 +3631,7 @@ Qt::BGMode QPainter::backgroundMode() const void QPainter::setPen(const QColor &color) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setPen(), color=%04x\n", color.rgb()); #endif Q_D(QPainter); @@ -3664,7 +3664,7 @@ void QPainter::setPen(const QPen &pen) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setPen(), color=%04x, (brushStyle=%d) style=%d, cap=%d, join=%d\n", pen.color().rgb(), pen.brush().style(), pen.style(), pen.capStyle(), pen.joinStyle()); #endif @@ -3743,7 +3743,7 @@ const QPen &QPainter::pen() const void QPainter::setBrush(const QBrush &brush) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setBrush(), color=%04x, style=%d\n", brush.color().rgb(), brush.style()); #endif Q_D(QPainter); @@ -3858,7 +3858,7 @@ const QBrush &QPainter::brush() const void QPainter::setBackground(const QBrush &bg) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setBackground(), color=%04x, style=%d\n", bg.color().rgb(), bg.style()); #endif @@ -3890,7 +3890,7 @@ void QPainter::setFont(const QFont &font) Q_D(QPainter); #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setFont(), family=%s, pointSize=%d\n", font.families().first().toLatin1().constData(), font.pointSize()); #endif @@ -3946,7 +3946,7 @@ const QFont &QPainter::font() const void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawRoundedRect(), [%.2f,%.2f,%.2f,%.2f]\n", rect.x(), rect.y(), rect.width(), rect.height()); #endif Q_D(QPainter); @@ -4010,7 +4010,7 @@ void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, void QPainter::drawEllipse(const QRectF &r) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawEllipse(), [%.2f,%.2f,%.2f,%.2f]\n", r.x(), r.y(), r.width(), r.height()); #endif Q_D(QPainter); @@ -4053,7 +4053,7 @@ void QPainter::drawEllipse(const QRectF &r) void QPainter::drawEllipse(const QRect &r) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawEllipse(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height()); #endif Q_D(QPainter); @@ -4141,7 +4141,7 @@ void QPainter::drawEllipse(const QRect &r) void QPainter::drawArc(const QRectF &r, int a, int alen) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawArc(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n", r.x(), r.y(), r.width(), r.height(), a/16, alen/16); #endif @@ -4205,7 +4205,7 @@ void QPainter::drawArc(const QRectF &r, int a, int alen) void QPainter::drawPie(const QRectF &r, int a, int alen) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPie(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n", r.x(), r.y(), r.width(), r.height(), a/16, alen/16); #endif @@ -4276,7 +4276,7 @@ void QPainter::drawPie(const QRectF &r, int a, int alen) void QPainter::drawChord(const QRectF &r, int a, int alen) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawChord(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n", r.x(), r.y(), r.width(), r.height(), a/16, alen/16); #endif @@ -4325,7 +4325,7 @@ void QPainter::drawChord(const QRectF &r, int a, int alen) void QPainter::drawLines(const QLineF *lines, int lineCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawLines(), line count=%d\n", lineCount); #endif @@ -4374,7 +4374,7 @@ void QPainter::drawLines(const QLineF *lines, int lineCount) void QPainter::drawLines(const QLine *lines, int lineCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawLine(), line count=%d\n", lineCount); #endif @@ -4493,7 +4493,7 @@ void QPainter::drawLines(const QPoint *pointPairs, int lineCount) void QPainter::drawPolyline(const QPointF *points, int pointCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPolyline(), count=%d\n", pointCount); #endif Q_D(QPainter); @@ -4534,7 +4534,7 @@ void QPainter::drawPolyline(const QPointF *points, int pointCount) void QPainter::drawPolyline(const QPoint *points, int pointCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPolyline(), count=%d\n", pointCount); #endif Q_D(QPainter); @@ -4609,7 +4609,7 @@ void QPainter::drawPolyline(const QPoint *points, int pointCount) void QPainter::drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPolygon(), count=%d\n", pointCount); #endif @@ -4648,7 +4648,7 @@ void QPainter::drawPolygon(const QPointF *points, int pointCount, Qt::FillRule f void QPainter::drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fillRule) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPolygon(), count=%d\n", pointCount); #endif @@ -4747,7 +4747,7 @@ void QPainter::drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fi void QPainter::drawConvexPolygon(const QPoint *points, int pointCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawConvexPolygon(), count=%d\n", pointCount); #endif @@ -4781,7 +4781,7 @@ void QPainter::drawConvexPolygon(const QPoint *points, int pointCount) void QPainter::drawConvexPolygon(const QPointF *points, int pointCount) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawConvexPolygon(), count=%d\n", pointCount); #endif @@ -4845,7 +4845,7 @@ static inline QPointF roundInDeviceCoordinates(const QPointF &p, const QTransfor void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) { #if defined QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPixmap(), p=[%.2f,%.2f], pix=[%d,%d]\n", p.x(), p.y(), pm.width(), pm.height()); @@ -4917,7 +4917,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { #if defined QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawPixmap(), target=[%.2f,%.2f,%.2f,%.2f], pix=[%d,%d], source=[%.2f,%.2f,%.2f,%.2f]\n", r.x(), r.y(), r.width(), r.height(), pm.width(), pm.height(), @@ -5637,7 +5637,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justificationPadding) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawText(), pos=[%.2f,%.2f], str='%s'\n", p.x(), p.y(), str.toLatin1().constData()); #endif @@ -5702,7 +5702,7 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawText(), r=[%d,%d,%d,%d], flags=%d, str='%s'\n", r.x(), r.y(), r.width(), r.height(), flags, str.toLatin1().constData()); #endif @@ -5789,7 +5789,7 @@ void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF *br) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawText(), r=[%.2f,%.2f,%.2f,%.2f], flags=%d, str='%s'\n", r.x(), r.y(), r.width(), r.height(), flags, str.toLatin1().constData()); #endif @@ -5908,7 +5908,7 @@ void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF * void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption &o) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawText(), r=[%.2f,%.2f,%.2f,%.2f], str='%s'\n", r.x(), r.y(), r.width(), r.height(), text.toLatin1().constData()); #endif @@ -6167,7 +6167,7 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti) void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QTextEngine *textEngine) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawTextItem(), pos=[%.f,%.f], str='%s'\n", p.x(), p.y(), qPrintable(_ti.text())); #endif @@ -6448,7 +6448,7 @@ QRectF QPainter::boundingRect(const QRectF &r, const QString &text, const QTextO void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &sp) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::drawTiledPixmap(), target=[%.2f,%.2f,%.2f,%.2f], pix=[%d,%d], offset=[%.2f,%.2f]\n", r.x(), r.y(), r.width(), r.height(), pixmap.width(), pixmap.height(), @@ -6899,7 +6899,7 @@ void QPainter::fillRect(const QRectF &r, const QColor &color) void QPainter::setRenderHint(RenderHint hint, bool on) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setRenderHint: hint=%x, %s\n", hint, on ? "on" : "off"); #endif @@ -7012,7 +7012,7 @@ bool QPainter::viewTransformEnabled() const void QPainter::setWindow(const QRect &r) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setWindow(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height()); #endif @@ -7076,7 +7076,7 @@ QRect QPainter::window() const void QPainter::setViewport(const QRect &r) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setViewport(), [%d,%d,%d,%d]\n", r.x(), r.y(), r.width(), r.height()); #endif @@ -7123,7 +7123,7 @@ QRect QPainter::viewport() const void QPainter::setViewTransformEnabled(bool enable) { #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::setViewTransformEnabled(), enable=%d\n", enable); #endif @@ -7975,7 +7975,7 @@ void QPainter::resetTransform() { Q_D(QPainter); #ifdef QT_DEBUG_DRAW - if (qt_show_painter_debug_output) + if constexpr (qt_show_painter_debug_output) printf("QPainter::resetMatrix()\n"); #endif if (!d->engine) { |