egl: fix platform selection
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sun, 1 Sep 2019 14:22:24 +0000 (17:22 +0300)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 2 Sep 2019 03:28:06 +0000 (06:28 +0300)
Add missing "device" platform

v2: Add the missing platform (Eric)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reported-by: Jean Hertel <jean.hertel@hotmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111529
Fixes: d6edccee8d ("egl: add EGL_platform_device support")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
src/egl/main/egldisplay.c

index c1e8c341ac6943fc18181eb0b804f1b37ed39654..05720015c245c6410e4ad6eff57bff6daabf4009 100644 (file)
@@ -38,6 +38,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include "c11/threads.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include "c11/threads.h"
+#include "util/macros.h"
 #include "util/u_atomic.h"
 
 #include "eglcontext.h"
 #include "util/u_atomic.h"
 
 #include "eglcontext.h"
 static const struct {
    _EGLPlatformType platform;
    const char *name;
 static const struct {
    _EGLPlatformType platform;
    const char *name;
-} egl_platforms[_EGL_NUM_PLATFORMS] = {
+} egl_platforms[] = {
    { _EGL_PLATFORM_X11, "x11" },
    { _EGL_PLATFORM_WAYLAND, "wayland" },
    { _EGL_PLATFORM_DRM, "drm" },
    { _EGL_PLATFORM_ANDROID, "android" },
    { _EGL_PLATFORM_HAIKU, "haiku" },
    { _EGL_PLATFORM_SURFACELESS, "surfaceless" },
    { _EGL_PLATFORM_X11, "x11" },
    { _EGL_PLATFORM_WAYLAND, "wayland" },
    { _EGL_PLATFORM_DRM, "drm" },
    { _EGL_PLATFORM_ANDROID, "android" },
    { _EGL_PLATFORM_HAIKU, "haiku" },
    { _EGL_PLATFORM_SURFACELESS, "surfaceless" },
+   { _EGL_PLATFORM_DEVICE, "device" },
 };
 
 
 };
 
 
@@ -86,6 +88,9 @@ _eglGetNativePlatformFromEnv(void)
    const char *plat_name;
    EGLint i;
 
    const char *plat_name;
    EGLint i;
 
+   static_assert(ARRAY_SIZE(egl_platforms) == _EGL_NUM_PLATFORMS,
+                 "Missing platform");
+
    plat_name = getenv("EGL_PLATFORM");
    /* try deprecated env variable */
    if (!plat_name || !plat_name[0])
    plat_name = getenv("EGL_PLATFORM");
    /* try deprecated env variable */
    if (!plat_name || !plat_name[0])
@@ -93,7 +98,7 @@ _eglGetNativePlatformFromEnv(void)
    if (!plat_name || !plat_name[0])
       return _EGL_INVALID_PLATFORM;
 
    if (!plat_name || !plat_name[0])
       return _EGL_INVALID_PLATFORM;
 
-   for (i = 0; i < _EGL_NUM_PLATFORMS; i++) {
+   for (i = 0; i < ARRAY_SIZE(egl_platforms); i++) {
       if (strcmp(egl_platforms[i].name, plat_name) == 0) {
          plat = egl_platforms[i].platform;
          break;
       if (strcmp(egl_platforms[i].name, plat_name) == 0) {
          plat = egl_platforms[i].platform;
          break;