Skip to content

Commit

Permalink
Use a separate image cache key for preview images to be used during
Browse files Browse the repository at this point in the history
preview composition only

This gives us freedom to invalidate the main cache image for a layer
upfront (e.g. when it participates in the labeling problem, so we
ALWAYS have to redraw it) while still being able to temporarily compose
a preview image for that layer while the render is happening.

Avoids flashing of vector layers during rendering when they have
labels enabled.
  • Loading branch information
nyalldawson committed Jan 27, 2021
1 parent c4818a0 commit ff07d9b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/qgsmaprendererjob.cpp
Expand Up @@ -686,6 +686,7 @@ void QgsMapRendererJob::cleanupJobs( LayerRenderJobs &jobs )
{
QgsDebugMsgLevel( QStringLiteral( "caching image for %1" ).arg( job.layerId ), 2 );
mCache->setCacheImage( job.layerId, *job.img, QList< QgsMapLayer * >() << job.layer );
mCache->setCacheImage( job.layerId + QStringLiteral( "_preview" ), *job.img, QList< QgsMapLayer * >() << job.layer );
}

delete job.img;
Expand Down Expand Up @@ -864,9 +865,9 @@ QImage QgsMapRendererJob::layerImageToBeComposed(
}
else
{
if ( cache && cache->hasAnyCacheImage( job.layerId ) )
if ( cache && cache->hasAnyCacheImage( job.layerId + QStringLiteral( "_preview" ) ) )
{
return cache->transformedCacheImage( job.layerId, settings.mapToPixel() );
return cache->transformedCacheImage( job.layerId + QStringLiteral( "_preview" ), settings.mapToPixel() );
}
else
return QImage();
Expand Down

0 comments on commit ff07d9b

Please sign in to comment.