reduce more calls to video_driver_get_ptr

This commit is contained in:
twinaphex 2018-02-16 17:54:39 +01:00
parent 964e9db588
commit b25e2ce4e8
16 changed files with 76 additions and 59 deletions

View File

@ -361,7 +361,7 @@ static void mui_draw_icon(
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
draw.pipeline.id = 0;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
menu_display_blend_end(video_info);
}
@ -454,6 +454,7 @@ static void mui_render_keyboard(mui_handle_t *mui,
menu_display_blend_begin(video_info);
menu_display_draw_texture(
video_info,
width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width,
height/2.0 + ptr_height*1.5 + line_y,
ptr_width, ptr_height,
@ -1155,7 +1156,7 @@ static void mui_draw_bg(menu_display_ctx_draw_t *draw,
menu_display_draw_bg(draw, video_info, add_opacity,
opacity_override);
menu_display_draw(draw);
menu_display_draw(draw, video_info);
menu_display_blend_end(video_info);
}

View File

@ -602,6 +602,7 @@ static INLINE float xmb_item_y(const xmb_handle_t *xmb, int i, size_t current)
}
static void xmb_draw_icon(
video_frame_info_t *video_info,
menu_display_frame_info_t menu_disp_info,
int icon_size,
math_matrix_4x4 *mymat,
@ -661,7 +662,7 @@ static void xmb_draw_icon(
draw.y = draw.y + (icon_size-draw.width)/2;
}
#endif
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
}
coords.color = (const float*)color;
@ -675,10 +676,11 @@ static void xmb_draw_icon(
draw.y = draw.y + (icon_size-draw.width)/2;
}
#endif
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
}
static void xmb_draw_thumbnail(
video_frame_info_t *video_info,
menu_display_frame_info_t menu_disp_info,
xmb_handle_t *xmb, float *color,
unsigned width, unsigned height,
@ -720,7 +722,7 @@ static void xmb_draw_thumbnail(
draw.x = x + xmb->shadow_offset;
draw.y = height - y - xmb->shadow_offset;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
}
coords.color = (const float*)color;
@ -729,7 +731,7 @@ static void xmb_draw_thumbnail(
menu_display_set_alpha(color, 1.0f);
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
}
static void xmb_draw_text(
@ -820,6 +822,7 @@ static void xmb_render_keyboard(xmb_handle_t *xmb,
menu_display_blend_begin(video_info);
menu_display_draw_texture(
video_info,
width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width,
height/2.0 + ptr_height*1.5 + line_y,
ptr_width, ptr_height,
@ -916,6 +919,7 @@ static void xmb_render_messagebox_internal(
menu_display_blend_begin(video_info);
menu_display_draw_texture_slice(
video_info,
x - longest_width/2 - xmb->margins_dialog,
y + xmb->margins_slice - xmb->margins_dialog,
256, 256,
@ -2339,6 +2343,7 @@ static void xmb_calculate_visible_range(const xmb_handle_t *xmb,
}
static int xmb_draw_item(
video_frame_info_t *video_info,
menu_display_frame_info_t menu_disp_info,
menu_entry_t *entry,
math_matrix_4x4 *mymat,
@ -2545,7 +2550,7 @@ static int xmb_draw_item(
menu_display_rotate_z(&rotate_draw);
xmb_draw_icon(
xmb_draw_icon(video_info,
menu_disp_info,
xmb->icon_size,
&mymat_tmp,
@ -2564,7 +2569,7 @@ static int xmb_draw_item(
menu_display_set_alpha(color, MIN(node->alpha, xmb->alpha));
if (texture_switch != 0 && color[3] != 0)
xmb_draw_icon(
xmb_draw_icon(video_info,
menu_disp_info,
xmb->icon_size,
mymat,
@ -2652,7 +2657,8 @@ static void xmb_draw_items(
menu_entry_t entry;
menu_entry_init(&entry);
menu_entry_get(&entry, 0, i, list, true);
ret = xmb_draw_item(menu_disp_info,
ret = xmb_draw_item(video_info,
menu_disp_info,
&entry,
&mymat,
xmb, core_node,
@ -2845,7 +2851,7 @@ static void xmb_draw_bg(
}
}
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
menu_display_blend_end(video_info);
}
@ -2883,7 +2889,7 @@ static void xmb_draw_dark_layer(
draw.pipeline.id = 0;
menu_display_blend_begin(video_info);
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
menu_display_blend_end(video_info);
}
@ -2978,7 +2984,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
menu_display_blend_begin(video_info);
if (xmb->savestate_thumbnail)
xmb_draw_thumbnail(menu_disp_info,
xmb_draw_thumbnail(video_info,
menu_disp_info,
xmb, &coord_white[0], width, height,
xmb->margins_screen_left
+ xmb->icon_spacing_horizontal +
@ -2995,7 +3002,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height);
#endif
xmb_draw_thumbnail(menu_disp_info,
xmb_draw_thumbnail(video_info,
menu_disp_info,
xmb, &coord_white[0], width, height,
xmb->margins_screen_left + xmb->icon_spacing_horizontal +
xmb->icon_spacing_horizontal*4 - xmb->icon_size / 4,
@ -3033,7 +3041,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
size_t x_pos_icon = xmb->margins_title_left;
if (coord_white[3] != 0)
xmb_draw_icon(
xmb_draw_icon(video_info,
menu_disp_info,
xmb->icon_size,
&mymat,
@ -3073,7 +3081,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
if (percent_width)
x_pos = percent_width + (xmb->icon_size / 2.5);
xmb_draw_icon(
xmb_draw_icon(video_info,
menu_disp_info,
xmb->icon_size,
&mymat,
@ -3110,7 +3118,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
menu_display_set_alpha(coord_white, MIN(xmb->textures_arrow_alpha, xmb->alpha));
if (coord_white[3] != 0)
xmb_draw_icon(
xmb_draw_icon(video_info,
menu_disp_info,
xmb->icon_size,
&mymat,
@ -3162,7 +3170,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
menu_display_rotate_z(&rotate_draw);
xmb_draw_icon(
xmb_draw_icon(video_info,
menu_disp_info,
xmb->icon_size,
&mymat,

View File

@ -38,7 +38,7 @@ static void menu_display_caca_blend_end(video_frame_info_t *video_info)
{
}
static void menu_display_caca_draw(void *data)
static void menu_display_caca_draw(void *data, video_frame_info_t *video_info)
{
(void)data;
}

View File

@ -59,11 +59,11 @@ static void menu_display_ctr_viewport(void *data)
}
static void menu_display_ctr_draw(void *data)
static void menu_display_ctr_draw(void *data, video_frame_info_t *video_info)
{
struct ctr_texture *texture = NULL;
const float *color = NULL;
ctr_video_t *ctr = (ctr_video_t*)video_driver_get_ptr(false);
struct ctr_texture *texture = NULL;
const float *color = NULL;
ctr_video_t *ctr = video_info ? (ctr_video_t*)video_info->userdata : NULL;
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!ctr || !draw)

View File

@ -122,13 +122,13 @@ static void menu_display_d3d_bind_texture(void *data)
}
static void menu_display_d3d_draw(void *data)
static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
{
unsigned i;
video_shader_ctx_mvp_t mvp;
math_matrix_4x4 mop, m1, m2;
unsigned width, height;
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false);
d3d_video_t *d3d = video_info ? (d3d_video_t*)video_info->userdata : NULL;
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
Vertex * pv = NULL;
const float *vertex = NULL;

View File

@ -50,10 +50,10 @@ static void menu_display_d3d11_blend_end(video_frame_info_t *video_info)
static void menu_display_d3d11_viewport(void* data) {}
static void menu_display_d3d11_draw(void* data)
static void menu_display_d3d11_draw(void* data, video_frame_info_t *video_info)
{
int vertex_count;
d3d11_video_t* d3d11 = (d3d11_video_t*)video_driver_get_ptr(false);
d3d11_video_t* d3d11 = video_info ? (d3d11_video_t*)video_info->userdata : NULL;
menu_display_ctx_draw_t* draw = (menu_display_ctx_draw_t*)data;
if (!d3d11 || !draw || !draw->texture)

View File

@ -52,10 +52,10 @@ static void menu_display_d3d12_blend_end(video_frame_info_t *video_info)
static void menu_display_d3d12_viewport(void* data) {}
static void menu_display_d3d12_draw(void* data)
static void menu_display_d3d12_draw(void* data, video_frame_info_t *video_info)
{
int vertex_count;
d3d12_video_t* d3d12 = (d3d12_video_t*)video_driver_get_ptr(false);
d3d12_video_t* d3d12 = video_info ? (d3d12_video_t*)video_info->userdata : NULL;
menu_display_ctx_draw_t* draw = (menu_display_ctx_draw_t*)data;
if (!d3d12 || !draw || !draw->texture)

View File

@ -42,7 +42,7 @@ static void menu_display_gdi_blend_end(video_frame_info_t *video_info)
{
}
static void menu_display_gdi_draw(void *data)
static void menu_display_gdi_draw(void *data, video_frame_info_t *video_info)
{
(void)data;
}

View File

@ -116,11 +116,11 @@ static void menu_display_gl_bind_texture(void *data)
glBindTexture(GL_TEXTURE_2D, (GLuint)draw->texture);
}
static void menu_display_gl_draw(void *data)
static void menu_display_gl_draw(void *data, video_frame_info_t *video_info)
{
video_shader_ctx_mvp_t mvp;
video_shader_ctx_coords_t coords;
gl_t *gl = (gl_t*)video_driver_get_ptr(false);
gl_t *gl = video_info ? (gl_t*)video_info->userdata : NULL;
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!gl || !draw)

View File

@ -36,7 +36,7 @@ static void menu_display_null_blend_end(video_frame_info_t *video_info)
{
}
static void menu_display_null_draw(void *data)
static void menu_display_null_draw(void *data, video_frame_info_t *video_info)
{
(void)data;
}

View File

@ -38,7 +38,7 @@ static void menu_display_vga_blend_end(video_frame_info_t *video_info)
{
}
static void menu_display_vga_draw(void *data)
static void menu_display_vga_draw(void *data, video_frame_info_t *video_info)
{
(void)data;
}

View File

@ -106,7 +106,8 @@ static void menu_display_vita2d_viewport(void *data)
}
static void menu_display_vita2d_draw(void *data)
static void menu_display_vita2d_draw(void *data,
video_frame_info_t *video_info)
{
#if 0
unsigned i;
@ -116,7 +117,7 @@ static void menu_display_vita2d_draw(void *data)
const float *vertex = NULL;
const float *tex_coord = NULL;
const float *color = NULL;
vita_video_t *vita2d = (vita_video_t*)video_driver_get_ptr(false);
vita_video_t *vita2d = video_info ? (vita_video_t*)video_info->userdata : NULL;
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!vita2d || !draw)

View File

@ -173,7 +173,7 @@ static void menu_display_vk_draw_pipeline(void *data)
#endif
}
static void menu_display_vk_draw(void *data)
static void menu_display_vk_draw(void *data, video_frame_info_t *video_info)
{
unsigned i;
struct vk_buffer_range range;
@ -183,7 +183,7 @@ static void menu_display_vk_draw(void *data)
const float *color = NULL;
struct vk_vertex *pv = NULL;
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
vk_t *vk = (vk_t*)video_driver_get_ptr(false);
vk_t *vk = video_info ? (vk_t*)video_info->userdata : NULL;
if (!vk || !draw)
return;

View File

@ -60,10 +60,10 @@ static void menu_display_wiiu_viewport(void *data)
}
static void menu_display_wiiu_draw(void *data)
static void menu_display_wiiu_draw(void *data, video_frame_info_t *video_info)
{
wiiu_video_t *wiiu = (wiiu_video_t*)video_driver_get_ptr(false);
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
wiiu_video_t *wiiu = video_info ? (wiiu_video_t*)video_info->userdata : NULL;
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!wiiu || !draw)

View File

@ -582,7 +582,8 @@ void menu_display_clear_color(menu_display_ctx_clearcolor_t *color)
menu_disp->clear_color(color);
}
void menu_display_draw(menu_display_ctx_draw_t *draw)
void menu_display_draw(menu_display_ctx_draw_t *draw,
video_frame_info_t *video_info)
{
if (!menu_disp || !draw || !menu_disp->draw)
return;
@ -591,7 +592,7 @@ void menu_display_draw(menu_display_ctx_draw_t *draw)
if (draw->height <= 0)
draw->height = 1;
menu_disp->draw(draw);
menu_disp->draw(draw, video_info);
}
void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw)
@ -649,7 +650,7 @@ void menu_display_draw_gradient(menu_display_ctx_draw_t *draw,
menu_display_draw_bg(draw, video_info, false,
video_info->menu_wallpaper_opacity);
menu_display_draw(draw);
menu_display_draw(draw, video_info);
}
void menu_display_draw_quad(
@ -682,13 +683,14 @@ void menu_display_draw_quad(
draw.scale_factor = 1.0f;
draw.rotation = 0.0f;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
if (menu_disp && menu_disp->blend_end)
menu_disp->blend_end(video_info);
}
void menu_display_draw_texture(
video_frame_info_t *video_info,
int x, int y, unsigned w, unsigned h,
unsigned width, unsigned height,
float *color, uintptr_t texture)
@ -720,13 +722,14 @@ void menu_display_draw_texture(
draw.texture = texture;
draw.x = x;
draw.y = height - y;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
}
/* Draw the texture split into 9 sections, without scaling the corners.
* The middle sections will only scale in the X axis, and the side
* sections will only scale in the Y axis. */
void menu_display_draw_texture_slice(
video_frame_info_t *video_info,
int x, int y, unsigned w, unsigned h,
unsigned new_w, unsigned new_h,
unsigned width, unsigned height,
@ -832,7 +835,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0];
tex_coord[7] = T_TR[1];
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
/* top-middle section */
vert_coord[0] = V_BL[0] + vert_woff;
@ -853,7 +856,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0] + tex_mid_width;
tex_coord[7] = T_TR[1];
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
/* top-right corner */
vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width;
@ -874,7 +877,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0] + tex_mid_width + tex_woff;
tex_coord[7] = T_TR[1];
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
/* middle-left section */
vert_coord[0] = V_BL[0];
@ -895,7 +898,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0];
tex_coord[7] = T_TR[1] + tex_hoff;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
/* center section */
vert_coord[0] = V_BL[0] + vert_woff;
@ -916,7 +919,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0] + tex_mid_width;
tex_coord[7] = T_TR[1] + tex_hoff;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
/* middle-right section */
vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width;
@ -937,7 +940,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0] + tex_woff + tex_mid_width;
tex_coord[7] = T_TR[1] + tex_hoff;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
/* bottom-left corner */
vert_coord[0] = V_BL[0];
@ -958,7 +961,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0];
tex_coord[7] = T_TR[1] + tex_hoff + tex_mid_height;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
/* bottom-middle section */
vert_coord[0] = V_BL[0] + vert_woff;
@ -979,7 +982,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0] + tex_mid_width;
tex_coord[7] = T_TR[1] + tex_mid_height;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
/* bottom-right corner */
vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width;
@ -1000,7 +1003,7 @@ void menu_display_draw_texture_slice(
tex_coord[6] = T_TR[0] + tex_woff + tex_mid_width;
tex_coord[7] = T_TR[1] + tex_hoff + tex_mid_height;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
free(colors);
free(vert_coord);
@ -1147,7 +1150,7 @@ void menu_display_draw_cursor(
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
draw.pipeline.id = 0;
menu_display_draw(&draw);
menu_display_draw(&draw, video_info);
if (menu_disp && menu_disp->blend_end)
menu_disp->blend_end(video_info);

View File

@ -320,7 +320,7 @@ typedef struct menu_display_frame_info
typedef struct menu_display_ctx_driver
{
/* Draw graphics to the screen. */
void (*draw)(void *data);
void (*draw)(void *data, video_frame_info_t *video_info);
/* Draw one of the menu pipeline shaders. */
void (*draw_pipeline)(void *data);
void (*viewport)(void *data);
@ -675,7 +675,7 @@ float menu_display_get_dpi(void);
bool menu_display_init_first_driver(bool video_is_threaded);
bool menu_display_restore_clear_color(void);
void menu_display_clear_color(menu_display_ctx_clearcolor_t *color);
void menu_display_draw(menu_display_ctx_draw_t *draw);
void menu_display_draw(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info);
void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw);
void menu_display_draw_bg(
@ -690,10 +690,14 @@ void menu_display_draw_quad(
int x, int y, unsigned w, unsigned h,
unsigned width, unsigned height,
float *color);
void menu_display_draw_texture(int x, int y, unsigned w, unsigned h,
void menu_display_draw_texture(
video_frame_info_t *video_info,
int x, int y, unsigned w, unsigned h,
unsigned width, unsigned height,
float *color, uintptr_t texture);
void menu_display_draw_texture_slice(int x, int y, unsigned w, unsigned h,
void menu_display_draw_texture_slice(
video_frame_info_t *video_info,
int x, int y, unsigned w, unsigned h,
unsigned new_w, unsigned new_h, unsigned width, unsigned height,
float *color, unsigned offset, float scale_factor, uintptr_t texture);
void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw);