From e613d05da79bd3b555fa285a00b6eac19d097538 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 8 May 2023 22:17:18 +0200 Subject: [PATCH] Remove some gfx_display_{set|get}_ functions --- gfx/drivers/gx_gfx.c | 26 +++++++++++-------- gfx/gfx_display.c | 59 +++++++++++++------------------------------- gfx/gfx_display.h | 6 ----- menu/drivers/ozone.c | 7 ++++-- menu/drivers/rgui.c | 6 ++--- menu/drivers/xmb.c | 6 ++--- 6 files changed, 44 insertions(+), 66 deletions(-) diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index dd3aafe686..62134712cc 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -542,9 +542,12 @@ 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_t *p_disp = disp_get_ptr(); + p_disp->framebuf_width = new_fb_width; + p_disp->framebuf_height = new_fb_height; + p_disp->framebuf_pitch = 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); @@ -661,8 +664,12 @@ static void init_texture(gx_video_t *gx, unsigned width, unsigned height, width &= ~3; height &= ~3; - gfx_display_get_fb_size(&fb_width, &fb_height, - &fb_pitch); + { + gfx_display_t *p_disp = disp_get_ptr(); + fb_width = p_disp->framebuf_width; + fb_height = p_disp->framebuf_height; + fb_pitch = p_disp->framebuf_pitch; + } GX_InitTexObj(fb_ptr, g_tex.data, width, height, (gx->rgb32) ? GX_TF_RGBA8 : gx->menu_texture_enable ? @@ -1686,11 +1693,10 @@ static bool gx_frame(void *data, const void *frame, if (gx->menu_texture_enable && gx->menu_data) { - size_t fb_pitch; - unsigned fb_width, fb_height; - - gfx_display_get_fb_size(&fb_width, &fb_height, - &fb_pitch); + gfx_display_t *p_disp = disp_get_ptr(); + unsigned fb_width = p_disp->framebuf_width; + unsigned fb_height = p_disp->framebuf_height; + unsigned fb_pitch = p_disp->framebuf_pitch; convert_texture16( gx->menu_data, diff --git a/gfx/gfx_display.c b/gfx/gfx_display.c index 55f6c6b1a2..466c91bd10 100644 --- a/gfx/gfx_display.c +++ b/gfx/gfx_display.c @@ -652,7 +652,7 @@ void gfx_display_draw_texture_slice( * [SIDE NOTE: this causes additional issues if the transparent * pixels have the wrong colour - i.e. if they are black, * every edge gets a nasty dark border...] - * > This burring is a problem because (by design) the corners + * > This blurring is a problem because (by design) the corners * of the sliced texture are drawn at native resolution, * whereas the middle segments are stretched to fit the * requested dimensions. Consequently, the corners are sharp @@ -677,7 +677,7 @@ void gfx_display_draw_texture_slice( (scale_factor < max_scale_h) ? scale_factor : max_scale_h : (max_scale_w < max_scale_h) ? max_scale_w : max_scale_h; - /* need space for the coordinates of two triangles in a strip, + /* Need space for the coordinates of two triangles in a strip, * so 8 vertices */ float tex_coord[8]; float vert_coord[8]; @@ -712,8 +712,13 @@ void gfx_display_draw_texture_slice( if (!dispctx || !dispctx->draw) return; - /* the four vertices of the top-left corner of the image, - * used as a starting point for all the other sections */ + /* The four vertices of the top-left corner of the image, + * used as a starting point for all the other sections + * BL - Bottom Left + * BR - Bottom Right + * TL - Top Left + * TR - Top Right + */ V_BL[0] = norm_x; V_BL[1] = norm_y; V_BR[0] = norm_x + vert_woff; @@ -753,7 +758,7 @@ void gfx_display_draw_texture_slice( /* If someone wants to change this to not draw several times, the * coordinates will need to be modified because of the triangle strip usage. */ - /* top-left corner */ + /* Top Left corner */ vert_coord[0] = V_BL[0]; vert_coord[1] = V_BL[1]; vert_coord[2] = V_BR[0]; @@ -774,7 +779,7 @@ void gfx_display_draw_texture_slice( dispctx->draw(&draw, userdata, video_width, video_height); - /* top-middle section */ + /* Top Middle section */ vert_coord[0] = V_BL[0] + vert_woff; vert_coord[1] = V_BL[1]; vert_coord[2] = V_BR[0] + vert_scaled_mid_width; @@ -795,7 +800,7 @@ void gfx_display_draw_texture_slice( dispctx->draw(&draw, userdata, video_width, video_height); - /* top-right corner */ + /* Top Right corner */ vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width; vert_coord[1] = V_BL[1]; vert_coord[2] = V_BR[0] + vert_scaled_mid_width + vert_woff; @@ -816,7 +821,7 @@ void gfx_display_draw_texture_slice( dispctx->draw(&draw, userdata, video_width, video_height); - /* middle-left section */ + /* Middle Left section */ vert_coord[0] = V_BL[0]; vert_coord[1] = V_BL[1] - vert_scaled_mid_height; vert_coord[2] = V_BR[0]; @@ -858,7 +863,7 @@ void gfx_display_draw_texture_slice( dispctx->draw(&draw, userdata, video_width, video_height); - /* middle-right section */ + /* Middle Right section */ vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width; vert_coord[1] = V_BL[1] - vert_scaled_mid_height; vert_coord[2] = V_BR[0] + vert_woff + vert_scaled_mid_width; @@ -879,7 +884,7 @@ void gfx_display_draw_texture_slice( dispctx->draw(&draw, userdata, video_width, video_height); - /* bottom-left corner */ + /* Bottom Left corner */ vert_coord[0] = V_BL[0]; vert_coord[1] = V_BL[1] - vert_hoff - vert_scaled_mid_height; vert_coord[2] = V_BR[0]; @@ -900,7 +905,7 @@ void gfx_display_draw_texture_slice( dispctx->draw(&draw, userdata, video_width, video_height); - /* bottom-middle section */ + /* Bottom Middle section */ vert_coord[0] = V_BL[0] + vert_woff; vert_coord[1] = V_BL[1] - vert_hoff - vert_scaled_mid_height; vert_coord[2] = V_BR[0] + vert_scaled_mid_width; @@ -921,7 +926,7 @@ void gfx_display_draw_texture_slice( dispctx->draw(&draw, userdata, video_width, video_height); - /* bottom-right corner */ + /* Bottom Right corner */ vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width; vert_coord[1] = V_BL[1] - vert_hoff - vert_scaled_mid_height; vert_coord[2] = V_BR[0] + vert_scaled_mid_width + vert_woff; @@ -1036,36 +1041,6 @@ int gfx_display_osk_ptr_at_pos(void *data, int x, int y, return -1; } -/* Get the display framebuffer's size dimensions. */ -void gfx_display_get_fb_size(unsigned *fb_width, - unsigned *fb_height, size_t *fb_pitch) -{ - gfx_display_t *p_disp = &dispgfx_st; - *fb_width = p_disp->framebuf_width; - *fb_height = p_disp->framebuf_height; - *fb_pitch = p_disp->framebuf_pitch; -} - -/* Set the display framebuffer's width. */ -void gfx_display_set_width(unsigned width) -{ - gfx_display_t *p_disp = &dispgfx_st; - p_disp->framebuf_width = width; -} - -/* Set the display framebuffer's height. */ -void gfx_display_set_height(unsigned height) -{ - gfx_display_t *p_disp = &dispgfx_st; - p_disp->framebuf_height = height; -} - -void gfx_display_set_framebuffer_pitch(size_t pitch) -{ - gfx_display_t *p_disp = &dispgfx_st; - p_disp->framebuf_pitch = pitch; -} - void gfx_display_draw_keyboard( gfx_display_t *p_disp, void *userdata, diff --git a/gfx/gfx_display.h b/gfx/gfx_display.h index 2b39011ad2..d83907715e 100644 --- a/gfx/gfx_display.h +++ b/gfx/gfx_display.h @@ -241,12 +241,6 @@ 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); - bool gfx_display_init_first_driver(gfx_display_t *p_disp, bool video_is_threaded); diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index 4e2737446d..555b05d2ad 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -8716,8 +8716,11 @@ 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); + /* TODO/FIXME - we don't use framebuffer at all + * for Ozone, we should refactor this dependency + * away. */ + p_disp->framebuf_width = width; + p_disp->framebuf_height = height; gfx_display_init_white_texture(); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 7dd925f9ea..acb95da915 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -6302,9 +6302,9 @@ static bool rgui_set_aspect_ratio( 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)); + p_disp->framebuf_width = rgui->frame_buf.width; + p_disp->framebuf_height = rgui->frame_buf.height; + p_disp->framebuf_pitch = rgui->frame_buf.width * sizeof(uint16_t); /* Determine terminal layout */ rgui->term_layout.start_x = (3 * 5) + 1; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 55c82214ed..4ebbc11b5a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -6664,6 +6664,7 @@ static void *xmb_init(void **userdata, bool video_is_threaded) xmb_handle_t *xmb = NULL; settings_t *settings = config_get_ptr(); gfx_animation_t *p_anim = anim_get_ptr(); + gfx_display_t *p_disp = disp_get_ptr(); menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu)); if (!menu) return NULL; @@ -6740,9 +6741,8 @@ static void *xmb_init(void **userdata, bool video_is_threaded) /* 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); + p_disp->framebuf_width = width; + p_disp->framebuf_height = height; gfx_display_init_white_texture();