hook: Fallback to eglGetPlatformDisplay() in eglGetDisplay()

Change-Id: Ia3a83523368270e0e811c8e3f15f415ca3288e78
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
This commit is contained in:
Jeffy Chen 2025-07-28 11:44:35 +08:00
parent 29be25a8a2
commit 8684dc51fe

View file

@ -704,8 +704,9 @@ EGLAPI EGLDisplay EGLAPIENTRY
eglGetDisplay (EGLNativeDisplayType display_id) eglGetDisplay (EGLNativeDisplayType display_id)
{ {
const char *type = getenv("MALI_DEFAULT_WINSYS"); const char *type = getenv("MALI_DEFAULT_WINSYS");
EGLDisplay display;
// HACK: For chromium angle with in-process-gpu. /* HACK: For chromium angle with in-process-gpu. */
if (getenv("MALI_FORCE_DEFAULT_DISPLAY") && if (getenv("MALI_FORCE_DEFAULT_DISPLAY") &&
display_id != EGL_DEFAULT_DISPLAY) { display_id != EGL_DEFAULT_DISPLAY) {
fprintf(stderr, "[MALI-HOOK] WARN: Native display(%p) ignored!\n", fprintf(stderr, "[MALI-HOOK] WARN: Native display(%p) ignored!\n",
@ -713,22 +714,46 @@ eglGetDisplay (EGLNativeDisplayType display_id)
display_id = EGL_DEFAULT_DISPLAY; display_id = EGL_DEFAULT_DISPLAY;
} }
/* Honor the native display. */
if (display_id != EGL_DEFAULT_DISPLAY)
return _eglGetDisplay(display_id);
/* Honor the default winsys config. */
#ifdef HAS_GBM #ifdef HAS_GBM
if (type && !strcmp(type, "gbm")) if (type && !strcmp(type, "gbm"))
return eglGetPlatformDisplay(EGL_PLATFORM_GBM_KHR, display_id, NULL); return eglGetPlatformDisplay(EGL_PLATFORM_GBM_KHR,
EGL_DEFAULT_DISPLAY, NULL);
#endif #endif
#ifdef HAS_WAYLAND #ifdef HAS_WAYLAND
if (type && !strcmp(type, "wayland")) if (type && !strcmp(type, "wayland"))
return eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, display_id, NULL); return eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT,
EGL_DEFAULT_DISPLAY, NULL);
#endif
#ifdef HAS_X11
if (type && !strcmp(type, "x11"))
return eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
EGL_DEFAULT_DISPLAY, NULL);
#endif #endif
#ifdef HAS_X11 display = _eglGetDisplay(EGL_DEFAULT_DISPLAY);
/* Use X11 by default when avaiable */
return eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR, display_id, NULL); /* Fallback to eglGetPlatformDisplay(). */
#else #ifdef HAS_GBM
return _eglGetDisplay(display_id); if (!display)
display = eglGetPlatformDisplay(EGL_PLATFORM_GBM_KHR,
EGL_DEFAULT_DISPLAY, NULL);
#endif #endif
#ifdef HAS_WAYLAND
if (!display)
display = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT,
EGL_DEFAULT_DISPLAY, NULL);
#endif
#ifdef HAS_X11
if (!display)
display = eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
EGL_DEFAULT_DISPLAY, NULL);
#endif
return display;
} }
/* Export for EGL 1.5 */ /* Export for EGL 1.5 */