diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2014-10-06 14:36:06 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@digia.com> | 2014-10-07 13:31:59 +0200 |
commit | a7f1eb4ab35a74e401c41d77e5fad13193c25c56 (patch) | |
tree | e17308080e29642288ec109a2a921ce960924d28 | |
parent | a1d66c9aee9a3155f559e7bb00751d1632194183 (diff) |
Correct devicePixelRatio for software OpenGL
[NSView setWantsBestResulutionOpenGLSurface] is a
hint and the driver may ignore it, for example when
using software OpenGL on a virtual machine.
In these cases devicePixelRatio() must return a value
corresponding to the actual OpenGL surface size. Use
[NSView convertSizeToBacking] which is one of the
recommended methods.
Task-number: QTBUG-41767
Change-Id: Ia79242219908a2454a83b44b6eb7463372764162
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index a0e02501de..9259c2c772 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1746,12 +1746,13 @@ qreal QCocoaWindow::devicePixelRatio() const { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { - NSWindow* window = [m_contentView window]; - if (window) { - return qreal([window backingScaleFactor]); - } else { - return 1.0; - } + // The documented way to observe the relationship between device-independent + // and device pixels is to use one for the convertToBacking functions. Other + // methods such as [NSWindow backingScaleFacor] might not give the correct + // result, for example if setWantsBestResolutionOpenGLSurface is not set or + // or ignored by the OpenGL driver. + NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)]; + return backingSize.height; } else #endif { |