[vlc-commits] egl: add Wayland extended platform support
Rémi Denis-Courmont
git at videolan.org
Thu Oct 16 19:26:14 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 27 20:11:24 2014 +0300| [9ef4ff3833c2c58767fa51abb63793b3fc2ae2ec] | committer: Rémi Denis-Courmont
egl: add Wayland extended platform support
This enables OpenGL/OpenGL ES through Wayland.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9ef4ff3833c2c58767fa51abb63793b3fc2ae2ec
---
configure.ac | 11 ++++++++
modules/video_output/Makefile.am | 8 ++++++
modules/video_output/egl.c | 52 ++++++++++++++++++++++++++++++++++++--
3 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index a1810b2..6fab05b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3205,8 +3205,19 @@ AS_IF([test "${enable_wayland}" != "no"], [
AC_MSG_ERROR([${WAYLAND_CLIENT_PKG_ERRORS}.])
])
])
+
+ AS_IF([test "${have_egl}" = "yes"], [
+ PKG_CHECK_MODULES([WAYLAND_EGL], [wayland-egl], [
+ have_wayland_egl="yes"
+ ], [
+ AS_IF([test -n "${enable_wayland}"], [
+ AC_MSG_ERROR([${WAYLAND_EGL_PKG_ERRORS}.])
+ ])
+ ])
+ ])
])
AM_CONDITIONAL([HAVE_WAYLAND], [test "${have_wayland}" = "yes"])
+AM_CONDITIONAL([HAVE_WAYLAND_EGL], [test "${have_wayland_egl}" = "yes"])
dnl
diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index c5db372..326a5a5 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -145,6 +145,14 @@ if HAVE_WAYLAND
vout_LTLIBRARIES += libwl_shell_surface_plugin.la
endif
+libegl_wl_plugin_la_SOURCES = video_output/egl.c
+libegl_wl_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PLATFORM_WAYLAND=1
+libegl_wl_plugin_la_CFLAGS = $(AM_CFLAGS) $(EGL_CFLAGS) $(WAYLAND_EGL_CFLAGS)
+libegl_wl_plugin_la_LIBADD = $(EGL_LIBS) $(WAYLAND_EGL_LIBS)
+if HAVE_EGL
+vout_LTLIBRARIES += libegl_wl_plugin.la
+endif
+
### Win32 ###
libdirect2d_plugin_la_SOURCES = video_output/msw/direct2d.c \
diff --git a/modules/video_output/egl.c b/modules/video_output/egl.c
index 81eaed3..adbc94e 100644
--- a/modules/video_output/egl.c
+++ b/modules/video_output/egl.c
@@ -3,7 +3,7 @@
* @brief EGL OpenGL extension module
*/
/*****************************************************************************
- * Copyright © 2010-2011 Rémi Denis-Courmont
+ * Copyright © 2010-2014 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
@@ -36,6 +36,9 @@
#ifdef USE_PLATFORM_X11
# include <vlc_xlib.h>
#endif
+#ifdef USE_PLATFORM_WAYLAND
+# include <wayland-egl.h>
+#endif
typedef struct vlc_gl_sys_t
{
@@ -45,6 +48,10 @@ typedef struct vlc_gl_sys_t
#if defined (USE_PLATFORM_X11)
Display *x11;
#endif
+#if defined (USE_PLATFORM_WAYLAND)
+ struct wl_egl_window *window;
+ unsigned width, height;
+#endif
} vlc_gl_sys_t;
static int MakeCurrent (vlc_gl_t *gl)
@@ -65,6 +72,21 @@ static void ReleaseCurrent (vlc_gl_t *gl)
EGL_NO_CONTEXT);
}
+#ifdef USE_PLATFORM_WAYLAND
+static void Resize (vlc_gl_t *gl, unsigned width, unsigned height)
+{
+ vlc_gl_sys_t *sys = gl->sys;
+
+ wl_egl_window_resize(sys->window, width, height,
+ (sys->width - width) / 2,
+ (sys->height - height) / 2);
+ sys->width = width;
+ sys->height = height;
+}
+#else
+# define Resize (NULL)
+#endif
+
static void SwapBuffers (vlc_gl_t *gl)
{
vlc_gl_sys_t *sys = gl->sys;
@@ -162,6 +184,10 @@ static void Close (vlc_object_t *obj)
if (sys->x11 != NULL)
XCloseDisplay(sys->x11);
#endif
+#ifdef USE_PLATFORM_WAYLAND
+ if (sys->window != NULL)
+ wl_egl_window_destroy(sys->window);
+#endif
free (sys);
}
@@ -222,6 +248,28 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
}
# endif
+#elif defined (USE_PLATFORM_WAYLAND)
+ sys->window = NULL;
+
+ if (wnd->type != VOUT_WINDOW_TYPE_WAYLAND)
+ goto error;
+
+# ifdef EGL_EXT_platform_wayland
+ if (!CheckClientExt("EGL_EXT_platform_wayland"))
+ goto error;
+
+ /* Resize() should be called with the proper size before Swap() */
+ window = wl_egl_window_create(wnd->handle.wl, 1, 1);
+ if (window == NULL)
+ goto error;
+ sys->window = window;
+
+ sys->display = GetDisplayEXT(EGL_PLATFORM_WAYLAND_EXT, wnd->display.wl,
+ NULL);
+ createSurface = CreateWindowSurfaceEXT;
+
+# endif
+
#elif defined (USE_PLATFORM_WIN32)
if (wnd->type != VOUT_WINDOW_TYPE_HWND)
goto error;
@@ -308,7 +356,7 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
/* Initialize OpenGL callbacks */
gl->makeCurrent = MakeCurrent;
gl->releaseCurrent = ReleaseCurrent;
- gl->resize = NULL;
+ gl->resize = Resize;
gl->swap = SwapBuffers;
gl->getProcAddress = GetSymbol;
gl->lock = NULL;
More information about the vlc-commits
mailing list