qtbase/src/plugins/platforms/android/qandroidplatformopenglwindow.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

46 lines
1.2 KiB
C++

// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
// Copyright (C) 2016 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 QANDROIDPLATFORMOPENGLWINDOW_H
#define QANDROIDPLATFORMOPENGLWINDOW_H
#include "qandroidplatformwindow.h"
#include <QWaitCondition>
#include <QtCore/qjnienvironment.h>
#include <QtCore/qjniobject.h>
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
class QAndroidPlatformOpenGLWindow : public QAndroidPlatformWindow
{
public:
explicit QAndroidPlatformOpenGLWindow(QWindow *window, EGLDisplay display);
~QAndroidPlatformOpenGLWindow();
void setGeometry(const QRect &rect) override;
EGLSurface eglSurface(EGLConfig config);
QSurfaceFormat format() const override;
bool checkNativeSurface(EGLConfig config);
void applicationStateChanged(Qt::ApplicationState) override;
protected:
void createEgl(EGLConfig config);
void clearSurface() override;
private:
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
EGLSurface m_eglSurface = EGL_NO_SURFACE;
EGLNativeWindowType m_nativeWindow = nullptr;
QSurfaceFormat m_format;
};
QT_END_NAMESPACE
#endif // QANDROIDPLATFORMOPENGLWINDOW_H