rotate_draw - get rid of scale_x/y/enable - scaling is only done now

in XMB at two spots - refactor gfx_display_rotate_z so that it only
manipulates the input matrix' Z axis
This commit is contained in:
libretroadmin 2022-07-05 20:50:01 +02:00
parent 95db09d8c5
commit 6607ff3aaa
7 changed files with 43 additions and 85 deletions

View File

@ -959,43 +959,26 @@ 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)
{
float cosine, sine;
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
math_matrix_4x4 *b = (dispctx->get_default_mvp)
? (math_matrix_4x4*)dispctx->get_default_mvp(data)
: NULL;
if (b)
{
static math_matrix_4x4 rot = {
{ 0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 1.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 1.0f }
};
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
math_matrix_4x4 *b = (dispctx->get_default_mvp)
? (math_matrix_4x4*)dispctx->get_default_mvp(data)
: NULL;
float radians = draw->rotation;
if (!b)
return;
cosine = cosf(radians);
sine = sinf(radians);
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);
if (draw->scale_enable)
{
static math_matrix_4x4 matrix_scaled = {
{ 0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 1.0f }
};
MAT_ELEM_4X4(matrix_scaled, 0, 0) = draw->scale_x;
MAT_ELEM_4X4(matrix_scaled, 1, 1) = draw->scale_y;
MAT_ELEM_4X4(matrix_scaled, 2, 2) = draw->scale_z;
matrix_4x4_multiply(*draw->matrix, matrix_scaled, *draw->matrix);
}
}
@ -1157,10 +1140,6 @@ void gfx_display_draw_keyboard(
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0.0f;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}

View File

@ -174,10 +174,6 @@ typedef struct gfx_display_ctx_rotate_draw
{
math_matrix_4x4 *matrix;
float rotation;
float scale_x;
float scale_y;
float scale_z;
bool scale_enable;
} gfx_display_ctx_rotate_draw_t;
typedef struct gfx_display_ctx_coord_draw

View File

@ -921,15 +921,10 @@ void gfx_thumbnail_draw(
* rotation entirely
* > But we still have to call gfx_display_rotate_z(),
* or nothing will be drawn...
* Note that we also disable scaling here (scale_enable),
* since we handle scaling internally... */
*/
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0.0f;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}

View File

@ -626,10 +626,6 @@ void gfx_widgets_draw_icon(
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = rotation;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}

View File

@ -4005,10 +4005,6 @@ static void materialui_render_menu_entry_default(
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0.0f;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}
@ -4360,10 +4356,6 @@ static void materialui_render_menu_entry_playlist_list(
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0.0f;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}
@ -4621,10 +4613,6 @@ static void materialui_render_menu_entry_playlist_dual_icon(
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0.0f;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}
@ -4920,10 +4908,6 @@ static void materialui_render_selected_entry_aux_playlist_desktop(
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0.0f;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}
@ -6953,10 +6937,6 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0.0f;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}

View File

@ -9945,10 +9945,6 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0.0f;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}

View File

@ -3678,12 +3678,22 @@ static int xmb_draw_item(
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat_tmp;
rotate_draw.rotation = 0;
rotate_draw.scale_x = scale_factor;
rotate_draw.scale_y = scale_factor;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = (scale_factor == 1.0f) ? false : true;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
if (scale_factor != 1.0f)
{
static math_matrix_4x4 matrix_scaled = {
{ 0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 1.0f }
};
MAT_ELEM_4X4(matrix_scaled, 0, 0) = scale_factor;
MAT_ELEM_4X4(matrix_scaled, 1, 1) = scale_factor;
MAT_ELEM_4X4(matrix_scaled, 2, 2) = 1.0f;
matrix_4x4_multiply(mymat_tmp, matrix_scaled, mymat_tmp);
}
}
xmb_draw_icon(
@ -5191,10 +5201,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0;
rotate_draw.scale_x = 1.0f;
rotate_draw.scale_y = 1.0f;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = false;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
}
@ -5613,12 +5619,22 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
gfx_display_ctx_rotate_draw_t rotate_draw;
rotate_draw.matrix = &mymat_tmp;
rotate_draw.rotation = 0;
rotate_draw.scale_x = scale_factor;
rotate_draw.scale_y = scale_factor;
rotate_draw.scale_z = 1.0f;
rotate_draw.scale_enable = (scale_factor == 1.0f) ? false : true;
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
if (scale_factor != 1.0f)
{
static math_matrix_4x4 matrix_scaled = {
{ 0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 1.0f }
};
MAT_ELEM_4X4(matrix_scaled, 0, 0) = scale_factor;
MAT_ELEM_4X4(matrix_scaled, 1, 1) = scale_factor;
MAT_ELEM_4X4(matrix_scaled, 2, 2) = 1.0f;
matrix_4x4_multiply(mymat_tmp, matrix_scaled, mymat_tmp);
}
}
xmb_draw_icon(