mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +00:00
[client] egl: use new util_hasGLExt helper to check extensions
We previously used strstr, which can be prone to false positives when the name of one extension is a substring of another extension. This commit creates the helper function util_hasGLExt, which asserts that the substring found in extension list is bounded by either spaces or the beginning/end of the string.
This commit is contained in:
@@ -35,6 +35,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "egl_dynprocs.h"
|
||||
#include "common/types.h"
|
||||
#include "common/debug.h"
|
||||
#include "util.h"
|
||||
|
||||
struct SDLDSState
|
||||
{
|
||||
@@ -199,14 +200,14 @@ static EGLDisplay sdlGetEGLDisplay(void)
|
||||
|
||||
const char *early_exts = eglQueryString(NULL, EGL_EXTENSIONS);
|
||||
|
||||
if (strstr(early_exts, "EGL_KHR_platform_base") != NULL &&
|
||||
if (util_hasGLExt(early_exts, "EGL_KHR_platform_base") &&
|
||||
g_egl_dynProcs.eglGetPlatformDisplay)
|
||||
{
|
||||
DEBUG_INFO("Using eglGetPlatformDisplay");
|
||||
return g_egl_dynProcs.eglGetPlatformDisplay(platform, native, NULL);
|
||||
}
|
||||
|
||||
if (strstr(early_exts, "EGL_EXT_platform_base") != NULL &&
|
||||
if (util_hasGLExt(early_exts, "EGL_EXT_platform_base") &&
|
||||
g_egl_dynProcs.eglGetPlatformDisplayEXT)
|
||||
{
|
||||
DEBUG_INFO("Using eglGetPlatformDisplayEXT");
|
||||
|
@@ -28,6 +28,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
#include "app.h"
|
||||
#include "common/debug.h"
|
||||
#include "util.h"
|
||||
|
||||
#if defined(ENABLE_EGL) || defined(ENABLE_OPENGL)
|
||||
#include "egl_dynprocs.h"
|
||||
@@ -49,14 +50,14 @@ EGLDisplay waylandGetEGLDisplay(void)
|
||||
|
||||
const char *early_exts = eglQueryString(NULL, EGL_EXTENSIONS);
|
||||
|
||||
if (strstr(early_exts, "EGL_KHR_platform_wayland") != NULL &&
|
||||
if (util_hasGLExt(early_exts, "EGL_KHR_platform_wayland") &&
|
||||
g_egl_dynProcs.eglGetPlatformDisplay)
|
||||
{
|
||||
DEBUG_INFO("Using eglGetPlatformDisplay");
|
||||
return g_egl_dynProcs.eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, native, NULL);
|
||||
}
|
||||
|
||||
if (strstr(early_exts, "EGL_EXT_platform_wayland") != NULL &&
|
||||
if (util_hasGLExt(early_exts, "EGL_EXT_platform_wayland") &&
|
||||
g_egl_dynProcs.eglGetPlatformDisplayEXT)
|
||||
{
|
||||
DEBUG_INFO("Using eglGetPlatformDisplayEXT");
|
||||
|
@@ -42,6 +42,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "app.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/time.h"
|
||||
#include "util.h"
|
||||
|
||||
#define _NET_WM_STATE_REMOVE 0
|
||||
#define _NET_WM_STATE_ADD 1
|
||||
@@ -901,14 +902,14 @@ static EGLDisplay x11GetEGLDisplay(void)
|
||||
EGLDisplay ret;
|
||||
const char *early_exts = eglQueryString(NULL, EGL_EXTENSIONS);
|
||||
|
||||
if (strstr(early_exts, "EGL_KHR_platform_base") != NULL &&
|
||||
if (util_hasGLExt(early_exts, "EGL_KHR_platform_base") &&
|
||||
g_egl_dynProcs.eglGetPlatformDisplay)
|
||||
{
|
||||
DEBUG_INFO("Using eglGetPlatformDisplay");
|
||||
ret = g_egl_dynProcs.eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
|
||||
x11.display, NULL);
|
||||
}
|
||||
else if (strstr(early_exts, "EGL_EXT_platform_base") != NULL &&
|
||||
else if (util_hasGLExt(early_exts, "EGL_EXT_platform_base") &&
|
||||
g_egl_dynProcs.eglGetPlatformDisplayEXT)
|
||||
{
|
||||
DEBUG_INFO("Using eglGetPlatformDisplayEXT");
|
||||
|
Reference in New Issue
Block a user