Quick: Use devicePixelRatioF rather than devicePixelRatio

The integer version of devicePixelRatio cannot handle fractional ratios
and will lead to arithmetic exceptions for ratios between 0 and 1.

Change-Id: I4a06a12742fa85e6d2f0e24193ae796dec7e2f15
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Ulf Hermann 2018-07-12 10:00:31 +02:00 committed by Simon Hausmann
parent b98af3e0f3
commit 424cfef3cc
3 changed files with 5 additions and 5 deletions

View File

@ -962,7 +962,7 @@ static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV4::ExecutionE
*pixelData->d()->image = QImage(w, h, QImage::Format_ARGB32);
pixelData->d()->image->fill(0x00000000);
} else {
Q_ASSERT(image.width()== qRound(w * image.devicePixelRatio()) && image.height() == qRound(h * image.devicePixelRatio()));
Q_ASSERT(image.width()== qRound(w * image.devicePixelRatioF()) && image.height() == qRound(h * image.devicePixelRatioF()));
*pixelData->d()->image = image.format() == QImage::Format_ARGB32 ? image : image.convertToFormat(QImage::Format_ARGB32);
}

View File

@ -91,8 +91,8 @@ void QSGSoftwareGlyphNode::paint(QPainter *painter)
QPointF pos = m_position - QPointF(0, m_glyphRun.rawFont().ascent());
qreal offset = 1.0;
if (painter->device()->devicePixelRatio() != 0)
offset = 1.0 / painter->device()->devicePixelRatio();
if (painter->device()->devicePixelRatioF() > 0.0)
offset = 1.0 / painter->device()->devicePixelRatioF();
switch (m_style) {
case QQuickText::Normal: break;

View File

@ -113,8 +113,8 @@ void QSGSoftwareRenderer::render()
setBackgroundColor(clearColor());
setBackgroundRect(QRect(0, 0,
m_paintDevice->width() / m_paintDevice->devicePixelRatio(),
m_paintDevice->height() / m_paintDevice->devicePixelRatio()));
m_paintDevice->width() / m_paintDevice->devicePixelRatioF(),
m_paintDevice->height() / m_paintDevice->devicePixelRatioF()));
// Build Renderlist
// The renderlist is created by visiting each node in the tree and when a