diff options
Diffstat (limited to 'src/compositor/hardware_integration/qwltextureorphanage_p.h')
-rw-r--r-- | src/compositor/hardware_integration/qwltextureorphanage_p.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/compositor/hardware_integration/qwltextureorphanage_p.h b/src/compositor/hardware_integration/qwltextureorphanage_p.h new file mode 100644 index 000000000..f040ec750 --- /dev/null +++ b/src/compositor/hardware_integration/qwltextureorphanage_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWLTEXTUREORPHANAGE_P_H +#define QWLTEXTUREORPHANAGE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QObject> +#include <QMutex> +#include <QLoggingCategory> +#include <QtWaylandCompositor/qtwaylandcompositorglobal.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLContext; +class QOpenGLTexture; + +Q_DECLARE_LOGGING_CATEGORY(qLcWTO) + +namespace QtWayland { + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextureOrphanage : public QObject +{ + Q_OBJECT + +public: + QWaylandTextureOrphanage(){}; + ~QWaylandTextureOrphanage(); + + static QWaylandTextureOrphanage *instance(); + + // texture that isn't needed anymore will be "take care of" (killed) appropriately + void admitTexture(QOpenGLTexture *tex, QOpenGLContext *ctx); + + // uses QOpenGLContext::currentContext to call deleteTexturesByContext on all shared ctx + void deleteTextures(); + +public Q_SLOTS: + // uses sender() to call deleteTexturesByContext + void onContextAboutToBeDestroyed(QOpenGLContext *ctx); + +private: + void deleteTexturesByContext(QOpenGLContext *ctx); + + // tracks all the orphanes that need to be deleted + QMultiHash<QOpenGLContext *, QOpenGLTexture *> m_orphanedTextures; + + QMutex m_containerLock; +}; + +} // namespace QtWayland + +QT_END_NAMESPACE +#endif |