diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-05-17 08:11:50 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-05-17 08:12:24 (GMT) |
commit | 25ae30256bd7980ed42a65ab73a4d4395040391a (patch) | |
tree | d33a13fdb8f98a99e71c6d5fa03471c6a1987378 /src/gui/image | |
parent | bdbe09ad2c01ae11d10511b51f8d7a3dfb27b17c (diff) | |
download | Qt-25ae30256bd7980ed42a65ab73a4d4395040391a.zip Qt-25ae30256bd7980ed42a65ab73a4d4395040391a.tar.gz Qt-25ae30256bd7980ed42a65ab73a4d4395040391a.tar.bz2 |
Optimized pixmapcache key generation for icons and styles
This re-apply commit c8d2e18c4b431870560f324a17f20904bb47ae68
from Jens that was reverted in b0f4dab4 because it did not compile.
Added the missing include to make it compile on mac
Task-number: QTBUG-9850
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 891b1db..7696632 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -55,6 +55,7 @@ #include "qcache.h" #include "qdebug.h" #include "private/qguiplatformplugin_p.h" +#include "private/qstylehelper_p.h" #ifdef Q_WS_MAC #include <private/qt_mac_p.h> @@ -261,21 +262,17 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); - QString key = QLatin1String("$qt_icon_") - + QString::number(pm.cacheKey()) - + QString::number(pe->mode) - + QString::number(QApplication::palette().cacheKey()) - + QLatin1Char('_') - + QString::number(actualSize.width()) - + QLatin1Char('_') - + QString::number(actualSize.height()) - + QLatin1Char('_'); - + QString key = QLatin1Literal("qt_") + % HexString<quint64>(pm.cacheKey()) + % HexString<uint>(pe->mode) + % HexString<quint64>(QApplication::palette().cacheKey()) + % HexString<uint>(actualSize.width()) + % HexString<uint>(actualSize.height()); if (mode == QIcon::Active) { - if (QPixmapCache::find(key + QString::number(mode), pm)) + if (QPixmapCache::find(key % HexString<uint>(mode), pm)) return pm; // horray - if (QPixmapCache::find(key + QString::number(QIcon::Normal), pm)) { + if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) { QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); @@ -284,7 +281,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St } } - if (!QPixmapCache::find(key + QString::number(mode), pm)) { + if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { @@ -294,7 +291,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St if (!generated.isNull()) pm = generated; } - QPixmapCache::insert(key + QString::number(mode), pm); + QPixmapCache::insert(key % HexString<uint>(mode), pm); } return pm; } |