[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kdeui/icons
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2011-01-10 20:46:20
Message-ID: 20110110204620.60233AC8B2 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1213567 by aseigo:

an entire pixmap cache just to cache the values of the group sizes!
it used to be used for many more things, which made this more sensible.
not so much anymore.

what this does mean is that ~37ms of CPU time (on my laptop anyways) is
moved up into KIconLoader's init rather than on first icon fetch. what is saved
is the time to create the icon cache itself (negligable: ~2ms on my system)
and the memory overhead.

this "frees" KIconLoader from KIconCache and therefore also KPixmapCache.
we can now remove the class in "KDE5" as noted in the comments in the header.


 M  +11 -29    kiconloader.cpp  


--- trunk/KDE/kdelibs/kdeui/icons/kiconloader.cpp #1213566:1213567
@@ -61,7 +61,6 @@
 // kdeui
 #include "kicontheme.h"
 #include "kiconeffect.h"
-#include "kiconcache.h"
 #include "k3icon_p.h"
 
 // Used to make cache keys for icons with no group. Result type is QString*
@@ -74,8 +73,6 @@
 // (ereslibre)
 #undef KDE_QT_SVG_RENDERER_FIXED
 
-//#define NO_LAZYLOAD_ICONTHEME
-
 /**
  * Checks for relative paths quickly on UNIX-alikes, slowly on everything else.
  */
@@ -170,7 +167,6 @@
     KIconLoaderPrivate(KIconLoader *q)
         : q(q)
         , mpGroups(0)
-        , mIconThemeCache(0)
         , mIconCache(0)
     {
     }
@@ -181,7 +177,6 @@
         deleted when the elements of d->links are deleted */
         qDeleteAll(links);
         delete[] mpGroups;
-        delete mIconThemeCache;
         delete mIconCache;
     }
 
@@ -295,7 +290,6 @@
     KStandardDirs *mpDirs;
     KIconEffect mpEffect;
     QList<KIconThemeNode *> links;
-    KIconCache* mIconThemeCache;
 
     // This shares the icons across all processes
     KSharedDataCache* mIconCache;
@@ -482,43 +476,32 @@
     // smaller.
     mPixmapCache.setMaxCost(10 * 1024 * 1024);
 
-    // Initialize icon theme cache
-    mIconThemeCache = new KIconCache;
-    if (!mIconThemeCache->isValid()) {
-        initIconThemes();
-        QList<KIconTheme*> allThemes;
-        foreach (KIconThemeNode* node, links) {
-            allThemes.append(node->theme);
-        }
-        mIconThemeCache->setThemeInfo(allThemes);
-    }
-
     // These have to match the order in kicontheme.h
     static const char * const groups[] = { "Desktop", "Toolbar", "MainToolbar", \
"Small", "Panel", "Dialog", 0L };  KSharedConfig::Ptr config = KGlobal::config();
 
     // loading config and default sizes
+    initIconThemes();
+    KIconTheme *defaultSizesTheme = links.empty() ? 0 : links.first()->theme;
     mpGroups = new KIconGroup[(int) KIconLoader::LastGroup];
-    for (KIconLoader::Group i=KIconLoader::FirstGroup; i<KIconLoader::LastGroup; \
                ++i)
-    {
-        if (groups[i] == 0L)
+    for (KIconLoader::Group i = KIconLoader::FirstGroup; i < KIconLoader::LastGroup; \
++i) { +        if (groups[i] == 0L) {
             break;
+        }
 
         KConfigGroup cg(config, QLatin1String(groups[i]) + "Icons");
         mpGroups[i].size = cg.readEntry("Size", 0);
-        if (QPixmap::defaultDepth()>8)
+        if (QPixmap::defaultDepth() > 8) {
             mpGroups[i].alphaBlending = cg.readEntry("AlphaBlending", true);
-        else
+        } else {
             mpGroups[i].alphaBlending = false;
-
-        if (!mpGroups[i].size)
-            mpGroups[i].size = mIconThemeCache->defaultIconSize(i);
     }
 
-#ifdef NO_LAZYLOAD_ICONTHEME
-    initIconThemes();
-#endif
+        if (!mpGroups[i].size && defaultSizesTheme) {
+            mpGroups[i].size = defaultSizesTheme->defaultSize(i);
 }
+    }
+}
 
 bool KIconLoaderPrivate::initIconThemes()
 {
@@ -1187,7 +1170,6 @@
                               QString *path_store, bool canReturnNull) const
 {
     QString name = _name;
-    bool unknownIcon = false;
     bool favIconOverlay = false;
 
     if (size < 0 || _name.isEmpty())


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic