[QGIS Commit] r13775 - in branches/threading-branch/src: app
app/legend core core/raster gui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Jun 22 04:29:49 EDT 2010
Author: wonder
Date: 2010-06-22 08:29:49 +0000 (Tue, 22 Jun 2010)
New Revision: 13775
Modified:
branches/threading-branch/src/app/legend/qgslegend.cpp
branches/threading-branch/src/app/qgisapp.cpp
branches/threading-branch/src/app/qgsrasterlayerproperties.cpp
branches/threading-branch/src/app/qgsvectorlayerproperties.cpp
branches/threading-branch/src/core/qgsmaplayer.cpp
branches/threading-branch/src/core/qgsmaplayer.h
branches/threading-branch/src/core/qgsmaplayerregistry.cpp
branches/threading-branch/src/core/qgsmaplayerregistry.h
branches/threading-branch/src/core/qgsmaprenderer.cpp
branches/threading-branch/src/core/qgsmaprenderer.h
branches/threading-branch/src/core/qgsvectorlayer.cpp
branches/threading-branch/src/core/raster/qgsrasterlayer.cpp
branches/threading-branch/src/gui/qgsmapcanvas.cpp
Log:
Render caching done with QgsMapRendererCache, deprecated methods of QgsMapLayer for caching
Modified: branches/threading-branch/src/app/legend/qgslegend.cpp
===================================================================
--- branches/threading-branch/src/app/legend/qgslegend.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/app/legend/qgslegend.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -1332,6 +1332,7 @@
void QgsLegend::updateMapCanvasLayerSet()
{
+ QgsDebugMsg("updating layer set");
QList<QgsMapCanvasLayer> layers;
// create list of the layers
@@ -1463,8 +1464,6 @@
return;
}
- bool renderFlagState = mMapCanvas->renderFlag();
-
//if the text of a QgsLegendLayer has changed, change the display names of all its maplayers
// TODO: is this still necessary?
QgsLegendLayer* theLegendLayer = dynamic_cast<QgsLegendLayer *>( item ); //item is a legend layer
@@ -1477,13 +1476,13 @@
if ( item->data( 0, Qt::UserRole ).toInt() == item->checkState( 0 ) )
return;
+ mMapCanvas->freeze( true );
+
QgsLegendGroup* lg = dynamic_cast<QgsLegendGroup *>( item ); //item is a legend group
if ( lg )
{
//set all the child layer files to the new check state
std::list<QgsLegendLayer*> subfiles = lg->legendLayers();
- bool renderFlagState = mMapCanvas->renderFlag();
- mMapCanvas->setRenderFlag( false );
for ( std::list<QgsLegendLayer*>::iterator iter = subfiles.begin(); iter != subfiles.end(); ++iter )
{
#ifdef QGISDEBUG
@@ -1510,10 +1509,6 @@
}
}
- // If it was on, turn it back on, otherwise leave it
- // off, as turning it on causes a refresh.
- if ( renderFlagState )
- mMapCanvas->setRenderFlag( true );
item->setData( 0, Qt::UserRole, item->checkState( 0 ) );
}
@@ -1534,17 +1529,13 @@
static_cast<QgsLegendGroup*>( ll->parent() )->updateCheckState();
ll->parent()->setData( 0, Qt::UserRole, ll->parent()->checkState( 0 ) );
}
- // If it was on, turn it back on, otherwise leave it
- // off, as turning it on causes a refresh.
- if ( renderFlagState )
- {
- mMapCanvas->setRenderFlag( true );
- }
- mMapCanvas->freeze( false );
+
//update check state of the legend group
item->setData( 0, Qt::UserRole, item->checkState( 0 ) );
}
+ mMapCanvas->freeze( false );
+
// update layer set
updateMapCanvasLayerSet();
}
Modified: branches/threading-branch/src/app/qgisapp.cpp
===================================================================
--- branches/threading-branch/src/app/qgisapp.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/app/qgisapp.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -4488,7 +4488,7 @@
void QgisApp::refreshMapCanvas()
{
//clear all caches first
- QgsMapLayerRegistry::instance()->clearAllLayerCaches();
+ mMapCanvas->mapRenderer()->clearCache();
//then refresh
mMapCanvas->refresh();
}
Modified: branches/threading-branch/src/app/qgsrasterlayerproperties.cpp
===================================================================
--- branches/threading-branch/src/app/qgsrasterlayerproperties.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/app/qgsrasterlayerproperties.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -1471,9 +1471,6 @@
// update symbology
emit refreshLegend( mRasterLayer->getLayerID(), false );
- //no need to delete the old one, maplayer will do it if needed
- mRasterLayer->setCacheImage( 0 );
-
//make sure the layer is redrawn
mRasterLayer->triggerRepaint();
Modified: branches/threading-branch/src/app/qgsvectorlayerproperties.cpp
===================================================================
--- branches/threading-branch/src/app/qgsvectorlayerproperties.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/app/qgsvectorlayerproperties.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -665,9 +665,6 @@
// update symbology
emit refreshLegend( layer->getLayerID(), false );
- //no need to delete the old one, maplayer will do it if needed
- layer->setCacheImage( 0 );
-
layer->triggerRepaint();
// notify the project we've made a change
QgsProject::instance()->dirty( true );
Modified: branches/threading-branch/src/core/qgsmaplayer.cpp
===================================================================
--- branches/threading-branch/src/core/qgsmaplayer.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/core/qgsmaplayer.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -842,12 +842,7 @@
void QgsMapLayer::setCacheImage( QImage * thepImage )
{
- QgsDebugMsg( "cache Image set!" );
- if ( mpCacheImage )
- {
- delete mpCacheImage;
- }
- mpCacheImage = thepImage;
+ QgsDebugMsg( "warning: deprecated, does nothing." );
}
bool QgsMapLayer::isEditable() const
@@ -860,7 +855,8 @@
mValid = valid;
}
+
void QgsMapLayer::clearCacheImage()
{
- setCacheImage( 0 );
+ QgsDebugMsg( "warning: deprecated, does nothing." );
}
Modified: branches/threading-branch/src/core/qgsmaplayer.h
===================================================================
--- branches/threading-branch/src/core/qgsmaplayer.h 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/core/qgsmaplayer.h 2010-06-22 08:29:49 UTC (rev 13775)
@@ -290,10 +290,10 @@
/** Return pointer to layer's undo stack */
QUndoStack* undoStack();
- /** Get the QImage used for caching render operations
+ /** @deprecated Caching is done now in QgsMapRendererCache. Returns always 0.
* @note This method was added in QGIS 1.4 **/
- QImage * cacheImage() { return mpCacheImage; }
- /** Set the QImage used for caching render operations
+ QImage * cacheImage() { return 0; }
+ /** @deprecated Caching is done now in QgsMapRendererCache. Does nothing.
* @note This method was added in QGIS 1.4 **/
void setCacheImage( QImage * thepImage );
@@ -314,7 +314,7 @@
void toggleScaleBasedVisibility( bool theVisibilityFlag );
bool hasScaleBasedVisibility();
- /** Clear cached image
+ /** @deprecated Caching is done now in QgsMapRendererCache. Clear cache by emitting dataChanged() signal.
* added in 1.5 */
void clearCacheImage();
Modified: branches/threading-branch/src/core/qgsmaplayerregistry.cpp
===================================================================
--- branches/threading-branch/src/core/qgsmaplayerregistry.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/core/qgsmaplayerregistry.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -117,16 +117,9 @@
} // QgsMapLayerRegistry::removeAllMapLayers()
-//Added in QGIS 1.4
void QgsMapLayerRegistry::clearAllLayerCaches()
{
- QMap<QString, QgsMapLayer *>::iterator it;
- for ( it = mMapLayers.begin(); it != mMapLayers.end() ; ++it )
- {
- //the map layer will take care of deleting the QImage
- it.value()->setCacheImage( 0 );
- }
-} // QgsMapLayerRegistry::clearAllLayerCaches()
+}
QMap<QString, QgsMapLayer*> & QgsMapLayerRegistry::mapLayers()
{
Modified: branches/threading-branch/src/core/qgsmaplayerregistry.h
===================================================================
--- branches/threading-branch/src/core/qgsmaplayerregistry.h 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/core/qgsmaplayerregistry.h 2010-06-22 08:29:49 UTC (rev 13775)
@@ -82,10 +82,8 @@
*/
void removeAllMapLayers();
- /* Clears all layer caches, resetting them to zero and
- * freeing up any memory they may have been using. Layer
- * caches are used to speed up rendering in certain situations
- * see ticket #1974 for more details.
+ /** Does nothing.
+ * @deprecated clearing of caches is now done with QgsMapRenderer::clearCache()
* @note this method was added in QGIS 1.4
*/
void clearAllLayerCaches();
Modified: branches/threading-branch/src/core/qgsmaprenderer.cpp
===================================================================
--- branches/threading-branch/src/core/qgsmaprenderer.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/core/qgsmaprenderer.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -54,7 +54,7 @@
mDrawing = false;
mOverview = false;
mThreadingEnabled = false;
- mCachingEnabled = false;
+ mCache = NULL;
// set default map units - we use WGS 84 thus use degrees
setMapUnits( QGis::Degrees );
@@ -83,6 +83,7 @@
delete mDistArea;
delete mDestCRS;
delete mLabelingEngine;
+ delete mCache;
}
@@ -104,9 +105,6 @@
return false; // do not allow changes while rendering
}
- //remember the previous extent
- mLastExtent = mExtent;
-
// Don't allow zooms where the current extent is so small that it
// can't be accurately represented using a double (which is what
// currentExtent uses). Excluding 0 avoids a divide by zero and an
@@ -233,15 +231,9 @@
{
mDrawing = true;
- //flag to see if the render context has changed
- //since the last time we rendered. If it hasnt changed we can
- //take some shortcuts with rendering
- bool mySameAsLastFlag = true;
-
QgsDebugMsg( "========== Rendering ==========" );
+ QgsDebugMsg( "caching enabled? " + QString::number(mCache != NULL) );
- QgsDebugMsg( "caching enabled? " + QString::number(mCachingEnabled) );
-
#ifdef QGISDEBUG
QgsDebugMsg( "Starting to render layer stack." );
mRenderTime.start();
@@ -264,41 +256,21 @@
scaleFactor = sceneDpi / 25.4;
}
double rasterScaleFactor = deviceDpi / sceneDpi;
- if ( mRenderContext.rasterScaleFactor() != rasterScaleFactor )
- {
- mRenderContext.setRasterScaleFactor( rasterScaleFactor );
- mySameAsLastFlag = false;
- }
- if ( mRenderContext.scaleFactor() != scaleFactor )
- {
- mRenderContext.setScaleFactor( scaleFactor );
- mySameAsLastFlag = false;
- }
- if ( mRenderContext.rendererScale() != mScale )
- {
- //add map scale to render context
- mRenderContext.setRendererScale( mScale );
- mySameAsLastFlag = false;
- }
- if ( mLastExtent != mExtent )
- {
- mLastExtent = mExtent;
- mySameAsLastFlag = false;
- }
+ // initialize render context scaling
+ mRenderContext.setRasterScaleFactor( rasterScaleFactor );
+ mRenderContext.setScaleFactor( scaleFactor );
+ mRenderContext.setRendererScale( mScale );
+
mRenderContext.setLabelingEngine( mLabelingEngine );
if ( mLabelingEngine )
mLabelingEngine->init( this );
- // know we know if this render is just a repeat of the last time, we
- // can clear caches if it has changed
- if ( !mySameAsLastFlag )
+ if (mCache)
{
- //clear the cache pixmap if we changed resolution / extent
- if ( mCachingEnabled )
- {
- QgsMapLayerRegistry::instance()->clearAllLayerCaches();
- }
+ // initialize cache: if the parameters are not the same as the last time,
+ // the cached images are removed
+ mCache->init(mExtent, mScale, scaleFactor, rasterScaleFactor);
}
mOverlayManager = overlayManagerFromSettings();
@@ -429,13 +401,13 @@
// Force render of layers that are being edited
// or if there's a labeling engine that needs the layer to register features
- if ( ml->type() == QgsMapLayer::VectorLayer )
+ if ( mCache && ml->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( ml );
if ( vl->isEditable() ||
( mRenderContext.labelingEngine() && mRenderContext.labelingEngine()->willUseLayer( vl ) ) )
{
- ml->setCacheImage( 0 );
+ mCache->setCacheImage(ml->getLayerID(), QImage());
}
}
@@ -564,61 +536,79 @@
void _renderLayerThreading( ThreadedRenderContext& tctx )
{
- QgsDebugMsg("threaded rendering start: "+tctx.ml->getLayerID());
- // TODO: error handling
- tctx.mr->renderLayer( tctx.ml, tctx.ctx );
+ QString layerId = tctx.ml->getLayerID();
+ if (tctx.cached)
+ {
+ QgsDebugMsg("threaded cached (doing nothing): "+layerId);
+ }
+ else
+ {
+ QgsDebugMsg("threaded rendering start: "+layerId);
+ // TODO: error handling
+ tctx.mr->renderLayer( tctx.ml, tctx.ctx );
- QgsDebugMsg("threaded rendering end : "+tctx.ml->getLayerID());
+ if (tctx.mr->mCache)
+ {
+ // save cache image
+ tctx.mr->mCache->setCacheImage( layerId, *tctx.img );
+ }
+
+ QgsDebugMsg("threaded rendering end : "+layerId);
+ }
}
void QgsMapRenderer::renderLayerThreading( QgsMapLayer* ml )
{
- if ( mCachingEnabled && ml->cacheImage() != 0 )
+ ThreadedRenderContext tctx;
+ tctx.ml = ml;
+
+ if ( mCache && ! mCache->cacheImage(ml->getLayerID()).isNull() )
{
- // do nothing - cached image will be used
- // TODO: resolve caching
+ // cached image will be used
+ tctx.img = new QImage( mCache->cacheImage(ml->getLayerID()));
+ tctx.cached = true;
}
else
{
- ThreadedRenderContext tctx;
- tctx.ml = ml;
-
// create image
tctx.img = new QImage( mSize, QImage::Format_ARGB32_Premultiplied );
tctx.img->fill( 0 );
+ tctx.cached = false;
+ }
- // create private context
- tctx.mr = this;
- tctx.ctx = mRenderContext;
+ // create private context
+ tctx.mr = this;
+ tctx.ctx = mRenderContext;
- QPainter* painter = new QPainter(tctx.img);
- painter->setRenderHint( QPainter::Antialiasing, mAntialiasingEnabled );
- tctx.ctx.setPainter( painter );
+ QPainter* painter = new QPainter(tctx.img);
+ painter->setRenderHint( QPainter::Antialiasing, mAntialiasingEnabled );
+ tctx.ctx.setPainter( painter );
- // schedule DRAW to a list
- mThreadedJobs.append(tctx);
- }
+ // schedule DRAW to a list
+ mThreadedJobs.append(tctx);
}
void QgsMapRenderer::renderLayerNoThreading( QgsMapLayer* ml )
{
- if ( mCachingEnabled )
+ if ( mCache )
{
// Store the painter in case we need to swap it out for the
// cache painter
QPainter * mypContextPainter = mRenderContext.painter();
- if ( ml->cacheImage() == 0 )
+ // retrieve cached image for the layer (will be null if not valid)
+ QImage cacheImage = mCache->cacheImage(ml->getLayerID());
+
+ if ( cacheImage.isNull() )
{
// create cached image
QgsDebugMsg( "\n\n\nCaching enabled --- redraw forced by extent change or empty cache\n\n\n" );
QPaintDevice* device = mRenderContext.painter()->device();
- QImage * mypImage = new QImage( device->width(), device->height(), QImage::Format_ARGB32_Premultiplied );
- mypImage->fill( 0 );
- ml->setCacheImage( mypImage ); //no need to delete the old one, maplayer does it for you
+ cacheImage = QImage( device->width(), device->height(), QImage::Format_ARGB32_Premultiplied );
+ cacheImage.fill( 0 );
// alter painter
- QPainter * mypPainter = new QPainter( ml->cacheImage() );
+ QPainter * mypPainter = new QPainter( &cacheImage );
mypPainter->setRenderHint( QPainter::Antialiasing, mAntialiasingEnabled );
mRenderContext.setPainter( mypPainter );
@@ -630,10 +620,13 @@
// by reinstating the painter as it was swapped out for caching renders
delete mRenderContext.painter();
mRenderContext.setPainter( mypContextPainter );
+
+ // set cache image to the newly rendered image
+ mCache->setCacheImage( ml->getLayerID(), cacheImage );
}
// draw cached image
- mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
+ mypContextPainter->drawImage( 0, 0, cacheImage );
}
else
{
@@ -1063,7 +1056,30 @@
return; // do not allow changes while rendering
}
+ foreach (QString layerId, mLayerSet)
+ {
+ QgsMapLayer* ml = QgsMapLayerRegistry::instance()->mapLayer(layerId);
+ if (ml)
+ {
+ disconnect(ml, SIGNAL(selectionChanged()), this, SLOT(clearLayerCache()));
+ disconnect(ml, SIGNAL(editingStopped()), this, SLOT(clearLayerCache()));
+ disconnect(ml, SIGNAL(dataChanged()), this, SLOT(clearLayerCache()));
+ }
+ }
+
mLayerSet = layers;
+
+ foreach (QString layerId, mLayerSet)
+ {
+ QgsMapLayer* ml = QgsMapLayerRegistry::instance()->mapLayer(layerId);
+ if (ml)
+ {
+ connect(ml, SIGNAL(selectionChanged()), this, SLOT(clearLayerCache()));
+ connect(ml, SIGNAL(editingStopped()), this, SLOT(clearLayerCache()));
+ connect(ml, SIGNAL(dataChanged()), this, SLOT(clearLayerCache()));
+ }
+ }
+
updateFullExtent();
}
@@ -1072,6 +1088,27 @@
return mLayerSet;
}
+void QgsMapRenderer::clearLayerCache()
+{
+ QgsMapLayer* ml = qobject_cast<QgsMapLayer*>(sender());
+ if (mCache)
+ {
+ if (ml)
+ {
+ QgsDebugMsg("clearing cache for: "+ml->getLayerID());
+ mCache->setCacheImage(ml->getLayerID(), QImage());
+ }
+ else
+ {
+ QgsDebugMsg("clearing cache - FOR WHOM ?????\n\n\n\n\n\n");
+ }
+ }
+ else
+ {
+ QgsDebugMsg("not caching -> not clearing cache");
+ }
+}
+
QgsOverlayObjectPositionManager* QgsMapRenderer::overlayManagerFromSettings()
{
QSettings settings;
@@ -1316,7 +1353,16 @@
return; // do not allow changes while rendering
}
- mCachingEnabled = enabled;
+ if ( mCache && !enabled )
+ {
+ delete mCache;
+ mCache = NULL;
+ }
+ else if ( !mCache && enabled )
+ {
+ mCache = new QgsMapRendererCache();
+ }
+
}
void QgsMapRenderer::setAntialiasingEnabled( bool enabled )
@@ -1329,3 +1375,64 @@
mAntialiasingEnabled = enabled;
}
+
+void QgsMapRenderer::clearCache()
+{
+ if ( mDrawing )
+ {
+ QgsDebugMsg("Ignored --- drawing now!");
+ return; // do not allow changes while rendering
+ }
+
+ if (mCache)
+ {
+ mCache->clear();
+ }
+}
+
+// ------------------------
+
+QgsMapRendererCache::QgsMapRendererCache()
+{
+ clear();
+}
+
+void QgsMapRendererCache::clear()
+{
+ mExtent.setMinimal();
+ mScale = 0;
+ mScaleFactor = 0;
+ mRasterScaleFactor = 0;
+ mCachedImages.clear();
+}
+
+bool QgsMapRendererCache::init(QgsRectangle extent, double scale, double scaleFactor, double rasterScaleFactor)
+{
+ // check whether the params are the same
+ if (extent == mExtent &&
+ scale == mScale &&
+ scaleFactor == mScaleFactor &&
+ rasterScaleFactor == mRasterScaleFactor )
+ return true;
+
+ // set new params
+ mExtent = extent;
+ mScale = scale;
+ mScaleFactor = scaleFactor;
+ mRasterScaleFactor = rasterScaleFactor;
+
+ // invalidate cache
+ mCachedImages.clear();
+
+ return false;
+}
+
+void QgsMapRendererCache::setCacheImage(QString layerId, const QImage& img)
+{
+ mCachedImages[layerId] = img;
+}
+
+QImage QgsMapRendererCache::cacheImage(QString layerId)
+{
+ return mCachedImages.value(layerId);
+}
Modified: branches/threading-branch/src/core/qgsmaprenderer.h
===================================================================
--- branches/threading-branch/src/core/qgsmaprenderer.h 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/core/qgsmaprenderer.h 2010-06-22 08:29:49 UTC (rev 13775)
@@ -49,6 +49,7 @@
QgsMapLayer* ml; // source map layer
QImage* img; // destination image
QgsRenderContext ctx; // private render context
+ bool cached; // whether the image is retrieved from cache (= rendering not necessary)
} ThreadedRenderContext;
@@ -78,6 +79,35 @@
};
+
+class CORE_EXPORT QgsMapRendererCache
+{
+ public:
+
+ QgsMapRendererCache();
+
+ //! invalidate the cache contents
+ void clear();
+
+ //! initialize cache: set new parameters and erase cache if parameters have changed
+ //! @return flag whether the extent and other factors are the same as last time
+ bool init(QgsRectangle extent, double scale, double scaleFactor, double rasterScaleFactor);
+
+ //! set cached image for the specified layer ID
+ void setCacheImage(QString layerId, const QImage& img);
+
+ //! get cached image for the specified layer ID. Returns null image if it is not cached.
+ QImage cacheImage(QString layerId);
+
+ protected:
+ QgsRectangle mExtent;
+ double mScale;
+ double mScaleFactor, mRasterScaleFactor;
+ QMap<QString, QImage> mCachedImages;
+};
+
+
+
/** \ingroup core
* A non GUI class for rendering a map layer set onto a QPainter.
*/
@@ -212,7 +242,7 @@
//! Determine whether the rendered layers are cached
//! Added in QGIS v1.6
- bool isCachingEnabled() const { return mCachingEnabled; }
+ bool isCachingEnabled() const { return mCache != NULL; }
//! Added in QGIS v1.6
void setAntialiasingEnabled( bool enabled );
@@ -241,6 +271,10 @@
//! Added in QGIS v1.6
bool isDrawing() const { return mDrawing; }
+ //! if caching is enabled, invalidate the renderer cache
+ //! Added in QGIS v1.6
+ void clearCache();
+
signals:
//! emitted when asynchronous rendering is finished (or canceled).
@@ -268,6 +302,8 @@
void futureFinished();
+ void clearLayerCache();
+
protected:
//! adjust extent to fit the pixmap size
@@ -324,13 +360,6 @@
//! current extent to be drawn
QgsRectangle mExtent;
- //
- /** Last extent to we drew so we know if we can
- used layer render caching or not. Note there are no
- accessors for this as it is intended to internal
- use only.
- @note added in QGIS 1.4 */
- QgsRectangle mLastExtent;
//! indicates whether it's map image for overview
bool mOverview;
@@ -362,7 +391,7 @@
bool mThreadingEnabled;
//! Render caching
- bool mCachingEnabled;
+ QgsMapRendererCache* mCache;
bool mAntialiasingEnabled;
Modified: branches/threading-branch/src/core/qgsvectorlayer.cpp
===================================================================
--- branches/threading-branch/src/core/qgsvectorlayer.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/core/qgsvectorlayer.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -1046,9 +1046,6 @@
if ( emitSignal )
{
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged();
}
}
@@ -1059,9 +1056,6 @@
if ( emitSignal )
{
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged();
}
}
@@ -1085,9 +1079,6 @@
select( f.id(), false ); // don't emit signal (not to redraw it everytime)
}
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged(); // now emit signal to redraw layer
}
@@ -1111,9 +1102,6 @@
mSelectedFeatureIds.remove( *iter );
}
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged();
}
@@ -1137,9 +1125,6 @@
}
}
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged();
}
@@ -1152,15 +1137,13 @@
if ( emitSignal )
{
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged();
}
}
void QgsVectorLayer::triggerRepaint()
{
+ emit dataChanged(); // invalidates caches of map renderers
emit repaintRequested();
}
@@ -1384,7 +1367,7 @@
updateExtents();
if ( res )
- setCacheImage( 0 );
+ emit dataChanged();
return res;
}
@@ -1839,9 +1822,6 @@
deleteFeature( fid ); // removes from selection
}
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged();
triggerRepaint();
@@ -2449,6 +2429,8 @@
// TODO: Check if the provider has the capability to send fullExtentCalculated
connect( mDataProvider, SIGNAL( fullExtentCalculated() ), this, SLOT( updateExtents() ) );
+ connect( mDataProvider, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()) );
+
// get the extent
QgsRectangle mbr = mDataProvider->extent();
@@ -3113,9 +3095,6 @@
{
bool success = true;
- //clear the cache image so markers don't appear anymore on next draw
- setCacheImage( 0 );
-
mCommitErrors.clear();
if ( !mDataProvider )
@@ -3443,9 +3422,6 @@
emit editingStopped();
setModified( false );
- // invalidate the cache so the layer updates properly to show its original
- // after the rollback
- setCacheImage( 0 );
triggerRepaint();
return true;
@@ -3456,9 +3432,6 @@
// TODO: check whether features with these ID exist
mSelectedFeatureIds = ids;
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged();
}
@@ -3552,9 +3525,6 @@
if ( makeSelected )
{
- // invalidate cache
- setCacheImage( 0 );
-
emit selectionChanged();
}
Modified: branches/threading-branch/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- branches/threading-branch/src/core/raster/qgsrasterlayer.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/core/raster/qgsrasterlayer.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -228,6 +228,7 @@
mDataProvider, SIGNAL( statusChanged( QString ) ),
this, SLOT( showStatusMessage( QString ) )
);
+ connect( mDataProvider, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()) );
QgsDebugMsg( "(8 arguments) exiting." );
emit statusChanged( tr( "QgsRasterLayer created" ) );
@@ -3612,6 +3613,7 @@
void QgsRasterLayer::triggerRepaint()
{
+ emit dataChanged(); // invalidates caches of map renderers
emit repaintRequested();
}
Modified: branches/threading-branch/src/gui/qgsmapcanvas.cpp
===================================================================
--- branches/threading-branch/src/gui/qgsmapcanvas.cpp 2010-06-22 07:22:40 UTC (rev 13774)
+++ branches/threading-branch/src/gui/qgsmapcanvas.cpp 2010-06-22 08:29:49 UTC (rev 13775)
@@ -229,6 +229,7 @@
{
if ( isDrawing() )
{
+ QgsDebugMsg("ignored - drawing!" );
return;
}
@@ -246,6 +247,7 @@
if ( lyr.isVisible() )
{
+ QgsDebugMsg("pushing layer "+ lyr.layer()->getLayerID() );
layerSet.push_back( lyr.layer()->getLayerID() );
}
if ( lyr.isInOverview() )
More information about the QGIS-commit
mailing list