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
qandroidplatformvulkanwindow.cpp
Go to the documentation of this file.
1
// Copyright (C) 2017 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
// Qt-Security score:significant reason:default
4
5
#
include
"androidjnimain.h"
6
#
include
"qandroidplatformscreen.h"
7
#
include
"qandroidplatformvulkanwindow.h"
8
9
#
include
<
QSurfaceFormat
>
10
#
include
<
qpa
/
qplatformscreen
.
h
>
11
#
include
<
qpa
/
qwindowsysteminterface
.
h
>
12
13
#
include
<
android
/
native_window
.
h
>
14
#
include
<
android
/
native_window_jni
.
h
>
15
16
QT_BEGIN_NAMESPACE
17
18
using
namespace
Qt::StringLiterals;
19
20
QAndroidPlatformVulkanWindow
::
QAndroidPlatformVulkanWindow
(QWindow *window)
21
:
QAndroidPlatformWindow
(
window
)
22
{
23
}
24
25
QAndroidPlatformVulkanWindow
::~
QAndroidPlatformVulkanWindow
()
26
{
27
// The base class destructor can't reach destroyWindowSurface().
28
destroySurface
();
29
}
30
31
void
QAndroidPlatformVulkanWindow
::
setGeometry
(
const
QRect &rect)
32
{
33
QAndroidPlatformWindow
::
setGeometry
(rect);
34
35
// Like the OpenGL window, programmatic resizes need an expose to
36
// re-layout widget-embedded scenes.
37
if
(!rect.isEmpty() && !screen()->availableGeometry().isEmpty())
38
QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), rect.size())));
39
}
40
41
QSurfaceFormat
QAndroidPlatformVulkanWindow
::
format
()
const
42
{
43
return
window()->requestedFormat();
44
}
45
46
VkSurfaceKHR
*
QAndroidPlatformVulkanWindow
::
vkSurface
()
47
{
48
if
(Q_LIKELY(m_vkSurface != VK_NULL_HANDLE))
49
return
&m_vkSurface;
50
ensureNativeWindow
();
51
if
(!m_nativeWindow)
52
return
&m_vkSurface;
53
54
QVulkanInstance *inst = window()->vulkanInstance();
55
if
(!inst) {
56
qWarning(
"Attempted to create Vulkan surface without an instance; "
57
"was QWindow::setVulkanInstance() called?"
);
58
return
&m_vkSurface;
59
}
60
if
(!m_createVkSurface) {
61
m_createVkSurface =
reinterpret_cast
<PFN_vkCreateAndroidSurfaceKHR>(
62
inst->getInstanceProcAddr(
"vkCreateAndroidSurfaceKHR"
));
63
}
64
if
(!m_destroyVkSurface) {
65
m_destroyVkSurface =
reinterpret_cast
<PFN_vkDestroySurfaceKHR>(
66
inst->getInstanceProcAddr(
"vkDestroySurfaceKHR"
));
67
}
68
VkAndroidSurfaceCreateInfoKHR surfaceInfo {};
69
surfaceInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
70
surfaceInfo.window = m_nativeWindow;
71
const
VkResult err = m_createVkSurface(inst->vkInstance(), &surfaceInfo,
nullptr
, &m_vkSurface);
72
if
(err != VK_SUCCESS)
73
qWarning(
"Failed to create Android VkSurface: %d"
, err);
74
return
&m_vkSurface;
75
}
76
77
void
QAndroidPlatformVulkanWindow
::
destroyWindowSurface
()
78
{
79
if
(m_vkSurface && m_destroyVkSurface) {
80
m_destroyVkSurface(window()->vulkanInstance()->vkInstance(), m_vkSurface,
nullptr
);
81
m_vkSurface = VK_NULL_HANDLE;
82
}
83
}
84
85
QT_END_NAMESPACE
QAndroidPlatformVulkanWindow
Definition
qandroidplatformvulkanwindow.h:23
QAndroidPlatformVulkanWindow::~QAndroidPlatformVulkanWindow
~QAndroidPlatformVulkanWindow()
Definition
qandroidplatformvulkanwindow.cpp:25
QAndroidPlatformVulkanWindow::QAndroidPlatformVulkanWindow
QAndroidPlatformVulkanWindow(QWindow *window)
Definition
qandroidplatformvulkanwindow.cpp:20
QAndroidPlatformVulkanWindow::setGeometry
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
Definition
qandroidplatformvulkanwindow.cpp:31
QAndroidPlatformVulkanWindow::vkSurface
VkSurfaceKHR * vkSurface()
Definition
qandroidplatformvulkanwindow.cpp:46
QAndroidPlatformVulkanWindow::format
QSurfaceFormat format() const override
Returns the actual surface format of the window.
Definition
qandroidplatformvulkanwindow.cpp:41
QAndroidPlatformVulkanWindow::destroyWindowSurface
void destroyWindowSurface() override
Definition
qandroidplatformvulkanwindow.cpp:77
QAndroidPlatformWindow
Definition
qandroidplatformwindow.h:41
QAndroidPlatformWindow::QAndroidPlatformWindow
QAndroidPlatformWindow(QWindow *window)
QAndroidPlatformWindow::ensureNativeWindow
void ensureNativeWindow()
Definition
qandroidplatformwindow.cpp:421
QAndroidPlatformWindow::destroySurface
void destroySurface()
Definition
qandroidplatformwindow.cpp:521
QAndroidPlatformWindow::setGeometry
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
Definition
qandroidplatformwindow.cpp:143
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
plugins
platforms
android
qandroidplatformvulkanwindow.cpp
Generated on
for Qt by
1.18.0