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

List:       kde-commits
Subject:    KDE/kdegames/lskat/src
From:       Parker Coates <parker.coates () gmail ! com>
Date:       2009-06-15 0:02:21
Message-ID: 1245024141.602564.24223.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 982123 by coates:

Added threaded card rendering to LSkat. This fixes a "stutter" that was occuring at \
certain points when the game had to wait for the SVG renderer to load.

See http://reviewboard.kde.org/r/792/

 M  +22 -2     thememanager.cpp  
 M  +2 -0      thememanager.h  


--- trunk/KDE/kdegames/lskat/src/thememanager.cpp #982122:982123
@@ -180,6 +180,8 @@
   mDeckTheme = deckTheme;
   mCardCache->setBackTheme(mDeckTheme);
 
+  mCardCache->setSize(QSize());
+
   updateTheme(themefile);
 }
 
@@ -278,7 +280,13 @@
 {
   KCardInfo info = convertToKCardInfo(CardDeck::Suite(suite),CardDeck::CardType(cardtype));
  QSize s(int(width), int(width/mCardAspectRatio));
-  mCardCache->setSize(s);
+
+  if ( s != mCardCache->size() )
+  {
+    mCardCache->setSize(s);
+    QMetaObject::invokeMethod(this, "loadCardsInBackground", Qt::QueuedConnection);
+  }
+
   QPixmap pix = mCardCache->frontside(info);
   return pix;
 }
@@ -288,7 +296,12 @@
 const QPixmap ThemeManager::getCardback(double width)
 {
   QSize s(int(width), int(width/mCardAspectRatio));
-  mCardCache->setSize(s);
+  if ( s != mCardCache->size() )
+  {
+    mCardCache->setSize(s);
+    QMetaObject::invokeMethod(this, "loadCardsInBackground", Qt::QueuedConnection);
+  }
+
   QPixmap pix = mCardCache->backside();
   return pix;
 }
@@ -361,6 +374,13 @@
   return getPixmap(svgid, size);
 }
 
+
+void ThemeManager::loadCardsInBackground()
+{
+    mCardCache->loadTheme(KCardCache::LoadFrontSide|KCardCache::Load32Cards);
+}
+
+
 // ========================== Themable interface ===============================
 
 // Constructs a themable interface
--- trunk/KDE/kdegames/lskat/src/thememanager.h #982122:982123
@@ -244,6 +244,8 @@
       */
     void updateCardTheme(const QString &themefile, const QString &cardTheme, const \
QString &deckTheme);  
+   private slots:
+    void loadCardsInBackground();
 
    private:
      // The used SVG rendered


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

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