summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaglcontext.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-10-05 18:01:21 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-10-16 17:22:17 +0000
commited9340a926aabcf3bf98091ed0436d6b02dd2c14 (patch)
treea8f61fb816323edaeb6a31c5e7f53eca21570a1a /src/plugins/platforms/cocoa/qcocoaglcontext.mm
parenta520c179b89610248ef97f614d6b831ccee54c6b (diff)
macOS: Add support for non-window backed offscreen surfaces
The modern approach to offscreen rendering on macOS is via FBOs, which means there's no reason to allocate an NSView and corresponding NSWindow just for that. In the offscreen case the NSOpenGLContext has a nil-view. Change-Id: I2d1d407069af4d5283e6f56fba83db8eaf694ac6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaglcontext.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 75ac348802..5ed81a7f1b 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -218,6 +218,9 @@ void QCocoaGLContext::windowWasHidden()
void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
{
+ if (surface->surface()->surfaceClass() == QSurface::Offscreen)
+ return; // Nothing to do
+
QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
setActiveWindow(window);
@@ -229,11 +232,13 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
Q_ASSERT(surface->surface()->supportsOpenGL());
QMacAutoReleasePool pool;
+ [m_context makeCurrentContext];
+
+ if (surface->surface()->surfaceClass() == QSurface::Offscreen)
+ return true;
QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
setActiveWindow(window);
-
- [m_context makeCurrentContext];
update();
return true;
}