From 078d5ac5b504f397306f10b029c098506fe331e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Tue, 22 Jul 2014 17:16:54 +0200 Subject: [PATCH] Add support for EGL_EXT_platform_wayland --- egl_wayland_backend.cpp | 30 ++++++++++++++++++++++++++++-- egl_wayland_backend.h | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/egl_wayland_backend.cpp b/egl_wayland_backend.cpp index 9a3aec4134..f86815f6d8 100644 --- a/egl_wayland_backend.cpp +++ b/egl_wayland_backend.cpp @@ -79,7 +79,29 @@ EglWaylandBackend::~EglWaylandBackend() bool EglWaylandBackend::initializeEgl() { - m_display = eglGetDisplay(m_wayland->display()); + // Get the list of client extensions + const QByteArray clientExtensionString = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + if (clientExtensionString.isEmpty()) { + // If eglQueryString() returned NULL, the implementation doesn't support + // EGL_EXT_client_extensions. Expect an EGL_BAD_DISPLAY error. + (void) eglGetError(); + } + + const QList clientExtensions = clientExtensionString.split(' '); + + // Use eglGetPlatformDisplayEXT() to get the display pointer + // if the implementation supports it. + m_havePlatformBase = clientExtensions.contains("EGL_EXT_platform_base"); + if (m_havePlatformBase) { + // Make sure that the wayland platform is supported + if (!clientExtensions.contains("EGL_EXT_platform_wayland")) + return false; + + m_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_WAYLAND_EXT, m_wayland->display(), nullptr); + } else { + m_display = eglGetDisplay(m_wayland->display()); + } + if (m_display == EGL_NO_DISPLAY) return false; @@ -180,7 +202,11 @@ bool EglWaylandBackend::initRenderingContext() return false; } - m_surface = eglCreateWindowSurface(m_display, m_config, m_overlay, NULL); + if (m_havePlatformBase) + m_surface = eglCreatePlatformWindowSurfaceEXT(m_display, m_config, (void *) m_overlay, nullptr); + else + m_surface = eglCreateWindowSurface(m_display, m_config, m_overlay, nullptr); + if (m_surface == EGL_NO_SURFACE) { qCritical() << "Create Window Surface failed"; return false; diff --git a/egl_wayland_backend.h b/egl_wayland_backend.h index ea04559743..4c7ab6babe 100644 --- a/egl_wayland_backend.h +++ b/egl_wayland_backend.h @@ -92,6 +92,7 @@ private: wl_egl_window *m_overlay; QScopedPointer m_shm; bool m_lastFrameRendered; + bool m_havePlatformBase; friend class EglWaylandTexture; };