From 7fbc14053cb3db4b0cfe31d00da158720d7c24ee Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 17 Nov 2020 20:09:28 +0100 Subject: Native style: use the same scale from all places MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To be on the safe side, let's ensure that we set the same scale one the scene graph node as on the image it's created from Pick-to: 6.0 Change-Id: Ib8a86dd29f6f458d4c43dd36c6838dd632cb4078 Reviewed-by: Jan Arve Sæther --- src/imports/nativestyle/items/qquickstyleitem.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/imports/nativestyle/items/qquickstyleitem.cpp') diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp index 38e7fd6d..b50a38c5 100644 --- a/src/imports/nativestyle/items/qquickstyleitem.cpp +++ b/src/imports/nativestyle/items/qquickstyleitem.cpp @@ -114,11 +114,13 @@ QSGNode *QQuickStyleItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePa QSGNinePatchNode *node = static_cast(oldNode); if (!node) node = window()->createNinePatchNode(); + if (m_paintedImage.isNull()) + return node; auto texture = window()->createTextureFromImage(m_paintedImage, QQuickWindow::TextureCanUseAtlas); QRectF bounds = boundingRect(); - const qreal scale = window()->devicePixelRatio(); + const qreal scale = m_paintedImage.devicePixelRatioF(); const QSizeF ninePatchImageSize = m_paintedImage.rect().size() / scale; #ifdef QT_DEBUG if (m_debugFlags.testFlag(Unscaled)) { @@ -154,7 +156,7 @@ QSGNode *QQuickStyleItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePa node->setBounds(bounds); node->setTexture(texture); - node->setDevicePixelRatio(window()->devicePixelRatio()); + node->setDevicePixelRatio(scale); node->setPadding(padding.left(), padding.top(), padding.right(), padding.bottom()); node->update(); -- cgit v1.2.3