summaryrefslogtreecommitdiff
path: root/src/egl
diff options
context:
space:
mode:
authorEric Engestrom <eric@engestrom.ch>2017-06-15 23:53:54 +0100
committerEric Engestrom <eric.engestrom@imgtec.com>2017-06-16 11:02:05 +0100
commit4ca9ae587c083b6f03feb65b4ce84929109d5d59 (patch)
tree9aa5a2f73688da6eec2ebf9d901e41f793dd88b3 /src/egl
parent9d81ab73768db6647c116f4710f7a93d8d41e3b1 (diff)
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. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101252 Fixes: 7adb9b094894a512c019 ("egl/display: remove unnecessary code and make it easier to read") Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Grazvydas Ignotas <notasas@gmail.com> Acked-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/main/egldisplay.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 2a1f02738df..53c6e6346d7 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -180,24 +180,27 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay)
_EGLPlatformType
_eglGetNativePlatform(void *nativeDisplay)
{
- static _EGLPlatformType native_platform;
- char *detection_method;
-
- native_platform = _eglGetNativePlatformFromEnv();
- detection_method = "environment overwrite";
+ static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
if (native_platform == _EGL_INVALID_PLATFORM) {
- native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
- detection_method = "autodetected";
- }
+ const char *detection_method;
- if (native_platform == _EGL_INVALID_PLATFORM) {
- native_platform = _EGL_NATIVE_PLATFORM;
- detection_method = "build-time configuration";
- }
+ native_platform = _eglGetNativePlatformFromEnv();
+ detection_method = "environment overwrite";
- _eglLog(_EGL_DEBUG, "Native platform type: %s (%s)",
- egl_platforms[native_platform].name, detection_method);
+ if (native_platform == _EGL_INVALID_PLATFORM) {
+ 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;
}