diff options
-rw-r--r-- | src/gui/kernel/qsurface.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qsurface.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_drawing.mm | 14 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsnativeinterface.cpp | 5 |
4 files changed, 17 insertions, 9 deletions
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp index 63651ee822..415e64b39c 100644 --- a/src/gui/kernel/qsurface.cpp +++ b/src/gui/kernel/qsurface.cpp @@ -80,6 +80,10 @@ QT_BEGIN_NAMESPACE in conjunction with OpenVG contexts. \value VulkanSurface The surface is a Vulkan compatible surface and can be used in conjunction with the Vulkan graphics API. + \value MetalSurface The surface is a Metal compatible surface and can be used + in conjunction with Apple's Metal graphics API. This surface type is supported + on macOS only. + */ diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h index 7e09449d12..e3e5106e3a 100644 --- a/src/gui/kernel/qsurface.h +++ b/src/gui/kernel/qsurface.h @@ -66,7 +66,8 @@ public: OpenGLSurface, RasterGLSurface, OpenVGSurface, - VulkanSurface + VulkanSurface, + MetalSurface }; virtual ~QSurface(); diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm index daa1a2e250..5d637bb6b6 100644 --- a/src/plugins/platforms/cocoa/qnsview_drawing.mm +++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm @@ -133,6 +133,12 @@ } } +- (BOOL)shouldUseMetalLayer:(QSurface::SurfaceType)surfaceType +{ + // MetalSurface needs a layer, and so does VulkanSurface (via MoltenVK) + return surfaceType == QWindow::MetalSurface || surfaceType == QWindow::VulkanSurface; +} + - (BOOL)wantsLayer { Q_ASSERT(m_platformWindow); @@ -144,16 +150,14 @@ bool layerRequested = qt_mac_resolveOption(false, m_platformWindow->window(), "_q_mac_wantsLayer", "QT_MAC_WANTS_LAYER"); - // Support Vulkan via MoltenVK, which requires a Metal layer - bool layerForVulkan = (m_platformWindow->window()->surfaceType() == QWindow::VulkanSurface); + bool layerForSurfaceType = [self shouldUseMetalLayer:m_platformWindow->window()->surfaceType()]; - return layerRequested || layerForVulkan; + return layerRequested || layerForSurfaceType; } - (CALayer *)makeBackingLayer { - // Support Vulkan via MoltenVK, which requires a Metal layer - bool makeMetalLayer = (m_platformWindow->window()->surfaceType() == QWindow::VulkanSurface); + bool makeMetalLayer = [self shouldUseMetalLayer:m_platformWindow->window()->surfaceType()]; if (makeMetalLayer) { // Check if Metal is supported. If it isn't then it's most likely // too late at this point and the QWindow will be non-functional, diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 324b00144e..80f02c43e8 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -111,15 +111,14 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc return 0; } break; - case QWindow::OpenGLSurface: - case QWindow::OpenVGSurface: - break; case QWindow::VulkanSurface: #if QT_CONFIG(vulkan) if (type == VkSurface) return bw->surface(nullptr, nullptr); // returns the address of the VkSurfaceKHR, not the value, as expected #endif break; + default: + break; } qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); return 0; |