[QGIS-trac] [Quantum GIS] #2037: Enable multi-threaded rendering in QGIS

Quantum GIS qgis at qgis.org
Tue Oct 27 19:02:39 EDT 2009

#2037: Enable multi-threaded rendering in QGIS
   Reporter:  timlinux          |              Owner:  nobody       
       Type:  enhancement       |             Status:  new          
   Priority:  minor: annoyance  |          Milestone:  Version 1.4.0
  Component:  Build/Install     |            Version:  HEAD         
   Keywords:                    |   Platform_version:               
   Platform:  Debian            |           Must_fix:  No           
Status_info:  0                 |  
 User story 1: Joe has a multicore processor but when QGIS  is rendering a
 map, one of the cores is heavily utilised whilst the rest remain idle.

 User story 2: Pam wishes she didnt need to wait so long for maps to draw
 as each layer draw carries out a long running query against a database

 Qt4 includes QThread which makes writing multithreaded cross platform
 libraries fairly easily. Thus it would be good to start thinking about how
 we can make QGIS take advantage of this.

 In my mind there are two main areas of work required:

  - making map layers inherit from QThread and adding in sufficient
 foundation for them to be able to render in a thread (pretty much covered
 in the attached patch).

  - Updating qgsmaprenderer.cpp to orchestrate the threaded rendering of
 map layers and the composition of the results.

 For the second (renderer part) we will need to split the render process
 into three parts I think:

 - a setup phase which sets the render context for each maplayer (which
 would need to become a member of qgsmaplayer) and then calls the run()
 method to launch the thread
 - a slot to listen for when each thread is done and tally up when all the
 rendering work is completed
 - a finalise method to end the render process with label and acetate
 rendering and perform final compositing from layer render cache images.

Ticket URL: <http://trac.osgeo.org/qgis/ticket/2037>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats

More information about the QGIS-trac mailing list