[Development] resolution independence (was Re: Retina display support)

Sorvig Morten Morten.Sorvig at digia.com
Thu Oct 4 14:10:37 CEST 2012


By now the pros and cons of the two approaches ("free scaling" vs. "2x") have been well argued by Rutledge and Ziller; I'll go on an present the patches. These implement the 2x type of high-dpi support.

In short, there is now an distinction between points and pixels. Window, widget and event geometry is specified in points, and this coordinate system does not change when moving to high-dpi displays. The backing store is in pixels, which grows 2x horizontally and vertically on high-dpi displays. When painting images and pixmaps we need to make sure there are enough source pixels available, and also take care to get the conversion between image (pixel) size to point size correct.

Qt 4:  https://codereview.qt-project.org/#change,33266
        - Mac only
	- Core graphics gives us high-dpi text/macstyle/vector graphics for free.
	- New API: QPixmap, QImage gets a dpiScaleFactor getter and setter.
	- Loading "@2x" images set the scale factor to 2.0.
	- QIcon::pixmap() generates 2x pixmaps when it can and should.
	- export QT_HIHDPI_AWARE to enable the QIcon::pixmap() behaviour change.
	- QPainter can paint 2x images correctly.	
	- misc fixes in Qt where we assume points==pixels.

Qt 5: https://codereview.qt-project.org/#change,36293
	- Includes most of the Qt 4 fixes, plus:
	- Sets a system scale on QPainter when drawing on high-dpi QImages.
	- The QImage used for the backing store gets a dpi scale factor of 2 on retina displays.
	- Cross-platform, adds an emulation mode: export QT_EMULATED_HIDPI on OS X or Xcb.

(The patches are still work-in-progress, but should work well enough for testing)


More information about the Development mailing list