summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaglcontext.mm
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2017-08-07 19:54:41 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2017-12-15 08:45:45 +0000
commite739e984c3006ed2e88ef8f087455116cf9c4ebb (patch)
tree5b9b4c4fab50ca7308e4def79eb1dedcda4c26bf /src/plugins/platforms/cocoa/qcocoaglcontext.mm
parentae55e75b1b6c2c07f4ef084ee27448fc0262c7c0 (diff)
macOS: Make retina OpenGL work on VMware
Qt requests full resolution OpenGL surfaces by default. However, when running as a VMware guest it looks like the OS silently creates low-resolution surfaces. This is not possible to detect using the standard NSWindow APIs for converting to backing coordinates or for reading the backing scale factor. The result of this is that Qt will incorrectly display one quarter of the window content only. Fall back to detecting if the OpenGL renderer is the Apple software renderer, which it will be on VMware. Cancel the high-resolution surface request if this is the case. This needs to be done while we have a valid OpenGL context. Task-number: QTBUG-62357 Change-Id: I33bf12b3bb0408249e6d66e0a8ca86b044bea781 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaglcontext.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index be5029b7e0..b656025ec7 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -121,7 +121,8 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo
const QVariant &nativeHandle)
: m_context(nil),
m_shareContext(nil),
- m_format(format)
+ m_format(format),
+ m_didCheckForSoftwareContext(false)
{
if (!nativeHandle.isNull()) {
if (!nativeHandle.canConvert<QCocoaNativeContext>()) {
@@ -262,6 +263,22 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
setActiveWindow(window);
+
+ // Disable high-resolution surfaces when using the software renderer, which has the
+ // problem that the system silently falls back to a to using a low-resolution buffer
+ // when a high-resolution buffer is requested. This is not detectable using the NSWindow
+ // convertSizeToBacking and backingScaleFactor APIs. A typical result of this is that Qt
+ // will display a quarter of the window content when running in a virtual machine.
+ if (!m_didCheckForSoftwareContext) {
+ m_didCheckForSoftwareContext = true;
+
+ const GLubyte* renderer = glGetString(GL_RENDERER);
+ if (qstrcmp((const char *)renderer, "Apple Software Renderer") == 0) {
+ NSView *view = static_cast<QCocoaWindow *>(surface)->m_view;
+ [view setWantsBestResolutionOpenGLSurface:NO];
+ }
+ }
+
update();
return true;
}