Improve style drawing under DPR scaling further

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 <morten.sorvig@qt.io>
This commit is contained in:
David Schulz 2023-04-18 12:57:03 +02:00
parent 0d26db5737
commit c818acda97

View File

@ -230,8 +230,8 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
p->scale(inverseScale, inverseScale); p->scale(inverseScale, inverseScale);
x = qRound(devicePixelRatio * x); x = qRound(devicePixelRatio * x);
y = qRound(devicePixelRatio * y); y = qRound(devicePixelRatio * y);
w = qRound(devicePixelRatio * w); w = devicePixelRatio * w;
h = qRound(devicePixelRatio * h); h = devicePixelRatio * h;
lineWidth = qRound(devicePixelRatio * lineWidth); lineWidth = qRound(devicePixelRatio * lineWidth);
midLineWidth = qRound(devicePixelRatio * midLineWidth); midLineWidth = qRound(devicePixelRatio * midLineWidth);
p->translate(0.5, 0.5); 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); p->scale(inverseScale, inverseScale);
x = qRound(devicePixelRatio * x); x = qRound(devicePixelRatio * x);
y = qRound(devicePixelRatio * y); y = qRound(devicePixelRatio * y);
w = qRound(devicePixelRatio * w); w = devicePixelRatio * w;
h = qRound(devicePixelRatio * h); h = devicePixelRatio * h;
lineWidth = qRound(devicePixelRatio * lineWidth); lineWidth = qRound(devicePixelRatio * lineWidth);
p->translate(0.5, 0.5); p->translate(0.5, 0.5);
isTranslated = true; isTranslated = true;
@ -443,8 +443,8 @@ static void qDrawWinShades(QPainter *p,
p->scale(inverseScale, inverseScale); p->scale(inverseScale, inverseScale);
x = qRound(devicePixelRatio * x); x = qRound(devicePixelRatio * x);
y = qRound(devicePixelRatio * y); y = qRound(devicePixelRatio * y);
w = qRound(devicePixelRatio * w); w = devicePixelRatio * w;
h = qRound(devicePixelRatio * h); h = devicePixelRatio * h;
p->translate(0.5, 0.5); p->translate(0.5, 0.5);
isTranslated = true; 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); p->scale(inverseScale, inverseScale);
x = qRound(devicePixelRatio * x); x = qRound(devicePixelRatio * x);
y = qRound(devicePixelRatio * y); y = qRound(devicePixelRatio * y);
w = qRound(devicePixelRatio * w); w = devicePixelRatio * w;
h = qRound(devicePixelRatio * h); h = devicePixelRatio * h;
lineWidth = qRound(devicePixelRatio * lineWidth); lineWidth = qRound(devicePixelRatio * lineWidth);
p->translate(0.5, 0.5); p->translate(0.5, 0.5);
} }