mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-22 10:49:02 +00:00
Create menu_display_draw_cursor - code de-duplication
This commit is contained in:
parent
528eddbed5
commit
cbcbd895d2
@ -646,34 +646,6 @@ static void mui_render_menu_list(mui_handle_t *mui,
|
||||
}
|
||||
}
|
||||
|
||||
static void mui_draw_cursor(mui_handle_t *mui,
|
||||
float *color,
|
||||
float x, float y, unsigned width, unsigned height)
|
||||
{
|
||||
menu_display_ctx_draw_t draw;
|
||||
struct gfx_coords coords;
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = NULL;
|
||||
coords.tex_coord = NULL;
|
||||
coords.lut_tex_coord = NULL;
|
||||
coords.color = (const float*)color;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
|
||||
|
||||
draw.x = x - (mui->cursor.size / 2);
|
||||
draw.y = (int)height - y - (mui->cursor.size / 2);
|
||||
draw.width = mui->cursor.size;
|
||||
draw.height = mui->cursor.size;
|
||||
draw.coords = &coords;
|
||||
draw.matrix_data = NULL;
|
||||
draw.texture = mui->textures.list[MUI_TEXTURE_POINTER];
|
||||
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw);
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL);
|
||||
}
|
||||
|
||||
static size_t mui_list_get_size(void *data, enum menu_list_type type)
|
||||
{
|
||||
@ -1019,7 +991,14 @@ static void mui_frame(void *data)
|
||||
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
||||
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||
|
||||
mui_draw_cursor(mui, &white_bg[0], mouse_x, mouse_y, width, height);
|
||||
menu_display_draw_cursor(
|
||||
&white_bg[0],
|
||||
mui->cursor.size,
|
||||
mui->textures.list[MUI_TEXTURE_POINTER],
|
||||
mouse_x,
|
||||
mouse_y,
|
||||
width,
|
||||
height);
|
||||
}
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_RESTORE_CLEAR_COLOR, NULL);
|
||||
|
@ -1765,34 +1765,6 @@ static void xmb_draw_items(xmb_handle_t *xmb,
|
||||
}
|
||||
}
|
||||
|
||||
static void xmb_draw_cursor(xmb_handle_t *xmb,
|
||||
float *color,
|
||||
float x, float y, unsigned width, unsigned height)
|
||||
{
|
||||
menu_display_ctx_draw_t draw;
|
||||
struct gfx_coords coords;
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = NULL;
|
||||
coords.tex_coord = NULL;
|
||||
coords.lut_tex_coord = NULL;
|
||||
coords.color = (const float*)color;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
|
||||
|
||||
draw.x = x - (xmb->cursor.size / 2);
|
||||
draw.y = height - y - (xmb->cursor.size / 2);
|
||||
draw.width = xmb->cursor.size;
|
||||
draw.height = xmb->cursor.size;
|
||||
draw.coords = &coords;
|
||||
draw.matrix_data = NULL;
|
||||
draw.texture = xmb->textures.list[XMB_TEXTURE_POINTER];
|
||||
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL);
|
||||
}
|
||||
|
||||
static void xmb_render(void *data)
|
||||
{
|
||||
float delta_time;
|
||||
@ -2192,7 +2164,14 @@ static void xmb_frame(void *data)
|
||||
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
||||
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||
|
||||
xmb_draw_cursor(xmb, &coord_color2[0], mouse_x, mouse_y, width, height);
|
||||
menu_display_draw_cursor(
|
||||
&coord_color2[0],
|
||||
xmb->cursor.size,
|
||||
xmb->textures.list[XMB_TEXTURE_POINTER],
|
||||
mouse_x,
|
||||
mouse_y,
|
||||
width,
|
||||
height);
|
||||
}
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL);
|
||||
|
@ -606,6 +606,34 @@ void menu_display_allocate_white_texture(void)
|
||||
TEXTURE_FILTER_NEAREST, &menu_display_white_texture);
|
||||
}
|
||||
|
||||
void menu_display_draw_cursor(
|
||||
float *color, float cursor_size, uintptr_t texture,
|
||||
float x, float y, unsigned width, unsigned height)
|
||||
{
|
||||
menu_display_ctx_draw_t draw;
|
||||
struct gfx_coords coords;
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = NULL;
|
||||
coords.tex_coord = NULL;
|
||||
coords.lut_tex_coord = NULL;
|
||||
coords.color = (const float*)color;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
|
||||
|
||||
draw.x = x - (cursor_size / 2);
|
||||
draw.y = (int)height - y - (cursor_size / 2);
|
||||
draw.width = cursor_size;
|
||||
draw.height = cursor_size;
|
||||
draw.coords = &coords;
|
||||
draw.matrix_data = NULL;
|
||||
draw.texture = texture;
|
||||
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL);
|
||||
}
|
||||
|
||||
static INLINE float menu_display_scalef(float val,
|
||||
float oldmin, float oldmax, float newmin, float newmax)
|
||||
{
|
||||
|
@ -183,8 +183,13 @@ void menu_display_push_quad(
|
||||
|
||||
void menu_display_snow(int width, int height);
|
||||
|
||||
void menu_display_allocate_white_texture(void);
|
||||
|
||||
void menu_display_draw_cursor(
|
||||
float *color, float cursor_size, uintptr_t texture,
|
||||
float x, float y, unsigned width, unsigned height);
|
||||
|
||||
extern uintptr_t menu_display_white_texture;
|
||||
void menu_display_allocate_white_texture();
|
||||
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_gl;
|
||||
extern menu_display_ctx_driver_t menu_display_ctx_vulkan;
|
||||
|
Loading…
Reference in New Issue
Block a user