Commit 9ef4ff38 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

egl: add Wayland extended platform support

This enables OpenGL/OpenGL ES through Wayland.
parent c4ee2fc8
......@@ -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
......
......@@ -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 \
......
......@@ -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;
......@@ -161,6 +183,10 @@ static void Close (vlc_object_t *obj)
#ifdef USE_PLATFORM_X11
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment