[QGIS Commit] r13675 - in branches/threading-branch/src: app core core/composer providers/wms

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Jun 7 06:43:20 EDT 2010


Author: wonder
Date: 2010-06-07 06:43:18 -0400 (Mon, 07 Jun 2010)
New Revision: 13675

Modified:
   branches/threading-branch/src/app/qgisapp.cpp
   branches/threading-branch/src/core/composer/qgscomposermap.cpp
   branches/threading-branch/src/core/qgsmaprenderer.cpp
   branches/threading-branch/src/core/qgsmaprenderer.h
   branches/threading-branch/src/providers/wms/qgswmsprovider.cpp
Log:
More housekeeping: determine whether to use render caching from renderer properties, not from global QSettings


Modified: branches/threading-branch/src/app/qgisapp.cpp
===================================================================
--- branches/threading-branch/src/app/qgisapp.cpp	2010-06-07 08:39:17 UTC (rev 13674)
+++ branches/threading-branch/src/app/qgisapp.cpp	2010-06-07 10:43:18 UTC (rev 13675)
@@ -2102,6 +2102,7 @@
   QSettings mySettings;
   mMapCanvas->enableAntiAliasing( mySettings.value( "/qgis/enable_anti_aliasing", false ).toBool() );
   mMapCanvas->useImageToRender( mySettings.value( "/qgis/use_qimage_to_render", false ).toBool() );
+  mMapCanvas->mapRenderer()->setCachingEnabled( mySettings.value( "/qgis/enable_render_caching", false ).toBool() );
 
   int action = mySettings.value( "/qgis/wheel_action", 0 ).toInt();
   double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
@@ -5083,6 +5084,7 @@
     QSettings mySettings;
     mMapCanvas->enableAntiAliasing( mySettings.value( "/qgis/enable_anti_aliasing" ).toBool() );
     mMapCanvas->useImageToRender( mySettings.value( "/qgis/use_qimage_to_render" ).toBool() );
+    mMapCanvas->mapRenderer()->setCachingEnabled( mySettings.value( "/qgis/enable_render_caching", false ).toBool() );
 
     int action = mySettings.value( "/qgis/wheel_action", 0 ).toInt();
     double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();

Modified: branches/threading-branch/src/core/composer/qgscomposermap.cpp
===================================================================
--- branches/threading-branch/src/core/composer/qgscomposermap.cpp	2010-06-07 08:39:17 UTC (rev 13674)
+++ branches/threading-branch/src/core/composer/qgscomposermap.cpp	2010-06-07 10:43:18 UTC (rev 13675)
@@ -149,13 +149,7 @@
   double bk_scale = theMapRenderer.scale();
   theMapRenderer.setScale( scale() );
 
-  //layer caching (as QImages) cannot be done for composer prints
-  QSettings s;
-  bool bkLayerCaching = s.value( "/qgis/enable_render_caching", false ).toBool();
-  s.setValue( "/qgis/enable_render_caching", false );
-
   theMapRenderer.render( painter );
-  s.setValue( "/qgis/enable_render_caching", bkLayerCaching );
 
   theMapRenderer.setScale( bk_scale );
 }

Modified: branches/threading-branch/src/core/qgsmaprenderer.cpp
===================================================================
--- branches/threading-branch/src/core/qgsmaprenderer.cpp	2010-06-07 08:39:17 UTC (rev 13674)
+++ branches/threading-branch/src/core/qgsmaprenderer.cpp	2010-06-07 10:43:18 UTC (rev 13675)
@@ -48,6 +48,8 @@
 
   mDrawing = false;
   mOverview = false;
+  mThreadingEnabled = false;
+  mCachingEnabled = false;
 
   // set default map units - we use WGS 84 thus use degrees
   setMapUnits( QGis::Degrees );
@@ -285,8 +287,7 @@
   if ( !mySameAsLastFlag )
   {
     //clear the cache pixmap if we changed resolution / extent
-    QSettings mySettings;
-    if ( mySettings.value( "/qgis/enable_render_caching", false ).toBool() )
+    if ( mCachingEnabled )
     {
       QgsMapLayerRegistry::instance()->clearAllLayerCaches();
     }
@@ -436,35 +437,31 @@
     }
   }
 
-  QSettings mySettings;
-  if ( ! split )//render caching does not yet cater for split extents
+  if ( mCachingEnabled )
   {
-    if ( mySettings.value( "/qgis/enable_render_caching", false ).toBool() )
+    if ( !mySameAsLastFlag || ml->cacheImage() == 0 )
     {
-      if ( !mySameAsLastFlag || ml->cacheImage() == 0 )
+      QgsDebugMsg( "\n\n\nCaching enabled but layer redraw forced by extent change or empty cache\n\n\n" );
+      QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
+                                      mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
+      mypImage->fill( 0 );
+      ml->setCacheImage( mypImage ); //no need to delete the old one, maplayer does it for you
+      QPainter * mypPainter = new QPainter( ml->cacheImage() );
+      if ( mypContextPainter->testRenderHint( QPainter::Antialiasing ) )
       {
-        QgsDebugMsg( "\n\n\nCaching enabled but layer redraw forced by extent change or empty cache\n\n\n" );
-        QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
-                                        mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
-        mypImage->fill( 0 );
-        ml->setCacheImage( mypImage ); //no need to delete the old one, maplayer does it for you
-        QPainter * mypPainter = new QPainter( ml->cacheImage() );
-        if ( mySettings.value( "/qgis/enable_anti_aliasing", false ).toBool() )
-        {
-          mypPainter->setRenderHint( QPainter::Antialiasing );
-        }
-        mRenderContext.setPainter( mypPainter );
+        mypPainter->setRenderHint( QPainter::Antialiasing );
       }
-      else if ( mySameAsLastFlag )
-      {
-        //draw from cached image
-        QgsDebugMsg( "\n\n\nCaching enabled --- drawing layer from cached image\n\n\n" );
-        mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
-        disconnect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) );
-        //short circuit as there is nothing else to do...
-        return;
-      }
+      mRenderContext.setPainter( mypPainter );
     }
+    else if ( mySameAsLastFlag )
+    {
+      //draw from cached image
+      QgsDebugMsg( "\n\n\nCaching enabled --- drawing layer from cached image\n\n\n" );
+      mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
+      disconnect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) );
+      //short circuit as there is nothing else to do...
+      return;
+    }
   }
 
   if ( scaleRaster )
@@ -495,6 +492,7 @@
     {
       emit drawError( ml );
     }
+    mRenderContext.setExtent( mExtent ); // return back to the original extent
   }
 
   if ( scaleRaster )
@@ -503,17 +501,14 @@
     mRenderContext.painter()->restore();
   }
 
-  if ( mySettings.value( "/qgis/enable_render_caching", false ).toBool() )
+  if ( mCachingEnabled )
   {
-    if ( !split )
-    {
-      // composite the cached image into our view and then clean up from caching
-      // by reinstating the painter as it was swapped out for caching renders
-      delete mRenderContext.painter();
-      mRenderContext.setPainter( mypContextPainter );
-      //draw from cached image that we created further up
-      mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
-    }
+    // composite the cached image into our view and then clean up from caching
+    // by reinstating the painter as it was swapped out for caching renders
+    delete mRenderContext.painter();
+    mRenderContext.setPainter( mypContextPainter );
+    //draw from cached image that we created further up
+    mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
   }
   disconnect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) );
 
@@ -1047,3 +1042,4 @@
 
   mLabelingEngine = iface;
 }
+

Modified: branches/threading-branch/src/core/qgsmaprenderer.h
===================================================================
--- branches/threading-branch/src/core/qgsmaprenderer.h	2010-06-07 08:39:17 UTC (rev 13674)
+++ branches/threading-branch/src/core/qgsmaprenderer.h	2010-06-07 10:43:18 UTC (rev 13675)
@@ -64,7 +64,6 @@
 };
 
 
-
 /** \ingroup core
  * A non GUI class for rendering a map layer set onto a QPainter.
  */
@@ -187,12 +186,20 @@
 
     //! Enable or disable rendering in multiple threads on multiprocessor computers
     //! Added in QGIS v1.6
-    void setUsingThreadedRendering( bool use ) { mUsingThreadedRendering = use; }
+    void setThreadingEnabled( bool use ) { mThreadingEnabled = use; }
 
     //! Determine whether we are using threaded rendering
     //! Added in QGIS v1.6
-    bool isUsingThreadedRendering() const { return mUsingThreadedRendering; }
+    bool isThreadingEnabled() const { return mThreadingEnabled; }
 
+    //! Enable or disable caching of rendered layers
+    //! Added in QGIS v1.6
+    void setCachingEnabled( bool enabled ) { mCachingEnabled = enabled; }
+
+    //! Determine whether the rendered layers are cached
+    //! Added in QGIS v1.6
+    bool isCachingEnabled() const { return mCachingEnabled; }
+
   signals:
 
     void drawingProgress( int current, int total );
@@ -290,7 +297,10 @@
     QgsLabelingEngineInterface* mLabelingEngine;
 
     //! Multithreaded rendering
-    bool mUsingThreadedRendering;
+    bool mThreadingEnabled;
+
+    //! Render caching
+    bool mCachingEnabled;
 };
 
 #endif

Modified: branches/threading-branch/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/wms/qgswmsprovider.cpp	2010-06-07 08:39:17 UTC (rev 13674)
+++ branches/threading-branch/src/providers/wms/qgswmsprovider.cpp	2010-06-07 10:43:18 UTC (rev 13675)
@@ -422,7 +422,7 @@
   cachedViewHeight = pixelHeight;
 
   QSettings s;
-  bool bkLayerCaching = s.value( "/qgis/enable_render_caching", false ).toBool();
+  bool bkLayerCaching = s.value( "/qgis/enable_render_caching", false ).toBool(); // TODO: move this into render context
 
   if ( !mTiled )
   {



More information about the QGIS-commit mailing list