Commit 4a91b3ae authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

egl: revector

parent 31dc0fd4
...@@ -118,34 +118,43 @@ struct gl_api ...@@ -118,34 +118,43 @@ struct gl_api
EGLint attr[3]; EGLint attr[3];
}; };
/* See http://www.khronos.org/registry/egl/api/EGL/eglplatform.h * #ifdef EGL_EXT_platform_base
* for list and order of default EGL platforms. */ static EGLDisplay GetDisplayEXT(EGLenum plat, void *dpy, const EGLint *attrs)
#if defined (_WIN32) || defined (__VC32__) \ {
&& !defined (__CYGWIN__) && !defined (__SCITECH_SNAP__) /* Win32 and WinCE */ PFNEGLGETPLATFORMDISPLAYEXTPROC getDisplay =
# define USE_DEFAULT_PLATFORM USE_PLATFORM_WIN32 (PFNEGLGETPLATFORMDISPLAYEXTPROC)
#elif defined (__WINSCW__) || defined (__SYMBIAN32__) /* Symbian */ eglGetProcAddress("eglGetPlatformDisplayEXT");
# define USE_DEFAULT_PLATFORM USE_PLATFORM_SYMBIAN
#elif defined (__ANDROID__) || defined (ANDROID) assert(getDisplay != NULL);
# define USE_DEFAULT_PLATFORM USE_PLATFORM_ANDROID return getDisplay(plat, dpy, attrs);
#elif defined (__unix__) /* X11 (tentative) */ }
# define USE_DEFAULT_PLATFORM USE_PLATFORM_X11
static EGLSurface CreateWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config,
void *window, const EGLint *attrs)
{
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC createSurface =
(PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
assert(createSurface != NULL);
return createSurface(dpy, config, window, attrs);
}
#endif #endif
static EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config,
void *window, const EGLint *attrs)
{
EGLNativeWindowType *native = window;
return eglCreateWindowSurface(dpy, config, *native, attrs);
}
/** /**
* Probe EGL display availability * Probe EGL display availability
*/ */
static int Open (vlc_object_t *obj, const struct gl_api *api) static int Open (vlc_object_t *obj, const struct gl_api *api)
{ {
vlc_gl_t *gl = (vlc_gl_t *)obj; vlc_gl_t *gl = (vlc_gl_t *)obj;
vout_window_t *wnd = gl->surface;
union {
void *ext_platform;
EGLNativeWindowType native;
} window;
#ifdef EGL_EXT_platform_base
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC createSurface = NULL;
#endif
vlc_gl_sys_t *sys = malloc(sizeof (*sys)); vlc_gl_sys_t *sys = malloc(sizeof (*sys));
if (unlikely(sys == NULL)) if (unlikely(sys == NULL))
return VLC_ENOMEM; return VLC_ENOMEM;
...@@ -154,12 +163,18 @@ static int Open (vlc_object_t *obj, const struct gl_api *api) ...@@ -154,12 +163,18 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
sys->display = EGL_NO_DISPLAY; sys->display = EGL_NO_DISPLAY;
sys->surface = EGL_NO_SURFACE; sys->surface = EGL_NO_SURFACE;
vout_window_t *wnd = gl->surface;
EGLSurface (*createSurface)(EGLDisplay, EGLConfig, void *, const EGLint *)
= CreateWindowSurface;
void *window;
#ifdef USE_PLATFORM_X11 #ifdef USE_PLATFORM_X11
sys->x11 = NULL; sys->x11 = NULL;
if (wnd->type != VOUT_WINDOW_TYPE_XID || !vlc_xlib_init(obj)) if (wnd->type != VOUT_WINDOW_TYPE_XID || !vlc_xlib_init(obj))
goto error; goto error;
window = &wnd->handle.xid;
sys->x11 = XOpenDisplay(wnd->display.x11); sys->x11 = XOpenDisplay(wnd->display.x11);
if (sys->x11 == NULL) if (sys->x11 == NULL)
goto error; goto error;
...@@ -175,47 +190,39 @@ static int Open (vlc_object_t *obj, const struct gl_api *api) ...@@ -175,47 +190,39 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
# ifdef EGL_EXT_platform_x11 # ifdef EGL_EXT_platform_x11
if (CheckClientExt("EGL_EXT_platform_x11")) if (CheckClientExt("EGL_EXT_platform_x11"))
{ {
PFNEGLGETPLATFORMDISPLAYEXTPROC getDisplay;
const EGLint attrs[] = { const EGLint attrs[] = {
EGL_PLATFORM_X11_SCREEN_EXT, snum, EGL_PLATFORM_X11_SCREEN_EXT, snum,
EGL_NONE EGL_NONE
}; };
sys->display = GetDisplayEXT(EGL_PLATFORM_X11_EXT, sys->x11, attrs);
getDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC) createSurface = CreateWindowSurfaceEXT;
eglGetProcAddress("eglGetPlatformDisplayEXT");
createSurface = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
sys->display = getDisplay(EGL_PLATFORM_X11_EXT, sys->x11, attrs);
window.ext_platform = &wnd->handle.xid;
} }
else else
# endif # endif
{ {
# if USE_DEFAULT_PLATFORM # ifdef __unix__
if (snum == XDefaultScreen(sys->x11)) if (snum == XDefaultScreen(sys->x11))
{
sys->display = eglGetDisplay(sys->x11); sys->display = eglGetDisplay(sys->x11);
window.native = wnd->handle.xid;
}
# endif
} }
# endif
#elif defined (USE_PLATFORM_WIN32) #elif defined (USE_PLATFORM_WIN32)
if (wnd->type != VOUT_WINDOW_TYPE_HWND) if (wnd->type != VOUT_WINDOW_TYPE_HWND)
goto error; goto error;
# if USE_DEFAULT_PLATFORM window = &wnd->handle.hwnd;
# if defined (_WIN32) || defined (__VC32__) \
&& !defined (__CYGWIN__) && !defined (__SCITECH_SNAP__)
sys->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); sys->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
window.native = wnd->handle.hwnd;
# endif # endif
#elif defined (USE_PLATFORM_ANDROID) #elif defined (USE_PLATFORM_ANDROID)
if (wnd->type != VOUT_WINDOW_TYPE_ANDROID_NATIVE) if (wnd->type != VOUT_WINDOW_TYPE_ANDROID_NATIVE)
goto error; goto error;
# if USE_DEFAULT_PLATFORM window = &wnd->handle.anativewindow;
# if defined (__ANDROID__) || defined (ANDROID)
sys->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); sys->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
window.native = wnd->handle.anativewindow;
# endif # endif
#endif #endif
...@@ -260,15 +267,7 @@ static int Open (vlc_object_t *obj, const struct gl_api *api) ...@@ -260,15 +267,7 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
} }
/* Create a drawing surface */ /* Create a drawing surface */
#ifdef EGL_EXT_platform_base sys->surface = createSurface(sys->display, cfgv[0], window, NULL);
if (createSurface != NULL)
sys->surface = createSurface(sys->display, cfgv[0],
window.ext_platform, NULL);
else
#endif
sys->surface = eglCreateWindowSurface(sys->display, cfgv[0],
window.native, NULL);
if (sys->surface == EGL_NO_SURFACE) if (sys->surface == EGL_NO_SURFACE)
{ {
msg_Err (obj, "cannot create EGL window surface"); msg_Err (obj, "cannot create EGL window surface");
......
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