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
qgstreameregldisplay.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#if QT_CONFIG(gstreamer_gl) && QT_CONFIG(gstreamer_gl_egl)
7
8#include <QtCore/qapplicationstatic.h>
9#include <QtCore/qmutex.h>
10#include <QtCore/qthread.h>
11#include <QtGui/qguiapplication.h>
12#include <QtGui/qpa/qplatformnativeinterface.h>
13
14#if QT_CONFIG(linux_dmabuf)
15# include <QtMultimedia/private/qdmabuftextureimporter_p.h>
16#endif
17
18QT_BEGIN_NAMESPACE
19
20struct EglHolder
21{
22 QMutex mutex;
23 Qt::HANDLE display = nullptr;
24
25 void queryDisplay()
26 {
27 Q_ASSERT(QThread::isMainThread());
28 using namespace Qt::StringLiterals;
29 auto *pni = qGuiApp ? qGuiApp->platformNativeInterface() : nullptr;
30 display = pni ? pni->nativeResourceForIntegration("egldisplay"_ba) : nullptr;
31 }
32};
33
34Q_APPLICATION_STATIC(EglHolder, s_eglHolder);
35
36Qt::HANDLE qGstEglDisplay()
37{
38 EglHolder *holder = s_eglHolder();
39 QMutexLocker lock(&holder->mutex);
40 if (!holder->display && QThread::isMainThread())
41 holder->queryDisplay();
42 return holder->display;
43}
44
45# if QT_CONFIG(linux_dmabuf)
46bool qGstEglCanMapDmaBuf()
47{
48 using namespace QtMultimediaPrivate;
49
50 EglHolder *holder = s_eglHolder();
51 QMutexLocker lock(&holder->mutex);
52 if (!holder->display && QThread::isMainThread())
53 holder->queryDisplay();
54 return (holder->display && QEglImageFunctions::instance().isValid());
55}
56# endif
57
58QT_END_NAMESPACE
59
60#endif // QT_CONFIG(gstreamer_gl) && QT_CONFIG(gstreamer_gl_egl)