From ed9340a926aabcf3bf98091ed0436d6b02dd2c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 5 Oct 2017 18:01:21 +0200 Subject: 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 --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/plugins/platforms/cocoa/qcocoaintegration.mm') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 61eeeaf436..dd17848109 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -331,6 +332,24 @@ QPlatformWindow *QCocoaIntegration::createForeignWindow(QWindow *window, WId nat return new QCocoaWindow(window, nativeHandle); } +class QCocoaOffscreenSurface : public QPlatformOffscreenSurface +{ +public: + QCocoaOffscreenSurface(QOffscreenSurface *offscreenSurface) : QPlatformOffscreenSurface(offscreenSurface) {} + + QSurfaceFormat format() const override + { + Q_ASSERT(offscreenSurface()); + return offscreenSurface()->requestedFormat(); + } + bool isValid() const override { return true; } +}; + +QPlatformOffscreenSurface *QCocoaIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const +{ + return new QCocoaOffscreenSurface(surface); +} + #ifndef QT_NO_OPENGL QPlatformOpenGLContext *QCocoaIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { -- cgit v1.2.3