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#include <EGL/egl.h>
15
16QT_BEGIN_NAMESPACE
17
18struct EglHolder
19{
20 QMutex mutex;
21 Qt::HANDLE display = nullptr;
22
23# if QT_CONFIG(linux_dmabuf)
24 QFunctionPointer targetTexture2D = eglGetProcAddress("glEGLImageTargetTexture2DOES");
25# endif
26
27 void queryDisplay()
28 {
29 Q_ASSERT(QThread::isMainThread());
30 using namespace Qt::StringLiterals;
31 auto *pni = qGuiApp ? qGuiApp->platformNativeInterface() : nullptr;
32 display = pni ? pni->nativeResourceForIntegration("egldisplay"_ba) : nullptr;
33 }
34};
35
36Q_APPLICATION_STATIC(EglHolder, s_eglHolder);
37
38Qt::HANDLE qGstEglDisplay()
39{
40 EglHolder *holder = s_eglHolder();
41 QMutexLocker lock(&holder->mutex);
42 if (!holder->display && QThread::isMainThread())
43 holder->queryDisplay();
44 return holder->display;
45}
46
47# if QT_CONFIG(linux_dmabuf)
48bool qGstEglCanMapDmaBuf()
49{
50 EglHolder *holder = s_eglHolder();
51 QMutexLocker lock(&holder->mutex);
52 if (!holder->display && QThread::isMainThread())
53 holder->queryDisplay();
54 return (holder->display && holder->targetTexture2D);
55}
56
57QFunctionPointer qGstEglImageTargetTexture2D()
58{
59 EglHolder *holder = s_eglHolder();
60 return holder->targetTexture2D;
61}
62# endif
63
64QT_END_NAMESPACE
65
66#endif // QT_CONFIG(gstreamer_gl) && QT_CONFIG(gstreamer_gl_egl)