From 618cfacd590ea69d49ee6b73285a9372cc21c56e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 26 Aug 2021 18:26:44 +0200 Subject: [PATCH] (gfx_display) Make gfx_display_set_fb_size - get rid of the small getter/setter functions - also finally take this opportunity to stop setting framebuffer width/height/pitch for menu drivers that don't use a framebuffer texture at all --- gfx/drivers/gx_gfx.c | 4 +--- gfx/gfx_display.c | 37 ++++++++++++++++--------------------- gfx/gfx_display.h | 9 ++++----- menu/drivers/ozone/ozone.c | 3 --- menu/drivers/rgui.c | 7 ++++--- menu/drivers/stripes.c | 7 ------- menu/drivers/xmb.c | 7 ------- retroarch.c | 4 ++-- 8 files changed, 27 insertions(+), 51 deletions(-) diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index b14f1bfb03..aeee835f96 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -534,9 +534,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, new_fb_pitch = new_fb_width * 2; - gfx_display_set_width(new_fb_width); - gfx_display_set_height(new_fb_height); - gfx_display_set_framebuffer_pitch(new_fb_pitch); + gfx_display_set_framebuf(new_fb_width, new_fb_height, new_fb_pitch); GX_SetViewportJitter(0, 0, gx_mode.fbWidth, gx_mode.efbHeight, 0, 1, 1); GX_SetDispCopySrc(0, 0, gx_mode.fbWidth, gx_mode.efbHeight); diff --git a/gfx/gfx_display.c b/gfx/gfx_display.c index 77be7676ac..97be537c18 100644 --- a/gfx/gfx_display.c +++ b/gfx/gfx_display.c @@ -531,8 +531,12 @@ void gfx_display_draw_quad( void *data, unsigned video_width, unsigned video_height, - int x, int y, unsigned w, unsigned h, - unsigned width, unsigned height, + int x, + int y, + unsigned w, + unsigned h, + unsigned width, + unsigned height, float *color, uintptr_t *texture) { @@ -1092,24 +1096,17 @@ void gfx_display_get_fb_size(unsigned *fb_width, *fb_pitch = p_disp->framebuf_pitch; } -/* Set the display framebuffer's width. */ -void gfx_display_set_width(unsigned width) -{ - gfx_display_t *p_disp = disp_get_ptr(); - p_disp->framebuf_width = width; -} - -/* Set the display framebuffer's height. */ -void gfx_display_set_height(unsigned height) +/* Set the display framebuffer's dimensions. */ +void gfx_display_set_fb_size( + unsigned width, + unsigned height, + size_t pitch +) { gfx_display_t *p_disp = disp_get_ptr(); + p_disp->framebuf_width = width; p_disp->framebuf_height = height; -} - -void gfx_display_set_framebuffer_pitch(size_t pitch) -{ - gfx_display_t *p_disp = disp_get_ptr(); - p_disp->framebuf_pitch = pitch; + p_disp->framebuf_pitch = pitch; } void gfx_display_set_msg_force(bool state) @@ -1274,9 +1271,8 @@ void gfx_display_init_white_texture(uintptr_t white_texture) TEXTURE_FILTER_NEAREST, &gfx_display_white_texture); } -void gfx_display_free(void) +void gfx_display_free(gfx_display_t *p_disp) { - gfx_display_t *p_disp = disp_get_ptr(); video_coord_array_free(&p_disp->dispca); p_disp->msg_force = false; @@ -1288,9 +1284,8 @@ void gfx_display_free(void) p_disp->dispctx = NULL; } -void gfx_display_init(void) +void gfx_display_init(gfx_display_t *p_disp) { - gfx_display_t *p_disp = disp_get_ptr(); video_coord_array_t *p_dispca = &p_disp->dispca; p_disp->has_windowed = video_driver_has_windowed(); diff --git a/gfx/gfx_display.h b/gfx/gfx_display.h index 63039902aa..8bc3d0e64e 100644 --- a/gfx/gfx_display.h +++ b/gfx/gfx_display.h @@ -223,9 +223,9 @@ struct gfx_display bool framebuf_dirty; }; -void gfx_display_free(void); +void gfx_display_free(gfx_display_t *p_disp); -void gfx_display_init(void); +void gfx_display_init(gfx_display_t *p_disp); void gfx_display_draw_cursor( gfx_display_t *p_disp, @@ -258,11 +258,10 @@ void gfx_display_scissor_begin( void gfx_display_font_free(font_data_t *font); -void gfx_display_set_width(unsigned width); void gfx_display_get_fb_size(unsigned *fb_width, unsigned *fb_height, size_t *fb_pitch); -void gfx_display_set_height(unsigned height); -void gfx_display_set_framebuffer_pitch(size_t pitch); + +void gfx_display_set_fb_size(unsigned width, unsigned height, size_t pitch); void gfx_display_set_msg_force(bool state); bool gfx_display_init_first_driver(gfx_display_t *p_disp, diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index b6f3a21a78..51d0c41ec3 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -791,9 +791,6 @@ static void *ozone_init(void **userdata, bool video_is_threaded) menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); - gfx_display_set_width(width); - gfx_display_set_height(height); - gfx_display_init_white_texture(gfx_display_white_texture); file_list_initialize(&ozone->horizontal_list); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 519f17eed4..b7431e58f2 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -5695,9 +5695,10 @@ static bool rgui_set_aspect_ratio(rgui_t *rgui, return false; /* Configure 'menu display' settings */ - gfx_display_set_width(rgui->frame_buf.width); - gfx_display_set_height(rgui->frame_buf.height); - gfx_display_set_framebuffer_pitch(rgui->frame_buf.width * sizeof(uint16_t)); + gfx_display_set_fb_size( + rgui->frame_buf.width, + rgui->frame_buf.height, + rgui->frame_buf.width * sizeof(uint16_t)); /* Determine terminal layout */ rgui->term_layout.start_x = (3 * 5) + 1; diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 78f90c0a9d..eb6102d0d6 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -3366,13 +3366,6 @@ static void *stripes_init(void **userdata, bool video_is_threaded) menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); - /* TODO/FIXME - we don't use framebuffer at all - * for XMB, we should refactor this dependency - * away. */ - - gfx_display_set_width(width); - gfx_display_set_height(height); - gfx_display_init_white_texture(gfx_display_white_texture); file_list_initialize(&stripes->horizontal_list); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index f47eabd0c1..9ce94e89b9 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -5833,13 +5833,6 @@ static void *xmb_init(void **userdata, bool video_is_threaded) menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); - /* TODO/FIXME - we don't use framebuffer at all - * for XMB, we should refactor this dependency - * away. */ - - gfx_display_set_width(width); - gfx_display_set_height(height); - gfx_display_init_white_texture(gfx_display_white_texture); file_list_initialize(&xmb->horizontal_list); diff --git a/retroarch.c b/retroarch.c index f94c21e23d..9ca6e4d513 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4787,7 +4787,7 @@ static bool menu_driver_init_internal( settings)) return false; - gfx_display_init(); + gfx_display_init(&p_rarch->dispgfx); /* TODO/FIXME - can we get rid of this? Is this needed? */ configuration_set_string(settings, @@ -5395,7 +5395,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) } gfx_animation_deinit(&p_rarch->anim); - gfx_display_free(); + gfx_display_free(&p_rarch->dispgfx); menu_entries_settings_deinit(menu_st); menu_entries_list_deinit(p_rarch->menu_driver_ctx, menu_st);