gl-renderer: move check_extension() to shared/

... prefixing it with a "weston_". This way we can reuse it across the
board, instead of the current strstr. The latter of which can give us
false positives, thus it will be resolved with next commit(s).

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Emil Velikov
2016-07-04 15:34:18 +01:00
committed by Daniel Stone
parent cbcf545fd9
commit f0c3a1c112
2 changed files with 44 additions and 43 deletions
+28
View File
@@ -55,6 +55,34 @@ typedef EGLSurface (*PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy,
const EGLint *attrib_list);
#endif
static bool
weston_check_egl_extension(const char *extensions, const char *extension)
{
size_t extlen = strlen(extension);
const char *end = extensions + strlen(extensions);
while (extensions < end) {
size_t n = 0;
/* Skip whitespaces, if any */
if (*extensions == ' ') {
extensions++;
continue;
}
n = strcspn(extensions, " ");
/* Compare strings */
if (n == extlen && strncmp(extension, extensions, n) == 0)
return true; /* Found */
extensions += n;
}
/* Not found */
return false;
}
static inline void *
weston_platform_get_egl_proc_address(const char *address)
{