From: Kai Uwe Broulik Date: Mon, 16 Sep 2019 06:52:05 +0000 (+0200) Subject: [KStandardItemListWidget] Request the pixmap size we want and let the icon loader... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/cef2c67613ef07a350d18f690b3b5960b9dfda12 [KStandardItemListWidget] Request the pixmap size we want and let the icon loader scale it I noticed that depending on the configured icon size it would spend a significant amount of time in KPixmapModifier::scale. I don't see a point in requesting a fixed icon size and then scale it down manually as opposed to having the KIconLoader do the scaling for us. Especially for SVGs it could then even serve us a properly rendered SVG for this size rather than a scaled down pixmap version. Differential Revision: https://phabricator.kde.org/D22116 --- diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 617ed57f8..c963b7196 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -1463,24 +1463,7 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin { static const QIcon fallbackIcon = QIcon::fromTheme(QStringLiteral("unknown")); - int requestedSize = size; - if (size <= KIconLoader::SizeSmall) { - requestedSize = KIconLoader::SizeSmall; - } else if (size <= KIconLoader::SizeSmallMedium) { - requestedSize = KIconLoader::SizeSmallMedium; - } else if (size <= KIconLoader::SizeMedium) { - requestedSize = KIconLoader::SizeMedium; - } else if (size <= KIconLoader::SizeLarge) { - requestedSize = KIconLoader::SizeLarge; - } else if (size <= KIconLoader::SizeHuge) { - requestedSize = KIconLoader::SizeHuge; - } else if (size <= KIconLoader::SizeEnormous) { - requestedSize = KIconLoader::SizeEnormous; - } else if (size <= KIconLoader::SizeEnormous * 2) { - requestedSize = KIconLoader::SizeEnormous * 2; - } size *= qApp->devicePixelRatio(); - requestedSize *= qApp->devicePixelRatio(); const QString key = "KStandardItemListWidget:" % name % ":" % overlays.join(QLatin1Char(':')) % ":" % QString::number(size) % ":" % QString::number(mode); QPixmap pixmap; @@ -1488,8 +1471,8 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin if (!QPixmapCache::find(key, pixmap)) { const QIcon icon = QIcon::fromTheme(name, fallbackIcon); - pixmap = icon.pixmap(requestedSize / qApp->devicePixelRatio(), requestedSize / qApp->devicePixelRatio(), mode); - if (requestedSize != size) { + pixmap = icon.pixmap(size / qApp->devicePixelRatio(), size / qApp->devicePixelRatio(), mode); + if (pixmap.width() != size || pixmap.height() != size) { KPixmapModifier::scale(pixmap, QSize(size, size)); }