28 QMutexLocker lock( &mMutex );
32 void QgsMapRendererCache::clearInternal()
46 mCachedImages.clear();
47 mConnectedLayers.clear();
50 void QgsMapRendererCache::dropUnusedConnections()
53 QSet< QgsWeakMapLayerPointer > disconnects = mConnectedLayers.subtract( stillDepends );
63 mConnectedLayers = stillDepends;
68 QSet< QgsWeakMapLayerPointer > result;
69 QMap<QString, CacheParameters>::const_iterator it = mCachedImages.constBegin();
70 for ( ; it != mCachedImages.constEnd(); ++it )
83 QMutexLocker lock( &mMutex );
86 if ( extent == mExtent &&
101 QMutexLocker lock( &mMutex );
103 CacheParameters params;
104 params.cachedImage = image;
111 params.dependentLayers << layer;
116 mConnectedLayers << layer;
121 mCachedImages[cacheKey] = params;
126 return mCachedImages.contains( cacheKey );
131 QMutexLocker lock( &mMutex );
132 return mCachedImages.value( cacheKey ).cachedImage;
137 if ( mCachedImages.contains( cacheKey ) )
139 return _qgis_listQPointerToRaw( mCachedImages.value( cacheKey ).dependentLayers );
141 return QList< QgsMapLayer * >();
144 void QgsMapRendererCache::layerRequestedRepaint()
150 QMutexLocker lock( &mMutex );
153 QMap<QString, CacheParameters>::iterator it = mCachedImages.begin();
154 for ( ; it != mCachedImages.end(); )
156 if ( !it.value().dependentLayers.contains( layer ) )
162 it = mCachedImages.erase( it );
164 dropUnusedConnections();
169 QMutexLocker lock( &mMutex );
171 mCachedImages.remove( cacheKey );
172 dropUnusedConnections();
QList< QgsMapLayer *> dependentLayers(const QString &cacheKey) const
Returns a list of map layers on which an image in the cache depends.
A rectangle specified with double values.
Base class for all map layer types.
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void setCacheImage(const QString &cacheKey, const QImage &image, const QList< QgsMapLayer * > &dependentLayers=QList< QgsMapLayer * >())
Set the cached image for a particular cacheKey.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
bool init(const QgsRectangle &extent, double scale)
Initialize cache: set new parameters and clears the cache if any parameters have changed since last i...
QImage cacheImage(const QString &cacheKey) const
Returns the cached image for the specified cacheKey.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
bool hasCacheImage(const QString &cacheKey) const
Returns true if the cache contains an image with the specified cacheKey.
void clear()
Invalidates the cache contents, clearing all cached images.
void clearCacheImage(const QString &cacheKey)
Removes an image from the cache with matching cacheKey.