diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoanativeinterface.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 955b147bfd..7979e430ac 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -71,6 +71,10 @@ #include <AppKit/AppKit.h> +#if QT_CONFIG(vulkan) +#include <MoltenVK/mvk_vulkan.h> +#endif + QT_BEGIN_NAMESPACE QCocoaNativeInterface::QCocoaNativeInterface() @@ -81,31 +85,32 @@ QCocoaNativeInterface::QCocoaNativeInterface() void *QCocoaNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) { if (!context) - return 0; + return nullptr; if (resourceString.toLower() == "nsopenglcontext") return nsOpenGLContextForContext(context); if (resourceString.toLower() == "cglcontextobj") return cglContextForContext(context); - return 0; + return nullptr; } #endif void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { if (!window->handle()) - return 0; + return nullptr; if (resourceString == "nsview") { return static_cast<QCocoaWindow *>(window->handle())->m_view; -#ifndef QT_NO_OPENGL - } else if (resourceString == "nsopenglcontext") { - return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext(); -#endif } else if (resourceString == "nswindow") { return static_cast<QCocoaWindow *>(window->handle())->nativeWindow(); +#if QT_CONFIG(vulkan) + } else if (resourceString == "vkSurface") { + if (QVulkanInstance *instance = window->vulkanInstance()) + return static_cast<QCocoaVulkanInstance *>(instance->handle())->createSurface(window); +#endif } - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource) @@ -143,7 +148,7 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter if (resource.toLower() == "testcontentborderposition") return NativeResourceForIntegrationFunction(QCocoaNativeInterface::testContentBorderPosition); - return 0; + return nullptr; } QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport() @@ -152,7 +157,7 @@ QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport() return new QCocoaPrinterSupport(); #else qFatal("Printing is not supported when Qt is configured with -no-widgets"); - return 0; + return nullptr; #endif } @@ -166,7 +171,7 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine #else Q_UNUSED(printEngine); qFatal("Printing is not supported when Qt is configured with -no-widgets"); - return 0; + return nullptr; #endif } @@ -180,10 +185,10 @@ QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard() CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0); QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url); if (bundle) { - url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0); + url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), nullptr); if (url) { - QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0); - QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); + QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, nullptr); + QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, nullptr); if (image) { int width = CGImageGetWidth(image); int height = CGImageGetHeight(image); @@ -213,18 +218,16 @@ void *QCocoaNativeInterface::cglContextForContext(QOpenGLContext* context) NSOpenGLContext *nsOpenGLContext = static_cast<NSOpenGLContext*>(nsOpenGLContextForContext(context)); if (nsOpenGLContext) return [nsOpenGLContext CGLContextObj]; - return 0; + return nullptr; } void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context) { if (context) { - QCocoaGLContext *cocoaGLContext = static_cast<QCocoaGLContext *>(context->handle()); - if (cocoaGLContext) { - return cocoaGLContext->nsOpenGLContext(); - } + if (QCocoaGLContext *cocoaGLContext = static_cast<QCocoaGLContext *>(context->handle())) + return cocoaGLContext->nativeContext(); } - return 0; + return nullptr; } #endif @@ -256,7 +259,7 @@ void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu) QMacAutoReleasePool pool; QCocoaMenu *cocoaPlatformMenu = static_cast<QCocoaMenu *>(platformMenu); NSMenu *menu = cocoaPlatformMenu->nsMenu(); - [[QCocoaApplicationDelegate sharedDelegate] setDockMenu:menu]; + [QCocoaApplicationDelegate sharedDelegate].dockMenu = menu; } void *QCocoaNativeInterface::qMenuToNSMenu(QPlatformMenu *platformMenu) @@ -285,8 +288,9 @@ QImage QCocoaNativeInterface::cgImageToQImage(CGImageRef image) void QCocoaNativeInterface::setEmbeddedInForeignView(QPlatformWindow *window, bool embedded) { + Q_UNUSED(embedded); // "embedded" state is now automatically detected QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window); - cocoaPlatformWindow->setEmbeddedInForeignView(embedded); + cocoaPlatformWindow->setEmbeddedInForeignView(); } void QCocoaNativeInterface::registerTouchWindow(QWindow *window, bool enable) |