summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <[email protected]>2025-05-30 12:01:49 +0200
committerGiuseppe D'Angelo <[email protected]>2025-05-30 19:45:39 +0200
commit7c0a96785fee4fea8ef1452166b1dde88957445c (patch)
treed742041c477af4850983ddbabe046d780286edca
parent89ec9276fc96569172bf74181dd92bbb20453dd7 (diff)
Wayland: support adoption of native EGL contextsHEADdev
QWaylandIntegration does not implement the QNativeInterface::Private::QEGLIntegration interface. This means that trying to create a QOpenGLContext from a native EGL context fails, and QNativeInterface::QEGLContext::fromNative() always returns nullptr. This commit makes QWaylandIntegration inherit from QEGLIntegration and implement its interface. This in turn requires adding a new API to the HW interfaces (implemented by both the EGL and the brcm-egl integrations) to request adoption of a native context. Fixes: QTBUG-110758 Change-Id: I81c08fcf1110b5e9e1d8739532df9ce78410d694 Reviewed-by: David Edmundson <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]>
-rw-r--r--src/plugins/platforms/wayland/hardwareintegration/qwaylandclientbufferintegration_p.h3
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.cpp5
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.h1
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.cpp2
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.h1
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration.cpp5
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h1
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp2
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h1
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp5
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration_p.h5
11 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/platforms/wayland/hardwareintegration/qwaylandclientbufferintegration_p.h b/src/plugins/platforms/wayland/hardwareintegration/qwaylandclientbufferintegration_p.h
index e8b78c52b67..3a42dcb62e7 100644
--- a/src/plugins/platforms/wayland/hardwareintegration/qwaylandclientbufferintegration_p.h
+++ b/src/plugins/platforms/wayland/hardwareintegration/qwaylandclientbufferintegration_p.h
@@ -17,10 +17,12 @@
#include <QtCore/private/qglobal_p.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtGui/private/qeglplatformcontext_p.h>
QT_BEGIN_NAMESPACE
class QWindow;
+class QOpenGLContext;
class QPlatformOpenGLContext;
class QSurfaceFormat;
@@ -44,6 +46,7 @@ public:
virtual QWaylandWindow *createEglWindow(QWindow *window) = 0;
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const = 0;
+ virtual QOpenGLContext *createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const = 0;
enum NativeResource {
EglDisplay,
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.cpp b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.cpp
index 8f9047993ed..4ac04a53583 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.cpp
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.cpp
@@ -84,6 +84,11 @@ QPlatformOpenGLContext *QWaylandBrcmEglIntegration::createPlatformOpenGLContext(
return new QWaylandBrcmGLContext(m_eglDisplay, glFormat, share);
}
+QOpenGLContext *QWaylandBrcmEglIntegration::createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const
+{
+ return QEGLPlatformContext::createFrom<QWaylandBrcmGLContext>(context, contextDisplay, m_eglDisplay, shareContext);
+}
+
EGLDisplay QWaylandBrcmEglIntegration::eglDisplay() const
{
return m_eglDisplay;
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.h
index ac164ab9dac..50c51bf094c 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmeglintegration.h
@@ -38,6 +38,7 @@ public:
QWaylandWindow *createEglWindow(QWindow *window);
QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const override;
+ QOpenGLContext *createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const override;
EGLDisplay eglDisplay() const;
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.cpp b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.cpp
index 66135a7cc43..5265256544b 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.cpp
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.cpp
@@ -20,6 +20,8 @@ namespace QtWaylandClient {
extern QSurfaceFormat brcmFixFormat(const QSurfaceFormat &format);
+QWaylandBrcmGLContext::QWaylandBrcmGLContext() = default;
+
QWaylandBrcmGLContext::QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share)
: QPlatformOpenGLContext()
, m_eglDisplay(eglDisplay)
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.h
index e64a20d9b73..4ff73f9c13a 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/qwaylandbrcmglcontext.h
@@ -18,6 +18,7 @@ class QWaylandWindow;
class QWaylandBrcmGLContext : public QPlatformOpenGLContext {
public:
+ QWaylandBrcmGLContext();
QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share);
~QWaylandBrcmGLContext();
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration.cpp b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration.cpp
index 3b97aef208b..562e02390ca 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration.cpp
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration.cpp
@@ -129,6 +129,11 @@ QPlatformOpenGLContext *QWaylandEglClientBufferIntegration::createPlatformOpenGL
return new QWaylandGLContext(m_eglDisplay, m_display, fmt, share);
}
+QOpenGLContext *QWaylandEglClientBufferIntegration::createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const
+{
+ return QEGLPlatformContext::createFrom<QWaylandGLContext>(context, contextDisplay, m_eglDisplay, shareContext);
+}
+
void *QWaylandEglClientBufferIntegration::nativeResource(NativeResource resource)
{
switch (resource) {
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h
index ed8fdec2d94..2d003305b11 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h
@@ -40,6 +40,7 @@ public:
QWaylandWindow *createEglWindow(QWindow *window) override;
QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const override;
+ QOpenGLContext *createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const override;
void *nativeResource(NativeResource resource) override;
void *nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context) override;
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp
index be5a36fa01a..a3e6c534663 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext.cpp
@@ -191,6 +191,8 @@ public:
int m_textureWrap;
};
+QWaylandGLContext::QWaylandGLContext() = default;
+
QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *display,
const QSurfaceFormat &fmt, QPlatformOpenGLContext *share)
: QEGLPlatformContext(fmt, share, eglDisplay)
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h
index bd9eb53f85e..e653e60e215 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h
@@ -34,6 +34,7 @@ class DecorationsBlitter;
class Q_WAYLANDCLIENT_EXPORT QWaylandGLContext : public QEGLPlatformContext
{
public:
+ QWaylandGLContext();
QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *display, const QSurfaceFormat &format, QPlatformOpenGLContext *share);
~QWaylandGLContext();
void swapBuffers(QPlatformSurface *surface) override;
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
index b0033876bba..772143c12f8 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.cpp
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -161,6 +161,11 @@ QPlatformOpenGLContext *QWaylandIntegration::createPlatformOpenGLContext(QOpenGL
return mDisplay->clientBufferIntegration()->createPlatformOpenGLContext(context->format(), context->shareHandle());
return nullptr;
}
+
+QOpenGLContext *QWaylandIntegration::createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const
+{
+ return mClientBufferIntegration->createOpenGLContext(context, contextDisplay, shareContext);
+}
#endif // opengl
QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow *window) const
diff --git a/src/plugins/platforms/wayland/qwaylandintegration_p.h b/src/plugins/platforms/wayland/qwaylandintegration_p.h
index e379668adb4..d799555570d 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration_p.h
+++ b/src/plugins/platforms/wayland/qwaylandintegration_p.h
@@ -17,6 +17,7 @@
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformopenglcontext.h>
#include <QtCore/QScopedPointer>
#include <QtCore/QMutex>
#include <QtCore/private/qglobal_p.h>
@@ -37,6 +38,9 @@ class QWaylandCursor;
class QWaylandPlatformServices;
class Q_WAYLANDCLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
+#if QT_CONFIG(opengl)
+ , public QNativeInterface::Private::QEGLIntegration
+#endif
{
public:
QWaylandIntegration(const QString &platformName);
@@ -50,6 +54,7 @@ public:
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
#if QT_CONFIG(opengl)
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
+ QOpenGLContext *createOpenGLContext(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext) const override;
#endif
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;