[Digikam-devel] extragear/graphics/digikam/digikam

Marcel Wiesweg marcel.wiesweg at gmx.de
Thu Aug 9 18:56:19 BST 2007


SVN commit 698276 by mwiesweg:

Switch to multithreaded thumbnail loading:
AlbumIconView uses ThumbnailLoadThread now.

Previously, we used to load thumbnails with an ioslave and transfer the data over shared memory.
This overhead can be avoided now.

The new classes ThumbnailLoadThread and ThumbnailCreator have the functionality that was 
contained in the digikamthumbnail ioslave and the classes ThumbnailJob and PixmapManager.
ThumbnailJob/ioslave is still used in other parts of digikam. PixmapManager is now unused.

Subjectively, thumbnail loading feels faster in certain situations for me.
I have no measurements because the experimental setting would be difficult.

CCMAIL: digikam-devel at kde.org


 M  +3 -3      albumiconitem.cpp  
 M  +10 -20    albumiconview.cpp  
 M  +2 -3      albumiconview.h  


--- trunk/extragear/graphics/digikam/digikam/albumiconitem.cpp #698275:698276
@@ -48,7 +48,7 @@
 #include "imageinfo.h"
 #include "albumsettings.h"
 #include "icongroupitem.h"
-#include "pixmapmanager.h"
+#include "thumbnailloadthread.h"
 #include "albumiconview.h"
 #include "albumiconitem.h"
 
@@ -237,8 +237,8 @@
 
     d->dirty = true;
 
-    QPixmap thumbnail = d->view->pixmapManager()->find(d->info.fileUrl());
-    if (!thumbnail.isNull())
+    QPixmap thumbnail;
+    if (ThumbnailLoadThread::defaultThread()->find(d->info.filePath(), thumbnail))
     {
         r = d->view->itemPixmapRect();
         p->drawPixmap(r.x() + (r.width()-thumbnail.width())/2,
--- trunk/extragear/graphics/digikam/digikam/albumiconview.cpp #698275:698276
@@ -112,7 +112,7 @@
 #include "dpopupmenu.h"
 #include "tagspopupmenu.h"
 #include "ratingpopupmenu.h"
-#include "pixmapmanager.h"
+#include "thumbnailloadthread.h"
 #include "cameradragobject.h"
 #include "dragobjects.h"
 #include "dmetadata.h"
@@ -140,7 +140,6 @@
         imageLister   = 0;
         currentAlbum  = 0;
         albumSettings = 0;
-        pixMan        = 0;
         toolTip       = 0;
 
         // Pre-computed star polygon for a 15x15 pixmap.
@@ -195,10 +194,9 @@
     Album                           *currentAlbum;
     const AlbumSettings             *albumSettings;
     Q3IntDict<AlbumIconGroupItem>    albumDict;
-    PixmapManager                   *pixMan;
 
     ThumbnailSize                    thumbSize;
-    
+
     AlbumFileTip                    *toolTip;
 };
 
@@ -208,7 +206,6 @@
     d = new AlbumIconViewPrivate;
     d->init();
     d->imageLister = AlbumLister::componentData();
-    d->pixMan      = new PixmapManager(this);
     d->toolTip     = new AlbumFileTip(this);
 
     setAcceptDrops(true);
@@ -252,8 +249,8 @@
 
     // -- Pixmap manager connections ------------------------------------
 
-    connect(d->pixMan, SIGNAL(signalPixmap(const KUrl&)),
-            this, SLOT(slotGotThumbnail(const KUrl&)));
+    connect(ThumbnailLoadThread::defaultThread(), SIGNAL(signalThumbnailLoaded(const LoadingDescription &, const QPixmap&)),
+            this, SLOT(slotThumbnailLoaded(const LoadingDescription &, const QPixmap&)));
 
     // -- ImageAttributesWatch connections ------------------------------
 
@@ -277,7 +274,6 @@
 
 AlbumIconView::~AlbumIconView()
 {
-    delete d->pixMan;
     delete d->toolTip;
     delete d;
 }
@@ -300,7 +296,7 @@
     d->imageLister->stop();
     clear();
 
-    d->pixMan->setThumbnailSize(d->thumbSize.size());
+    ThumbnailLoadThread::defaultThread()->setThumbnailSize(d->thumbSize.size());
 
     if (d->currentAlbum)
     {
@@ -316,7 +312,7 @@
         clear();
 
         d->thumbSize = thumbSize;
-        d->pixMan->setThumbnailSize(d->thumbSize.size());
+        ThumbnailLoadThread::defaultThread()->setThumbnailSize(d->thumbSize.size());
 
         updateRectsAndPixmaps();
 
@@ -359,7 +355,6 @@
 {
     emit signalCleared();
 
-    d->pixMan->clear();
     d->itemDict.clear();
     d->albumDict.clear();
     d->itemInfoMap.clear();
@@ -852,7 +847,7 @@
     fileURL.addPath(newURL.path());
 
     // refresh thumbnail
-    d->pixMan->deleteThumbnail(fileURL);
+    ThumbnailLoadThread::deleteThumbnail(fileURL.path());
     // clean LoadingCache as well - be pragmatic, do it here.
     LoadingCacheInterface::cleanFromCache(fileURL.path());
 }
@@ -1529,7 +1524,7 @@
 
         ImageInfo info = iconItem->imageInfo();
         info.refresh();
-        d->pixMan->deleteThumbnail(info.fileUrl());
+        ThumbnailLoadThread::deleteThumbnail((*it).path());
         // clean LoadingCache as well - be pragmatic, do it here.
         LoadingCacheInterface::cleanFromCache((*it).path());
     }
@@ -1540,9 +1535,9 @@
     triggerRearrangement();
 }
 
-void AlbumIconView::slotGotThumbnail(const KUrl& url)
+void AlbumIconView::slotThumbnailLoaded(const LoadingDescription &loadingDescription, const QPixmap&)
 {
-    AlbumIconItem* iconItem = findItem(url.url());
+    AlbumIconItem* iconItem = findItem(KUrl::fromPath(loadingDescription.filePath).url());
     if (!iconItem)
         return;
 
@@ -1963,11 +1958,6 @@
     return 0;
 }
 
-PixmapManager* AlbumIconView::pixmapManager() const
-{
-    return d->pixMan;
-}
-
 void AlbumIconView::slotAlbumModified()
 {
     d->imageLister->stop();
--- trunk/extragear/graphics/digikam/digikam/albumiconview.h #698275:698276
@@ -34,6 +34,7 @@
 
 // Local includes.
 
+#include "loadingdescription.h"
 #include "iconview.h"
 #include "imageinfo.h"
 #include "imageinfolist.h"
@@ -58,7 +59,6 @@
 class AlbumSettings;
 class ThumbnailSize;
 class Album;
-class PixmapManager;
 class AlbumIconViewPrivate;
 
 class AlbumIconView : public IconView,
@@ -117,7 +117,6 @@
     AlbumIconItem* findItem(const QPoint& pos);
     AlbumIconItem* findItem(const QString& url) const;
     AlbumIconItem* nextItemToThumbnail() const;
-    PixmapManager* pixmapManager() const;
 
     void insertSelectionToLightTable();
     void insertToLightTable(const ImageInfoList& list, const ImageInfo &current);
@@ -173,7 +172,7 @@
     void slotRightButtonClicked(const QPoint& pos);
     void slotRightButtonClicked(IconItem *item, const QPoint& pos);
 
-    void slotGotThumbnail(const KUrl& url);
+    void slotThumbnailLoaded(const LoadingDescription &loadingDescription, const QPixmap& thumb);
     void slotSelectionChanged();
 
     void slotFilesModified();



More information about the Digikam-devel mailing list