From e272edc8c0421c666d7cbaabffbc9233281d7a14 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 24 Jan 2023 21:54:06 +0100 Subject: [PATCH] (SDL2) Cleanups --- gfx/common/ctr_common.h | 53 +++++++++++++++++++--------------------- gfx/common/sdl2_common.h | 10 +++++--- gfx/drivers/sdl2_gfx.c | 35 ++++++++++---------------- 3 files changed, 45 insertions(+), 53 deletions(-) diff --git a/gfx/common/ctr_common.h b/gfx/common/ctr_common.h index 33184206c3..5d6143c065 100644 --- a/gfx/common/ctr_common.h +++ b/gfx/common/ctr_common.h @@ -40,12 +40,6 @@ extern PrintConsole* ctrConsole; extern const u8 ctr_sprite_shbin[]; extern const u32 ctr_sprite_shbin_size; -static const bool bottom_font_enable; -static const int bottom_font_color_red; -static const int bottom_font_color_green; -static const int bottom_font_color_blue; -static const int bottom_font_color_opacity; - typedef struct { float v; @@ -73,7 +67,7 @@ typedef enum { CTR_BOTTOM_MENU_NOT_AVAILABLE = 0, CTR_BOTTOM_MENU_DEFAULT, - CTR_BOTTOM_MENU_SELECT, + CTR_BOTTOM_MENU_SELECT } ctr_bottom_menu; typedef struct ctr_video @@ -116,23 +110,11 @@ typedef struct ctr_video video_viewport_t vp; - bool rgb32; - bool vsync; - bool smooth; - bool menu_texture_enable; - bool menu_texture_frame_enable; unsigned rotation; - bool keep_aspect; - bool should_resize; - bool msg_rendering_enabled; - bool supports_parallax_disable; - bool enable_3d; #ifdef HAVE_OVERLAY struct ctr_overlay_data *overlay; unsigned overlays; - bool overlay_enabled; - bool overlay_full_screen; #endif aptHookCookie lcd_aptHook; @@ -140,9 +122,6 @@ typedef struct ctr_video int current_buffer_top; int current_buffer_bottom; - bool p3d_event_pending; - bool ppf_event_pending; - volatile bool vsync_event_pending; struct { @@ -151,20 +130,38 @@ typedef struct ctr_video int size; }vertex_cache; + int state_slot; + u64 idle_timestamp; + ctr_bottom_menu bottom_menu; + ctr_bottom_menu prev_bottom_menu; + struct ctr_bottom_texture_data *bottom_textures; + + volatile bool vsync_event_pending; +#ifdef HAVE_OVERLAY + bool overlay_enabled; + bool overlay_full_screen; +#endif + bool rgb32; + bool vsync; + bool smooth; + bool menu_texture_enable; + bool menu_texture_frame_enable; + bool keep_aspect; + bool should_resize; + bool msg_rendering_enabled; + bool supports_parallax_disable; + bool enable_3d; + bool p3d_event_pending; + bool ppf_event_pending; bool init_bottom_menu; bool refresh_bottom_menu; bool render_font_bottom; bool render_state_from_png_file; bool state_data_exist; - char state_date[CTR_STATE_DATE_SIZE]; - int state_slot; bool bottom_check_idle; bool bottom_is_idle; bool bottom_is_fading; - u64 idle_timestamp; - ctr_bottom_menu bottom_menu; - ctr_bottom_menu prev_bottom_menu; - struct ctr_bottom_texture_data *bottom_textures; + char state_date[CTR_STATE_DATE_SIZE]; } ctr_video_t; typedef struct ctr_texture diff --git a/gfx/common/sdl2_common.h b/gfx/common/sdl2_common.h index 6a5ee11258..2845969920 100644 --- a/gfx/common/sdl2_common.h +++ b/gfx/common/sdl2_common.h @@ -36,6 +36,12 @@ typedef struct sdl2_tex bool rgb32; } sdl2_tex_t; +enum sd2l_flags +{ + SDL2_FLAG_QUITTING = (1 << 0), + SDL2_FLAG_SHOULD_RESIZE = (1 << 1) +}; + typedef struct _sdl2_video { double rotation; @@ -57,9 +63,7 @@ typedef struct _sdl2_video uint8_t font_g; uint8_t font_b; - bool gl; - bool quitting; - bool should_resize; + uint8_t flags; } sdl2_video_t; void sdl2_set_handles(void *data, enum rarch_display_type diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 4dbe33f446..8d4ebdc218 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -276,7 +276,7 @@ static void sdl_refresh_viewport(sdl2_video_t *vid) } } - vid->should_resize = false; + vid->flags &= ~SDL2_FLAG_SHOULD_RESIZE; sdl_refresh_renderer(vid); } @@ -399,7 +399,7 @@ static void *sdl2_gfx_init(const video_info_t *video, vid->video = *video; vid->video.smooth = video->smooth; - vid->should_resize = true; + vid->flags |= SDL2_FLAG_SHOULD_RESIZE; sdl_tex_zero(&vid->frame); sdl_tex_zero(&vid->menu); @@ -456,14 +456,13 @@ static void check_window(sdl2_video_t *vid) switch (event.type) { case SDL_QUIT: - vid->quitting = true; + vid->flags |= SDL2_FLAG_QUITTING; break; case SDL_WINDOWEVENT: if (event.window.event == SDL_WINDOWEVENT_RESIZED) - vid->should_resize = true; + vid->flags |= SDL2_FLAG_SHOULD_RESIZE; break; - default: break; } @@ -480,7 +479,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, bool menu_is_alive = video_info->menu_is_alive; #endif - if (vid->should_resize) + if (vid->flags & SDL2_FLAG_SHOULD_RESIZE) sdl_refresh_viewport(vid); if (frame) @@ -518,7 +517,6 @@ static void sdl2_gfx_set_nonblock_state(void *data, bool toggle, bool adaptive_vsync_enabled, unsigned swap_interval) { sdl2_video_t *vid = (sdl2_video_t*)data; - vid->video.vsync = !toggle; sdl_refresh_renderer(vid); } @@ -527,7 +525,9 @@ static bool sdl2_gfx_alive(void *data) { sdl2_video_t *vid = (sdl2_video_t*)data; check_window(vid); - return !vid->quitting; + if (vid->flags & SDL2_FLAG_QUITTING) + return false; + return true; } static bool sdl2_gfx_focus(void *data) @@ -539,9 +539,6 @@ static bool sdl2_gfx_focus(void *data) static bool sdl2_gfx_suppress_screensaver(void *data, bool enable) { - (void)data; - (void)enable; - if (video_driver_display_type_get() == RARCH_DISPLAY_X11) { #ifdef HAVE_X11 @@ -553,14 +550,8 @@ static bool sdl2_gfx_suppress_screensaver(void *data, bool enable) return false; } -static bool sdl2_gfx_has_windowed(void *data) -{ - (void)data; - - /* TODO - implement */ - - return true; -} +/* TODO/FIXME - implement */ +static bool sdl2_gfx_has_windowed(void *data) { return true; } static void sdl2_gfx_free(void *data) { @@ -633,13 +624,13 @@ static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) return; vid->video.force_aspect = true; - vid->should_resize = true; + vid->flags |= SDL2_FLAG_SHOULD_RESIZE; } static void sdl2_poke_apply_state_changes(void *data) { - sdl2_video_t *vid = (sdl2_video_t*)data; - vid->should_resize = true; + sdl2_video_t *vid = (sdl2_video_t*)data; + vid->flags |= SDL2_FLAG_SHOULD_RESIZE; } static void sdl2_poke_set_texture_frame(void *data,