mirror of
https://github.com/libretro/RetroArch
synced 2025-04-25 00:02:31 +00:00
(egl_common.c) Cleanups/style nits
This commit is contained in:
parent
996bb990a0
commit
96d984b04d
@ -210,62 +210,47 @@ void egl_get_video_size(egl_ctx_data_t *egl, unsigned *width, unsigned *height)
|
|||||||
|
|
||||||
static bool check_egl_version(int minMajorVersion, int minMinorVersion)
|
static bool check_egl_version(int minMajorVersion, int minMinorVersion)
|
||||||
{
|
{
|
||||||
const char *str = eglQueryString(EGL_NO_DISPLAY, EGL_VERSION);
|
|
||||||
int major, minor;
|
|
||||||
int count;
|
int count;
|
||||||
|
int major, minor;
|
||||||
|
const char *str = eglQueryString(EGL_NO_DISPLAY, EGL_VERSION);
|
||||||
|
|
||||||
if (str == NULL)
|
if (!str)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
count = sscanf(str, "%d.%d", &major, &minor);
|
count = sscanf(str, "%d.%d", &major, &minor);
|
||||||
if (count != 2)
|
if (count != 2)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (major < minMajorVersion)
|
if (major < minMajorVersion)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
else if (major > minMajorVersion)
|
if (major > minMajorVersion)
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
else if (minor >= minMinorVersion)
|
if (minor >= minMinorVersion)
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static bool check_egl_client_extension(const char *name)
|
static bool check_egl_client_extension(const char *name)
|
||||||
{
|
{
|
||||||
const char *str;
|
|
||||||
size_t nameLen;
|
size_t nameLen;
|
||||||
|
const char *str = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
|
||||||
|
|
||||||
str = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
|
/* The EGL implementation doesn't support client extensions at all. */
|
||||||
if (str == NULL)
|
if (!str)
|
||||||
{
|
|
||||||
// The EGL implementation doesn't support client extensions at all.
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
nameLen = strlen(name);
|
nameLen = strlen(name);
|
||||||
while (*str != '\0')
|
while (*str != '\0')
|
||||||
{
|
{
|
||||||
// Use strspn and strcspn to find the start position and length of each
|
/* Use strspn and strcspn to find the start position and length of each
|
||||||
// token in the extension string. Using strtok could also work, but
|
* token in the extension string. Using strtok could also work, but
|
||||||
// that would require allocating a copy of the string.
|
* that would require allocating a copy of the string. */
|
||||||
size_t len = strcspn(str, " ");
|
size_t len = strcspn(str, " ");
|
||||||
if (len == nameLen && strncmp(str, name, nameLen) == 0)
|
if (len == nameLen && strncmp(str, name, nameLen) == 0)
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
str += len;
|
str += len;
|
||||||
str += strspn(str, " ");
|
str += strspn(str, " ");
|
||||||
}
|
}
|
||||||
@ -277,9 +262,9 @@ static EGLDisplay get_egl_display(EGLenum platform, void *native)
|
|||||||
{
|
{
|
||||||
if (platform != EGL_NONE)
|
if (platform != EGL_NONE)
|
||||||
{
|
{
|
||||||
// If the client library supports at least EGL 1.5, then we can call
|
/* If the client library supports at least EGL 1.5, then we can call
|
||||||
// eglGetPlatformDisplay. Otherwise, see if eglGetPlatformDisplayEXT
|
* eglGetPlatformDisplay. Otherwise, see if eglGetPlatformDisplayEXT
|
||||||
// is available.
|
* is available. */
|
||||||
if (check_egl_version(1, 5))
|
if (check_egl_version(1, 5))
|
||||||
{
|
{
|
||||||
typedef EGLDisplay (EGLAPIENTRY * pfn_eglGetPlatformDisplay)
|
typedef EGLDisplay (EGLAPIENTRY * pfn_eglGetPlatformDisplay)
|
||||||
@ -293,11 +278,9 @@ static EGLDisplay get_egl_display(EGLenum platform, void *native)
|
|||||||
{
|
{
|
||||||
EGLDisplay dpy = ptr_eglGetPlatformDisplay(platform, native, NULL);
|
EGLDisplay dpy = ptr_eglGetPlatformDisplay(platform, native, NULL);
|
||||||
if (dpy != EGL_NO_DISPLAY)
|
if (dpy != EGL_NO_DISPLAY)
|
||||||
{
|
|
||||||
return dpy;
|
return dpy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (check_egl_client_extension("EGL_EXT_platform_base"))
|
if (check_egl_client_extension("EGL_EXT_platform_base"))
|
||||||
{
|
{
|
||||||
@ -310,16 +293,14 @@ static EGLDisplay get_egl_display(EGLenum platform, void *native)
|
|||||||
{
|
{
|
||||||
EGLDisplay dpy = ptr_eglGetPlatformDisplayEXT(platform, native, NULL);
|
EGLDisplay dpy = ptr_eglGetPlatformDisplayEXT(platform, native, NULL);
|
||||||
if (dpy != EGL_NO_DISPLAY)
|
if (dpy != EGL_NO_DISPLAY)
|
||||||
{
|
|
||||||
return dpy;
|
return dpy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Either the caller didn't provide a platform type, or the EGL
|
/* Either the caller didn't provide a platform type, or the EGL
|
||||||
// implementation doesn't support eglGetPlatformDisplay. In this case, try
|
* implementation doesn't support eglGetPlatformDisplay. In this case, try
|
||||||
// eglGetDisplay and hope for the best.
|
* eglGetDisplay and hope for the best. */
|
||||||
RARCH_LOG("[EGL] Falling back to eglGetDisplay\n");
|
RARCH_LOG("[EGL] Falling back to eglGetDisplay\n");
|
||||||
return eglGetDisplay((EGLNativeDisplayType) native);
|
return eglGetDisplay((EGLNativeDisplayType) native);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user