Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.0.1
-
None
-
MacOSX Mountain Lion on MBP 15" Retina
-
cea58f4b77e1639e5671cf424544d4948fb8e9ef
Description
I don't know that this is limited to QGraphicsView, but that was where it hit us. To reproduce:
- On a Retina MBP, open the Display settings
- Choose "Scaled" then "More Space"
- Run the attached "retina" application
- Note the result: retina-more-space.png. Everything draws scaled 2x.
I've tracked this down to a call to QPainterPrivate::hidpiScaleTransform(). On OSX, the logical DPI is hardcoded to 72 pixels in qcocoaintegration.mm. When the display is set to "More Space", CGDisplayScreenSize() returns (330.631, 207.347), while the screen's resolution returns (1920, 1200). This means the physical DPI, calculated by QScreen::physicalDotsPerInchX:
return size().width() / physicalSize().width() * qreal(25.4);
Comes out to 147.5. Divided by the logical DPI which is hardcoded to 72, QPainterPrivate gets a scaling factor of 2.
It seems like QPainterPrivate::hidpiScaleTransform() should be using a devicePixelRatio() function instead of doing this calculation on its own, but none exists in QPaintDevice. Since that doesn't seem to be an option, my inclination was to remove the hard-coding of the logical DPI, but then I found http://qt.gitorious.org/qt/qtbase/commit/b2189acfc142397e8f3f547b0affdfc0b233fbb2