Skip to content

Commit 022e228

Browse files
authored
Fill image with 0 in rendering thread (#3722)
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.
1 parent 5984b21 commit 022e228

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/core/qgsmaprenderercustompainterjob.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ void QgsMapRendererCustomPainterJob::doRender()
244244
QTime layerTime;
245245
layerTime.start();
246246

247+
if ( job.img )
248+
job.img->fill( 0 );
249+
247250
job.renderer->render();
248251

249252
job.renderingTime = layerTime.elapsed();

src/core/qgsmaprendererjob.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter* painter, QgsLabelingEn
286286
layerJobs.removeLast();
287287
continue;
288288
}
289-
mypFlattenedImage->fill( 0 );
290289

291290
job.img = mypFlattenedImage;
292291
QPainter* mypPainter = new QPainter( job.img );

src/core/qgsmaprendererparalleljob.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ void QgsMapRendererParallelJob::renderLayerStatic( LayerRenderJob& job )
215215
if ( job.cached )
216216
return;
217217

218+
if ( job.img )
219+
job.img->fill( 0 );
220+
218221
QTime t;
219222
t.start();
220223
QgsDebugMsgLevel( QString( "job %1 start (layer %2)" ).arg( reinterpret_cast< ulong >( &job ), 0, 16 ).arg( job.layerId ), 2 );

0 commit comments

Comments
 (0)