1
0
mirror of https://github.com/libretro/RetroArch synced 2025-04-04 13:20:15 +00:00

Get rid of disp_get_ptr pointer grabbing in gfx/widgets

This commit is contained in:
twinaphex 2021-04-05 15:13:28 +02:00
parent af00dca08b
commit cd016824f8
7 changed files with 71 additions and 70 deletions

@ -101,30 +101,31 @@ static void gfx_widget_achievement_popup_context_destroy(void)
static void gfx_widget_achievement_popup_frame(void* data, void* userdata) static void gfx_widget_achievement_popup_frame(void* data, void* userdata)
{ {
static float pure_white[16] = {
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
};
gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st;
gfx_display_t *p_disp = disp_get_ptr();
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
/* if there's nothing in the queue, just bail */ /* if there's nothing in the queue, just bail */
if (state->queue_read_index < 0 || !state->queue[state->queue_read_index].title) if (
state->queue_read_index < 0
|| !state->queue[state->queue_read_index].title)
return; return;
SLOCK_LOCK(state->queue_lock); SLOCK_LOCK(state->queue_lock);
if (state->queue[state->queue_read_index].title)
{ {
static float pure_white[16] = {
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
};
const video_frame_info_t* video_info = (const video_frame_info_t*)data; const video_frame_info_t* video_info = (const video_frame_info_t*)data;
const unsigned video_width = video_info->width; const unsigned video_width = video_info->width;
const unsigned video_height = video_info->height; const unsigned video_height = video_info->height;
gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
dispgfx_widget_t* p_dispwidget = (dispgfx_widget_t*)userdata; dispgfx_widget_t* p_dispwidget = (dispgfx_widget_t*)userdata;
const unsigned unfold_offet = ((1.0f - state->unfold) * const unsigned unfold_offet = ((1.0f - state->unfold) *
state->width / 2); state->width / 2);
int scissor_me_timbers = 0; int scissor_me_timbers = 0;
gfx_display_set_alpha(p_dispwidget->backdrop_orig, DEFAULT_BACKDROP); gfx_display_set_alpha(p_dispwidget->backdrop_orig, DEFAULT_BACKDROP);
@ -150,17 +151,17 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata)
if (dispctx && dispctx->blend_begin) if (dispctx && dispctx->blend_begin)
dispctx->blend_begin(video_info->userdata); dispctx->blend_begin(video_info->userdata);
gfx_widgets_draw_icon( gfx_widgets_draw_icon(
video_info->userdata, video_info->userdata,
p_disp, p_disp,
video_width, video_width,
video_height, video_height,
state->height, state->height,
state->height, state->height,
p_dispwidget->gfx_widgets_icons_textures[ p_dispwidget->gfx_widgets_icons_textures[
MENU_WIDGETS_ICON_ACHIEVEMENT], MENU_WIDGETS_ICON_ACHIEVEMENT],
0, 0,
state->y, state->y,
0, 1, pure_white); 0, 1, pure_white);
if (dispctx && dispctx->blend_end) if (dispctx && dispctx->blend_end)
dispctx->blend_end(video_info->userdata); dispctx->blend_end(video_info->userdata);
} }
@ -169,18 +170,18 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata)
else else
{ {
gfx_widgets_draw_icon( gfx_widgets_draw_icon(
video_info->userdata, video_info->userdata,
p_disp, p_disp,
video_width, video_width,
video_height, video_height,
state->height, state->height,
state->height, state->height,
state->queue[state->queue_read_index].badge, state->queue[state->queue_read_index].badge,
0, 0,
state->y, state->y,
0, 0,
1, 1,
pure_white); pure_white);
} }
/* I _think_ state->unfold changes in another thread */ /* I _think_ state->unfold changes in another thread */
@ -212,33 +213,33 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata)
/* Title */ /* Title */
gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular, gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular,
msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED), msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED),
state->height + p_dispwidget->simple_widget_padding - unfold_offet, state->height + p_dispwidget->simple_widget_padding - unfold_offet,
state->y + p_dispwidget->gfx_widget_fonts.regular.line_height state->y + p_dispwidget->gfx_widget_fonts.regular.line_height
+ p_dispwidget->gfx_widget_fonts.regular.line_ascender, + p_dispwidget->gfx_widget_fonts.regular.line_ascender,
video_width, video_height, video_width, video_height,
TEXT_COLOR_FAINT, TEXT_COLOR_FAINT,
TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT,
true); true);
/* Cheevo name */ /* Cheevo name */
/* TODO: is a ticker necessary ? */ /* TODO: is a ticker necessary ? */
gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular, gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular,
state->queue[state->queue_read_index].title, state->queue[state->queue_read_index].title,
state->height + p_dispwidget->simple_widget_padding - unfold_offet, state->height + p_dispwidget->simple_widget_padding - unfold_offet,
state->y + state->height state->y + state->height
- p_dispwidget->gfx_widget_fonts.regular.line_height - p_dispwidget->gfx_widget_fonts.regular.line_height
- p_dispwidget->gfx_widget_fonts.regular.line_descender, - p_dispwidget->gfx_widget_fonts.regular.line_descender,
video_width, video_height, video_width, video_height,
TEXT_COLOR_INFO, TEXT_COLOR_INFO,
TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT,
true); true);
if (scissor_me_timbers) if (scissor_me_timbers)
{ {
gfx_widgets_flush_text(video_width, video_height, gfx_widgets_flush_text(video_width, video_height,
&p_dispwidget->gfx_widget_fonts.regular); &p_dispwidget->gfx_widget_fonts.regular);
if (dispctx && dispctx->scissor_end) if (dispctx && dispctx->scissor_end)
dispctx->scissor_end(video_info->userdata, dispctx->scissor_end(video_info->userdata,
video_width, video_height); video_width, video_height);

@ -406,7 +406,6 @@ static void gfx_widget_generic_message_iterate(void *user_data,
static void gfx_widget_generic_message_frame(void *data, void *user_data) static void gfx_widget_generic_message_frame(void *data, void *user_data)
{ {
gfx_display_t *p_disp = disp_get_ptr();
gfx_widget_generic_message_state_t *state = &p_w_generic_message_st; gfx_widget_generic_message_state_t *state = &p_w_generic_message_st;
if (state->status != GFX_WIDGET_GENERIC_MESSAGE_IDLE) if (state->status != GFX_WIDGET_GENERIC_MESSAGE_IDLE)
@ -419,6 +418,7 @@ static void gfx_widget_generic_message_frame(void *data, void *user_data)
unsigned video_width = video_info->width; unsigned video_width = video_info->width;
unsigned video_height = video_info->height; unsigned video_height = video_info->height;
void *userdata = video_info->userdata; void *userdata = video_info->userdata;
gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
gfx_widget_font_data_t *font_msg_queue = &p_dispwidget->gfx_widget_fonts.msg_queue; gfx_widget_font_data_t *font_msg_queue = &p_dispwidget->gfx_widget_fonts.msg_queue;
size_t msg_queue_size = p_dispwidget->current_msgs_size; size_t msg_queue_size = p_dispwidget->current_msgs_size;

@ -77,7 +77,6 @@ static void gfx_widget_leaderboard_display_context_destroy(void)
static void gfx_widget_leaderboard_display_frame(void* data, void* userdata) static void gfx_widget_leaderboard_display_frame(void* data, void* userdata)
{ {
gfx_display_t *p_disp = disp_get_ptr();
gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st; gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st;
/* if there's nothing to display, just bail */ /* if there's nothing to display, just bail */
@ -92,15 +91,15 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata)
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
}; };
dispgfx_widget_t* p_dispwidget = (dispgfx_widget_t*)userdata; unsigned i, x;
const video_frame_info_t* video_info = (const video_frame_info_t*)data; dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata;
const unsigned video_width = video_info->width; const video_frame_info_t *video_info = (const video_frame_info_t*)data;
const unsigned video_height = video_info->height; gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
const unsigned spacing = MIN(video_width, video_height) / 64; const unsigned video_width = video_info->width;
const unsigned widget_height = p_dispwidget->gfx_widget_fonts.regular.line_height + (CHEEVO_LBOARD_DISPLAY_PADDING - 1) * 2; const unsigned video_height = video_info->height;
unsigned y = video_height; const unsigned spacing = MIN(video_width, video_height) / 64;
unsigned x; const unsigned widget_height = p_dispwidget->gfx_widget_fonts.regular.line_height + (CHEEVO_LBOARD_DISPLAY_PADDING - 1) * 2;
int i; unsigned y = video_height;
gfx_display_set_alpha(p_dispwidget->backdrop_orig, DEFAULT_BACKDROP); gfx_display_set_alpha(p_dispwidget->backdrop_orig, DEFAULT_BACKDROP);
gfx_display_set_alpha(pure_white, 1.0f); gfx_display_set_alpha(pure_white, 1.0f);
@ -108,8 +107,8 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata)
for (i = 0; i < state->count; ++i) for (i = 0; i < state->count; ++i)
{ {
const unsigned widget_width = state->info[i].width; const unsigned widget_width = state->info[i].width;
x = video_width - widget_width - spacing; x = video_width - widget_width - spacing;
y -= (widget_height + spacing); y -= (widget_height + spacing);
/* Backdrop */ /* Backdrop */
gfx_display_draw_quad( gfx_display_draw_quad(
@ -124,7 +123,8 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata)
gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular, gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular,
state->info[i].display, state->info[i].display,
(float)(x + CHEEVO_LBOARD_DISPLAY_PADDING), (float)(x + CHEEVO_LBOARD_DISPLAY_PADDING),
(float)(y + widget_height - (CHEEVO_LBOARD_DISPLAY_PADDING - 1) - p_dispwidget->gfx_widget_fonts.regular.line_descender), (float)(y + widget_height - (CHEEVO_LBOARD_DISPLAY_PADDING - 1)
- p_dispwidget->gfx_widget_fonts.regular.line_descender),
video_width, video_height, video_width, video_height,
TEXT_COLOR_INFO, TEXT_COLOR_INFO,
TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT,

@ -334,12 +334,12 @@ static void gfx_widget_libretro_message_iterate(void *user_data,
static void gfx_widget_libretro_message_frame(void *data, void *user_data) static void gfx_widget_libretro_message_frame(void *data, void *user_data)
{ {
gfx_display_t *p_disp = disp_get_ptr();
gfx_widget_libretro_message_state_t *state = &p_w_libretro_message_st; gfx_widget_libretro_message_state_t *state = &p_w_libretro_message_st;
if (state->status != GFX_WIDGET_LIBRETRO_MESSAGE_IDLE) if (state->status != GFX_WIDGET_LIBRETRO_MESSAGE_IDLE)
{ {
video_frame_info_t *video_info = (video_frame_info_t*)data; video_frame_info_t *video_info = (video_frame_info_t*)data;
gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)user_data; dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)user_data;
unsigned video_width = video_info->width; unsigned video_width = video_info->width;

@ -217,7 +217,6 @@ static void gfx_widget_progress_message_layout(
static void gfx_widget_progress_message_frame(void *data, void *user_data) static void gfx_widget_progress_message_frame(void *data, void *user_data)
{ {
gfx_display_t *p_disp = disp_get_ptr();
gfx_widget_progress_message_state_t *state = &p_w_progress_message_st; gfx_widget_progress_message_state_t *state = &p_w_progress_message_st;
if (state->active) if (state->active)
@ -228,6 +227,7 @@ static void gfx_widget_progress_message_frame(void *data, void *user_data)
unsigned video_width = video_info->width; unsigned video_width = video_info->width;
unsigned video_height = video_info->height; unsigned video_height = video_info->height;
void *userdata = video_info->userdata; void *userdata = video_info->userdata;
gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
float *backdrop_color = p_dispwidget->backdrop_orig; float *backdrop_color = p_dispwidget->backdrop_orig;
unsigned text_color = COLOR_TEXT_ALPHA(0xFFFFFFFF, (unsigned)(state->alpha * 255.0f)); unsigned text_color = COLOR_TEXT_ALPHA(0xFFFFFFFF, (unsigned)(state->alpha * 255.0f));

@ -203,7 +203,7 @@ static void gfx_widget_screenshot_frame(void* data, void *user_data)
unsigned video_width = video_info->width; unsigned video_width = video_info->width;
unsigned video_height = video_info->height; unsigned video_height = video_info->height;
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)user_data; dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)user_data;
gfx_display_t *p_disp = disp_get_ptr(); gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
gfx_animation_t *p_anim = anim_get_ptr(); gfx_animation_t *p_anim = anim_get_ptr();
gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; gfx_widget_screenshot_state_t *state = &p_w_screenshot_st;
gfx_widget_font_data_t* font_regular = &p_dispwidget->gfx_widget_fonts.regular; gfx_widget_font_data_t* font_regular = &p_dispwidget->gfx_widget_fonts.regular;

@ -120,7 +120,7 @@ static void gfx_widget_volume_frame(void* data, void *user_data)
float *bar_background = NULL; float *bar_background = NULL;
float *bar_foreground = NULL; float *bar_foreground = NULL;
float bar_percentage = 0.0f; float bar_percentage = 0.0f;
gfx_display_t *p_disp = disp_get_ptr(); gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx; gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
/* Note: Volume + percentage text has no component /* Note: Volume + percentage text has no component