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

List:       kde-commits
Subject:    KDE/kdegames/kpat/libkcardgame
From:       Parker Coates <parker.coates () kdemail ! net>
Date:       2010-09-03 21:39:11
Message-ID: 20100903213911.9FB64AC897 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1171455 by coates:

Move checking of the cache for existing elements to Rendering thread.

Thanks to the existence of the contains() method and the inherent thread
safety of KSharedDataCache, we're no longer forced to filter for already
cached elements in the main thread. That work can be safely moved to the
rendering thread. Yet another benfit of porting to KImageCache.

 M  +5 -18     kabstractcarddeck.cpp  


--- trunk/KDE/kdegames/kpat/libkcardgame/kabstractcarddeck.cpp #1171454:1171455
@@ -84,6 +84,8 @@
         }
 
         QString key = keyForPixmap( element, m_size );
+        if ( !d->cache->contains( key ) )
+        {
         kDebug() << "Renderering" << key << "in rendering thread.";
 
         QImage img = QImage( m_size, QImage::Format_ARGB32 );
@@ -100,6 +102,7 @@
         emit renderingDone( element );
     }
 }
+}
 
 
 KAbstractCardDeckPrivate::KAbstractCardDeckPrivate( KAbstractCardDeck * q )
@@ -420,24 +423,8 @@
 
         d->deleteThread();
 
-        // We have to compile the list of elements to load here, because we can't
-        // check the contents of the KPixmapCache from outside the GUI thread.
-        QStringList unrenderedElements;
-        QHash<QString,CardElementData>::const_iterator it;
-        QHash<QString,CardElementData>::const_iterator end;
-        it = d->frontIndex.constBegin();
-        end = d->frontIndex.constEnd();
-        for ( ; it != end; ++it )
-            if ( !d->cache->contains( keyForPixmap( it.key(), d->currentCardSize ) ) )
-                unrenderedElements << it.key();
-
-        it = d->backIndex.constBegin();
-        end = d->backIndex.constEnd();
-        for ( ; it != end; ++it )
-            if ( !d->cache->contains( keyForPixmap( it.key(), d->currentCardSize ) ) )
-                unrenderedElements << it.key();
-
-        d->thread = new RenderingThread( d, d->currentCardSize, unrenderedElements );
+        QStringList elementsToRender = d->frontIndex.keys() + d->backIndex.keys();
+        d->thread = new RenderingThread( d, d->currentCardSize, elementsToRender );
         d->thread->start();
     }
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

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