Commit 4ca9ae58 authored by Eric Engestrom's avatar Eric Engestrom Committed by Eric Engestrom

egl/display: only detect the platform once

My refactor missed the fact that `native_platform` is static.
Add the proper guard around the detection code, as it might not be
necessary, and only print the debug message when a detection was
actually performed.

Fixes: 7adb9b09 ("egl/display: remove unnecessary code and
                              make it easier to read")
Signed-off-by: Eric Engestrom's avatarEric Engestrom <>
Reviewed-by: Grazvydas Ignotas's avatarGrazvydas Ignotas <>
Acked-by: Emil Velikov's avatarEmil Velikov <>
parent 9d81ab73
...@@ -180,24 +180,27 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay) ...@@ -180,24 +180,27 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay)
_EGLPlatformType _EGLPlatformType
_eglGetNativePlatform(void *nativeDisplay) _eglGetNativePlatform(void *nativeDisplay)
{ {
static _EGLPlatformType native_platform; static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
char *detection_method;
native_platform = _eglGetNativePlatformFromEnv();
detection_method = "environment overwrite";
if (native_platform == _EGL_INVALID_PLATFORM) { if (native_platform == _EGL_INVALID_PLATFORM) {
native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay); const char *detection_method;
detection_method = "autodetected";
if (native_platform == _EGL_INVALID_PLATFORM) { native_platform = _eglGetNativePlatformFromEnv();
native_platform = _EGL_NATIVE_PLATFORM; detection_method = "environment overwrite";
detection_method = "build-time configuration";
_eglLog(_EGL_DEBUG, "Native platform type: %s (%s)", if (native_platform == _EGL_INVALID_PLATFORM) {
egl_platforms[native_platform].name, detection_method); native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
detection_method = "autodetected";
if (native_platform == _EGL_INVALID_PLATFORM) {
native_platform = _EGL_NATIVE_PLATFORM;
detection_method = "build-time configuration";
_eglLog(_EGL_DEBUG, "Native platform type: %s (%s)",
egl_platforms[native_platform].name, detection_method);
return native_platform; return native_platform;
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment