From 8cbeeab39f89d8cc40769eb89a298e8e98648221 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 8 Oct 2014 18:09:01 +0200 Subject: [PATCH] Create unique names for context driver static functions - needed for Griffin builds --- gfx/context/androidegl_ctx.c | 65 ++++++++------- gfx/context/drm_egl_ctx.c | 69 +++++++-------- gfx/context/emscriptenegl_ctx.c | 95 +++++++++++---------- gfx/context/mali_fbdev_ctx.c | 71 ++++++++-------- gfx/context/ps3_ctx.c | 78 +++++++++-------- gfx/context/vc_egl_ctx.c | 143 +++++++++++++++++++------------- gfx/context/vivante_fbdev_ctx.c | 72 ++++++++-------- gfx/context/wayland_ctx.c | 87 ++++++++++--------- gfx/context/wgl_ctx.c | 111 +++++++++++++------------ gfx/context/xegl_ctx.c | 85 ++++++++++--------- 10 files changed, 479 insertions(+), 397 deletions(-) diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index 0b3c85abad..9b19da2552 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -34,14 +34,14 @@ static EGLDisplay g_egl_dpy; static EGLConfig g_config; static bool g_es3; -static void gfx_ctx_set_swap_interval(void *data, unsigned interval) +static void android_gfx_ctx_set_swap_interval(void *data, unsigned interval) { (void)data; - RARCH_LOG("gfx_ctx_set_swap_interval(%u).\n", interval); + RARCH_LOG("android_gfx_ctx_set_swap_interval(%u).\n", interval); eglSwapInterval(g_egl_dpy, interval); } -static void gfx_ctx_destroy(void *data) +static void android_gfx_ctx_destroy(void *data) { (void)data; @@ -70,7 +70,7 @@ static void gfx_ctx_destroy(void *data) g_config = 0; } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void android_gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; if (g_egl_dpy) @@ -88,7 +88,7 @@ static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height } } -static bool gfx_ctx_init(void *data) +static bool android_gfx_ctx_init(void *data) { struct android_app *android_app = (struct android_app*)g_android; const EGLint attribs[] = { @@ -160,17 +160,17 @@ static bool gfx_ctx_init(void *data) return true; error: - gfx_ctx_destroy(data); + android_gfx_ctx_destroy(data); return false; } -static void gfx_ctx_swap_buffers(void *data) +static void android_gfx_ctx_swap_buffers(void *data) { (void)data; eglSwapBuffers(g_egl_dpy, g_egl_surf); } -static void gfx_ctx_check_window(void *data, bool *quit, +static void android_gfx_ctx_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)frame_count; @@ -178,7 +178,7 @@ static void gfx_ctx_check_window(void *data, bool *quit, *quit = false; unsigned new_width, new_height; - gfx_ctx_get_video_size(data, &new_width, &new_height); + android_gfx_ctx_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) { *width = new_width; @@ -191,14 +191,14 @@ static void gfx_ctx_check_window(void *data, bool *quit, *quit = true; } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void android_gfx_ctx_set_resize(void *data, unsigned width, unsigned height) { (void)data; (void)width; (void)height; } -static void gfx_ctx_update_window_title(void *data) +static void android_gfx_ctx_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; @@ -209,7 +209,7 @@ static void gfx_ctx_update_window_title(void *data) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static bool gfx_ctx_set_video_mode(void *data, +static bool android_gfx_ctx_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -220,7 +220,8 @@ static bool gfx_ctx_set_video_mode(void *data, return true; } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void android_gfx_ctx_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; void *androidinput = input_android.init(); @@ -228,7 +229,8 @@ static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void *input_data = androidinput; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static gfx_ctx_proc_t android_gfx_ctx_get_proc_address( + const char *symbol) { rarch_assert(sizeof(void*) == sizeof(void (*)(void))); gfx_ctx_proc_t ret; @@ -239,7 +241,8 @@ static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) return ret; } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool android_gfx_ctx_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; @@ -255,13 +258,13 @@ static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, u return api == GFX_CTX_OPENGL_ES_API; } -static bool gfx_ctx_has_focus(void *data) +static bool android_gfx_ctx_has_focus(void *data) { (void)data; return true; } -static bool gfx_ctx_has_windowed(void *data) +static bool android_gfx_ctx_has_windowed(void *data) { (void)data; return false; @@ -277,21 +280,21 @@ static void android_gfx_ctx_bind_hw_render(void *data, bool enable) } const gfx_ctx_driver_t gfx_ctx_android = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_set_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, + android_gfx_ctx_init, + android_gfx_ctx_destroy, + android_gfx_ctx_bind_api, + android_gfx_ctx_set_swap_interval, + android_gfx_ctx_set_video_mode, + android_gfx_ctx_get_video_size, NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, + android_gfx_ctx_update_window_title, + android_gfx_ctx_check_window, + android_gfx_ctx_set_resize, + android_gfx_ctx_has_focus, + android_gfx_ctx_has_windowed, + android_gfx_ctx_swap_buffers, + android_gfx_ctx_input_driver, + android_gfx_ctx_get_proc_address, #ifdef HAVE_EGL NULL, NULL, diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 8e8c6eeb29..7e633a827d 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -92,7 +92,8 @@ struct drm_fb }; static struct drm_fb *drm_fb_get_from_bo(struct gbm_bo *bo); -static void gfx_ctx_destroy(void *data); + +static void gfx_ctx_drm_egl_destroy(void *data); static void sighandler(int sig) { @@ -100,7 +101,7 @@ static void sighandler(int sig) g_quit = 1; } -static void gfx_ctx_swap_interval(void *data, unsigned interval) +static void gfx_ctx_drm_egl_swap_interval(void *data, unsigned interval) { (void)data; g_interval = interval; @@ -108,7 +109,7 @@ static void gfx_ctx_swap_interval(void *data, unsigned interval) RARCH_WARN("[KMS/EGL]: Swap intervals > 1 currently not supported. Will use swap interval of 1.\n"); } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_drm_egl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)data; @@ -197,7 +198,7 @@ static void queue_flip(void) waiting_for_flip = true; } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_drm_egl_swap_buffers(void *data) { (void)data; eglSwapBuffers(g_egl_dpy, g_egl_surf); @@ -220,14 +221,14 @@ static void gfx_ctx_swap_buffers(void *data) } } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void gfx_ctx_drm_egl_set_resize(void *data, unsigned width, unsigned height) { (void)data; (void)width; (void)height; } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_drm_egl_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; @@ -238,7 +239,7 @@ static void gfx_ctx_update_window_title(void *data) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_drm_egl_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; *width = g_fb_width; @@ -277,7 +278,7 @@ static void free_drm_resources(void) g_drm_fd = -1; } -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_drm_egl_init(void *data) { int i; unsigned monitor_index; @@ -409,7 +410,7 @@ nextgpu: error: dir_list_free(gpu_descriptors); - gfx_ctx_destroy(data); + gfx_ctx_drm_egl_destroy(data); return false; } @@ -511,7 +512,7 @@ static EGLint *egl_fill_attribs(EGLint *attr) return attr; } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_drm_egl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -689,11 +690,11 @@ static bool gfx_ctx_set_video_mode(void *data, return true; error: - gfx_ctx_destroy(data); + gfx_ctx_drm_egl_destroy(data); return false; } -void gfx_ctx_destroy(void *data) +static void gfx_ctx_drm_egl_destroy(void *data) { (void)data; // Make sure we acknowledge all page-flips. @@ -752,31 +753,33 @@ void gfx_ctx_destroy(void *data) g_inited = false; } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_drm_egl_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; *input = NULL; *input_data = NULL; } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_drm_egl_has_focus(void *data) { (void)data; return g_inited; } -static bool gfx_ctx_has_windowed(void *data) +static bool gfx_ctx_drm_egl_has_windowed(void *data) { (void)data; return false; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static gfx_ctx_proc_t gfx_ctx_drm_egl_get_proc_address(const char *symbol) { return eglGetProcAddress(symbol); } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_drm_egl_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; g_major = major; @@ -803,7 +806,7 @@ static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, u } } -static void gfx_ctx_bind_hw_render(void *data, bool enable) +static void gfx_ctx_drm_egl_bind_hw_render(void *data, bool enable) { (void)data; g_use_hw_ctx = enable; @@ -812,25 +815,25 @@ static void gfx_ctx_bind_hw_render(void *data, bool enable) } const gfx_ctx_driver_t gfx_ctx_drm_egl = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, + gfx_ctx_drm_egl_init, + gfx_ctx_drm_egl_destroy, + gfx_ctx_drm_egl_bind_api, + gfx_ctx_drm_egl_swap_interval, + gfx_ctx_drm_egl_set_video_mode, + gfx_ctx_drm_egl_get_video_size, NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, + gfx_ctx_drm_egl_update_window_title, + gfx_ctx_drm_egl_check_window, + gfx_ctx_drm_egl_set_resize, + gfx_ctx_drm_egl_has_focus, + gfx_ctx_drm_egl_has_windowed, + gfx_ctx_drm_egl_swap_buffers, + gfx_ctx_drm_egl_input_driver, + gfx_ctx_drm_egl_get_proc_address, NULL, NULL, NULL, "kms-egl", - gfx_ctx_bind_hw_render, + gfx_ctx_drm_egl_bind_hw_render, }; diff --git a/gfx/context/emscriptenegl_ctx.c b/gfx/context/emscriptenegl_ctx.c index 236c7986e8..1f8c7a9a7b 100644 --- a/gfx/context/emscriptenegl_ctx.c +++ b/gfx/context/emscriptenegl_ctx.c @@ -42,14 +42,14 @@ static bool g_inited; static unsigned g_fb_width; static unsigned g_fb_height; -static void gfx_ctx_swap_interval(void *data, unsigned interval) +static void gfx_ctx_emscripten_swap_interval(void *data, unsigned interval) { (void)data; - // no way to control vsync in WebGL + /* no way to control VSync in WebGL. */ (void)interval; } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_emscripten_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)data; @@ -59,32 +59,32 @@ static void gfx_ctx_check_window(void *data, bool *quit, emscripten_get_canvas_size(&iWidth, &iHeight, &isFullscreen); *width = (unsigned) iWidth; *height = (unsigned) iHeight; + *resize = false; if (*width != g_fb_width || *height != g_fb_height) *resize = true; - else - *resize = false; g_fb_width = (unsigned) iWidth; g_fb_height = (unsigned) iHeight; *quit = false; } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_emscripten_swap_buffers(void *data) { (void)data; - // no-op in emscripten, no way to force swap/wait for vsync in browsers + // no-op in emscripten, no way to force swap/wait for VSync in browsers //eglSwapBuffers(g_egl_dpy, g_egl_surf); } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void gfx_ctx_emscripten_set_resize(void *data, + unsigned width, unsigned height) { (void)data; (void)width; (void)height; } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_emscripten_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; @@ -95,16 +95,17 @@ static void gfx_ctx_update_window_title(void *data) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_emscripten_get_video_size(void *data, + unsigned *width, unsigned *height) { (void)data; *width = g_fb_width; *height = g_fb_height; } -static void gfx_ctx_destroy(void *data); +static void gfx_ctx_emscripten_destroy(void *data); -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_emscripten_init(void *data) { (void)data; EGLint width; @@ -171,11 +172,11 @@ static bool gfx_ctx_init(void *data) return true; error: - gfx_ctx_destroy(data); + gfx_ctx_emscripten_destroy(data); return false; } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_emscripten_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -187,7 +188,8 @@ static bool gfx_ctx_set_video_mode(void *data, return true; } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_emscripten_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; (void)major; @@ -201,7 +203,7 @@ static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, u } } -static void gfx_ctx_destroy(void *data) +static void gfx_ctx_emscripten_destroy(void *data) { (void)data; if (g_egl_dpy) @@ -209,14 +211,10 @@ static void gfx_ctx_destroy(void *data) eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (g_egl_ctx) - { eglDestroyContext(g_egl_dpy, g_egl_ctx); - } if (g_egl_surf) - { eglDestroySurface(g_egl_dpy, g_egl_surf); - } eglTerminate(g_egl_dpy); } @@ -228,7 +226,8 @@ static void gfx_ctx_destroy(void *data) g_inited = false; } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_emscripten_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; *input = NULL; @@ -242,52 +241,64 @@ static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void } } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_emscripten_has_focus(void *data) { (void)data; return g_inited; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static bool gfx_ctx_emscripten_has_windowed(void *data) +{ + (void)data; + /* TODO -verify. */ + return true; +} + +static gfx_ctx_proc_t gfx_ctx_emscripten_get_proc_address(const char *symbol) { return eglGetProcAddress(symbol); } -static float gfx_ctx_translate_aspect(void *data, unsigned width, unsigned height) +static float gfx_ctx_emscripten_translate_aspect(void *data, + unsigned width, unsigned height) { (void)data; return (float)width / height; } -static bool gfx_ctx_init_egl_image_buffer(void *data, const video_info_t *video) +static bool gfx_ctx_emscripten_init_egl_image_buffer(void *data, + const video_info_t *video) { (void)data; return false; } -static bool gfx_ctx_write_egl_image(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, bool rgb32, unsigned index, void **image_handle) +static bool gfx_ctx_emscripten_write_egl_image(void *data, + const void *frame, unsigned width, unsigned height, unsigned pitch, + bool rgb32, unsigned index, void **image_handle) { (void)data; return false; } const gfx_ctx_driver_t gfx_ctx_emscripten = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, - gfx_ctx_translate_aspect, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, - gfx_ctx_init_egl_image_buffer, - gfx_ctx_write_egl_image, + gfx_ctx_emscripten_init, + gfx_ctx_emscripten_destroy, + gfx_ctx_emscripten_bind_api, + gfx_ctx_emscripten_swap_interval, + gfx_ctx_emscripten_set_video_mode, + gfx_ctx_emscripten_get_video_size, + gfx_ctx_emscripten_translate_aspect, + gfx_ctx_emscripten_update_window_title, + gfx_ctx_emscripten_check_window, + gfx_ctx_emscripten_set_resize, + gfx_ctx_emscripten_has_focus, + gfx_ctx_emscripten_has_windowed, + gfx_ctx_emscripten_swap_buffers, + gfx_ctx_emscripten_input_driver, + gfx_ctx_emscripten_get_proc_address, + gfx_ctx_emscripten_init_egl_image_buffer, + gfx_ctx_emscripten_write_egl_image, NULL, "emscripten", }; diff --git a/gfx/context/mali_fbdev_ctx.c b/gfx/context/mali_fbdev_ctx.c index a015316d26..c99d5cc935 100644 --- a/gfx/context/mali_fbdev_ctx.c +++ b/gfx/context/mali_fbdev_ctx.c @@ -35,14 +35,15 @@ static void sighandler(int sig) g_quit = 1; } -static void gfx_ctx_set_swap_interval(void *data, unsigned interval) +static void gfx_ctx_mali_fbdev_set_swap_interval( + void *data, unsigned interval) { (void)data; if (g_egl_dpy) eglSwapInterval(g_egl_dpy, interval); } -static void gfx_ctx_destroy(void *data) +static void gfx_ctx_mali_fbdev_destroy(void *data) { (void)data; @@ -70,7 +71,8 @@ static void gfx_ctx_destroy(void *data) g_resize = false; } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_mali_fbdev_get_video_size(void *data, + unsigned *width, unsigned *height) { (void)data; if (g_egl_dpy != EGL_NO_DISPLAY && g_egl_surf != EGL_NO_SURFACE) @@ -85,7 +87,7 @@ static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height } } -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_mali_fbdev_init(void *data) { (void)data; @@ -136,23 +138,23 @@ static bool gfx_ctx_init(void *data) error: RARCH_ERR("[Mali fbdev]: EGL error: %d.\n", eglGetError()); - gfx_ctx_destroy(data); + gfx_ctx_mali_fbdev_destroy(data); return false; } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_mali_fbdev_swap_buffers(void *data) { (void)data; eglSwapBuffers(g_egl_dpy, g_egl_surf); } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_mali_fbdev_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)frame_count; unsigned new_width, new_height; - gfx_ctx_get_video_size(data, &new_width, &new_height); + gfx_ctx_mali_fbdev_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) { *width = new_width; @@ -163,14 +165,15 @@ static void gfx_ctx_check_window(void *data, bool *quit, *quit = g_quit; } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void gfx_ctx_mali_fbdev_set_resize(void *data, + unsigned width, unsigned height) { (void)data; (void)width; (void)height; } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_mali_fbdev_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; @@ -181,11 +184,11 @@ static void gfx_ctx_update_window_title(void *data) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { - // Pick some arbitrary default. + /* Pick some arbitrary default. */ if (!width || !fullscreen) width = 1280; if (!height || !fullscreen) @@ -195,7 +198,7 @@ static bool gfx_ctx_set_video_mode(void *data, g_height = height; static const EGLint attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, // Use version 2, even for GLES3. + EGL_CONTEXT_CLIENT_VERSION, 2, /* Use version 2, even for GLES3. */ EGL_NONE }; @@ -222,18 +225,19 @@ static bool gfx_ctx_set_video_mode(void *data, error: RARCH_ERR("[Mali fbdev]: EGL error: %d.\n", eglGetError()); - gfx_ctx_destroy(data); + gfx_ctx_mali_fbdev_destroy(data); return false; } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_mali_fbdev_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; *input = NULL; *input_data = NULL; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static gfx_ctx_proc_t gfx_ctx_mali_fbdev_get_proc_address(const char *symbol) { rarch_assert(sizeof(void*) == sizeof(void (*)(void))); gfx_ctx_proc_t ret; @@ -244,40 +248,41 @@ static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) return ret; } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_mali_fbdev_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; return api == GFX_CTX_OPENGL_ES_API; } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_mali_fbdev_has_focus(void *data) { (void)data; return true; } -static bool gfx_ctx_has_windowed(void *data) +static bool gfx_ctx_mali_fbdev_has_windowed(void *data) { (void)data; return false; } const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_set_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, + gfx_ctx_mali_fbdev_init, + gfx_ctx_mali_fbdev_destroy, + gfx_ctx_mali_fbdev_bind_api, + gfx_ctx_mali_fbdev_set_swap_interval, + gfx_ctx_mali_fbdev_set_video_mode, + gfx_ctx_mali_fbdev_get_video_size, NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, + gfx_ctx_mali_fbdev_update_window_title, + gfx_ctx_mali_fbdev_check_window, + gfx_ctx_mali_fbdev_set_resize, + gfx_ctx_mali_fbdev_has_focus, + gfx_ctx_mali_fbdev_has_windowed, + gfx_ctx_mali_fbdev_swap_buffers, + gfx_ctx_mali_fbdev_input_driver, + gfx_ctx_mali_fbdev_get_proc_address, #ifdef HAVE_EGL NULL, NULL, diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 99bc12cf4f..1f8240aa7d 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -45,7 +45,7 @@ static PSGLdevice* gl_device; static PSGLcontext* gl_context; #endif -static unsigned gfx_ctx_get_resolution_width(unsigned resolution_id) +static unsigned gfx_ctx_ps3_get_resolution_width(unsigned resolution_id) { CellVideoOutResolution resolution; cellVideoOutGetResolution(resolution_id, &resolution); @@ -53,7 +53,7 @@ static unsigned gfx_ctx_get_resolution_width(unsigned resolution_id) return resolution.width; } -static unsigned gfx_ctx_get_resolution_height(unsigned resolution_id) +static unsigned gfx_ctx_ps3_get_resolution_height(unsigned resolution_id) { CellVideoOutResolution resolution; cellVideoOutGetResolution(resolution_id, &resolution); @@ -61,7 +61,7 @@ static unsigned gfx_ctx_get_resolution_height(unsigned resolution_id) return resolution.height; } -static float gfx_ctx_get_aspect_ratio(void *data) +static float gfx_ctx_ps3_get_aspect_ratio(void *data) { (void)data; CellVideoOutState videoState; @@ -78,7 +78,7 @@ static float gfx_ctx_get_aspect_ratio(void *data) return 16.0f/9.0f; } -static void gfx_ctx_get_available_resolutions(void) +static void gfx_ctx_ps3_get_available_resolutions(void) { bool defaultresolution; uint32_t resolution_count; @@ -137,7 +137,7 @@ static void gfx_ctx_get_available_resolutions(void) g_extern.console.screen.resolutions.check = true; } -static void gfx_ctx_set_swap_interval(void *data, unsigned interval) +static void gfx_ctx_ps3_set_swap_interval(void *data, unsigned interval) { (void)data; #if defined(HAVE_PSGL) @@ -151,7 +151,7 @@ static void gfx_ctx_set_swap_interval(void *data, unsigned interval) #endif } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_ps3_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { gl_t *gl = data; @@ -166,19 +166,19 @@ static void gfx_ctx_check_window(void *data, bool *quit, *resize = true; } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_ps3_has_focus(void *data) { (void)data; return true; } -static bool gfx_ctx_has_windowed(void *data) +static bool gfx_ctx_ps3_has_windowed(void *data) { (void)data; return false; } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_ps3_swap_buffers(void *data) { (void)data; #ifdef HAVE_LIBDBGFONT @@ -192,20 +192,23 @@ static void gfx_ctx_swap_buffers(void *data) #endif } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) { } +static void gfx_ctx_ps3_set_resize(void *data, + unsigned width, unsigned height) { } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_ps3_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + gfx_get_fps(buf, sizeof(buf), fps_draw + ? buf_fps : NULL, sizeof(buf_fps)); if (fps_draw) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_ps3_get_video_size(void *data, + unsigned *width, unsigned *height) { (void)data; #if defined(HAVE_PSGL) @@ -213,7 +216,7 @@ static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height #endif } -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_ps3_init(void *data) { (void)data; #if defined(HAVE_PSGL) @@ -239,8 +242,8 @@ static bool gfx_ctx_init(void *data) if (g_extern.console.screen.resolutions.current.id) { params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; - params.width = gfx_ctx_get_resolution_width(g_extern.console.screen.resolutions.current.id); - params.height = gfx_ctx_get_resolution_height(g_extern.console.screen.resolutions.current.id); + params.width = gfx_ctx_ps3_get_resolution_width(g_extern.console.screen.resolutions.current.id); + params.height = gfx_ctx_ps3_get_resolution_height(g_extern.console.screen.resolutions.current.id); g_extern.console.screen.pal_enable = false; if (params.width == 720 && params.height == 576) @@ -266,14 +269,17 @@ static bool gfx_ctx_init(void *data) psglResetCurrentContext(); #endif - g_extern.console.screen.pal_enable = cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576, CELL_VIDEO_OUT_ASPECT_AUTO, 0); + g_extern.console.screen.pal_enable = + cellVideoOutGetResolutionAvailability( + CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576, + CELL_VIDEO_OUT_ASPECT_AUTO, 0); - gfx_ctx_get_available_resolutions(); + gfx_ctx_ps3_get_available_resolutions(); return true; } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_ps3_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -281,7 +287,7 @@ static bool gfx_ctx_set_video_mode(void *data, return true; } -static void gfx_ctx_destroy(void *data) +static void gfx_ctx_ps3_destroy(void *data) { (void)data; #if defined(HAVE_PSGL) @@ -292,7 +298,8 @@ static void gfx_ctx_destroy(void *data) #endif } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_ps3_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; void *ps3input = input_ps3.init(); @@ -300,7 +307,8 @@ static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void *input_data = ps3input; } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_ps3_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; (void)major; @@ -309,20 +317,20 @@ static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, u } const gfx_ctx_driver_t gfx_ctx_ps3 = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_set_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, + gfx_ctx_ps3_init, + gfx_ctx_ps3_destroy, + gfx_ctx_ps3_bind_api, + gfx_ctx_ps3_set_swap_interval, + gfx_ctx_ps3_set_video_mode, + gfx_ctx_ps3_get_video_size, NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, + gfx_ctx_ps3_update_window_title, + gfx_ctx_ps3_check_window, + gfx_ctx_ps3_set_resize, + gfx_ctx_ps3_has_focus, + gfx_ctx_ps3_has_windowed, + gfx_ctx_ps3_swap_buffers, + gfx_ctx_ps3_input_driver, NULL, NULL, "ps3", diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index 8bb80d888c..a7130d0962 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -62,7 +62,7 @@ static unsigned g_egl_res; static PFNEGLCREATEIMAGEKHRPROC peglCreateImageKHR; static PFNEGLDESTROYIMAGEKHRPROC peglDestroyImageKHR; -static inline bool gfx_ctx_egl_query_extension(const char *ext) +static inline bool gfx_ctx_vc_egl_query_extension(const char *ext) { const char *str = (const char*)eglQueryString(g_egl_dpy, EGL_EXTENSIONS); bool ret = str && strstr(str, ext); @@ -78,7 +78,7 @@ static void sighandler(int sig) g_quit = 1; } -static void gfx_ctx_swap_interval(void *data, unsigned interval) +static void gfx_ctx_vc_swap_interval(void *data, unsigned interval) { (void)data; // Can be called before initialization. @@ -88,7 +88,7 @@ static void gfx_ctx_swap_interval(void *data, unsigned interval) eglSwapInterval(g_egl_dpy, interval); } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_vc_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)data; @@ -100,20 +100,20 @@ static void gfx_ctx_check_window(void *data, bool *quit, *quit = g_quit; } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_vc_swap_buffers(void *data) { (void)data; eglSwapBuffers(g_egl_dpy, g_egl_surf); } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void gfx_ctx_vc_set_resize(void *data, unsigned width, unsigned height) { (void)data; (void)width; (void)height; } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_vc_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; @@ -124,16 +124,17 @@ static void gfx_ctx_update_window_title(void *data) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_vc_get_video_size(void *data, + unsigned *width, unsigned *height) { (void)data; *width = g_fb_width; *height = g_fb_height; } -static void gfx_ctx_destroy(void *data); +static void gfx_ctx_vc_destroy(void *data); -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_vc_init(void *data) { RARCH_LOG("[VC/EGL]: Initializing...\n"); if (g_inited) @@ -184,7 +185,9 @@ static bool gfx_ctx_init(void *data) goto error; // create an EGL rendering context - g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (g_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL); + g_egl_ctx = eglCreateContext( + g_egl_dpy, g_config, EGL_NO_CONTEXT, + (g_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL); if (!g_egl_ctx) goto error; @@ -241,11 +244,11 @@ static bool gfx_ctx_init(void *data) return true; error: - gfx_ctx_destroy(data); + gfx_ctx_vc_destroy(data); return false; } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_vc_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -259,13 +262,14 @@ static bool gfx_ctx_set_video_mode(void *data, sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); - gfx_ctx_swap_interval(data, g_interval); + gfx_ctx_vc_swap_interval(data, g_interval); g_inited = true; return true; } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_vc_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; (void)major; @@ -284,7 +288,7 @@ static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, u } } -static void gfx_ctx_destroy(void *data) +static void gfx_ctx_vc_destroy(void *data) { (void)data; unsigned i; @@ -309,7 +313,7 @@ static void gfx_ctx_destroy(void *data) if (g_egl_ctx) { - gfx_ctx_bind_api(data, g_api, 0, 0); + gfx_ctx_vc_bind_api(data, g_api, 0, 0); eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(g_egl_dpy, g_egl_ctx); } @@ -326,7 +330,7 @@ static void gfx_ctx_destroy(void *data) if (g_egl_surf) { - gfx_ctx_bind_api(data, g_api, 0, 0); + gfx_ctx_vc_bind_api(data, g_api, 0, 0); eglDestroySurface(g_egl_dpy, g_egl_surf); } @@ -338,7 +342,7 @@ static void gfx_ctx_destroy(void *data) eglBindAPI(EGL_OPENVG_API); eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - gfx_ctx_bind_api(data, g_api, 0, 0); + gfx_ctx_vc_bind_api(data, g_api, 0, 0); eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglTerminate(g_egl_dpy); } @@ -359,31 +363,33 @@ static void gfx_ctx_destroy(void *data) } } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_vc_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; *input = NULL; *input_data = NULL; } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_vc_has_focus(void *data) { (void)data; return g_inited; } -static bool gfx_ctx_has_windowed(void *data) +static bool gfx_ctx_vc_has_windowed(void *data) { (void)data; return false; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static gfx_ctx_proc_t gfx_ctx_vc_get_proc_address(const char *symbol) { return eglGetProcAddress(symbol); } -static float gfx_ctx_translate_aspect(void *data, unsigned width, unsigned height) +static float gfx_ctx_vc_translate_aspect(void *data, + unsigned width, unsigned height) { (void)data; // check for SD televisions: they should always be 4:3. @@ -393,20 +399,21 @@ static float gfx_ctx_translate_aspect(void *data, unsigned width, unsigned heigh return (float)width / height; } -static bool gfx_ctx_init_egl_image_buffer(void *data, const video_info_t *video) +static bool gfx_ctx_vc_init_egl_image_buffer(void *data, + const video_info_t *video) { - if (g_api == GFX_CTX_OPENVG_API) // don't bother, we just use VGImages for our EGLImage anyway - { + /* Don't bother, we just use VGImages for our EGLImage anyway. */ + if (g_api == GFX_CTX_OPENVG_API) return false; - } - peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)gfx_ctx_get_proc_address("eglCreateImageKHR"); - peglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)gfx_ctx_get_proc_address("eglDestroyImageKHR"); + peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) + gfx_ctx_vc_get_proc_address("eglCreateImageKHR"); + peglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) + gfx_ctx_vc_get_proc_address("eglDestroyImageKHR"); - if (!peglCreateImageKHR || !peglDestroyImageKHR || !gfx_ctx_egl_query_extension("KHR_image")) - { + if (!peglCreateImageKHR || !peglDestroyImageKHR + || !gfx_ctx_vc_egl_query_extension("KHR_image")) return false; - } g_egl_res = video->input_scale * RARCH_SCALE_BASE; @@ -442,7 +449,7 @@ static bool gfx_ctx_init_egl_image_buffer(void *data, const video_info_t *video) goto fail; } - gfx_ctx_bind_api(data, g_api, 0, 0); + gfx_ctx_vc_bind_api(data, g_api, 0, 0); eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx); g_smooth = video->smooth; @@ -461,13 +468,14 @@ fail: g_pbuff_surf = EGL_NO_CONTEXT; } - gfx_ctx_bind_api(data, g_api, 0, 0); + gfx_ctx_vc_bind_api(data, g_api, 0, 0); eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx); return false; } -static bool gfx_ctx_write_egl_image(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, bool rgb32, unsigned index, void **image_handle) +static bool gfx_ctx_vc_write_egl_image(void *data, const void *frame, unsigned width, + unsigned height, unsigned pitch, bool rgb32, unsigned index, void **image_handle) { bool ret = false; @@ -482,48 +490,65 @@ static bool gfx_ctx_write_egl_image(void *data, const void *frame, unsigned widt if (!eglBuffer[index] || !g_egl_vgimage[index]) { - g_egl_vgimage[index] = vgCreateImage(rgb32 ? VG_sXRGB_8888 : VG_sRGB_565, g_egl_res, g_egl_res, VG_IMAGE_QUALITY_NONANTIALIASED); - eglBuffer[index] = peglCreateImageKHR(g_egl_dpy, g_eglimage_ctx, EGL_VG_PARENT_IMAGE_KHR, (EGLClientBuffer)g_egl_vgimage[index], NULL); + g_egl_vgimage[index] = vgCreateImage( + rgb32 ? VG_sXRGB_8888 : VG_sRGB_565, + g_egl_res, + g_egl_res, + VG_IMAGE_QUALITY_NONANTIALIASED); + eglBuffer[index] = peglCreateImageKHR( + g_egl_dpy, + g_eglimage_ctx, + EGL_VG_PARENT_IMAGE_KHR, + (EGLClientBuffer)g_egl_vgimage[index], + NULL); ret = true; } - vgImageSubData(g_egl_vgimage[index], frame, pitch, (rgb32 ? VG_sXRGB_8888 : VG_sRGB_565), 0, 0, width, height); + vgImageSubData( + g_egl_vgimage[index], + frame, pitch, + (rgb32 ? VG_sXRGB_8888 : VG_sRGB_565), + 0, + 0, + width, + height); *image_handle = eglBuffer[index]; - gfx_ctx_bind_api(data, g_api, 0, 0); + gfx_ctx_vc_bind_api(data, g_api, 0, 0); eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx); return ret; } -static void vc_gfx_ctx_bind_hw_render(void *data, bool enable) +static void gfx_ctx_vc_bind_hw_render(void *data, bool enable) { (void)data; g_use_hw_ctx = enable; if (g_egl_dpy && g_egl_surf) - eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); + eglMakeCurrent(g_egl_dpy, g_egl_surf, + g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); } const gfx_ctx_driver_t gfx_ctx_videocore = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, - gfx_ctx_translate_aspect, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, - gfx_ctx_init_egl_image_buffer, - gfx_ctx_write_egl_image, + gfx_ctx_vc_init, + gfx_ctx_vc_destroy, + gfx_ctx_vc_bind_api, + gfx_ctx_vc_swap_interval, + gfx_ctx_vc_set_video_mode, + gfx_ctx_vc_get_video_size, + gfx_ctx_vc_translate_aspect, + gfx_ctx_vc_update_window_title, + gfx_ctx_vc_check_window, + gfx_ctx_vc_set_resize, + gfx_ctx_vc_has_focus, + gfx_ctx_vc_has_windowed, + gfx_ctx_vc_swap_buffers, + gfx_ctx_vc_input_driver, + gfx_ctx_vc_get_proc_address, + gfx_ctx_vc_init_egl_image_buffer, + gfx_ctx_vc_write_egl_image, NULL, "videocore", - vc_gfx_ctx_bind_hw_render, + gfx_ctx_vc_bind_hw_render, }; diff --git a/gfx/context/vivante_fbdev_ctx.c b/gfx/context/vivante_fbdev_ctx.c index 419a31483b..e6b42504b0 100644 --- a/gfx/context/vivante_fbdev_ctx.c +++ b/gfx/context/vivante_fbdev_ctx.c @@ -36,14 +36,14 @@ static void sighandler(int sig) g_quit = 1; } -static void gfx_ctx_set_swap_interval(void *data, unsigned interval) +static void gfx_ctx_vivante_set_swap_interval(void *data, unsigned interval) { (void)data; if (g_egl_dpy) eglSwapInterval(g_egl_dpy, interval); } -static void gfx_ctx_destroy(void *data) +static void gfx_ctx_vivante_destroy(void *data) { (void)data; @@ -71,7 +71,8 @@ static void gfx_ctx_destroy(void *data) g_resize = false; } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_vivante_get_video_size(void *data, + unsigned *width, unsigned *height) { (void)data; if (g_egl_dpy != EGL_NO_DISPLAY && g_egl_surf != EGL_NO_SURFACE) @@ -89,7 +90,7 @@ static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height } } -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_vivante_init(void *data) { (void)data; @@ -141,23 +142,23 @@ static bool gfx_ctx_init(void *data) error: RARCH_ERR("[Vivante fbdev]: EGL error: %d.\n", eglGetError()); - gfx_ctx_destroy(data); + gfx_ctx_vivante_destroy(data); return false; } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_vivante_swap_buffers(void *data) { (void)data; eglSwapBuffers(g_egl_dpy, g_egl_surf); } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_vivante_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)frame_count; unsigned new_width, new_height; - gfx_ctx_get_video_size(data, &new_width, &new_height); + gfx_ctx_vivante_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) { *width = new_width; @@ -168,14 +169,15 @@ static void gfx_ctx_check_window(void *data, bool *quit, *quit = g_quit; } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void gfx_ctx_vivante_set_resize(void *data, + unsigned width, unsigned height) { (void)data; (void)width; (void)height; } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_vivante_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; @@ -186,7 +188,7 @@ static void gfx_ctx_update_window_title(void *data) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_vivante_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -205,13 +207,15 @@ static bool gfx_ctx_set_video_mode(void *data, }; EGLNativeWindowType window = fbCreateWindow(fbGetDisplayByIndex(0), 0, 0, 0, 0); - if ((g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, window, 0)) == EGL_NO_SURFACE) + g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, window, 0); + if (g_egl_surf == EGL_NO_SURFACE) { RARCH_ERR("eglCreateWindowSurface failed.\n"); goto error; } - if ((g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, 0, attribs)) == EGL_NO_CONTEXT) + g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, 0, attribs); + if (g_egl_ctx == EGL_NO_CONTEXT) { RARCH_ERR("eglCreateContext failed.\n"); goto error; @@ -227,18 +231,19 @@ static bool gfx_ctx_set_video_mode(void *data, error: RARCH_ERR("[Vivante fbdev]: EGL error: %d.\n", eglGetError()); - gfx_ctx_destroy(data); + gfx_ctx_vivante_destroy(data); return false; } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_vivante_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; *input = NULL; *input_data = NULL; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static gfx_ctx_proc_t gfx_ctx_vivante_get_proc_address(const char *symbol) { rarch_assert(sizeof(void*) == sizeof(void (*)(void))); gfx_ctx_proc_t ret; @@ -249,40 +254,41 @@ static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) return ret; } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_vivante_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; return api == GFX_CTX_OPENGL_ES_API; } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_vivante_has_focus(void *data) { (void)data; return true; } -static bool gfx_ctx_has_windowed(void *data) +static bool gfx_ctx_vivante_has_windowed(void *data) { (void)data; return false; } const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_set_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, + gfx_ctx_vivante_init, + gfx_ctx_vivante_destroy, + gfx_ctx_vivante_bind_api, + gfx_ctx_vivante_set_swap_interval, + gfx_ctx_vivante_set_video_mode, + gfx_ctx_vivante_get_video_size, NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, + gfx_ctx_vivante_update_window_title, + gfx_ctx_vivante_check_window, + gfx_ctx_vivante_set_resize, + gfx_ctx_vivante_has_focus, + gfx_ctx_vivante_has_windowed, + gfx_ctx_vivante_swap_buffers, + gfx_ctx_vivante_input_driver, + gfx_ctx_vivante_get_proc_address, #ifdef HAVE_EGL NULL, NULL, diff --git a/gfx/context/wayland_ctx.c b/gfx/context/wayland_ctx.c index 8d7bb2bf46..22204c391f 100644 --- a/gfx/context/wayland_ctx.c +++ b/gfx/context/wayland_ctx.c @@ -124,8 +124,10 @@ static const struct wl_registry_listener registry_listener = { -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height); -static void gfx_ctx_destroy(void *data); +static void gfx_ctx_wl_get_video_size(void *data, + unsigned *width, unsigned *height); + +static void gfx_ctx_wl_destroy(void *data); static void egl_report_error(void) { @@ -157,7 +159,7 @@ static void egl_report_error(void) RARCH_ERR("[Wayland/EGL]: #0x%x, %s\n", (unsigned)error, str); } -static void gfx_ctx_swap_interval(void *data, unsigned interval) +static void gfx_ctx_wl_swap_interval(void *data, unsigned interval) { (void)data; g_interval = interval; @@ -196,7 +198,7 @@ static void flush_wayland_fd(void) } } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_wl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)frame_count; @@ -204,7 +206,7 @@ static void gfx_ctx_check_window(void *data, bool *quit, flush_wayland_fd(); unsigned new_width = *width, new_height = *height; - gfx_ctx_get_video_size(data, &new_width, &new_height); + gfx_ctx_wl_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) { @@ -216,30 +218,32 @@ static void gfx_ctx_check_window(void *data, bool *quit, *quit = g_quit; } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_wl_swap_buffers(void *data) { (void)data; eglSwapBuffers(g_egl_dpy, g_egl_surf); } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) { (void)data; wl_egl_window_resize(g_win, width, height, 0, 0); } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_wl_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), + fps_draw ? buf_fps : NULL, sizeof(buf_fps))) wl_shell_surface_set_title(g_shell_surf, buf); if (fps_draw) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_wl_get_video_size(void *data, + unsigned *width, unsigned *height) { (void)data; *width = g_width; @@ -249,7 +253,7 @@ static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height #define DEFAULT_WINDOWED_WIDTH 640 #define DEFAULT_WINDOWED_HEIGHT 480 -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_wl_init(void *data) { #define EGL_ATTRIBS_BASE \ EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \ @@ -365,7 +369,7 @@ static bool gfx_ctx_init(void *data) return true; error: - gfx_ctx_destroy(data); + gfx_ctx_wl_destroy(data); return false; } @@ -429,7 +433,7 @@ static EGLint *egl_fill_attribs(EGLint *attr) return attr; } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_wl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -482,7 +486,7 @@ static bool gfx_ctx_set_video_mode(void *data, RARCH_LOG("[Wayland/EGL]: Current context: %p.\n", (void*)eglGetCurrentContext()); - gfx_ctx_swap_interval(data, g_interval); + gfx_ctx_wl_swap_interval(data, g_interval); if (fullscreen) wl_shell_surface_set_fullscreen(g_shell_surf, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); @@ -491,11 +495,11 @@ static bool gfx_ctx_set_video_mode(void *data, return true; error: - gfx_ctx_destroy(data); + gfx_ctx_wl_destroy(data); return false; } -static void gfx_ctx_destroy(void *data) +static void gfx_ctx_wl_destroy(void *data) { (void)data; @@ -503,7 +507,8 @@ static void gfx_ctx_destroy(void *data) { if (g_egl_ctx) { - eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglMakeCurrent(g_egl_dpy, + EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(g_egl_dpy, g_egl_ctx); } @@ -551,7 +556,8 @@ static void gfx_ctx_destroy(void *data) g_width = g_height = 0; } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_wl_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; //void *wl = input_wayland.init(); @@ -561,24 +567,25 @@ static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void *input_data = NULL; } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_wl_has_focus(void *data) { (void)data; return true; } -static bool gfx_ctx_has_windowed(void *data) +static bool gfx_ctx_wl_has_windowed(void *data) { (void)data; return true; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static gfx_ctx_proc_t gfx_ctx_wl_get_proc_address(const char *symbol) { return eglGetProcAddress(symbol); } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_wl_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; g_major = major; @@ -605,12 +612,14 @@ static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, u } } -static void gfx_ctx_bind_hw_render(void *data, bool enable) +static void gfx_ctx_wl_bind_hw_render(void *data, bool enable) { (void)data; g_use_hw_ctx = enable; + if (g_egl_dpy && g_egl_surf) - eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); + eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, + enable ? g_egl_hw_ctx : g_egl_ctx); } static void keyboard_handle_keymap(void* data, @@ -754,24 +763,24 @@ static const struct wl_seat_listener seat_listener = { }; const gfx_ctx_driver_t gfx_ctx_wayland = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, + gfx_ctx_wl_init, + gfx_ctx_wl_destroy, + gfx_ctx_wl_bind_api, + gfx_ctx_wl_swap_interval, + gfx_ctx_wl_set_video_mode, + gfx_ctx_wl_get_video_size, NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, + gfx_ctx_wl_update_window_title, + gfx_ctx_wl_check_window, + gfx_ctx_wl_set_resize, + gfx_ctx_wl_has_focus, + gfx_ctx_wl_has_windowed, + gfx_ctx_wl_swap_buffers, + gfx_ctx_wl_input_driver, + gfx_ctx_wl_get_proc_address, NULL, NULL, NULL, "wayland", - gfx_ctx_bind_hw_render, + gfx_ctx_wl_bind_hw_render, }; diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index 3ca719ba7c..5f1b4360ba 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -57,7 +57,8 @@ static bool g_resized; static bool g_restore_desktop; static void monitor_info(MONITORINFOEX *mon, HMONITOR *hm_to_use); -static void gfx_ctx_destroy(void *data); + +static void gfx_ctx_wgl_destroy(void *data); static BOOL (APIENTRY *p_swap_interval)(int); @@ -79,6 +80,25 @@ static void setup_pixel_format(HDC hdc) SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); } +#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#endif +#ifndef WGL_CONTEXT_MINOR_VERSION_ARB +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#endif +#ifndef WGL_CONTEXT_PROFILE_MASK_ARB +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#endif +#ifndef WGL_CONTEXT_CORE_PROFILE_BIT_ARB +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x0001 +#endif +#ifndef WGL_CONTEXT_FLAGS_ARB +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#endif +#ifndef WGL_CONTEXT_DEBUG_BIT_ARB +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#endif + static void create_gl_context(HWND hwnd) { g_hdc = GetDC(hwnd); @@ -130,24 +150,6 @@ static void create_gl_context(HWND hwnd) if (core_context || debug) { -#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#endif -#ifndef WGL_CONTEXT_MINOR_VERSION_ARB -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#endif -#ifndef WGL_CONTEXT_PROFILE_MASK_ARB -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#endif -#ifndef WGL_CONTEXT_CORE_PROFILE_BIT_ARB -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x0001 -#endif -#ifndef WGL_CONTEXT_FLAGS_ARB -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#endif -#ifndef WGL_CONTEXT_DEBUG_BIT_ARB -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#endif int attribs[16]; int *aptr = attribs; @@ -268,7 +270,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, return DefWindowProc(hwnd, message, wparam, lparam); } -static void gfx_ctx_swap_interval(void *data, unsigned interval) +static void gfx_ctx_wgl_swap_interval(void *data, unsigned interval) { (void)data; g_interval = interval; @@ -281,7 +283,7 @@ static void gfx_ctx_swap_interval(void *data, unsigned interval) } } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_wgl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)data; @@ -304,20 +306,21 @@ static void gfx_ctx_check_window(void *data, bool *quit, } } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_wgl_swap_buffers(void *data) { (void)data; SwapBuffers(g_hdc); } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void gfx_ctx_wgl_set_resize(void *data, + unsigned width, unsigned height) { (void)data; (void)width; (void)height; } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_wgl_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; @@ -329,7 +332,7 @@ static void gfx_ctx_update_window_title(void *data) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; if (!g_hwnd) @@ -355,7 +358,7 @@ static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT return TRUE; } -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_wgl_init(void *data) { (void)data; if (g_inited) @@ -419,7 +422,7 @@ static void monitor_info(MONITORINFOEX *mon, HMONITOR *hm_to_use) GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_wgl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -499,7 +502,7 @@ static bool gfx_ctx_set_video_mode(void *data, p_swap_interval = (BOOL (APIENTRY *)(int))wglGetProcAddress("wglSwapIntervalEXT"); - gfx_ctx_swap_interval(data, g_interval); + gfx_ctx_wgl_swap_interval(data, g_interval); driver.display_type = RARCH_DISPLAY_WIN32; driver.video_display = 0; @@ -508,11 +511,11 @@ static bool gfx_ctx_set_video_mode(void *data, return true; error: - gfx_ctx_destroy(data); + gfx_ctx_wgl_destroy(data); return false; } -static void gfx_ctx_destroy(void *data) +static void gfx_ctx_wgl_destroy(void *data) { (void)data; if (g_hrc) @@ -559,7 +562,8 @@ static void gfx_ctx_destroy(void *data) p_swap_interval = NULL; } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_wgl_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; dinput_wgl = input_dinput.init(); @@ -567,7 +571,7 @@ static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void *input_data = dinput_wgl; } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_wgl_has_focus(void *data) { (void)data; if (!g_inited) @@ -576,19 +580,20 @@ static bool gfx_ctx_has_focus(void *data) return GetFocus() == g_hwnd; } -static bool gfx_ctx_has_windowed(void *data) +static bool gfx_ctx_wgl_has_windowed(void *data) { (void)data; return true; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol) { return (gfx_ctx_proc_t)wglGetProcAddress(symbol); } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_wgl_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; g_major = major; @@ -596,13 +601,13 @@ static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, u return api == GFX_CTX_OPENGL_API; } -static void gfx_ctx_show_mouse(void *data, bool state) +static void gfx_ctx_wgl_show_mouse(void *data, bool state) { (void)data; show_cursor(state); } -static void gfx_ctx_bind_hw_render(void *data, bool enable) +static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable) { g_use_hw_ctx = enable; if (g_hdc) @@ -610,23 +615,23 @@ static void gfx_ctx_bind_hw_render(void *data, bool enable) } const gfx_ctx_driver_t gfx_ctx_wgl = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, + gfx_ctx_wgl_init, + gfx_ctx_wgl_destroy, + gfx_ctx_wgl_bind_api, + gfx_ctx_wgl_swap_interval, + gfx_ctx_wgl_set_video_mode, + gfx_ctx_wgl_get_video_size, NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, - gfx_ctx_show_mouse, + gfx_ctx_wgl_update_window_title, + gfx_ctx_wgl_check_window, + gfx_ctx_wgl_set_resize, + gfx_ctx_wgl_has_focus, + gfx_ctx_wgl_has_windowed, + gfx_ctx_wgl_swap_buffers, + gfx_ctx_wgl_input_driver, + gfx_ctx_wgl_get_proc_address, + gfx_ctx_wgl_show_mouse, "wgl", - gfx_ctx_bind_hw_render, + gfx_ctx_wgl_bind_hw_render, }; diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 48be82f346..5fa25294da 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -82,8 +82,10 @@ static int nul_handler(Display *dpy, XErrorEvent *event) return 0; } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height); -static void gfx_ctx_destroy(void *data); +static void gfx_ctx_xegl_get_video_size(void *data, + unsigned *width, unsigned *height); + +static void gfx_ctx_xegl_destroy(void *data); static void egl_report_error(void) { @@ -115,7 +117,7 @@ static void egl_report_error(void) RARCH_ERR("[X/EGL]: #0x%x, %s\n", (unsigned)error, str); } -static void gfx_ctx_swap_interval(void *data, unsigned interval) +static void gfx_ctx_xegl_swap_interval(void *data, unsigned interval) { (void)data; g_interval = interval; @@ -130,13 +132,13 @@ static void gfx_ctx_swap_interval(void *data, unsigned interval) } } -static void gfx_ctx_check_window(void *data, bool *quit, +static void gfx_ctx_xegl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { (void)frame_count; unsigned new_width = *width, new_height = *height; - gfx_ctx_get_video_size(data, &new_width, &new_height); + gfx_ctx_xegl_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) { @@ -185,32 +187,35 @@ static void gfx_ctx_check_window(void *data, bool *quit, *quit = g_quit; } -static void gfx_ctx_swap_buffers(void *data) +static void gfx_ctx_xegl_swap_buffers(void *data) { (void)data; eglSwapBuffers(g_egl_dpy, g_egl_surf); } -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) +static void gfx_ctx_xegl_set_resize(void *data, + unsigned width, unsigned height) { (void)data; (void)width; (void)height; } -static void gfx_ctx_update_window_title(void *data) +static void gfx_ctx_xegl_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), + fps_draw ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(g_dpy, g_win, buf); if (fps_draw) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) +static void gfx_ctx_xegl_get_video_size(void *data, + unsigned *width, unsigned *height) { (void)data; if (!g_dpy || g_win == None) @@ -239,7 +244,7 @@ static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height } } -static bool gfx_ctx_init(void *data) +static bool gfx_ctx_xegl_init(void *data) { if (g_inited) return false; @@ -346,7 +351,7 @@ static bool gfx_ctx_init(void *data) return true; error: - gfx_ctx_destroy(data); + gfx_ctx_xegl_destroy(data); return false; } @@ -410,7 +415,7 @@ static EGLint *egl_fill_attribs(EGLint *attr) return attr; } -static bool gfx_ctx_set_video_mode(void *data, +static bool gfx_ctx_xegl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { @@ -555,7 +560,7 @@ static bool gfx_ctx_set_video_mode(void *data, if (g_quit_atom) XSetWMProtocols(g_dpy, g_win, &g_quit_atom, 1); - gfx_ctx_swap_interval(data, g_interval); + gfx_ctx_xegl_swap_interval(data, g_interval); // This can blow up on some drivers. It's not fatal, so override errors for this call. old_handler = XSetErrorHandler(nul_handler); @@ -581,11 +586,11 @@ error: if (vi) XFree(vi); - gfx_ctx_destroy(data); + gfx_ctx_xegl_destroy(data); return false; } -static void gfx_ctx_destroy(void *data) +static void gfx_ctx_xegl_destroy(void *data) { (void)data; x11_destroy_input_context(&g_xim, &g_xic); @@ -650,7 +655,8 @@ static void gfx_ctx_destroy(void *data) g_inited = false; } -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) +static void gfx_ctx_xegl_input_driver(void *data, + const input_driver_t **input, void **input_data) { (void)data; void *xinput = input_x.init(); @@ -658,7 +664,7 @@ static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void *input_data = xinput; } -static bool gfx_ctx_has_focus(void *data) +static bool gfx_ctx_xegl_has_focus(void *data) { (void)data; if (!g_inited) @@ -671,7 +677,7 @@ static bool gfx_ctx_has_focus(void *data) return (win == g_win && g_has_focus) || g_true_full; } -static bool gfx_ctx_has_windowed(void *data) +static bool gfx_ctx_xegl_has_windowed(void *data) { (void)data; @@ -679,12 +685,13 @@ static bool gfx_ctx_has_windowed(void *data) return true; } -static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +static gfx_ctx_proc_t gfx_ctx_xegl_get_proc_address(const char *symbol) { return eglGetProcAddress(symbol); } -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) +static bool gfx_ctx_xegl_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; g_major = major; @@ -711,13 +718,13 @@ static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, u } } -static void gfx_ctx_show_mouse(void *data, bool state) +static void gfx_ctx_xegl_show_mouse(void *data, bool state) { (void)data; x11_show_mouse(g_dpy, g_win, state); } -static void gfx_ctx_bind_hw_render(void *data, bool enable) +static void gfx_ctx_xegl_bind_hw_render(void *data, bool enable) { (void)data; g_use_hw_ctx = enable; @@ -726,25 +733,25 @@ static void gfx_ctx_bind_hw_render(void *data, bool enable) } const gfx_ctx_driver_t gfx_ctx_x_egl = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, + gfx_ctx_xegl_init, + gfx_ctx_xegl_destroy, + gfx_ctx_xegl_bind_api, + gfx_ctx_xegl_swap_interval, + gfx_ctx_xegl_set_video_mode, + gfx_ctx_xegl_get_video_size, NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_has_windowed, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - gfx_ctx_get_proc_address, + gfx_ctx_xegl_update_window_title, + gfx_ctx_xegl_check_window, + gfx_ctx_xegl_set_resize, + gfx_ctx_xegl_has_focus, + gfx_ctx_xegl_has_windowed, + gfx_ctx_xegl_swap_buffers, + gfx_ctx_xegl_input_driver, + gfx_ctx_xegl_get_proc_address, NULL, NULL, - gfx_ctx_show_mouse, + gfx_ctx_xegl_show_mouse, "x-egl", - gfx_ctx_bind_hw_render, + gfx_ctx_xegl_bind_hw_render, };