Commit 2a1feab2 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

EGL: add CheckClientExt() helper

Checks support for a EGL client extension.
parent e1cdb462
...@@ -79,27 +79,35 @@ static void ReleaseCurrent (vlc_gl_t *); ...@@ -79,27 +79,35 @@ static void ReleaseCurrent (vlc_gl_t *);
static void SwapBuffers (vlc_gl_t *); static void SwapBuffers (vlc_gl_t *);
static void *GetSymbol(vlc_gl_t *, const char *); static void *GetSymbol(vlc_gl_t *, const char *);
static bool CheckAPI (EGLDisplay dpy, const char *api) static bool CheckToken(const char *haystack, const char *needle)
{ {
const char *apis = eglQueryString (dpy, EGL_CLIENT_APIS); size_t len = strlen(needle);
size_t apilen = strlen (api);
/* Cannot use strtok_r() on constant string... */ while (haystack != NULL)
do
{ {
while (*apis == ' ') while (*haystack == ' ')
apis++; haystack++;
if (!strncmp (apis, api, apilen) if (!strncmp(haystack, needle, len)
&& (memchr (" ", apis[apilen], 2) != NULL)) && (memchr(" ", haystack[len], 2) != NULL))
return true; return true;
apis = strchr (apis, ' '); haystack = strchr(haystack, ' ');
} }
while (apis != NULL);
return false; return false;
} }
static bool CheckAPI (EGLDisplay dpy, const char *api)
{
const char *apis = eglQueryString (dpy, EGL_CLIENT_APIS);
return CheckToken(apis, api);
}
static bool CheckClientExt(const char *name)
{
const char *exts = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
return CheckToken(exts, name);
}
struct gl_api struct gl_api
{ {
const char name[10]; const char name[10];
......
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