aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickimage.cpp
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-08-19 13:29:43 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-20 22:12:24 +0100
commit63fb30eb29c26cd7ba0d9133610acb85cad83775 (patch)
treefb0d4870c3f2c22d14a90ad26956b8b6f45d3886 /src/quick/items/qquickimage.cpp
parent5277a60f56c83376c1f2e9d9d502f1793d8c4857 (diff)
Implement high-dpi "@2x" image handling.
Make QQuickBaseImage::load() load "@2x" image files on high-dpi displays. Reload images on screen change in order to load the correct version depending on screen dpi. Modify QQuickImageBase::updatePaintNode() to work with @2x images. QQuickBaseImage::load() now looks at the target window's devicePixelRatio and checks for the presence of a "@2x" file on disk. If found the @2x version will be used. Unlike QPixmap, QQuickPixmap has no special knowledge of "@2x" files. They pixmap system will be asked to load "@2x" files and will cache them and report the (device) pixel size, like any other pixmap. Add auto-test and manual test. Task-number: QTBUG-32862, QTBUG-33069 Change-Id: I1f57a10075e499f6eee61df5421e1986521c6ab0 Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Diffstat (limited to 'src/quick/items/qquickimage.cpp')
-rw-r--r--src/quick/items/qquickimage.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index 69a39d2396..08dbfa3c23 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -589,8 +589,8 @@ QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
QSGTexture::WrapMode hWrap = QSGTexture::ClampToEdge;
QSGTexture::WrapMode vWrap = QSGTexture::ClampToEdge;
- qreal pixWidth = (d->fillMode == PreserveAspectFit) ? d->paintedWidth : d->pix.width();
- qreal pixHeight = (d->fillMode == PreserveAspectFit) ? d->paintedHeight : d->pix.height();
+ qreal pixWidth = (d->fillMode == PreserveAspectFit) ? d->paintedWidth : d->pix.width() / d->devicePixelRatio;
+ qreal pixHeight = (d->fillMode == PreserveAspectFit) ? d->paintedHeight : d->pix.height() / d->devicePixelRatio;
int xOffset = 0;
if (d->hAlign == QQuickImage::AlignHCenter)
@@ -671,10 +671,12 @@ QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
break;
};
- QRectF nsrect(sourceRect.x() / d->pix.width(),
- sourceRect.y() / d->pix.height(),
- sourceRect.width() / d->pix.width(),
- sourceRect.height() / d->pix.height());
+ qreal nsWidth = (hWrap == QSGTexture::Repeat) ? d->pix.width() / d->devicePixelRatio : d->pix.width();
+ qreal nsHeight = (vWrap == QSGTexture::Repeat) ? d->pix.height() / d->devicePixelRatio : d->pix.height();
+ QRectF nsrect(sourceRect.x() / nsWidth,
+ sourceRect.y() / nsHeight,
+ sourceRect.width() / nsWidth,
+ sourceRect.height() / nsHeight);
if (targetRect.isEmpty()
|| !qIsFinite(targetRect.width()) || !qIsFinite(targetRect.height())