summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/cglconvenience
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2015-02-03 12:40:49 +0100
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2015-02-12 20:33:28 +0000
commitdb5c011da1f3d8b233af17d104b6fecfc0d7d716 (patch)
treeb295faa8b2cc1baccd08e2e5ae10edf26e6a4e7d /src/platformsupport/cglconvenience
parent1b79d1cfe28a8fb77a3fb32438231d3670a268bc (diff)
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 <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/platformsupport/cglconvenience')
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience.mm9
1 files changed, 9 insertions, 0 deletions
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 <QtCore/qglobal.h>
#include <QtCore/private/qcore_mac_p.h>
#include <Cocoa/Cocoa.h>
#include <QVector>
@@ -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()];