blob: f040ec750c435f0840d8b2ae7730ed8f561aec3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
|