Fix misuses of 0.9999 constant

Replace it with floor and round. It appears the old behavior
was to work around combining ceil with inaccurate FP, but
it doesn't appear this hacky ceil is needed.

Change-Id: I5c16ec0fa4916e17198a733c46937fde53f2ddb5
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2022-04-07 18:11:48 +02:00
parent bc922223cf
commit 0806d9799a
3 changed files with 7 additions and 18 deletions

View File

@ -4783,13 +4783,8 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
else if (mat.m11() == -1. && mat.m22() == -1.)
return rotated180(*this);
if (mode == Qt::FastTransformation) {
hd = qRound(qAbs(mat.m22()) * hs);
wd = qRound(qAbs(mat.m11()) * ws);
} else {
hd = int(qAbs(mat.m22()) * hs + 0.9999);
wd = int(qAbs(mat.m11()) * ws + 0.9999);
}
scale_xform = true;
// The paint-based scaling is only bilinear, and has problems
// with scaling smoothly more than 2x down.

View File

@ -626,8 +626,8 @@ qreal QWindowsFontEngine::minRightBearing() const
fmr = qMin(fmr,abc[i].abcfC);
}
}
ml = int(fml - 0.9999);
mr = int(fmr - 0.9999);
ml = qFloor(fml);
mr = qFloor(fmr);
delete [] abc;
}
lbearing = ml;

View File

@ -1437,22 +1437,16 @@ QPixmap QX11PlatformPixmap::transformed(const QTransform &transform, Qt::Transfo
transform.m21(), transform.m22(), transform.m23(),
0., 0., 1);
bool complex_xform = false;
qreal scaledWidth;
qreal scaledHeight;
if (mat.type() <= QTransform::TxScale) {
scaledHeight = qAbs(mat.m22()) * hs + 0.9999;
scaledWidth = qAbs(mat.m11()) * ws + 0.9999;
h = qAbs(int(scaledHeight));
w = qAbs(int(scaledWidth));
h = qRound(qAbs(mat.m22()) * hs);
w = qRound(qAbs(mat.m11()) * ws);
} else { // rotation or shearing
QPolygonF a(QRectF(0, 0, ws, hs));
a = mat.map(a);
QRect r = a.boundingRect().toAlignedRect();
w = r.width();
h = r.height();
scaledWidth = w;
scaledHeight = h;
complex_xform = true;
}
mat = QPixmap::trueMatrix(mat, ws, hs); // true matrix
@ -1461,7 +1455,7 @@ QPixmap QX11PlatformPixmap::transformed(const QTransform &transform, Qt::Transfo
mat = mat.inverted(&invertible); // invert matrix
if (h == 0 || w == 0 || !invertible
|| qAbs(scaledWidth) >= 32768 || qAbs(scaledHeight) >= 32768 )
|| qAbs(h) >= 32768 || qAbs(w) >= 32768 )
// error, return null pixmap
return QPixmap();