forked from qt-creator/qt-creator
App: Set QPixmapCache limit according to devicePixelRatio
Higher resolution also means more data to be cached. The default 10MB cache limit don't cut it in HighDpi, especially in cache-intensive parts like the welcome screen. Change-Id: I653a939c3a37f80647d73e8de8df616d5386e39c Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QPixmapCache>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryDir>
|
||||
@@ -294,6 +295,14 @@ static void setHighDpiEnvironmentVariable()
|
||||
}
|
||||
}
|
||||
|
||||
void setPixmapCacheLimit()
|
||||
{
|
||||
const int originalLimit = QPixmapCache::cacheLimit();
|
||||
const qreal dpr = qApp->devicePixelRatio();
|
||||
const qreal multiplier = std::clamp(dpr * dpr, 1.0, 4.0);
|
||||
QPixmapCache::setCacheLimit(originalLimit * multiplier);
|
||||
}
|
||||
|
||||
void loadFonts()
|
||||
{
|
||||
const QDir dir(resourcePath() + "/fonts/");
|
||||
@@ -562,6 +571,7 @@ int main(int argc, char **argv)
|
||||
QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
|
||||
QLatin1String(Core::Constants::IDE_CASED_ID));
|
||||
Utils::TerminalCommand::setSettings(settings);
|
||||
setPixmapCacheLimit();
|
||||
loadFonts();
|
||||
|
||||
if (Utils::HostOsInfo::isWindowsHost()
|
||||
|
Reference in New Issue
Block a user