diff options
Diffstat (limited to 'src/platformsupport')
7 files changed, 289 insertions, 36 deletions
diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm index 09901ba0a5..caa2ccc6e5 100644 --- a/src/platformsupport/clipboard/qmacmime.mm +++ b/src/platformsupport/clipboard/qmacmime.mm @@ -536,13 +536,13 @@ QVariant QMacPasteboardMimeRtfText::convertToMime(const QString &mimeType, QList // Read RTF into to NSAttributedString, then convert the string to HTML NSAttributedString *string = [[NSAttributedString alloc] initWithData:data.at(0).toNSData() - options:[NSDictionary dictionaryWithObject:NSRTFTextDocumentType forKey:NSDocumentTypeDocumentAttribute] + options:@{NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType} documentAttributes:nil error:nil]; NSError *error; NSRange range = NSMakeRange(0, [string length]); - NSDictionary *dict = [NSDictionary dictionaryWithObject:NSHTMLTextDocumentType forKey:NSDocumentTypeDocumentAttribute]; + NSDictionary *dict = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}; NSData *htmlData = [string dataFromRange:range documentAttributes:dict error:&error]; return QByteArray::fromNSData(htmlData); } @@ -554,13 +554,13 @@ QList<QByteArray> QMacPasteboardMimeRtfText::convertFromMime(const QString &mime return ret; NSAttributedString *string = [[NSAttributedString alloc] initWithData:data.toByteArray().toNSData() - options:[NSDictionary dictionaryWithObject:NSHTMLTextDocumentType forKey:NSDocumentTypeDocumentAttribute] + options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil]; NSError *error; NSRange range = NSMakeRange(0, [string length]); - NSDictionary *dict = [NSDictionary dictionaryWithObject:NSRTFTextDocumentType forKey:NSDocumentTypeDocumentAttribute]; + NSDictionary *dict = @{NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType}; NSData *rtfData = [string dataFromRange:range documentAttributes:dict error:&error]; ret << QByteArray::fromNSData(rtfData); return ret; @@ -853,8 +853,8 @@ QList<QByteArray> QMacPasteboardMimeTiff::convertFromMime(const QString &mime, Q QImage img = qvariant_cast<QImage>(variant); NSDictionary *props = @{ - static_cast<NSString *>(kCGImagePropertyPixelWidth) : [NSNumber numberWithInt:img.width()], - static_cast<NSString *>(kCGImagePropertyPixelHeight) : [NSNumber numberWithInt:img.height()] + static_cast<NSString *>(kCGImagePropertyPixelWidth): @(img.width()), + static_cast<NSString *>(kCGImagePropertyPixelHeight): @(img.height()) }; CGImageDestinationAddImage(imageDestination, qt_mac_toCGImage(img), static_cast<CFDictionaryRef>(props)); diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 91c2dc8cf0..5faeca0618 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -101,14 +101,14 @@ enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) } #ifdef Q_OS_OSX static NSInteger languageMapSort(id obj1, id obj2, void *context) { - NSArray *map1 = (NSArray *) obj1; - NSArray *map2 = (NSArray *) obj2; - NSArray *languages = (NSArray *) context; + NSArray<NSString *> *map1 = reinterpret_cast<NSArray<NSString *> *>(obj1); + NSArray<NSString *> *map2 = reinterpret_cast<NSArray<NSString *> *>(obj2); + NSArray<NSString *> *languages = reinterpret_cast<NSArray<NSString *> *>(context); - NSString *lang1 = [map1 objectAtIndex: 0]; - NSString *lang2 = [map2 objectAtIndex: 0]; + NSString *lang1 = [map1 objectAtIndex:0]; + NSString *lang2 = [map2 objectAtIndex:0]; - return [languages indexOfObject: lang1] - [languages indexOfObject: lang2]; + return [languages indexOfObject:lang1] - [languages indexOfObject:lang2]; } #endif @@ -184,23 +184,9 @@ QCoreTextFontDatabase::~QCoreTextFontDatabase() CFRelease(ref); } -static CFArrayRef availableFamilyNames() -{ -#if QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(1060, 100000, 100000, 30000) - if (&CTFontManagerCopyAvailableFontFamilyNames) - return CTFontManagerCopyAvailableFontFamilyNames(); -#endif -#if defined(QT_PLATFORM_UIKIT) - CFMutableArrayRef familyNames = CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, (CFArrayRef)[UIFont familyNames]); - CFArrayAppendValue(familyNames, CFSTR(".PhoneFallback")); - return familyNames; -#endif - Q_UNREACHABLE(); -} - void QCoreTextFontDatabase::populateFontDatabase() { - QCFType<CFArrayRef> familyNames = availableFamilyNames(); + QCFType<CFArrayRef> familyNames = CTFontManagerCopyAvailableFontFamilyNames(); for (NSString *familyName in familyNames.as<const NSArray *>()) QPlatformFontDatabase::registerFontFamily(QString::fromNSString(familyName)); @@ -220,7 +206,7 @@ bool QCoreTextFontDatabase::populateFamilyAliases() if (m_hasPopulatedAliases) return false; - QCFType<CFArrayRef> familyNames = availableFamilyNames(); + QCFType<CFArrayRef> familyNames = CTFontManagerCopyAvailableFontFamilyNames(); for (NSString *familyName in familyNames.as<const NSArray *>()) { NSFontManager *fontManager = [NSFontManager sharedFontManager]; NSString *localizedFamilyName = [fontManager localizedNameForFamily:familyName face:nil]; @@ -571,21 +557,21 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo if (!didPopulateStyleFallbacks) { #if defined(Q_OS_MACX) NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"]; + NSArray<NSString *> *languages = [defaults stringArrayForKey:@"AppleLanguages"]; - NSDictionary *fallbackDict = [NSDictionary dictionaryWithContentsOfFile: @"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist"]; + NSDictionary<NSString *, id> *fallbackDict = [NSDictionary<NSString *, id> dictionaryWithContentsOfFile:@"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist"]; for (NSString *style in [fallbackDict allKeys]) { - NSArray *list = [fallbackDict valueForKey: style]; + NSArray *list = [fallbackDict valueForKey:style]; QFont::StyleHint fallbackStyleHint = styleHintFromNSString(style); QStringList fallbackList; for (id item in list) { // sort the array based on system language preferences - if ([item isKindOfClass: [NSArray class]]) { - NSArray *langs = [(NSArray *) item sortedArrayUsingFunction: languageMapSort - context: languages]; - for (NSArray *map in langs) - fallbackList.append(familyNameFromPostScriptName([map objectAtIndex: 1])); + if ([item isKindOfClass:[NSArray class]]) { + NSArray *langs = [reinterpret_cast<NSArray *>(item) + sortedArrayUsingFunction:languageMapSort context:languages]; + for (NSArray<NSString *> *map in langs) + fallbackList.append(familyNameFromPostScriptName([map objectAtIndex:1])); } else if ([item isKindOfClass: [NSString class]]) fallbackList.append(familyNameFromPostScriptName(item)); diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 59db3da776..71422b469b 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -366,6 +366,25 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, if (!cloneSource.isEmpty()) qCDebug(qLcKmsDebug) << "Output" << connectorName << " clones output " << cloneSource; + const QByteArray fbsize = userConnectorConfig.value(QStringLiteral("size")).toByteArray().toLower(); + QSize framebufferSize; + framebufferSize.setWidth(modes[selected_mode].hdisplay); + framebufferSize.setHeight(modes[selected_mode].vdisplay); + +#if QT_CONFIG(drm_atomic) + if (hasAtomicSupport()) { + if (sscanf(fbsize.constData(), "%dx%d", &framebufferSize.rwidth(), &framebufferSize.rheight()) != 2) { + qWarning("Framebuffer size format is invalid."); + } + } else { + qWarning("Setting framebuffer size is only available with DRM atomic API"); + } +#else + if (fbsize.size()) + qWarning("Setting framebuffer size is only available with DRM atomic API"); +#endif + qCDebug(qLcKmsDebug) << "Output" << connectorName << "framebuffer size is " << framebufferSize; + QKmsOutput output; output.name = QString::fromUtf8(connectorName); output.connector_id = connector->connector_id; @@ -385,6 +404,17 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, output.forced_plane_set = false; output.drm_format = drmFormat; output.clone_source = cloneSource; + output.size = framebufferSize; + +#if QT_CONFIG(drm_atomic) + if (drmModeCreatePropertyBlob(m_dri_fd, &modes[selected_mode], sizeof(drmModeModeInfo), + &output.mode_blob_id) != 0) { + qCDebug(qLcKmsDebug) << "Failed to create mode blob for mode" << selected_mode; + } + + parseConnectorProperties(output.connector_id, &output); + parseCrtcProperties(output.crtc_id, &output); +#endif QString planeListStr; for (const QKmsPlane &plane : qAsConst(m_planes)) { @@ -392,6 +422,8 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, output.available_planes.append(plane); planeListStr.append(QString::number(plane.id)); planeListStr.append(QLatin1Char(' ')); + if (plane.type == QKmsPlane::PrimaryPlane) + output.eglfs_plane = (QKmsPlane*)&plane; } } qCDebug(qLcKmsDebug, "Output %s can use %d planes: %s", @@ -412,6 +444,12 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, output.forced_plane_id = plane->plane_id; qCDebug(qLcKmsDebug, "Forcing plane index %d, plane id %u (belongs to crtc id %u)", idx, plane->plane_id, plane->crtc_id); + + for (const QKmsPlane &kmsplane : qAsConst(m_planes)) { + if (kmsplane.id == output.forced_plane_id) + output.eglfs_plane = (QKmsPlane*)&kmsplane; + } + drmModeFreePlane(plane); } } else { @@ -420,6 +458,9 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } } + if (output.eglfs_plane) + qCDebug(qLcKmsDebug, "Output eglfs plane is: %d", output.eglfs_plane->id); + m_crtc_allocator |= (1 << output.crtc_index); vinfo->output = output; @@ -464,6 +505,11 @@ QKmsDevice::QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path) : m_screenConfig(screenConfig) , m_path(path) , m_dri_fd(-1) + , m_has_atomic_support(false) +#if QT_CONFIG(drm_atomic) + , m_atomic_request(nullptr) + , m_previous_request(nullptr) +#endif , m_crtc_allocator(0) { if (m_path.isEmpty()) { @@ -478,6 +524,9 @@ QKmsDevice::QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path) QKmsDevice::~QKmsDevice() { +#if QT_CONFIG(drm_atomic) + atomicReset(); +#endif } struct OrderedScreen @@ -522,6 +571,14 @@ void QKmsDevice::createScreens() drmSetClientCap(m_dri_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); +#if QT_CONFIG(drm_atomic) + // check atomic support + m_has_atomic_support = !drmSetClientCap(m_dri_fd, DRM_CLIENT_CAP_ATOMIC, 1) + && qEnvironmentVariableIntValue("QT_QPA_EGLFS_KMS_ATOMIC"); + if (m_has_atomic_support) + qCDebug(qLcKmsDebug) << "Atomic Support found"; +#endif + drmModeResPtr resources = drmModeGetResources(m_dri_fd); if (!resources) { qErrnoWarning(errno, "drmModeGetResources failed"); @@ -747,6 +804,28 @@ void QKmsDevice::discoverPlanes() plane.availableRotations |= QKmsPlane::Rotation(1 << prop->enums[i].value); } plane.rotationPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "crtc_id")) { + plane.crtcPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "fb_id")) { + plane.framebufferPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "src_w")) { + plane.srcwidthPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "src_h")) { + plane.srcheightPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "crtc_w")) { + plane.crtcwidthPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "crtc_h")) { + plane.crtcheightPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "src_x")) { + plane.srcXPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "src_y")) { + plane.srcYPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "crtc_x")) { + plane.crtcXPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "crtc_y")) { + plane.crtcYPropertyId = prop->prop_id; + } else if (!strcasecmp(prop->name, "zpos")) { + plane.zposPropertyId = prop->prop_id; } }); @@ -773,6 +852,86 @@ void QKmsDevice::setFd(int fd) m_dri_fd = fd; } + +bool QKmsDevice::hasAtomicSupport() +{ + return m_has_atomic_support; +} + +#if QT_CONFIG(drm_atomic) +drmModeAtomicReq * QKmsDevice::atomic_request() +{ + if (!m_atomic_request && m_has_atomic_support) + m_atomic_request = drmModeAtomicAlloc(); + + return m_atomic_request; +} + +bool QKmsDevice::atomicCommit(void *user_data) +{ + if (m_atomic_request) { + int ret = drmModeAtomicCommit(m_dri_fd, m_atomic_request, + DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_ALLOW_MODESET, user_data); + + if (ret) { + qWarning("Failed to commit atomic request (code=%d)", ret); + return false; + } + + m_previous_request = m_atomic_request; + m_atomic_request = nullptr; + + return true; + } + + return false; +} + +void QKmsDevice::atomicReset() +{ + if (m_previous_request) { + drmModeAtomicFree(m_previous_request); + m_previous_request = nullptr; + } +} +#endif + +void QKmsDevice::parseConnectorProperties(uint32_t connectorId, QKmsOutput *output) +{ + drmModeObjectPropertiesPtr objProps = drmModeObjectGetProperties(m_dri_fd, connectorId, DRM_MODE_OBJECT_CONNECTOR); + if (!objProps) { + qCDebug(qLcKmsDebug, "Failed to query connector %d object properties", connectorId); + return; + } + + enumerateProperties(objProps, [output](drmModePropertyPtr prop, quint64 value) { + Q_UNUSED(value); + if (!strcasecmp(prop->name, "crtc_id")) + output->crtcIdPropertyId = prop->prop_id; + }); + + drmModeFreeObjectProperties(objProps); +} + +void QKmsDevice::parseCrtcProperties(uint32_t crtcId, QKmsOutput *output) +{ + drmModeObjectPropertiesPtr objProps = drmModeObjectGetProperties(m_dri_fd, crtcId, DRM_MODE_OBJECT_CRTC); + if (!objProps) { + qCDebug(qLcKmsDebug, "Failed to query crtc %d object properties", crtcId); + return; + } + + enumerateProperties(objProps, [output](drmModePropertyPtr prop, quint64 value) { + Q_UNUSED(value) + if (!strcasecmp(prop->name, "mode_id")) + output->modeIdPropertyId = prop->prop_id; + else if (!strcasecmp(prop->name, "active")) + output->activePropertyId = prop->prop_id; + }); + + drmModeFreeObjectProperties(objProps); +} + QKmsScreenConfig *QKmsDevice::screenConfig() const { return m_screenConfig; diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index 5eecedec39..403972fbb8 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -53,6 +53,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qpa/qplatformscreen.h> #include <QtCore/QMap> #include <QtCore/QVariant> @@ -166,6 +167,17 @@ struct QKmsPlane Rotations initialRotation = Rotation0; Rotations availableRotations = Rotation0; uint32_t rotationPropertyId = 0; + uint32_t crtcPropertyId = 0; + uint32_t framebufferPropertyId = 0; + uint32_t srcXPropertyId = 0; + uint32_t srcYPropertyId = 0; + uint32_t crtcXPropertyId = 0; + uint32_t crtcYPropertyId = 0; + uint32_t srcwidthPropertyId = 0; + uint32_t srcheightPropertyId = 0; + uint32_t crtcwidthPropertyId = 0; + uint32_t crtcheightPropertyId = 0; + uint32_t zposPropertyId = 0; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QKmsPlane::Rotations) @@ -191,6 +203,13 @@ struct QKmsOutput uint32_t drm_format = DRM_FORMAT_XRGB8888; QString clone_source; QVector<QKmsPlane> available_planes; + struct QKmsPlane *eglfs_plane = nullptr; + QSize size; + uint32_t crtcIdPropertyId = 0; + uint32_t modeIdPropertyId = 0; + uint32_t activePropertyId = 0; + + uint32_t mode_blob_id = 0; void restoreMode(QKmsDevice *device); void cleanup(QKmsDevice *device); @@ -215,6 +234,14 @@ public: virtual void close() = 0; virtual void *nativeDisplay() const = 0; + bool hasAtomicSupport(); + +#if QT_CONFIG(drm_atomic) + bool atomicCommit(void *user_data); + void atomicReset(); + + drmModeAtomicReq *atomic_request(); +#endif void createScreens(); int fd() const; @@ -243,11 +270,19 @@ protected: typedef std::function<void(drmModePropertyPtr, quint64)> PropCallback; void enumerateProperties(drmModeObjectPropertiesPtr objProps, PropCallback callback); void discoverPlanes(); + void parseConnectorProperties(uint32_t connectorId, QKmsOutput *output); + void parseCrtcProperties(uint32_t crtcId, QKmsOutput *output); QKmsScreenConfig *m_screenConfig; QString m_path; int m_dri_fd; + bool m_has_atomic_support; + +#if QT_CONFIG(drm_atomic) + drmModeAtomicReq *m_atomic_request; + drmModeAtomicReq *m_previous_request; +#endif quint32 m_crtc_allocator; QVector<QKmsPlane> m_planes; diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index cb1e367b9f..5b15cccaf1 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -177,6 +177,41 @@ static inline bool checkRunningUnderFlatpak() return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty(); } +static inline bool flatpakOpenFile(const QUrl &url) +{ + // DBus signature: + // OpenFile (IN s parent_window, + // IN h fd, + // IN a{sv} options, + // OUT o handle) + // Options: + // handle_token (s) - A string that will be used as the last element of the @handle. + // writable (b) - Whether to allow the chosen application to write to the file. + +#ifdef O_PATH + const int fd = qt_safe_open(QFile::encodeName(url.toLocalFile()), O_PATH); + if (fd != -1) { + QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"), + QLatin1String("/org/freedesktop/portal/desktop"), + QLatin1String("org.freedesktop.portal.OpenURI"), + QLatin1String("OpenFile")); + + QDBusUnixFileDescriptor descriptor(fd); + qt_safe_close(fd); + + // FIXME parent_window_id and handle writable option + message << QString() << QVariant::fromValue(descriptor) << QVariantMap(); + + QDBusPendingReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(message); + return !reply.isError(); + } +#else + Q_UNUSED(url) +#endif + + return false; +} + static inline bool flatpakOpenUrl(const QUrl &url) { // DBus signature: @@ -185,6 +220,7 @@ static inline bool flatpakOpenUrl(const QUrl &url) // IN a{sv} options, // OUT o handle) // Options: + // handle_token (s) - A string that will be used as the last element of the @handle. // writable (b) - Whether to allow the chosen application to write to the file. // This key only takes effect the uri points to a local file that is exported in the document portal, // and the chosen application is sandboxed itself. @@ -278,6 +314,11 @@ bool QGenericUnixServices::openUrl(const QUrl &url) bool QGenericUnixServices::openDocument(const QUrl &url) { +#if QT_CONFIG(dbus) + if (checkRunningUnderFlatpak()) + return flatpakOpenFile(url); +#endif + if (m_documentLauncher.isEmpty() && !detectWebBrowser(desktopEnvironment(), false, &m_documentLauncher)) { qWarning("Unable to detect a launcher for '%s'", qPrintable(url.toString())); return false; diff --git a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp index 382d142334..b9c5669b3f 100644 --- a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp +++ b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp @@ -82,6 +82,21 @@ QBasicPlatformVulkanInstance::~QBasicPlatformVulkanInstance() m_vkDestroyInstance(m_vkInst, nullptr); } +void QBasicPlatformVulkanInstance::loadVulkanLibrary(const QString &defaultLibraryName) +{ + if (qEnvironmentVariableIsSet("QT_VULKAN_LIB")) + m_vulkanLib.setFileName(QString::fromUtf8(qgetenv("QT_VULKAN_LIB"))); + else + m_vulkanLib.setFileName(defaultLibraryName); + + if (!m_vulkanLib.load()) { + qWarning("Failed to load %s: %s", qPrintable(m_vulkanLib.fileName()), qPrintable(m_vulkanLib.errorString())); + return; + } + + init(&m_vulkanLib); +} + void QBasicPlatformVulkanInstance::init(QLibrary *lib) { if (m_vkGetInstanceProcAddr) @@ -256,6 +271,11 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const if (!m_getPhysDevSurfaceSupport) qWarning("Failed to find vkGetPhysicalDeviceSurfaceSupportKHR"); + m_destroySurface = reinterpret_cast<PFN_vkDestroySurfaceKHR>( + m_vkGetInstanceProcAddr(m_vkInst, "vkDestroySurfaceKHR")); + if (!m_destroySurface) + qWarning("Failed to find vkDestroySurfaceKHR"); + if (!flags.testFlag(QVulkanInstance::NoDebugOutputRedirect)) setupDebugOutput(); } @@ -310,6 +330,12 @@ bool QBasicPlatformVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevi return supported; } +void QBasicPlatformVulkanInstance::destroySurface(VkSurfaceKHR surface) const +{ + if (m_destroySurface && surface) + m_destroySurface(m_vkInst, surface, nullptr); +} + static VKAPI_ATTR VkBool32 VKAPI_CALL defaultDebugCallbackFunc(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, diff --git a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h index 748b138f01..566140b032 100644 --- a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h +++ b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtCore/QLibrary> #include <qpa/qplatformvulkaninstance.h> QT_BEGIN_NAMESPACE @@ -72,18 +73,23 @@ public: QByteArrayList enabledExtensions() const override; PFN_vkVoidFunction getInstanceProcAddr(const char *name) override; bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override; + void destroySurface(VkSurfaceKHR surface) const; protected: + void loadVulkanLibrary(const QString &defaultLibraryName); void init(QLibrary *lib); void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts); VkInstance m_vkInst; PFN_vkGetInstanceProcAddr m_vkGetInstanceProcAddr; PFN_vkGetPhysicalDeviceSurfaceSupportKHR m_getPhysDevSurfaceSupport; + PFN_vkDestroySurfaceKHR m_destroySurface; private: void setupDebugOutput(); + QLibrary m_vulkanLib; + bool m_ownsVkInst; VkResult m_errorCode; QVulkanInfoVector<QVulkanLayer> m_supportedLayers; |