Create video_driver_ctl and get rid of video_driver_get_frame_count

This commit is contained in:
twinaphex 2015-11-20 15:08:27 +01:00
parent 1686eb8f7f
commit 533b799692
12 changed files with 61 additions and 21 deletions

View File

@ -369,11 +369,13 @@ static bool xdk_renderchain_render(void *data, const void *frame,
{
unsigned i;
unsigned width, height;
uint64_t *frame_count = NULL;
d3d_video_t *d3d = (d3d_video_t*)data;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
settings_t *settings = config_get_ptr();
xdk_renderchain_t *chain = (xdk_renderchain_t*)d3d->renderchain_data;
uint64_t *frame_count = video_driver_get_frame_count();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
video_driver_get_size(&width, &height);

View File

@ -235,14 +235,15 @@ bool gfx_ctx_has_windowed(void *data)
bool gfx_ctx_check_window(void *data, bool *quit, bool *resize,
unsigned *width, unsigned *height)
{
uint64_t *frame_count;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
uint64_t *frame_count = video_driver_get_frame_count();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
if (!data)
return false;
ctx->check_window(data, quit, resize, width, height,
(unsigned int)*frame_count);
ctx->check_window(data, quit, resize, width, height, *frame_count);
return true;
}

View File

@ -256,11 +256,6 @@ uintptr_t video_driver_get_current_framebuffer(void)
static uint64_t video_frame_count;
uint64_t *video_driver_get_frame_count(void)
{
return &video_frame_count;
}
retro_proc_address_t video_driver_get_proc_address(const char *sym)
{
driver_t *driver = driver_get_ptr();
@ -1211,3 +1206,24 @@ void video_driver_set_pixel_format(enum retro_pixel_format fmt)
{
video_state.pix_fmt = fmt;
}
bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
{
switch (state)
{
case RARCH_DISPLAY_CTL_GET_FRAME_COUNT:
{
uint64_t **ptr = (uint64_t**)data;
if (!ptr)
return false;
*ptr = &video_frame_count;
return true;
}
break;
case RARCH_DISPLAY_CTL_NONE:
default:
break;
}
return false;
}

View File

@ -218,6 +218,14 @@ enum rarch_display_type
RARCH_DISPLAY_OSX
};
enum rarch_display_ctl_state
{
RARCH_DISPLAY_CTL_NONE = 0,
RARCH_DISPLAY_CTL_GET_FRAME_COUNT
};
bool video_driver_ctl(enum rarch_display_ctl_state state, void *data);
/**
* video_driver_find_handle:
* @index : index of driver to get handle to.
@ -381,8 +389,6 @@ void video_driver_cached_frame_get(const void **data, unsigned *width,
bool video_driver_cached_frame_has_valid_fb(void);
uint64_t *video_driver_get_frame_count(void);
#ifdef __cplusplus
}
#endif

View File

@ -102,7 +102,7 @@ static void video_frame(const void *data, unsigned width,
pitch = output_pitch;
}
frame_count = video_driver_get_frame_count();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
if (!video->frame(driver->video_data, data, width, height, *frame_count,
pitch, driver->current_msg))

View File

@ -584,9 +584,10 @@ static void mui_render_menu_list(mui_handle_t *mui,
float *pure_white)
{
unsigned header_height;
uint64_t *frame_count;
size_t i = 0;
uint64_t *frame_count = video_driver_get_frame_count();
size_t end = menu_entries_get_end();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
if (!menu_display_ctl(MENU_DISPLAY_CTL_UPDATE_PENDING, NULL))
return;
@ -732,11 +733,11 @@ static void mui_frame(void)
char title_buf[PATH_MAX_LENGTH];
size_t selection;
size_t title_margin;
uint64_t *frame_count;
mui_handle_t *mui = NULL;
driver_t *driver = driver_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
uint64_t *frame_count = video_driver_get_frame_count();
const uint32_t normal_color = 0x212121ff;
const uint32_t hover_color = 0x212121ff;
const uint32_t title_color = 0xffffffff;
@ -745,6 +746,7 @@ static void mui_frame(void)
bool background_rendered = false;
bool libretro_running = menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL);
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
(void)passivetab_color;
(void)activetab_color;

View File

@ -418,6 +418,7 @@ static void rgui_render(void)
size_t i, end, fb_pitch;
unsigned fb_width, fb_height;
int bottom;
uint64_t *frame_count;
char title[256], title_buf[256], title_msg[64];
char msg[PATH_MAX_LENGTH], timedate[PATH_MAX_LENGTH];
uint16_t *fb_data = NULL;
@ -425,7 +426,8 @@ static void rgui_render(void)
menu_handle_t *menu = menu_driver_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
uint64_t *frame_count = video_driver_get_frame_count();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
msg[0] = '\0';
title[0] = '\0';

View File

@ -122,15 +122,17 @@ end:
static void rmenu_render(void)
{
bool msg_force;
uint64_t *frame_count;
size_t begin, end, i, j, selection;
struct font_params font_parms = {0};
char title[256] = {0};
char title_buf[256] = {0};
char title_msg[64] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
uint64_t *frame_count = video_driver_get_frame_count();
size_t entries_end = menu_entries_get_end();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;

View File

@ -534,6 +534,7 @@ static void rmenu_xui_set_list_text(int index, const wchar_t* leftText,
static void rmenu_xui_render(void)
{
uint64_t *frame_count;
bool display_kb, msg_force;
unsigned fb_width;
size_t end, i, selection;
@ -542,7 +543,8 @@ static void rmenu_xui_render(void)
const char *label = NULL;
unsigned menu_type = 0;
menu_handle_t *menu = menu_driver_get_ptr();
uint64_t *frame_count = video_driver_get_frame_count();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
menu_display_ctl(MENU_DISPLAY_CTL_MSG_FORCE, &msg_force);

View File

@ -1311,14 +1311,16 @@ static void xmb_draw_items(xmb_handle_t *xmb,
size_t current, size_t cat_selection_ptr, float *color,
unsigned width, unsigned height)
{
uint64_t *frame_count;
unsigned i, ticker_limit;
math_matrix_4x4 mymat;
xmb_node_t *core_node = NULL;
size_t end = 0;
uint64_t *frame_count = video_driver_get_frame_count();
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
if (!list || !list->size || !menu)
return;

View File

@ -464,6 +464,7 @@ static bool zarch_zui_button(zui_t *zui, int x1, int y1, const char *label)
static bool zarch_zui_list_item(zui_t *zui, zui_tabbed_t *tab, int x1, int y1,
const char *label, unsigned item_id, const char *entry)
{
uint64_t *frame_count;
char title_buf[PATH_MAX_LENGTH];
unsigned ticker_size;
bool set_active_id = false;
@ -472,7 +473,8 @@ static bool zarch_zui_list_item(zui_t *zui, zui_tabbed_t *tab, int x1, int y1,
int y2 = y1 + 50;
bool active = zarch_zui_check_button_up(zui, id, x1, y1, x2, y2);
const float *bg = ZUI_BG_PANEL;
uint64_t *frame_count = video_driver_get_frame_count();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
if (tab->active_id != tab->prev_id)
{

View File

@ -875,6 +875,7 @@ static void rarch_main_cmd_get_state(driver_t *driver,
*/
static INLINE int rarch_main_iterate_time_to_exit(event_cmd_state_t *cmd)
{
uint64_t *frame_count = NULL;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
driver_t *driver = driver_get_ptr();
@ -883,8 +884,10 @@ static INLINE int rarch_main_iterate_time_to_exit(event_cmd_state_t *cmd)
bool shutdown_pressed = (system && system->shutdown) || cmd->quit_key_pressed;
bool video_alive = video && video->alive(driver->video_data);
bool movie_end = (global->bsv.movie_end && global->bsv.eof_exit);
uint64_t *frame_count = video_driver_get_frame_count();
bool frame_count_end = main_max_frames && (*frame_count >= main_max_frames);
bool frame_count_end = false;
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
frame_count_end = main_max_frames && (*frame_count >= main_max_frames);
if (shutdown_pressed || frame_count_end || movie_end || !video_alive || global->exec)
{