diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2020-08-06 21:40:01 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2020-09-28 11:01:43 +0000 |
commit | 9e2f4e112776149be550dbea6003a192cd931538 (patch) | |
tree | 5c9b9ba8709edb24139179c1a37784a9f693b39c /src/quick | |
parent | 3eb9ee34c06d54ea21fedd3188c60e536a487b1c (diff) |
Port from devicePixelRatioF() to devicePixelRatio()
This ports all of QtDeclarative.
Change-Id: Ie6eb4d96b4d49fbed1e8be514d03e331549cd712
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/quick')
9 files changed, 17 insertions, 17 deletions
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index bae9906059..0e024bea8a 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -982,7 +982,7 @@ static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV4::ExecutionE pixelData->d()->image->fill(0x00000000); } else { // After qtbase 88e56d0932a3615231adf40d5ae033e742d72c33, the image size can be off by one. - Q_ASSERT(qAbs(image.width() - qRound(w * image.devicePixelRatioF())) <= 1 && qAbs(image.height() - qRound(h * image.devicePixelRatioF())) <= 1); + Q_ASSERT(qAbs(image.width() - qRound(w * image.devicePixelRatio())) <= 1 && qAbs(image.height() - qRound(h * image.devicePixelRatio())) <= 1); *pixelData->d()->image = image.format() == QImage::Format_ARGB32 ? image : image.convertToFormat(QImage::Format_ARGB32); } diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index 8143f8117c..5b3d9db091 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -787,7 +787,7 @@ QSGSpriteNode* QQuickAnimatedSprite::initNode() QSGSpriteNode *node = d->sceneGraphContext()->createSpriteNode(); - d->m_sheetSize = QSize(image.size() / image.devicePixelRatioF()); + d->m_sheetSize = QSize(image.size() / image.devicePixelRatio()); node->setTexture(window()->createTextureFromImage(image)); d->m_spriteEngine->start(0); node->setTime(0.0f); diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp index f20d8bc6c8..e35c766ab6 100644 --- a/src/quick/items/qquickspriteengine.cpp +++ b/src/quick/items/qquickspriteengine.cpp @@ -454,12 +454,12 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize) QImage img(state->m_pix.image()); const int frameWidth = state->m_frameWidth; const int frameHeight = state->m_frameHeight; - const int imgHeight = img.height() / img.devicePixelRatioF(); - const int imgWidth = img.width() / img.devicePixelRatioF(); + const int imgHeight = img.height() / img.devicePixelRatio(); + const int imgWidth = img.width() / img.devicePixelRatio(); if (imgHeight == frameHeight && imgWidth < maxSize){ //Simple case p.drawImage(QRect(0, y, state->m_frames * frameWidth, frameHeight), img, - QRect(state->m_frameX * img.devicePixelRatioF(), 0, state->m_frames * frameWidth * img.devicePixelRatioF(), frameHeight * img.devicePixelRatioF())); + QRect(state->m_frameX * img.devicePixelRatio(), 0, state->m_frames * frameWidth * img.devicePixelRatio(), frameHeight * img.devicePixelRatio())); state->m_rowStartX = 0; state->m_rowY = y; y += frameHeight; @@ -476,7 +476,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize) framesLeft -= copied/frameWidth; p.drawImage(QRect(x, y, copied, frameHeight), img, - QRect(curX * img.devicePixelRatioF(), curY * img.devicePixelRatioF(), copied * img.devicePixelRatioF(), frameHeight * img.devicePixelRatioF())); + QRect(curX * img.devicePixelRatio(), curY * img.devicePixelRatio(), copied * img.devicePixelRatio(), frameHeight * img.devicePixelRatio())); y += frameHeight; curX += copied; x = 0; @@ -489,7 +489,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize) framesLeft -= copied/frameWidth; p.drawImage(QRect(x, y, copied, frameHeight), img, - QRect(curX * img.devicePixelRatioF(), curY * img.devicePixelRatioF(), copied * img.devicePixelRatioF(), frameHeight * img.devicePixelRatioF())); + QRect(curX * img.devicePixelRatio(), curY * img.devicePixelRatio(), copied * img.devicePixelRatio(), frameHeight * img.devicePixelRatio())); curY += frameHeight; x += copied; curX = 0; diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp index c29938a1bb..ed16a9d3e3 100644 --- a/src/quick/items/qquickspritesequence.cpp +++ b/src/quick/items/qquickspritesequence.cpp @@ -229,7 +229,7 @@ QSGSpriteNode *QQuickSpriteSequence::initNode() QSGSpriteNode *node = d->sceneGraphContext()->createSpriteNode(); - d->m_sheetSize = QSize(image.size() / image.devicePixelRatioF()); + d->m_sheetSize = QSize(image.size() / image.devicePixelRatio()); node->setTexture(window()->createTextureFromImage(image)); d->m_spriteEngine->start(0); node->setTime(0.0f); diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp index 481d1f0304..47f4b5c696 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp @@ -132,8 +132,8 @@ void QSGSoftwareGlyphNode::paint(QPainter *painter) QPointF pos = m_position - QPointF(0, m_glyphRun.rawFont().ascent()); qreal offset = 1.0; - if (painter->device()->devicePixelRatioF() > 0.0) - offset = 1.0 / painter->device()->devicePixelRatioF(); + if (painter->device()->devicePixelRatio() > 0.0) + offset = 1.0 / painter->device()->devicePixelRatio(); switch (m_style) { case QQuickText::Normal: break; diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp index 214f7d790b..f237fa26d4 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp @@ -68,7 +68,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin QMargins sourceMargins = normalizedMargins(sourceMarginsIn); QMargins targetMargins = normalizedMargins(targetMarginsIn); - const qreal sourceDpr = pixmap.devicePixelRatioF(); + const qreal sourceDpr = pixmap.devicePixelRatio(); sourceMargins *= sourceDpr; // source center diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp index f50fa00b0b..e5b4191beb 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp @@ -237,8 +237,8 @@ void QSGSoftwareInternalRectangleNode::paint(QPainter *painter) { //We can only check for a device pixel ratio change when we know what //paint device is being used. - if (!qFuzzyCompare(painter->device()->devicePixelRatioF(), m_devicePixelRatio)) { - m_devicePixelRatio = painter->device()->devicePixelRatioF(); + if (!qFuzzyCompare(painter->device()->devicePixelRatio(), m_devicePixelRatio)) { + m_devicePixelRatio = painter->device()->devicePixelRatio(); generateCornerPixmap(); } diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp index af12df26ab..12ffa0ef57 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp @@ -108,9 +108,9 @@ void QSGSoftwareRenderer::render() setBackgroundColor(clearColor()); setBackgroundRect(QRect(0, 0, - m_paintDevice->width() / m_paintDevice->devicePixelRatioF(), - m_paintDevice->height() / m_paintDevice->devicePixelRatioF()), - m_paintDevice->devicePixelRatioF()); + m_paintDevice->width() / m_paintDevice->devicePixelRatio(), + m_paintDevice->height() / m_paintDevice->devicePixelRatio()), + m_paintDevice->devicePixelRatio()); // Build Renderlist // The renderlist is created by visiting each node in the tree and when a diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp index 17e8bdc2f9..e5442cdd99 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode.cpp @@ -128,7 +128,7 @@ void QSGSoftwareSpriteNode::paint(QPainter *painter) // XXX try to do some kind of interpolation between sourceA and sourceB using time painter->drawPixmap(QRectF(0, 0, m_size.width(), m_size.height()), pixmap, - QRectF(m_sourceA * pixmap.devicePixelRatioF(), m_spriteSize * pixmap.devicePixelRatioF())); + QRectF(m_sourceA * pixmap.devicePixelRatio(), m_spriteSize * pixmap.devicePixelRatio())); } bool QSGSoftwareSpriteNode::isOpaque() const |