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,
|
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;
|
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
||||||
math_matrix_4x4 *b = (dispctx->get_default_mvp)
|
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, 1.0f, 0.0f ,
|
||||||
0.0f, 0.0f, 0.0f, 1.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, 0) = cosine;
|
||||||
MAT_ELEM_4X4(rot, 0, 1) = -sine;
|
MAT_ELEM_4X4(rot, 0, 1) = -sine;
|
||||||
MAT_ELEM_4X4(rot, 1, 0) = sine;
|
MAT_ELEM_4X4(rot, 1, 0) = sine;
|
||||||
MAT_ELEM_4X4(rot, 1, 1) = cosine;
|
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)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0.0f;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 44; i++)
|
for (i = 0; i < 44; i++)
|
||||||
|
|
|
@ -170,12 +170,6 @@ struct gfx_display_ctx_draw
|
||||||
bool pipeline_active;
|
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
|
typedef struct gfx_display_ctx_coord_draw
|
||||||
{
|
{
|
||||||
const float *ptr;
|
const float *ptr;
|
||||||
|
@ -296,7 +290,7 @@ void gfx_display_draw_texture_slice(
|
||||||
math_matrix_4x4 *mymat);
|
math_matrix_4x4 *mymat);
|
||||||
|
|
||||||
void gfx_display_rotate_z(gfx_display_t *p_disp,
|
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,
|
font_data_t *gfx_display_font_file(gfx_display_t *p_disp,
|
||||||
char* fontpath, float font_size, bool is_threaded);
|
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(),
|
* > But we still have to call gfx_display_rotate_z(),
|
||||||
* or nothing will be drawn...
|
* or nothing will be drawn...
|
||||||
*/
|
*/
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0.0f;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure draw object
|
/* Configure draw object
|
||||||
|
|
|
@ -609,7 +609,7 @@ void gfx_widgets_draw_icon(
|
||||||
unsigned icon_height,
|
unsigned icon_height,
|
||||||
uintptr_t texture,
|
uintptr_t texture,
|
||||||
float x, float y,
|
float x, float y,
|
||||||
float rotation,
|
float radians,
|
||||||
float *color)
|
float *color)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_draw_t draw;
|
gfx_display_ctx_draw_t draw;
|
||||||
|
@ -623,11 +623,9 @@ void gfx_widgets_draw_icon(
|
||||||
|
|
||||||
if (!p_disp->dispctx->handles_transform)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = cosf(radians);
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = sinf(radians);
|
||||||
rotate_draw.rotation = rotation;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
coords.vertices = 4;
|
coords.vertices = 4;
|
||||||
|
@ -641,7 +639,7 @@ void gfx_widgets_draw_icon(
|
||||||
draw.width = icon_width;
|
draw.width = icon_width;
|
||||||
draw.height = icon_height;
|
draw.height = icon_height;
|
||||||
draw.scale_factor = 1.0f;
|
draw.scale_factor = 1.0f;
|
||||||
draw.rotation = rotation;
|
draw.rotation = radians;
|
||||||
draw.coords = &coords;
|
draw.coords = &coords;
|
||||||
draw.matrix_data = &mymat;
|
draw.matrix_data = &mymat;
|
||||||
draw.texture = texture;
|
draw.texture = texture;
|
||||||
|
|
|
@ -4002,11 +4002,9 @@ static void materialui_render_menu_entry_default(
|
||||||
|
|
||||||
if (!p_disp->dispctx->handles_transform)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0.0f;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initial ticker configuration
|
/* Initial ticker configuration
|
||||||
|
@ -4353,11 +4351,9 @@ static void materialui_render_menu_entry_playlist_list(
|
||||||
|
|
||||||
if (!p_disp->dispctx->handles_transform)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0.0f;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initial ticker configuration
|
/* Initial ticker configuration
|
||||||
|
@ -4610,11 +4606,9 @@ static void materialui_render_menu_entry_playlist_dual_icon(
|
||||||
|
|
||||||
if (!p_disp->dispctx->handles_transform)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0.0f;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initial ticker configuration
|
/* Initial ticker configuration
|
||||||
|
@ -4905,11 +4899,9 @@ static void materialui_render_selected_entry_aux_playlist_desktop(
|
||||||
|
|
||||||
if (!p_disp->dispctx->handles_transform)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0.0f;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw sidebar background
|
/* 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)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0.0f;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
video_driver_set_viewport(video_width, video_height, true, false);
|
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)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0.0f;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Header, footer */
|
/* Header, footer */
|
||||||
|
|
|
@ -3675,11 +3675,9 @@ static int xmb_draw_item(
|
||||||
|
|
||||||
if (!p_disp->dispctx->handles_transform)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat_tmp;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0;
|
gfx_display_rotate_z(p_disp, &mymat_tmp, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
|
|
||||||
if (scale_factor != 1.0f)
|
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)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0;
|
gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
|
||||||
|
|
||||||
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
|
@ -5616,11 +5612,10 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||||
|
|
||||||
if (!p_disp->dispctx->handles_transform)
|
if (!p_disp->dispctx->handles_transform)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
float cosine = 1.0f; /* cos(rad) = cos(0) = 1.0f */
|
||||||
rotate_draw.matrix = &mymat_tmp;
|
float sine = 0.0f; /* sine(rad) = sine(0) = 0.0f */
|
||||||
rotate_draw.rotation = 0;
|
|
||||||
|
|
||||||
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)
|
if (scale_factor != 1.0f)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue