Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qohosvulkansurface.cpp
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qohosvulkansurface.h"
5
6
#
include
<
QtCore
/
private
/
qohoslogger_p
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
void
QOhosVulkanSurface::setNativeWindowSurface(::OHNativeWindow *nativeWindow)
11
{
12
m_nativeWindow = nativeWindow;
13
}
14
15
VkSurfaceKHR *QOhosVulkanSurface::tryGetOrCreateVulkanWindowSurface(VkInstance instance,
16
PFN_vkCreateSurfaceOHOS createFn,
17
PFN_vkDestroySurfaceKHR destroyFn)
18
{
19
const
bool
surfaceValid = m_vulkanSurface.has_value() && m_surfaceNativeWindow == m_nativeWindow;
20
if
(surfaceValid)
21
return
&m_vulkanSurface->surface;
22
23
// safe to destroy: the RHI guarantees all swapchains are destroyed before requesting a new surface
24
m_vulkanSurface.reset();
25
26
if
(!createFn) {
27
qCWarning(QtForOhos,
"%s: vkCreateSurfaceOHOS not available"
, Q_FUNC_INFO);
28
return
nullptr
;
29
}
30
31
VkSurfaceCreateInfoOHOS surfaceInfo{};
32
surfaceInfo.sType = VK_STRUCTURE_TYPE_SURFACE_CREATE_INFO_OHOS;
33
surfaceInfo.pNext =
nullptr
;
34
surfaceInfo.flags = 0;
35
surfaceInfo.window = m_nativeWindow;
36
37
VkSurfaceKHR vkSurface = VK_NULL_HANDLE;
38
VkResult err = createFn(instance, &surfaceInfo,
nullptr
, &vkSurface);
39
if
(err != VK_SUCCESS) {
40
qCWarning(QtForOhos,
"%s: Failed to create OHOS VkSurface: %d"
, Q_FUNC_INFO, err);
41
return
nullptr
;
42
}
43
44
m_vulkanSurface.emplace(instance, vkSurface, destroyFn);
45
m_surfaceNativeWindow = m_nativeWindow;
46
47
return
&m_vulkanSurface->surface;
48
}
49
50
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
plugins
platforms
ohos
render
qohosvulkansurface.cpp
Generated on
for Qt by
1.18.0