title: Efficient off-screen rendering of QPainterPaths (OpenGL and non-OpenGL solution required)
body: <ol>
  <li>In my application, I paint a street map using <code>QPainter</code> on a <code>widget</code>
  <ul>
  <li>made by <code>QPainterPaths</code> that contain precalculated paths to be drawn</li>
  <li>the <code>widget</code> is currently a <code>QWidget</code>, not a <code>QGLWidget</code>, but this might change.</li>
  </ul></li>
  <li>I'm trying to move the painting off-screen and split it into chunked jobs
  <ul>
  <li>I want to paint each chunk onto a <code>QImage</code> and finally draw all images onto the <code>widget</code></li>
  <li><code>QPainterPaths</code> are already chunked, so this is not the problem</li>
  <li>problem is, that drawing on <code>QImages</code> is about <strong>5 times slower</strong> than drawing on <code>QWidget</code></li>
  </ul></li>
  <li>Some benchmark testing I've done
  <ul>
  <li>time values are rounded averages over multiple runs</li>
  <li>test chunk contains 100 <code>QPainterPaths</code> that have about 150 linear line segments each</li>
  <li>the roughly 15k paths are drawn with <code>QPainter::Antialiasing</code> render hint, <code>QPen</code> uses round cap and round join</li>
  </ul></li>
  <li>Remember that my source are <code>QPainterPaths</code> (and line width + color; some <strong><em>drawn</em></strong>, some <strong><em>filled</em></strong>)
  <ul>
  <li>I don't need all the other types of drawing <code>QPainter</code> supports</li>
  <li>Can <code>QPainterPaths</code> be converted to something else which can be drawn on a <code>OpenGL buffer</code>, this would be a good solution.</li>
  <li>I'm not familiar with <code>OpenGL</code> off-screen rendering and I know that there are different types of OpenGL buffers, of which most of them aren't for 2D image rendering but for vertex data.</li>
  </ul></li>
  </ol>
  
  <pre class="lang-none prettyprint-override"><code>Paint Device for chunk | Rendering the chunk itself | Painting chunk on QWidget
  -----------------------+----------------------------+--------------------------
  QImage                 |                    2000 ms |                   &lt; 10 ms
  QPixmap (*)            |                     250 ms |                   &lt; 10 ms
  QGLFramebufferObj. (*) |                      50 ms |                   &lt; 10 ms
  QPicture               |                      50 ms |                    400 ms
  -----------------------+----------------------------+--------------------------
  none (directly on a QWidget in paintEvent)          |                    400 ms
  ----------------------------------------------------+--------------------------
  </code></pre>
  
  <p><code>(*) These 2 lines have been added afterwards and are solutions to the problem!</code></p>
  
  <p>It would be nice if you can tell me a <strong>non-OpenGL-based solution</strong>, too, as I want to compile my application in two versions: <code>OpenGL</code> and <code>non-OpenGL</code> version.<br>
  Also, I want the solution to be able to render in a <strong>non-GUI thread</strong>.</p>
  
  <hr>
  
  <p><em>Is there a good way to efficiently draw the chunks off-screen?</em><br>
  <em>Is there an off-screen counter part of <code>QGLWidget</code> (an <code>OpenGL</code> off-screen buffer) which can be used as a paint device for <code>QPainter</code>?</em></p>