From 424cfef3cc3c140df51905713fa3849562bc494d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 12 Jul 2018 10:00:31 +0200 Subject: 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 Reviewed-by: Simon Hausmann Reviewed-by: Alessandro Portale --- src/quick/items/context2d/qquickcontext2d.cpp | 2 +- src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp | 4 ++-- src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 5af2a7169c..8f21c3ec05 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -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); } diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp index 21f20c66cd..7ab9c15d9b 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp @@ -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; diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp index ffcee5f56e..e9ed52d428 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp @@ -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 -- cgit v1.2.3