[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: [Panel-devel] [PATCH] QPixmapCache size (bug 151109)
From: Sean Harmer <sh () theharmers ! co ! uk>
Date: 2007-10-23 20:03:45
Message-ID: 200710232103.46053.sh () theharmers ! co ! uk
[Download RAW message or body]
HI All,
Please find a proposed patch that attempts to automatically set the size of
the QPixmapCache for plasma to a size that is (hopefully) suitable on an
arbitrarily sized set of screens. I and many other people have been bitten by
this bug when testing out KDE 4 svn builds and this is something that gives a
bad impression form the word go. So I thought I'd try a quick fix. ;-)
I am taking the conservative approach and assuming a bit depth of 32bpp. I
tried to use QPixmap::defaultDepth() but this was only returning 24bpp, i.e.
it did not include an alpha channel on my setup here.
I have (arbitrarily) increased the calculated value by 10% to allow some
leeway. If anybody with more information knows of a more realistic heuristic
than this then please feel free to change it. :-)
Kind regards,
Sean
["plasma-cache.patch" (text/x-diff)]
Index: workspace/plasma/plasma/plasmaapp.cpp
===================================================================
--- workspace/plasma/plasma/plasmaapp.cpp (revision 728541)
+++ workspace/plasma/plasma/plasmaapp.cpp (working copy)
@@ -25,6 +25,7 @@
#include <unistd.h>
+#include <QDesktopWidget>
#include <QPixmapCache>
#include <QTimer>
#include <QtDBus/QtDBus>
@@ -52,7 +53,7 @@
: m_root(0),
m_corona(0)
{
- new AppAdaptor(this);
+ new AppAdaptor(this);
QDBusConnection::sessionBus().registerObject("/App", this);
notifyStartup(false);
@@ -75,13 +76,24 @@
}
// enlarge application pixmap cache
- // TODO: make this dependand on system
- // memory and screen resolution. 8MB is ok for caching the background up
- // to 1600x1200 resolution
- if (QPixmapCache::cacheLimit() < 8192) {
- QPixmapCache::setCacheLimit(8192);
+ QDesktopWidget desktop;
+ int numScreens = desktop.numScreens();
+ int depth = 32;//QPixmap::defaultDepth();
+ int kbytes = 0;
+ for (int i = 0; i < numScreens; ++i) {
+ QRect screenRect = desktop.screenGeometry(i);
+ int tmp = (depth / 8) * screenRect.width() * screenRect.height();
+ kbytes += tmp / 1024;
}
+ // Increase this a little for good measure, 10% say
+ kbytes *= 1.1;
+
+ if (QPixmapCache::cacheLimit() < kbytes) {
+ kDebug() << "Setting PixmapCache to" << kbytes << "KB";
+ QPixmapCache::setCacheLimit(kbytes);
+ }
+
m_root = new RootWidget();
//TODO: the line below is just inane. get rid of it before release. seriously.
m_root->setAsDesktop(KCmdLineArgs::parsedArgs()->isSet("desktop"));
_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic