From c818acda97a7dc9f184e96fac4a0adbc56e1359e Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 18 Apr 2023 12:57:03 +0200 Subject: [PATCH] Improve style drawing under DPR scaling further MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rounding distances up can result in coordinates outside of the clip rect. So stick to always round distances down when we multiply a scaling. Fixes: QTBUG-109640 Pick-to: 6.5 Change-Id: I784b7c90da9b6e7f5a925d4275eb67497616001d Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qdrawutil.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp index bfffeecb6b..d04ed74dd0 100644 --- a/src/widgets/styles/qdrawutil.cpp +++ b/src/widgets/styles/qdrawutil.cpp @@ -230,8 +230,8 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, p->scale(inverseScale, inverseScale); x = qRound(devicePixelRatio * x); y = qRound(devicePixelRatio * y); - w = qRound(devicePixelRatio * w); - h = qRound(devicePixelRatio * h); + w = devicePixelRatio * w; + h = devicePixelRatio * h; lineWidth = qRound(devicePixelRatio * lineWidth); midLineWidth = qRound(devicePixelRatio * midLineWidth); p->translate(0.5, 0.5); @@ -346,8 +346,8 @@ void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, p->scale(inverseScale, inverseScale); x = qRound(devicePixelRatio * x); y = qRound(devicePixelRatio * y); - w = qRound(devicePixelRatio * w); - h = qRound(devicePixelRatio * h); + w = devicePixelRatio * w; + h = devicePixelRatio * h; lineWidth = qRound(devicePixelRatio * lineWidth); p->translate(0.5, 0.5); isTranslated = true; @@ -443,8 +443,8 @@ static void qDrawWinShades(QPainter *p, p->scale(inverseScale, inverseScale); x = qRound(devicePixelRatio * x); y = qRound(devicePixelRatio * y); - w = qRound(devicePixelRatio * w); - h = qRound(devicePixelRatio * h); + w = devicePixelRatio * w; + h = devicePixelRatio * h; p->translate(0.5, 0.5); isTranslated = true; } @@ -590,8 +590,8 @@ void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, p->scale(inverseScale, inverseScale); x = qRound(devicePixelRatio * x); y = qRound(devicePixelRatio * y); - w = qRound(devicePixelRatio * w); - h = qRound(devicePixelRatio * h); + w = devicePixelRatio * w; + h = devicePixelRatio * h; lineWidth = qRound(devicePixelRatio * lineWidth); p->translate(0.5, 0.5); }