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>
This commit is contained in:
Morten Johan Sørvig 2015-02-03 12:40:49 +01:00 committed by Morten Johan Sørvig
parent 1b79d1cfe2
commit db5c011da1

View File

@ -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()];