Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qxcbvulkanwindow.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
6
8
10 : QXcbWindow(window),
11 m_surface(VK_NULL_HANDLE)
12{
13}
14
15QXcbVulkanWindow::~QXcbVulkanWindow()
16{
17 if (m_surface) {
18 QVulkanInstance *inst = window()->vulkanInstance();
19 if (inst)
20 static_cast<QXcbVulkanInstance *>(inst->handle())->destroySurface(m_surface);
21 }
22}
23
24void QXcbVulkanWindow::resolveFormat(const QSurfaceFormat &format)
25{
26 m_format = format;
27 if (m_format.redBufferSize() <= 0)
28 m_format.setRedBufferSize(8);
29 if (m_format.greenBufferSize() <= 0)
30 m_format.setGreenBufferSize(8);
31 if (m_format.blueBufferSize() <= 0)
32 m_format.setBlueBufferSize(8);
33}
34
35// No createVisual() needed, use the default that picks one based on the R/G/B/A size.
36
38{
39 if (m_surface)
40 return &m_surface;
41
42 QVulkanInstance *inst = window()->vulkanInstance();
43 if (!inst) {
44 qWarning("Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?");
45 return nullptr;
46 }
47 QXcbVulkanInstance *xcbinst = static_cast<QXcbVulkanInstance *>(inst->handle());
48 m_surface = xcbinst->createSurface(this);
49
50 return &m_surface;
51}
52
53QT_END_NAMESPACE
\inmodule QtGui
Definition qwindow.h:63
VkSurfaceKHR * surface()
void resolveFormat(const QSurfaceFormat &format) override