mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(gfx_widgets) Cut down on strlens
This commit is contained in:
parent
663b5eed9d
commit
5e8987839e
@ -58,6 +58,8 @@ struct gfx_widget_generic_message_state
|
||||
float bg_color[16];
|
||||
float frame_color[16];
|
||||
|
||||
size_t message_len;
|
||||
|
||||
enum gfx_widget_generic_message_status status;
|
||||
|
||||
char message[512];
|
||||
@ -90,6 +92,8 @@ static gfx_widget_generic_message_state_t p_w_generic_message_st = {
|
||||
|
||||
COLOR_HEX_TO_FLOAT(0x3A3A3A, 1.0f), /* bg_color */
|
||||
COLOR_HEX_TO_FLOAT(0x7A7A7A, 1.0f), /* frame_color */
|
||||
|
||||
0, /* message_len */
|
||||
|
||||
GFX_WIDGET_GENERIC_MESSAGE_IDLE, /* status */
|
||||
|
||||
@ -172,13 +176,14 @@ void gfx_widget_set_generic_message(
|
||||
return;
|
||||
|
||||
/* Cache message parameters */
|
||||
strlcpy(state->message, msg, sizeof(state->message));
|
||||
state->message_len = strlcpy(state->message,
|
||||
msg, sizeof(state->message));
|
||||
state->message_duration = duration;
|
||||
|
||||
/* Get background width */
|
||||
text_width = font_driver_get_message_width(
|
||||
font_msg_queue->font, state->message,
|
||||
strlen(state->message), 1.0f);
|
||||
state->message_len, 1.0f);
|
||||
if (text_width < 0)
|
||||
text_width = 0;
|
||||
state->bg_width = (state->text_padding * 2) + (unsigned)text_width;
|
||||
@ -272,7 +277,7 @@ static void gfx_widget_generic_message_layout(
|
||||
{
|
||||
text_width = font_driver_get_message_width(
|
||||
font_msg_queue->font, state->message,
|
||||
strlen(state->message), 1.0f);
|
||||
state->message_len, 1.0f);
|
||||
if (text_width < 0)
|
||||
text_width = 0;
|
||||
|
||||
|
@ -54,6 +54,8 @@ struct gfx_widget_libretro_message_state
|
||||
float alpha;
|
||||
|
||||
float frame_color[16];
|
||||
|
||||
size_t message_len;
|
||||
|
||||
enum gfx_widget_libretro_message_status status;
|
||||
|
||||
@ -85,6 +87,8 @@ static gfx_widget_libretro_message_state_t p_w_libretro_message_st = {
|
||||
|
||||
COLOR_HEX_TO_FLOAT(0x909090, 1.0f), /* frame_color */
|
||||
|
||||
0, /* message_len */
|
||||
|
||||
GFX_WIDGET_LIBRETRO_MESSAGE_IDLE, /* status */
|
||||
|
||||
{'\0'}, /* message */
|
||||
@ -165,14 +169,14 @@ void gfx_widget_set_libretro_message(
|
||||
return;
|
||||
|
||||
/* Cache message parameters */
|
||||
strlcpy(state->message, msg, sizeof(state->message));
|
||||
state->message_len = strlcpy(state->message, msg, sizeof(state->message));
|
||||
state->message_duration = duration;
|
||||
|
||||
/* Get background width */
|
||||
state->bg_width = (state->text_padding * 2) +
|
||||
font_driver_get_message_width(
|
||||
font_msg_queue->font, state->message,
|
||||
strlen(state->message), 1.0f);
|
||||
state->message_len, 1.0f);
|
||||
|
||||
/* If a 'slide in' animation is already in
|
||||
* progress, no further action is required;
|
||||
@ -236,7 +240,7 @@ static void gfx_widget_libretro_message_layout(
|
||||
if (!string_is_empty(state->message))
|
||||
state->bg_width += font_driver_get_message_width(
|
||||
font_msg_queue->font, state->message,
|
||||
strlen(state->message), 1.0f);
|
||||
state->message_len, 1.0f);
|
||||
}
|
||||
|
||||
/* Widget iterate() */
|
||||
|
@ -93,6 +93,8 @@ struct gfx_widget_load_content_animation_state
|
||||
float margin_shadow_right_color[16];
|
||||
float icon_color[16];
|
||||
|
||||
size_t system_name_len;
|
||||
|
||||
enum gfx_widget_load_content_animation_status status;
|
||||
|
||||
char content_name[512];
|
||||
@ -149,6 +151,8 @@ static gfx_widget_load_content_animation_state_t p_w_load_content_animation_st =
|
||||
COLOR_HEX_TO_FLOAT(0x000000, 0.0f), /* margin_shadow_right_color */
|
||||
COLOR_HEX_TO_FLOAT(0xE0E0E0, 1.0f), /* icon_color */
|
||||
|
||||
0, /* system_name_len */
|
||||
|
||||
GFX_WIDGET_LOAD_CONTENT_IDLE, /* status */
|
||||
|
||||
{'\0'}, /* content_name */
|
||||
@ -393,17 +397,16 @@ bool gfx_widget_start_load_content_animation(void)
|
||||
|
||||
if (!string_is_empty(playlist_path))
|
||||
{
|
||||
size_t system_name_len;
|
||||
fill_pathname_base(state->system_name, playlist_path,
|
||||
sizeof(state->system_name));
|
||||
path_remove_extension(state->system_name);
|
||||
|
||||
system_name_len = strlen(state->system_name);
|
||||
state->system_name_len = strlen(state->system_name);
|
||||
/* Exclude history and favourites playlists */
|
||||
if (string_ends_with_size(state->system_name, "_history",
|
||||
system_name_len, STRLEN_CONST("_history")) ||
|
||||
state->system_name_len, STRLEN_CONST("_history")) ||
|
||||
string_ends_with_size(state->system_name, "_favorites",
|
||||
system_name_len, STRLEN_CONST("_favorites")))
|
||||
state->system_name_len, STRLEN_CONST("_favorites")))
|
||||
state->system_name[0] = '\0';
|
||||
|
||||
/* Check whether a valid system name was found */
|
||||
@ -601,7 +604,7 @@ static void gfx_widget_load_content_animation_iterate(void *user_data,
|
||||
strlen(state->content_name), 1.0f);
|
||||
system_name_width = font_driver_get_message_width(
|
||||
font_regular->font, state->system_name,
|
||||
strlen(state->system_name), 1.0f);
|
||||
state->system_name_len, 1.0f);
|
||||
|
||||
state->content_name_width = (content_name_width > 0) ?
|
||||
(unsigned)content_name_width : 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user