mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
pass draw pointer instead of plenty of params
This commit is contained in:
parent
159ebcc8a2
commit
c6cc006223
@ -107,20 +107,13 @@ static void menu_display_d3d_blend_end(void)
|
||||
d3d_disable_blend_func(d3d->dev);
|
||||
}
|
||||
|
||||
static void menu_display_d3d_draw(
|
||||
float x, float y,
|
||||
unsigned width, unsigned height,
|
||||
struct gfx_coords *coords,
|
||||
void *matrix_data,
|
||||
uintptr_t texture,
|
||||
enum menu_display_prim_type prim_type
|
||||
)
|
||||
static void menu_display_d3d_draw(menu_display_ctx_draw_t *draw)
|
||||
{
|
||||
D3DVIEWPORT vp = {0};
|
||||
d3d_video_t *d3d = d3d_get_ptr();
|
||||
math_matrix_4x4 *mat = (math_matrix_4x4*)matrix_data;
|
||||
|
||||
if (!d3d)
|
||||
if (!d3d || !draw)
|
||||
return;
|
||||
|
||||
/* TODO - edge case */
|
||||
@ -129,47 +122,37 @@ static void menu_display_d3d_draw(
|
||||
|
||||
if (!mat)
|
||||
mat = (math_matrix_4x4*)menu_display_d3d_get_default_mvp();
|
||||
if (!coords->vertex)
|
||||
coords->vertex = &d3d_vertexes[0];
|
||||
if (!coords->tex_coord)
|
||||
coords->tex_coord = &d3d_tex_coords[0];
|
||||
if (!coords->lut_tex_coord)
|
||||
coords->lut_tex_coord = &d3d_tex_coords[0];
|
||||
if (!draw->coords->vertex)
|
||||
draw->coords->vertex = &d3d_vertexes[0];
|
||||
if (!draw->coords->tex_coord)
|
||||
draw->coords->tex_coord = &d3d_tex_coords[0];
|
||||
if (!draw->coords->lut_tex_coord)
|
||||
draw->coords->lut_tex_coord = &d3d_tex_coords[0];
|
||||
|
||||
vp.X = x;
|
||||
vp.Y = y;
|
||||
vp.Width = width;
|
||||
vp.Height = height;
|
||||
vp.X = draw->x;
|
||||
vp.Y = draw->y;
|
||||
vp.Width = draw->width;
|
||||
vp.Height = draw->height;
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
|
||||
d3d_set_viewports(d3d->dev, &vp);
|
||||
d3d_set_texture(d3d->dev, 0, (LPDIRECT3DTEXTURE)texture);
|
||||
d3d_set_texture(d3d->dev, 0, (LPDIRECT3DTEXTURE)draw->texture);
|
||||
|
||||
#if 0
|
||||
video_shader_driver_set_coords(d3d, coords);
|
||||
video_shader_driver_set_coords(d3d, draw->coords);
|
||||
video_shader_driver_set_mvp(d3d, mat);
|
||||
#endif
|
||||
|
||||
d3d_draw_primitive(d3d->dev, (D3DPRIMITIVETYPE)menu_display_prim_to_d3d_enum(prim_type), 0, coords->vertices);
|
||||
d3d_draw_primitive(d3d->dev, (D3DPRIMITIVETYPE)
|
||||
menu_display_prim_to_d3d_enum(draw->prim_type), 0, draw->coords->vertices);
|
||||
|
||||
#if 0
|
||||
gl->coords.color = gl->white_color_ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void menu_display_d3d_draw_bg(
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
uintptr_t texture,
|
||||
float handle_alpha,
|
||||
bool force_transparency,
|
||||
float *coord_color,
|
||||
float *coord_color2,
|
||||
const float *vertex,
|
||||
const float *tex_coord,
|
||||
size_t vertex_count,
|
||||
enum menu_display_prim_type prim_type)
|
||||
static void menu_display_d3d_draw_bg(menu_display_ctx_draw_t *draw)
|
||||
{
|
||||
struct gfx_coords coords;
|
||||
const float *new_vertex = NULL;
|
||||
@ -178,7 +161,7 @@ static void menu_display_d3d_draw_bg(
|
||||
settings_t *settings = config_get_ptr();
|
||||
d3d_video_t *d3d = d3d_get_ptr();
|
||||
|
||||
if (!d3d)
|
||||
if (!d3d || !draw)
|
||||
return;
|
||||
|
||||
new_vertex = vertex;
|
||||
@ -189,7 +172,7 @@ static void menu_display_d3d_draw_bg(
|
||||
if (!new_tex_coord)
|
||||
new_tex_coord = &d3d_tex_coords[0];
|
||||
|
||||
coords.vertices = vertex_count;
|
||||
coords.vertices = draw->vertex_count;
|
||||
coords.vertex = new_vertex;
|
||||
coords.tex_coord = new_tex_coord;
|
||||
coords.lut_tex_coord = new_tex_coord;
|
||||
@ -201,13 +184,12 @@ static void menu_display_d3d_draw_bg(
|
||||
|
||||
if ((settings->menu.pause_libretro
|
||||
|| !rarch_ctl(RARCH_CTL_IS_INITED, NULL) || rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
||||
&& !force_transparency
|
||||
&& texture)
|
||||
&& !draw->force_transparency && draw->texture)
|
||||
coords.color = (const float*)coord_color2;
|
||||
|
||||
menu_display_d3d_draw(0, 0, width, height,
|
||||
&coords, (math_matrix_4x4*)menu_display_d3d_get_default_mvp(),
|
||||
(uintptr_t)texture, prim_type);
|
||||
menu_display_d3d_draw(0, 0, draw->width, draw->height,
|
||||
&draw->coords, (math_matrix_4x4*)menu_display_d3d_get_default_mvp(),
|
||||
(uintptr_t)draw->texture, draw->prim_type);
|
||||
|
||||
menu_display_d3d_blend_end();
|
||||
|
||||
|
@ -86,57 +86,42 @@ static void menu_display_gl_blend_end(void)
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
static void menu_display_gl_draw(
|
||||
float x, float y,
|
||||
unsigned width, unsigned height,
|
||||
struct gfx_coords *coords,
|
||||
void *matrix_data,
|
||||
uintptr_t texture,
|
||||
enum menu_display_prim_type prim_type
|
||||
)
|
||||
static void menu_display_gl_draw(menu_display_ctx_draw_t *draw)
|
||||
{
|
||||
gl_t *gl = gl_get_ptr();
|
||||
math_matrix_4x4 *mat = (math_matrix_4x4*)matrix_data;
|
||||
|
||||
if (!gl)
|
||||
math_matrix_4x4 *mat = NULL;
|
||||
|
||||
if (!gl || !draw)
|
||||
return;
|
||||
|
||||
mat = (math_matrix_4x4*)draw->matrix_data;
|
||||
|
||||
/* TODO - edge case */
|
||||
if (height <= 0)
|
||||
height = 1;
|
||||
if (draw->height <= 0)
|
||||
draw->height = 1;
|
||||
|
||||
if (!mat)
|
||||
mat = (math_matrix_4x4*)menu_display_gl_get_default_mvp();
|
||||
if (!coords->vertex)
|
||||
coords->vertex = &gl_vertexes[0];
|
||||
if (!coords->tex_coord)
|
||||
coords->tex_coord = &gl_tex_coords[0];
|
||||
if (!coords->lut_tex_coord)
|
||||
coords->lut_tex_coord = &gl_tex_coords[0];
|
||||
if (!draw->coords->vertex)
|
||||
draw->coords->vertex = &gl_vertexes[0];
|
||||
if (!draw->coords->tex_coord)
|
||||
draw->coords->tex_coord = &gl_tex_coords[0];
|
||||
if (!draw->coords->lut_tex_coord)
|
||||
draw->coords->lut_tex_coord = &gl_tex_coords[0];
|
||||
|
||||
glViewport(x, y, width, height);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)texture);
|
||||
glViewport(draw->x, draw->y, draw->width, draw->height);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)draw->texture);
|
||||
|
||||
video_shader_driver_set_coords(gl, coords);
|
||||
video_shader_driver_set_coords(gl, draw->coords);
|
||||
video_shader_driver_set_mvp(gl, mat);
|
||||
|
||||
glDrawArrays(menu_display_prim_to_gl_enum(prim_type), 0, coords->vertices);
|
||||
glDrawArrays(menu_display_prim_to_gl_enum(
|
||||
draw->prim_type), 0, draw->coords->vertices);
|
||||
|
||||
gl->coords.color = gl->white_color_ptr;
|
||||
}
|
||||
|
||||
static void menu_display_gl_draw_bg(
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
uintptr_t texture,
|
||||
float handle_alpha,
|
||||
bool force_transparency,
|
||||
GLfloat *coord_color,
|
||||
GLfloat *coord_color2,
|
||||
const float *vertex,
|
||||
const float *tex_coord,
|
||||
size_t vertex_count,
|
||||
enum menu_display_prim_type prim_type)
|
||||
static void menu_display_gl_draw_bg(menu_display_ctx_draw_t *draw)
|
||||
{
|
||||
struct gfx_coords coords;
|
||||
const GLfloat *new_vertex = NULL;
|
||||
@ -144,22 +129,22 @@ static void menu_display_gl_draw_bg(
|
||||
settings_t *settings = config_get_ptr();
|
||||
gl_t *gl = gl_get_ptr();
|
||||
|
||||
if (!gl)
|
||||
if (!gl || !draw)
|
||||
return;
|
||||
|
||||
new_vertex = vertex;
|
||||
new_tex_coord = tex_coord;
|
||||
new_vertex = draw->vertex;
|
||||
new_tex_coord = draw->tex_coord;
|
||||
|
||||
if (!new_vertex)
|
||||
new_vertex = &gl_vertexes[0];
|
||||
if (!new_tex_coord)
|
||||
new_tex_coord = &gl_tex_coords[0];
|
||||
|
||||
coords.vertices = vertex_count;
|
||||
coords.vertices = draw->vertex_count;
|
||||
coords.vertex = new_vertex;
|
||||
coords.tex_coord = new_tex_coord;
|
||||
coords.lut_tex_coord = new_tex_coord;
|
||||
coords.color = (const float*)coord_color;
|
||||
coords.color = (const float*)draw->color;
|
||||
|
||||
menu_display_gl_blend_begin();
|
||||
|
||||
@ -170,13 +155,15 @@ static void menu_display_gl_draw_bg(
|
||||
|| !rarch_ctl(RARCH_CTL_IS_INITED, NULL)
|
||||
|| rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)
|
||||
)
|
||||
&& !force_transparency
|
||||
&& texture)
|
||||
coords.color = (const float*)coord_color2;
|
||||
&& !draw->force_transparency && draw->texture)
|
||||
coords.color = (const float*)draw->color2;
|
||||
|
||||
menu_display_gl_draw(0, 0, width, height,
|
||||
&coords, (math_matrix_4x4*)menu_display_gl_get_default_mvp(),
|
||||
(GLuint)texture, prim_type);
|
||||
draw->x = 0;
|
||||
draw->y = 0;
|
||||
draw->coords = &coords;
|
||||
draw->matrix_data = (math_matrix_4x4*)menu_display_gl_get_default_mvp();
|
||||
|
||||
menu_display_gl_draw(draw);
|
||||
|
||||
menu_display_gl_blend_end();
|
||||
|
||||
|
@ -37,30 +37,14 @@ static void menu_display_null_blend_end(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void menu_display_null_draw(
|
||||
float x, float y,
|
||||
unsigned width, unsigned height,
|
||||
struct gfx_coords *coords,
|
||||
void *matrix_data,
|
||||
uintptr_t texture,
|
||||
enum menu_display_prim_type prim_type
|
||||
)
|
||||
static void menu_display_null_draw(menu_display_ctx_draw_t *draw)
|
||||
{
|
||||
(void)draw;
|
||||
}
|
||||
|
||||
static void menu_display_null_draw_bg(
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
uintptr_t texture,
|
||||
float handle_alpha,
|
||||
bool force_transparency,
|
||||
float *coord_color,
|
||||
float *coord_color2,
|
||||
const float *vertex,
|
||||
const float *tex_coord,
|
||||
size_t vertex_count,
|
||||
enum menu_display_prim_type prim_type)
|
||||
static void menu_display_null_draw_bg(menu_display_ctx_draw_t *draw)
|
||||
{
|
||||
(void)draw;
|
||||
}
|
||||
|
||||
static void menu_display_null_restore_clear_color(void)
|
||||
|
@ -121,21 +121,19 @@ static void menu_display_timedate(void *data)
|
||||
bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
{
|
||||
unsigned width, height;
|
||||
static bool menu_display_msg_force = false;
|
||||
static unsigned menu_display_framebuf_width = 0;
|
||||
static unsigned menu_display_framebuf_height = 0;
|
||||
static size_t menu_display_framebuf_pitch = 0;
|
||||
static int menu_display_font_size = 0;
|
||||
static unsigned menu_display_header_height = 0;
|
||||
static const uint8_t *menu_display_font_framebuf = NULL;
|
||||
static void *menu_display_font_buf = NULL;
|
||||
static bool menu_display_msg_force = false;
|
||||
static bool menu_display_font_alloc_framebuf = false;
|
||||
static bool menu_display_framebuf_dirty = false;
|
||||
static menu_display_draw_t draw_bak = NULL;
|
||||
static menu_display_draw_bg_t draw_bg_bak = NULL;
|
||||
static const uint8_t *menu_display_font_framebuf = NULL;
|
||||
static void *menu_display_font_buf = NULL;
|
||||
static msg_queue_t *menu_display_msg_queue = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
static menu_display_ctx_driver_t *menu_disp = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
@ -205,16 +203,8 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
retro_assert(menu_display_msg_queue = msg_queue_new(8));
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_SET_STUB_DRAW_FRAME:
|
||||
draw_bak = menu_disp->draw;
|
||||
draw_bg_bak = menu_disp->draw_bg;
|
||||
menu_disp->draw = menu_display_ctx_null.draw;
|
||||
menu_disp->draw_bg = menu_display_ctx_null.draw_bg;
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_UNSET_STUB_DRAW_FRAME:
|
||||
if (draw_bak != NULL)
|
||||
menu_disp->draw = draw_bak;
|
||||
if (draw_bg_bak != NULL)
|
||||
menu_disp->draw_bg = draw_bg_bak;
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_FONT_BUF:
|
||||
{
|
||||
@ -465,9 +455,7 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
|
||||
if (!menu_disp || !menu_disp->draw)
|
||||
return false;
|
||||
menu_disp->draw(draw->x, draw->y, draw->width, draw->height,
|
||||
draw->coords, draw->matrix_data,
|
||||
draw->texture, draw->prim_type);
|
||||
menu_disp->draw(draw);
|
||||
}
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_DRAW_BG:
|
||||
@ -476,11 +464,7 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
if (!menu_disp || !menu_disp->draw_bg)
|
||||
return false;
|
||||
|
||||
menu_disp->draw_bg(draw->width, draw->height,
|
||||
draw->texture, draw->handle_alpha,
|
||||
draw->force_transparency, draw->color,
|
||||
draw->color2, draw->vertex, draw->tex_coord,
|
||||
draw->vertex_count, draw->prim_type);
|
||||
menu_disp->draw_bg(draw);
|
||||
}
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_ROTATE_Z:
|
||||
|
@ -96,51 +96,6 @@ enum menu_display_driver_type
|
||||
MENU_VIDEO_DRIVER_DIRECT3D
|
||||
};
|
||||
|
||||
typedef void (*menu_display_draw_t)(float x, float y,
|
||||
unsigned width, unsigned height,
|
||||
struct gfx_coords *coords,
|
||||
void *matrix_data,
|
||||
uintptr_t texture,
|
||||
enum menu_display_prim_type prim_type
|
||||
);
|
||||
typedef void (*menu_display_draw_bg_t)(
|
||||
unsigned width, unsigned height,
|
||||
uintptr_t texture,
|
||||
float handle_alpha,
|
||||
bool force_transparency,
|
||||
float *color,
|
||||
float *color2,
|
||||
const float *vertex,
|
||||
const float *tex_coord,
|
||||
size_t vertex_count,
|
||||
enum menu_display_prim_type prim_type
|
||||
);
|
||||
|
||||
typedef struct menu_display_ctx_driver
|
||||
{
|
||||
menu_display_draw_t draw;
|
||||
menu_display_draw_bg_t draw_bg;
|
||||
void (*blend_begin)(void);
|
||||
void (*blend_end)(void);
|
||||
void (*restore_clear_color)(void);
|
||||
|
||||
void (*clear_color)(float r, float g, float b, float a);
|
||||
|
||||
void *(*get_default_mvp)(void);
|
||||
const float *(*get_tex_coords)(void);
|
||||
bool (*font_init_first)(
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size);
|
||||
enum menu_display_driver_type type;
|
||||
const char *ident;
|
||||
} menu_display_ctx_driver_t;
|
||||
|
||||
typedef struct menu_display_ctx_font
|
||||
{
|
||||
const char *path;
|
||||
float size;
|
||||
} menu_display_ctx_font_t;
|
||||
|
||||
typedef struct menu_display_ctx_clearcolor
|
||||
{
|
||||
float r;
|
||||
@ -190,6 +145,32 @@ typedef struct menu_display_ctx_datetime
|
||||
unsigned time_mode;
|
||||
} menu_display_ctx_datetime_t;
|
||||
|
||||
typedef struct menu_display_ctx_driver
|
||||
{
|
||||
void (*draw)(menu_display_ctx_draw_t *draw);
|
||||
void (*draw_bg)(menu_display_ctx_draw_t *draw);
|
||||
void (*blend_begin)(void);
|
||||
void (*blend_end)(void);
|
||||
void (*restore_clear_color)(void);
|
||||
|
||||
void (*clear_color)(float r, float g, float b, float a);
|
||||
|
||||
void *(*get_default_mvp)(void);
|
||||
const float *(*get_tex_coords)(void);
|
||||
bool (*font_init_first)(
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size);
|
||||
enum menu_display_driver_type type;
|
||||
const char *ident;
|
||||
} menu_display_ctx_driver_t;
|
||||
|
||||
typedef struct menu_display_ctx_font
|
||||
{
|
||||
const char *path;
|
||||
float size;
|
||||
} menu_display_ctx_font_t;
|
||||
|
||||
|
||||
bool menu_display_ctl(enum menu_display_ctl_state state, void *data);
|
||||
|
||||
void menu_display_handle_wallpaper_upload(void *task_data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user