From a719c630f14e175902f6f82b753c3d5030724cc6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Jan 2020 13:36:39 +0100 Subject: Mandelbrot Example: Use High DPI scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create the pixmap with a device pixel ratio set. Change-Id: I7f7e90aec4d117304852f050be70e14a0c6bf69d Reviewed-by: Morten Johan Sørvig --- examples/corelib/threads/doc/src/mandelbrot.qdoc | 25 ++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'examples/corelib/threads/doc/src/mandelbrot.qdoc') diff --git a/examples/corelib/threads/doc/src/mandelbrot.qdoc b/examples/corelib/threads/doc/src/mandelbrot.qdoc index b32fa097b3..2b12743538 100644 --- a/examples/corelib/threads/doc/src/mandelbrot.qdoc +++ b/examples/corelib/threads/doc/src/mandelbrot.qdoc @@ -187,6 +187,10 @@ generate more and more precise (and computationally expensive) approximations of the fractal. + We create a high resolution pixmap by applying the device + pixel ratio to the target size (see + \l{Drawing High Resolution Versions of Pixmaps and Images}). + If we discover inside the loop that \c restart has been set to \c true (by \c render()), we break out of the loop immediately, so that the control quickly returns to the very top of the outer @@ -273,12 +277,21 @@ \snippet threads/mandelbrot/mandelbrotwidget.cpp 8 If the pixmap has the right scale factor, we draw the pixmap directly onto - the widget. Otherwise, we scale and translate the \l{Coordinate - System}{coordinate system} before we draw the pixmap. By reverse mapping - the widget's rectangle using the scaled painter matrix, we also make sure - that only the exposed areas of the pixmap are drawn. The calls to - QPainter::save() and QPainter::restore() make sure that any painting - performed afterwards uses the standard coordinate system. + the widget. + + Otherwise, we create a preview pixmap to be shown until the calculation + finishes and translate the \l{Coordinate System}{coordinate system} + accordingly. + + Since we are going to use transformations on the painter + and use an overload of QPainter::drawPixmap() that does not support + high resolution pixmaps in that case, we create a pixmap with device pixel + ratio 1. + + By reverse mapping the widget's rectangle using the scaled painter matrix, + we also make sure that only the exposed areas of the pixmap are drawn. + The calls to QPainter::save() and QPainter::restore() make sure that any + painting performed afterwards uses the standard coordinate system. \snippet threads/mandelbrot/mandelbrotwidget.cpp 9 -- cgit v1.2.3