mirror of
https://github.com/libretro/RetroArch
synced 2025-03-17 10:21:26 +00:00
gfx_widget_draw_icon optimization - if radians is 0, we know cosine and
sine already. Avoid sinf/cosf computation when possible
This commit is contained in:
parent
bf5409881c
commit
bb6937949d
@ -610,6 +610,8 @@ void gfx_widgets_draw_icon(
|
||||
uintptr_t texture,
|
||||
float x, float y,
|
||||
float radians,
|
||||
float cosine,
|
||||
float sine,
|
||||
float *color)
|
||||
{
|
||||
gfx_display_ctx_draw_t draw;
|
||||
@ -622,11 +624,7 @@ void gfx_widgets_draw_icon(
|
||||
return;
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
float cosine = cosf(radians);
|
||||
float sine = sinf(radians);
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = NULL;
|
||||
@ -1103,9 +1101,13 @@ static int gfx_widgets_draw_indicator(
|
||||
p_disp,
|
||||
video_width,
|
||||
video_height,
|
||||
width, height,
|
||||
icon, top_right_x_advance - width, y,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
icon,
|
||||
top_right_x_advance - width, y,
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
p_dispwidget->pure_white
|
||||
);
|
||||
if (dispctx && dispctx->blend_end)
|
||||
@ -1255,21 +1257,34 @@ static void gfx_widgets_draw_task_msg(
|
||||
gfx_display_set_alpha(p_dispwidget->pure_white, msg->alpha);
|
||||
if (dispctx && dispctx->blend_begin)
|
||||
dispctx->blend_begin(userdata);
|
||||
gfx_widgets_draw_icon(
|
||||
userdata,
|
||||
p_disp,
|
||||
video_width,
|
||||
video_height,
|
||||
p_dispwidget->msg_queue_height / 2,
|
||||
p_dispwidget->msg_queue_height / 2,
|
||||
p_dispwidget->gfx_widgets_icons_textures[
|
||||
msg->task_finished
|
||||
? MENU_WIDGETS_ICON_CHECK
|
||||
: MENU_WIDGETS_ICON_HOURGLASS],
|
||||
p_dispwidget->msg_queue_task_hourglass_x,
|
||||
video_height - msg->offset_y,
|
||||
msg->task_finished ? 0 : msg->hourglass_rotation,
|
||||
p_dispwidget->pure_white);
|
||||
{
|
||||
float radians = 0.0f; /* rad */
|
||||
float cosine = 0.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 1.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
if (!msg->task_finished)
|
||||
{
|
||||
radians = msg->hourglass_rotation;
|
||||
cosine = cosf(radians);
|
||||
sine = sinf(radians);
|
||||
}
|
||||
gfx_widgets_draw_icon(
|
||||
userdata,
|
||||
p_disp,
|
||||
video_width,
|
||||
video_height,
|
||||
p_dispwidget->msg_queue_height / 2,
|
||||
p_dispwidget->msg_queue_height / 2,
|
||||
p_dispwidget->gfx_widgets_icons_textures[
|
||||
msg->task_finished
|
||||
? MENU_WIDGETS_ICON_CHECK
|
||||
: MENU_WIDGETS_ICON_HOURGLASS],
|
||||
p_dispwidget->msg_queue_task_hourglass_x,
|
||||
video_height - msg->offset_y,
|
||||
radians,
|
||||
cosine,
|
||||
sine,
|
||||
p_dispwidget->pure_white);
|
||||
}
|
||||
if (dispctx && dispctx->blend_end)
|
||||
dispctx->blend_end(userdata);
|
||||
|
||||
@ -1451,7 +1466,9 @@ static void gfx_widgets_draw_regular_msg(
|
||||
p_dispwidget->gfx_widgets_icons_textures[MENU_WIDGETS_ICON_INFO],
|
||||
p_dispwidget->msg_queue_spacing,
|
||||
video_height - msg->offset_y - p_dispwidget->msg_queue_icon_offset_y,
|
||||
0,
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
msg_queue_info);
|
||||
|
||||
if (dispctx && dispctx->blend_end)
|
||||
@ -1532,7 +1549,9 @@ void gfx_widgets_frame(void *data)
|
||||
p_dispwidget->ai_service_overlay_texture,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
p_dispwidget->pure_white
|
||||
);
|
||||
if (dispctx->blend_end)
|
||||
|
@ -286,7 +286,9 @@ void gfx_widgets_draw_icon(
|
||||
unsigned icon_height,
|
||||
uintptr_t texture,
|
||||
float x, float y,
|
||||
float rotation,
|
||||
float radians,
|
||||
float cosine,
|
||||
float sine,
|
||||
float *color);
|
||||
|
||||
void gfx_widgets_draw_text(
|
||||
|
@ -176,7 +176,10 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata)
|
||||
MENU_WIDGETS_ICON_ACHIEVEMENT],
|
||||
0,
|
||||
state->y,
|
||||
0, pure_white);
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
pure_white);
|
||||
if (dispctx && dispctx->blend_end)
|
||||
dispctx->blend_end(video_info->userdata);
|
||||
}
|
||||
@ -194,7 +197,10 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata)
|
||||
state->queue[state->queue_read_index].badge,
|
||||
0,
|
||||
state->y,
|
||||
0, pure_white);
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
pure_white);
|
||||
}
|
||||
|
||||
/* I _think_ state->unfold changes in another thread */
|
||||
|
@ -174,12 +174,21 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata)
|
||||
if (dispctx && dispctx->blend_begin)
|
||||
dispctx->blend_begin(video_info->userdata);
|
||||
|
||||
gfx_widgets_draw_icon(video_info->userdata,
|
||||
p_disp, video_width, video_height,
|
||||
widget_size, widget_size,
|
||||
gfx_widgets_draw_icon(
|
||||
video_info->userdata,
|
||||
p_disp,
|
||||
video_width,
|
||||
video_height,
|
||||
widget_size,
|
||||
widget_size,
|
||||
p_dispwidget->gfx_widgets_icons_textures[
|
||||
MENU_WIDGETS_ICON_ACHIEVEMENT],
|
||||
x, y, 0, pure_white);
|
||||
x,
|
||||
y,
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
pure_white);
|
||||
|
||||
if (dispctx && dispctx->blend_end)
|
||||
dispctx->blend_end(video_info->userdata);
|
||||
@ -188,11 +197,20 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata)
|
||||
else
|
||||
{
|
||||
/* achievement badge */
|
||||
gfx_widgets_draw_icon(video_info->userdata,
|
||||
p_disp, video_width, video_height,
|
||||
widget_size, widget_size,
|
||||
gfx_widgets_draw_icon(
|
||||
video_info->userdata,
|
||||
p_disp,
|
||||
video_width,
|
||||
video_height,
|
||||
widget_size,
|
||||
widget_size,
|
||||
state->challenge_info[i].image,
|
||||
x, y, 0, pure_white);
|
||||
x,
|
||||
y,
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
pure_white);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -805,7 +805,9 @@ static void gfx_widget_load_content_animation_frame(void *data, void *user_data)
|
||||
state->icon_texture,
|
||||
icon_x,
|
||||
state->icon_y,
|
||||
0.0f,
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
state->icon_color);
|
||||
|
||||
if (dispctx && dispctx->blend_end)
|
||||
|
@ -240,8 +240,12 @@ static void gfx_widget_screenshot_frame(void* data, void *user_data)
|
||||
state->thumbnail_width,
|
||||
state->thumbnail_height,
|
||||
state->texture,
|
||||
0, state->y,
|
||||
0, pure_white
|
||||
0,
|
||||
state->y,
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
pure_white
|
||||
);
|
||||
|
||||
gfx_widgets_draw_text(font_regular,
|
||||
|
@ -198,8 +198,12 @@ static void gfx_widget_volume_frame(void* data, void *user_data)
|
||||
video_height,
|
||||
icon_size, icon_size,
|
||||
volume_icon,
|
||||
0, 0,
|
||||
0, pure_white
|
||||
0,
|
||||
0,
|
||||
0.0f, /* rad */
|
||||
1.0f, /* cos(rad) = cos(0) = 1.0f */
|
||||
0.0f, /* sine(rad) = sine(0) = 0.0f */
|
||||
pure_white
|
||||
);
|
||||
if (dispctx && dispctx->blend_end)
|
||||
dispctx->blend_end(userdata);
|
||||
|
Loading…
x
Reference in New Issue
Block a user