From 25a4174b1db82b655d174e6f4482c6ce90e83d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 1 Oct 2024 11:22:25 -0700 Subject: [PATCH] Cleanup. --- 3rdparty/bgfx/src/glcontext_egl.cpp | 71 ++++++++++++++++------------- 3rdparty/bgfx/src/glcontext_egl.h | 10 ++-- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/3rdparty/bgfx/src/glcontext_egl.cpp b/3rdparty/bgfx/src/glcontext_egl.cpp index 555dabd611edf..85de92e1df5ad 100644 --- a/3rdparty/bgfx/src/glcontext_egl.cpp +++ b/3rdparty/bgfx/src/glcontext_egl.cpp @@ -113,34 +113,38 @@ EGL_IMPORT #if BX_PLATFORM_LINUX -#define WL_EGL_IMPORT \ - WL_EGL_FUNC(struct wl_egl_window *, wl_egl_window_create, (struct wl_surface *, int, int)) \ - WL_EGL_FUNC(void, wl_egl_window_destroy, (struct wl_egl_window *)) \ - WL_EGL_FUNC(void, wl_egl_window_resize, (struct wl_egl_window *, int, int, int, int)) \ - WL_EGL_FUNC(void, wl_egl_window_get_attached_size, (struct wl_egl_window *, int *, int *)) \ - -#define WL_EGL_FUNC(rt, fname, params) \ - typedef rt(*PFNWLEGL_##fname) params; \ - PFNWLEGL_##fname BGFX_WAYLAND_##fname; +# define WL_EGL_IMPORT \ + WL_EGL_FUNC(struct wl_egl_window *, wl_egl_window_create, (struct wl_surface *, int, int) ) \ + WL_EGL_FUNC(void, wl_egl_window_destroy, (struct wl_egl_window *)) \ + WL_EGL_FUNC(void, wl_egl_window_resize, (struct wl_egl_window *, int, int, int, int)) \ + WL_EGL_FUNC(void, wl_egl_window_get_attached_size, (struct wl_egl_window *, int *, int *) ) \ + +# define WL_EGL_FUNC(rt, fname, params) \ + typedef rt(*PFNWLEGL_##fname) params; \ + PFNWLEGL_##fname BGFX_WAYLAND_##fname; + WL_EGL_IMPORT -#undef WL_EGL_FUNC +# undef WL_EGL_FUNC - void *waylandEglOpen() { - void *so = bx::dlopen("libwayland-egl.so.1"); - BGFX_FATAL(so != NULL, Fatal::UnableToInitialize, "Could not dlopen() libwayland-egl.so.1"); + void* waylandEglOpen() + { + void* handle = bx::dlopen("libwayland-egl.so.1"); + BGFX_FATAL(handle != NULL, Fatal::UnableToInitialize, "Could not dlopen() libwayland-egl.so.1"); -#define WL_EGL_FUNC(rt, fname, params) BGFX_WAYLAND_##fname = (PFNWLEGL_##fname) bx::dlsym(so, #fname); +# define WL_EGL_FUNC(rt, fname, params) BGFX_WAYLAND_##fname = (PFNWLEGL_##fname) bx::dlsym(handle, #fname); WL_EGL_IMPORT -#undef WL_EGL_FUNC +# undef WL_EGL_FUNC - return so; + return handle; } - void waylandEglClose(void *so) { - bx::dlclose(so); -#define WL_EGL_FUNC(rt, fname, params) BGFX_WAYLAND_##fname = NULL; + void waylandEglClose(void* _handle) + { + bx::dlclose(_handle); + +# define WL_EGL_FUNC(rt, fname, params) BGFX_WAYLAND_##fname = NULL; WL_EGL_IMPORT -#undef WL_EGL_FUNC +# undef WL_EGL_FUNC } #endif // BX_PLATFORM_LINUX @@ -244,7 +248,7 @@ WL_EGL_IMPORT bcm_host_init(); # endif // BX_PLATFORM_RPI - m_eglLibrary = eglOpen(); + m_eglDll = eglOpen(); if (NULL == g_platformData.context) { @@ -263,7 +267,7 @@ WL_EGL_IMPORT } # endif // BX_PLATFORM_WINDOWS - m_display = eglGetDisplay(NULL == ndt ? EGL_DEFAULT_DISPLAY : ndt); + m_display = eglGetDisplay(NULL == ndt ? EGL_DEFAULT_DISPLAY : ndt); BGFX_FATAL(m_display != EGL_NO_DISPLAY, Fatal::UnableToInitialize, "Failed to create display %p", m_display); EGLint major = 0; @@ -373,8 +377,9 @@ WL_EGL_IMPORT # endif // BX_PLATFORM_ANDROID # if BX_PLATFORM_LINUX - if (g_platformData.type == NativeWindowHandleType::Wayland) { - m_waylandEglLibrary = waylandEglOpen(); + if (g_platformData.type == NativeWindowHandleType::Wayland) + { + m_waylandEglDll = waylandEglOpen(); } # endif if (headless) @@ -489,18 +494,19 @@ WL_EGL_IMPORT eglDestroyContext(m_display, m_context); eglDestroySurface(m_display, m_surface); # if BX_PLATFORM_LINUX - if (m_egl_window) { - BGFX_WAYLAND_wl_egl_window_destroy(m_egl_window); - waylandEglClose(m_waylandEglLibrary); - m_waylandEglLibrary = NULL; + if (m_eglWindow) + { + BGFX_WAYLAND_wl_egl_window_destroy(m_eglWindow); + waylandEglClose(m_waylandEglDll); + m_waylandEglDll = NULL; } # endif eglTerminate(m_display); m_context = NULL; } - eglClose(m_eglLibrary); - m_eglLibrary = NULL; + eglClose(m_eglDll); + m_eglDll = NULL; # if BX_PLATFORM_RPI bcm_host_deinit(); @@ -527,8 +533,9 @@ WL_EGL_IMPORT # elif BX_PLATFORM_EMSCRIPTEN EMSCRIPTEN_CHECK(emscripten_set_canvas_element_size(HTML5_TARGET_CANVAS_SELECTOR, _width, _height) ); # elif BX_PLATFORM_LINUX - if (NULL != m_egl_window) { - BGFX_WAYLAND_wl_egl_window_resize(m_egl_window, _width, _height, 0, 0); + if (NULL != m_eglWindow) + { + BGFX_WAYLAND_wl_egl_window_resize(m_eglWindow, _width, _height, 0, 0); } # else BX_UNUSED(_width, _height); diff --git a/3rdparty/bgfx/src/glcontext_egl.h b/3rdparty/bgfx/src/glcontext_egl.h index 4d7a8e81a802e..28e7a5d49fbed 100644 --- a/3rdparty/bgfx/src/glcontext_egl.h +++ b/3rdparty/bgfx/src/glcontext_egl.h @@ -39,8 +39,8 @@ namespace bgfx { namespace gl , m_display(NULL) , m_surface(NULL) #if BX_PLATFORM_LINUX - , m_waylandEglLibrary(NULL) - , m_egl_window(NULL) + , m_waylandEglDll(NULL) + , m_eglWindow(NULL) #endif , m_msaaContext(false) { @@ -63,15 +63,15 @@ namespace bgfx { namespace gl return NULL != m_context; } - void* m_eglLibrary; + void* m_eglDll; SwapChainGL* m_current; EGLConfig m_config; EGLContext m_context; EGLDisplay m_display; EGLSurface m_surface; #if BX_PLATFORM_LINUX - void *m_waylandEglLibrary; - struct wl_egl_window *m_egl_window; + void* m_waylandEglDll; + struct wl_egl_window *m_eglWindow; #endif // true when MSAA is handled by the context instead of using MSAA FBO bool m_msaaContext;