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
qwltextureorphanage.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
6#include <QOpenGLContext>
7#include <QOpenGLTexture>
8#include <QDebug>
9#include <QtTypeTraits>
10#include <QMutexLocker>
11
13
14Q_LOGGING_CATEGORY(qLcWTO, "qt.waylandcompositor.orphanage")
15
16Q_GLOBAL_STATIC(QtWayland::QWaylandTextureOrphanage, inst)
17
18namespace QtWayland {
19
21{
24 qCWarning(qLcWTO) << Q_FUNC_INFO << "m_orphanedTextures container isn't empty! content:"
26 }
27}
28
33
35{
36 qCDebug(qLcWTO) << Q_FUNC_INFO << "got a texture (" << (void *)tex
37 << ") ready to be deleted! It's ctx:" << ctx;
38
39 {
42 }
43
45 [this, ctx]() { this->onContextAboutToBeDestroyed(ctx); },
47}
48
50{
52
53 if (cCtx == nullptr) {
54 qCWarning(qLcWTO) << Q_FUNC_INFO << "cannot delete textures without current OpenGL context";
55 return;
56 }
57
58 {
60
63
64 qCDebug(qLcWTO) << Q_FUNC_INFO << "currentContext (" << cCtx
65 << ") and ctx of orphane(s) (" << aCtx
66 << ") are shared! => deleteTexturesByContext";
67
69 }
70 }
71 }
72}
73
75{
76 Q_ASSERT(ctx != nullptr);
77
78 qCDebug(qLcWTO) << Q_FUNC_INFO << " ctx (" << ctx
79 << ") fired aboutToBeDestroyed => deleteTexturesByContext(ctx)";
80
81 {
84 }
85}
86
88{
89 // NOTE: We are (by class-internal design) locked (m_containerLock)
90 // when we enter this function!
91 // If not (e.g.: someone changes something in/around this class),
92 // then in a debug-build we will fail below:
94
97
99 delete tex;
100 qCDebug(qLcWTO) << Q_FUNC_INFO << " texture (" << (void *)tex << ") got deleted";
101 }
102}
103
104} // namespace QtWayland
105
106QT_END_NAMESPACE
107
108#include "moc_qwltextureorphanage_p.cpp"