[Marble-commits] KDE/kdeedu/marble/src/lib

Jens-Michael Hoffmann jensmh at gmx.de
Fri Jan 29 23:02:54 CET 2010


SVN commit 1082181 by jmhoffmann:

TextureTile and TileLoader changed to use the image data of downloaded tiles
directly without loading from the filesystem as the data is in memory anyway.

 M  +0 -1      HttpDownloadManager.h  
 M  +9 -0      TextureTile.cpp  
 M  +3 -3      TextureTile.h  
 M  +10 -24    TileLoader.cpp  
 M  +1 -9      TileLoader.h  


--- trunk/KDE/kdeedu/marble/src/lib/HttpDownloadManager.h #1082180:1082181
@@ -86,7 +86,6 @@
      * This signal is emitted if a file is downloaded and the data argument
      * contains the files content. The HttpDownloadManager takes care to save
      * it using the given storage policy.
-     * This is experimental and needs more testing.
      */
     void downloadComplete( QByteArray data, QString initiatorId );
 
--- trunk/KDE/kdeedu/marble/src/lib/TextureTile.cpp #1082180:1082181
@@ -271,6 +271,15 @@
 {
 }
 
+void TextureTile::setImage( const QByteArray & data )
+{
+    d->m_rawtile = QImage::fromData( data );
+    d->m_depth = d->m_rawtile.depth();
+    d->m_isGrayscale = d->m_rawtile.isGrayscale();
+    d->m_created = QDateTime::currentDateTime();
+    initJumpTables();
+}
+
 void TextureTile::loadDataset( GeoSceneTexture *textureLayer,
                                QCache<TileId, TextureTile> *tileCache )
 {
--- trunk/KDE/kdeedu/marble/src/lib/TextureTile.h #1082180:1082181
@@ -41,11 +41,11 @@
     Q_OBJECT
 
  public:
-
     explicit TextureTile( TileId const& tid, QObject * parent = 0 );
+    virtual ~TextureTile();
 
-    virtual ~TextureTile();
-    
+    void setImage( const QByteArray & data );
+
     // TODO: Move into DatasetProvider:
     void loadDataset( GeoSceneTexture *textureLayer,
                       QCache<TileId, TextureTile> *tileCache = 0 );
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.cpp #1082180:1082181
@@ -100,8 +100,8 @@
 
     d->m_downloadManager = downloadManager;
     if ( d->m_downloadManager != 0 ) {
-        connect( d->m_downloadManager, SIGNAL( downloadComplete( QString, QString ) ),
-                 this,              SLOT( reloadTile( QString, QString ) ) );
+        connect( d->m_downloadManager, SIGNAL( downloadComplete( QByteArray, QString )),
+                 SLOT( updateTile( QByteArray, QString )));
     }
 }
 
@@ -347,38 +347,24 @@
     d->m_tileCache.setMaxCost( kiloBytes * 1024 );
 }
 
-void TileLoader::reloadTile( const QString &idStr )
+void TileLoader::updateTile( const QByteArray &data, const QString &idStr )
 {
-    if ( !d->m_layer ) return;
+    if ( !d->m_layer )
+        return;
 
-//    mDebug() << "TileLoader::reloadTile:" << idStr;
- 
     const TileId id = TileId::fromString( idStr );
-    if ( d->m_tilesOnDisplay.contains( id ) ) {
-
-        // TODO should emit signal rather than directly calling paintTile
-//         emit paintTile( d->m_tilesOnDisplay[id], x, y, level, d->m_theme, true );
-        GeoSceneTexture * texture = static_cast<GeoSceneTexture *>( d->m_layer->groundDataset() );
-
-        d->m_tilesOnDisplay[id]->loadDataset( texture, &d->m_tileCache );
-        m_parent->paintTile( d->m_tilesOnDisplay[id], texture );
+    QHash<TileId, TextureTile*>::iterator pos = d->m_tilesOnDisplay.find( id );
+    if ( pos != d->m_tilesOnDisplay.end()) {
+        pos.value()->setImage( data );
+        GeoSceneTexture * const texture = static_cast<GeoSceneTexture *>( d->m_layer->groundDataset() );
+        m_parent->paintTile( pos.value(), texture );
         emit tileUpdateAvailable();
-//         (d->m_tilesOnDisplay[id])->reloadTile( x, y, level, d->m_theme );
     } else {
         // Remove "false" tile from cache so it doesn't get loaded anymore
         d->m_tileCache.remove( id );
-        mDebug() << "No such ID:" << idStr;
     }
 }
 
-void TileLoader::reloadTile( const QString &relativeUrlString, const QString &id )
-{
-    Q_UNUSED( relativeUrlString );
-    // mDebug() << "Reloading Tile" << relativeUrlString << "id:" << id;
-
-    reloadTile( id );
-}
-
 void TileLoader::update()
 {
     mDebug() << "TileLoader::update()";
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.h #1082180:1082181
@@ -165,10 +165,7 @@
          */
         void setVolatileCacheLimit( quint64 kiloBytes );
 
-        /**
-         * Reloads the tile with the given @p id.
-         */
-        void reloadTile( const QString &relativeUrlString, const QString &id );
+        void updateTile( const QByteArray &data, const QString &id );
 
         /**
          * Effectively triggers a reload of all tiles that are currently in use
@@ -188,11 +185,6 @@
                        bool requestTileUpdate);
 
     private:
-        /**
-         * @brief Helper method for the slots reloadTile.
-         */
-        void reloadTile( const QString &idStr );
-
         Q_DISABLE_COPY( TileLoader )
 
         TileLoaderPrivate* const d;


More information about the Marble-commits mailing list