Skip to content

Commit

Permalink
Fill image with 0 in rendering thread (#3722)
Browse files Browse the repository at this point in the history
Calling QImage::fill( 0 ) on rendering start takes about 40% of the
time required for setting up a new job.
Since this is done on the main thread, the interface feels more
snappy the quicker the setup process is completed.
  • Loading branch information
m-kuhn committed Nov 5, 2016
1 parent 5984b21 commit 022e228
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core/qgsmaprenderercustompainterjob.cpp
Expand Up @@ -244,6 +244,9 @@ void QgsMapRendererCustomPainterJob::doRender()
QTime layerTime;
layerTime.start();

if ( job.img )
job.img->fill( 0 );

job.renderer->render();

job.renderingTime = layerTime.elapsed();
Expand Down
1 change: 0 additions & 1 deletion src/core/qgsmaprendererjob.cpp
Expand Up @@ -286,7 +286,6 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter* painter, QgsLabelingEn
layerJobs.removeLast();
continue;
}
mypFlattenedImage->fill( 0 );

job.img = mypFlattenedImage;
QPainter* mypPainter = new QPainter( job.img );
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsmaprendererparalleljob.cpp
Expand Up @@ -215,6 +215,9 @@ void QgsMapRendererParallelJob::renderLayerStatic( LayerRenderJob& job )
if ( job.cached )
return;

if ( job.img )
job.img->fill( 0 );

QTime t;
t.start();
QgsDebugMsgLevel( QString( "job %1 start (layer %2)" ).arg( reinterpret_cast< ulong >( &job ), 0, 16 ).arg( job.layerId ), 2 );
Expand Down

0 comments on commit 022e228

Please sign in to comment.