qtbase/src/plugins/platforms/android/qandroidplatformvulkanwindow.h
Tinja Paavoseppä 6eb29cab2a Android: clean up Surface resources when it is destroyed
Clean up any resources using the Android Surface when it
has been destroyed. Previously the resource clean up was done
only after Qt app state changed to Hidden or below and we initiate
the removal of the Surface. However, in the case of QtSurface
which is a SurfaceView, it will destroy its Surface before
we ever get to that part, leading to the resources holding
a reference to a destroyed Surface.

Task-number: QTBUG-118231
Change-Id: I282ddcc2813bf0a4e19cbb906376258dd2b4004f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 9343d1ab6e1a5df3166d211809f2eb0e5a3cd878)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-02 09:15:14 +00:00

50 lines
1.3 KiB
C++

// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QANDROIDPLATFORMVULKANWINDOW_H
#define QANDROIDPLATFORMVULKANWINDOW_H
#if defined(VULKAN_H_) && !defined(VK_USE_PLATFORM_ANDROID_KHR)
#error "vulkan.h included without Android WSI"
#endif
#define VK_USE_PLATFORM_ANDROID_KHR
#include "qandroidplatformvulkaninstance.h"
#include "qandroidplatformwindow.h"
#include <QWaitCondition>
#include <QtCore/QJniEnvironment>
#include <QtCore/QJniObject>
QT_BEGIN_NAMESPACE
class QAndroidPlatformVulkanWindow : public QAndroidPlatformWindow
{
public:
explicit QAndroidPlatformVulkanWindow(QWindow *window);
~QAndroidPlatformVulkanWindow();
void setGeometry(const QRect &rect) override;
QSurfaceFormat format() const override;
void applicationStateChanged(Qt::ApplicationState) override;
VkSurfaceKHR *vkSurface();
protected:
void clearSurface() override;
private:
void destroyAndClearSurface();
ANativeWindow *m_nativeWindow;
QSurfaceFormat m_format;
VkSurfaceKHR m_vkSurface;
PFN_vkCreateAndroidSurfaceKHR m_createVkSurface;
PFN_vkDestroySurfaceKHR m_destroyVkSurface;
};
QT_END_NAMESPACE
#endif // QANDROIDPLATFORMVULKANWINDOW_H