summaryrefslogtreecommitdiffstats
path: root/src/hardwareintegration/client/wayland-egl
diff options
context:
space:
mode:
authorGiulio Camuffo <giulio.camuffo@kdab.com>2016-06-02 12:57:47 +0300
committerGiulio Camuffo <giulio.camuffo@kdab.com>2016-06-21 08:15:06 +0000
commit6de4e14d6ba632ee32df2a703e0a6e6660fa61f6 (patch)
tree9b1c36efecdd82f954ac94bda6c67d9af4d28870 /src/hardwareintegration/client/wayland-egl
parent8b3626b9a48fcf303cd7a20aede9a1577311a684 (diff)
Use the EGL_EXT_platform_wayland extension if available
This allows to avoid polluting the environment with the EGL_PLATFORM variable, and conversely to avoid relying on it and still be sure to get a valid display. Change-Id: I3dd4b62b1358fdc0ba8a5cedb1233e13405611df Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/hardwareintegration/client/wayland-egl')
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp36
-rw-r--r--src/hardwareintegration/client/wayland-egl/wayland-egl.pri1
2 files changed, 32 insertions, 5 deletions
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp
index 0843badc9..771b4b2e4 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp
@@ -45,6 +45,15 @@
#include <wayland-client.h>
#include <QtCore/QDebug>
+#include <private/qeglconvenience_p.h>
+
+#ifndef EGL_EXT_platform_base
+typedef EGLDisplay (*PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
+#endif
+
+#ifndef EGL_PLATFORM_WAYLAND_KHR
+#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
+#endif
QT_BEGIN_NAMESPACE
@@ -70,20 +79,37 @@ QWaylandEglClientBufferIntegration::~QWaylandEglClientBufferIntegration()
void QWaylandEglClientBufferIntegration::initialize(QWaylandDisplay *display)
{
- QByteArray eglPlatform = qgetenv("EGL_PLATFORM");
- if (eglPlatform.isEmpty()) {
- setenv("EGL_PLATFORM","wayland",true);
+ if (q_hasEglExtension(EGL_NO_DISPLAY, "EGL_EXT_platform_base")) {
+ if (q_hasEglExtension(EGL_NO_DISPLAY, "EGL_KHR_platform_wayland") ||
+ q_hasEglExtension(EGL_NO_DISPLAY, "EGL_EXT_platform_wayland") ||
+ q_hasEglExtension(EGL_NO_DISPLAY, "EGL_MESA_platform_wayland")) {
+
+ static PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplay = nullptr;
+ if (!eglGetPlatformDisplay)
+ eglGetPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
+
+ m_eglDisplay = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, display->wl_display(), nullptr);
+ } else {
+ qWarning("The EGL implementation does not support the Wayland platform");
+ return;
+ }
+ } else {
+ QByteArray eglPlatform = qgetenv("EGL_PLATFORM");
+ if (eglPlatform.isEmpty()) {
+ setenv("EGL_PLATFORM","wayland",true);
+ }
+
+ m_eglDisplay = eglGetDisplay((EGLNativeDisplayType) display->wl_display());
}
m_display = display;
- EGLint major,minor;
- m_eglDisplay = eglGetDisplay((EGLNativeDisplayType) display->wl_display());
if (m_eglDisplay == EGL_NO_DISPLAY) {
qWarning("EGL not available");
return;
}
+ EGLint major,minor;
if (!eglInitialize(m_eglDisplay, &major, &minor)) {
qWarning("failed to initialize EGL display");
m_eglDisplay = EGL_NO_DISPLAY;
diff --git a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri
index 6768307dc..c5e01f125 100644
--- a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri
+++ b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri
@@ -7,6 +7,7 @@ INCLUDEPATH += $$PWD
}
CONFIG += egl
+QT += platformsupport-private
SOURCES += $$PWD/qwaylandeglclientbufferintegration.cpp \
$$PWD/qwaylandglcontext.cpp \