From 2dc46c09026362cc267b1183faf09fb29479ef93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 29 Aug 2020 22:28:34 +0200 Subject: Deprecate and remove all uses of AA_UseHighDpiPixmaps High-DPI pixmaps are always enabled, and cannot be disabled. Change-Id: I01a006b404e5431582b64ef812974c1c022b39ae Reviewed-by: Volker Hilsheimer --- src/gui/image/qicon.cpp | 34 ++++++++-------------------------- src/gui/image/qiconloader.cpp | 5 +---- src/gui/image/qimagereader.cpp | 2 +- 3 files changed, 10 insertions(+), 31 deletions(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index a4f6369fd2..2278eb8201 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -128,15 +128,9 @@ static void qt_cleanup_icon_cache() Returns the effective device pixel ratio, using the provided window pointer if possible. - - if Qt::AA_UseHighDpiPixmaps is not set this function - returns 1.0 to keep non-hihdpi aware code working. */ static qreal qt_effective_device_pixel_ratio(QWindow *window = nullptr) { - if (!qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) - return qreal(1.0); - if (window) return window->devicePixelRatio(); @@ -190,11 +184,8 @@ QPixmapIconEngine::~QPixmapIconEngine() void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { - qreal dpr = 1.0; - if (QCoreApplication::testAttribute(Qt::AA_UseHighDpiPixmaps)) { - auto paintDevice = painter->device(); - dpr = paintDevice ? paintDevice->devicePixelRatioF() : qApp->devicePixelRatio(); - } + auto paintDevice = painter->device(); + qreal dpr = paintDevice ? paintDevice->devicePixelRatioF() : qApp->devicePixelRatio(); const QSize pixmapSize = rect.size() * dpr; QPixmap px = pixmap(pixmapSize, mode, state); painter->drawPixmap(rect, px); @@ -800,11 +791,8 @@ qint64 QIcon::cacheKey() const /*! Returns a pixmap with the requested \a size, \a mode, and \a state, generating one if necessary. The pixmap might be smaller than - requested, but never larger. - - Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this - function to return pixmaps that are larger than the requested size. Such - images will have a devicePixelRatio larger than 1. + requested, but never larger, unless the device-pixel ratio of the returned + pixmap is larger than 1. \sa actualSize(), paint() */ @@ -822,11 +810,8 @@ QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const \overload Returns a pixmap of size QSize(\a w, \a h). The pixmap might be smaller than - requested, but never larger. - - Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this - function to return pixmaps that are larger than the requested size. Such - images will have a devicePixelRatio larger than 1. + requested, but never larger, unless the device-pixel ratio of the returned + pixmap is larger than 1. */ /*! @@ -835,11 +820,8 @@ QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const \overload Returns a pixmap of size QSize(\a extent, \a extent). The pixmap might be smaller - than requested, but never larger. - - Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this - function to return pixmaps that are larger than the requested size. Such - images will have a devicePixelRatio larger than 1. + than requested, but never larger, unless the device-pixel ratio of the returned + pixmap is larger than 1. */ /*! diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 250e695574..51a9632dcc 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -641,10 +641,7 @@ void QIconLoaderEngine::ensureLoaded() void QIconLoaderEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { - const qreal dpr = !qApp->testAttribute(Qt::AA_UseHighDpiPixmaps) ? - qreal(1.0) : painter->device()->devicePixelRatioF(); - - QSize pixmapSize = rect.size() * dpr; + QSize pixmapSize = rect.size() * painter->device()->devicePixelRatioF(); painter->drawPixmap(rect, pixmap(pixmapSize, mode, state)); } diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 0702e2bb23..611cbb1df1 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -102,7 +102,7 @@ \c QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING. \sa QImageWriter, QImageIOHandler, QImageIOPlugin, QMimeDatabase, QColorSpace - \sa QImage::devicePixelRatio(), QPixmap::devicePixelRatio(), QIcon, QPainter::drawPixmap(), QPainter::drawImage(), Qt::AA_UseHighDpiPixmaps + \sa QImage::devicePixelRatio(), QPixmap::devicePixelRatio(), QIcon, QPainter::drawPixmap(), QPainter::drawImage() */ /*! -- cgit v1.2.3