From db5c011da1f3d8b233af17d104b6fecfc0d7d716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 3 Feb 2015 12:40:49 +0100 Subject: [PATCH] Cocoa: Improve QT_MAC_WANTS_LAYER for GL windows Add the NSOpenGLPFANoRecovery pixel format attribute. This disables the software rendering fallback and makes compositing OpenGL and raster NSViews using Core Animation layers possible. With QT_MAC_WANTS_LAYER enabled, native NSViews now stack correctly with QWindows with OpenGL content. One known limitation is that this mode currently supports main-thread rendering only. Change-Id: I2060cceda846b305b33b47f2eba3cb7cb838039c Reviewed-by: Christian Stromme --- src/platformsupport/cglconvenience/cglconvenience.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm index c5f09f15ec..d0663078f5 100644 --- a/src/platformsupport/cglconvenience/cglconvenience.mm +++ b/src/platformsupport/cglconvenience/cglconvenience.mm @@ -32,6 +32,7 @@ ****************************************************************************/ #include "cglconvenience_p.h" +#include #include #include #include @@ -125,6 +126,14 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format) attrs << NSOpenGLPFAStereo; attrs << NSOpenGLPFAAllowOfflineRenderers; + + QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER"); + if (!useLayer.isEmpty() && useLayer.toInt() > 0) { + // Disable the software rendering fallback. This makes compositing + // OpenGL and raster NSViews using Core Animation layers possible. + attrs << NSOpenGLPFANoRecovery; + } + attrs << 0; NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()];