mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 03:40:24 +00:00
gfx_display_rotate_z optimizations - if radians is 0, we know cosine
and sine already. Avoid the computation with sinf/cosf and pass it as value to the function when possible
This commit is contained in:
parent
6607ff3aaa
commit
bf5409881c
@ -957,7 +957,7 @@ void gfx_display_draw_texture_slice(
|
||||
}
|
||||
|
||||
void gfx_display_rotate_z(gfx_display_t *p_disp,
|
||||
gfx_display_ctx_rotate_draw_t *draw, void *data)
|
||||
math_matrix_4x4 *matrix, float cosine, float sine, void *data)
|
||||
{
|
||||
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
||||
math_matrix_4x4 *b = (dispctx->get_default_mvp)
|
||||
@ -971,14 +971,11 @@ void gfx_display_rotate_z(gfx_display_t *p_disp,
|
||||
0.0f, 0.0f, 1.0f, 0.0f ,
|
||||
0.0f, 0.0f, 0.0f, 1.0f }
|
||||
};
|
||||
float radians = draw->rotation;
|
||||
float cosine = cosf(radians);
|
||||
float sine = sinf(radians);
|
||||
MAT_ELEM_4X4(rot, 0, 0) = cosine;
|
||||
MAT_ELEM_4X4(rot, 0, 1) = -sine;
|
||||
MAT_ELEM_4X4(rot, 1, 0) = sine;
|
||||
MAT_ELEM_4X4(rot, 1, 1) = cosine;
|
||||
matrix_4x4_multiply(*draw->matrix, rot, *b);
|
||||
matrix_4x4_multiply(*matrix, rot, *b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1137,11 +1134,9 @@ void gfx_display_draw_keyboard(
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0.0f;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
for (i = 0; i < 44; i++)
|
||||
|
@ -170,12 +170,6 @@ struct gfx_display_ctx_draw
|
||||
bool pipeline_active;
|
||||
};
|
||||
|
||||
typedef struct gfx_display_ctx_rotate_draw
|
||||
{
|
||||
math_matrix_4x4 *matrix;
|
||||
float rotation;
|
||||
} gfx_display_ctx_rotate_draw_t;
|
||||
|
||||
typedef struct gfx_display_ctx_coord_draw
|
||||
{
|
||||
const float *ptr;
|
||||
@ -296,7 +290,7 @@ void gfx_display_draw_texture_slice(
|
||||
math_matrix_4x4 *mymat);
|
||||
|
||||
void gfx_display_rotate_z(gfx_display_t *p_disp,
|
||||
gfx_display_ctx_rotate_draw_t *draw, void *data);
|
||||
math_matrix_4x4 *matrix, float cosine, float sine, void *data);
|
||||
|
||||
font_data_t *gfx_display_font_file(gfx_display_t *p_disp,
|
||||
char* fontpath, float font_size, bool is_threaded);
|
||||
|
@ -922,11 +922,9 @@ void gfx_thumbnail_draw(
|
||||
* > But we still have to call gfx_display_rotate_z(),
|
||||
* or nothing will be drawn...
|
||||
*/
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0.0f;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
/* Configure draw object
|
||||
|
@ -609,7 +609,7 @@ void gfx_widgets_draw_icon(
|
||||
unsigned icon_height,
|
||||
uintptr_t texture,
|
||||
float x, float y,
|
||||
float rotation,
|
||||
float radians,
|
||||
float *color)
|
||||
{
|
||||
gfx_display_ctx_draw_t draw;
|
||||
@ -623,11 +623,9 @@ void gfx_widgets_draw_icon(
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = rotation;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = cosf(radians);
|
||||
float sine = sinf(radians);
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
coords.vertices = 4;
|
||||
@ -641,7 +639,7 @@ void gfx_widgets_draw_icon(
|
||||
draw.width = icon_width;
|
||||
draw.height = icon_height;
|
||||
draw.scale_factor = 1.0f;
|
||||
draw.rotation = rotation;
|
||||
draw.rotation = radians;
|
||||
draw.coords = &coords;
|
||||
draw.matrix_data = &mymat;
|
||||
draw.texture = texture;
|
||||
|
@ -4002,11 +4002,9 @@ static void materialui_render_menu_entry_default(
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0.0f;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
/* Initial ticker configuration
|
||||
@ -4353,11 +4351,9 @@ static void materialui_render_menu_entry_playlist_list(
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0.0f;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
/* Initial ticker configuration
|
||||
@ -4610,11 +4606,9 @@ static void materialui_render_menu_entry_playlist_dual_icon(
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0.0f;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
/* Initial ticker configuration
|
||||
@ -4905,11 +4899,9 @@ static void materialui_render_selected_entry_aux_playlist_desktop(
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0.0f;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
/* Draw sidebar background
|
||||
@ -6934,11 +6926,9 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0.0f;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
video_driver_set_viewport(video_width, video_height, true, false);
|
||||
|
@ -9942,11 +9942,9 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0.0f;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
/* Header, footer */
|
||||
|
@ -3675,11 +3675,9 @@ static int xmb_draw_item(
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat_tmp;
|
||||
rotate_draw.rotation = 0;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat_tmp, cosine, sine, userdata);
|
||||
|
||||
if (scale_factor != 1.0f)
|
||||
{
|
||||
@ -5198,11 +5196,9 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0;
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||
}
|
||||
|
||||
/**************************/
|
||||
@ -5616,11 +5612,10 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
|
||||
if (!p_disp->dispctx->handles_transform)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
rotate_draw.matrix = &mymat_tmp;
|
||||
rotate_draw.rotation = 0;
|
||||
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||
|
||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
||||
gfx_display_rotate_z(p_disp, &mymat_tmp, cosine, sine, userdata);
|
||||
|
||||
if (scale_factor != 1.0f)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user