mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Don't init assets from init.
Rename to context_reset/context_destroy and let the driver init/uninit step signal the menu when the context is going down and coming up.
This commit is contained in:
parent
d5ec0c8d90
commit
f1b3252193
14
driver.c
14
driver.c
@ -508,9 +508,10 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info)
|
|||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
static void init_menu(void)
|
static void init_menu(void)
|
||||||
{
|
{
|
||||||
if (!driver.menu_ctx)
|
if (driver.menu)
|
||||||
find_menu_driver();
|
return;
|
||||||
|
|
||||||
|
find_menu_driver();
|
||||||
if (!(driver.menu = (rgui_handle_t*)menu_init(driver.menu_ctx)))
|
if (!(driver.menu = (rgui_handle_t*)menu_init(driver.menu_ctx)))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Cannot initialize menu.\n");
|
RARCH_ERR("Cannot initialize menu.\n");
|
||||||
@ -547,6 +548,9 @@ void init_drivers(void)
|
|||||||
g_extern.system.hw_render_callback.context_reset();
|
g_extern.system.hw_render_callback.context_reset();
|
||||||
driver.video_cache_context_ack = false;
|
driver.video_cache_context_ack = false;
|
||||||
|
|
||||||
|
if (driver.menu_ctx && driver.menu_ctx->context_reset)
|
||||||
|
driver.menu_ctx->context_reset(driver.menu);
|
||||||
|
|
||||||
init_audio();
|
init_audio();
|
||||||
|
|
||||||
#ifdef HAVE_CAMERA
|
#ifdef HAVE_CAMERA
|
||||||
@ -631,9 +635,15 @@ void uninit_drivers(void)
|
|||||||
if (g_extern.system.hw_render_callback.context_destroy && !driver.video_cache_context)
|
if (g_extern.system.hw_render_callback.context_destroy && !driver.video_cache_context)
|
||||||
g_extern.system.hw_render_callback.context_destroy();
|
g_extern.system.hw_render_callback.context_destroy();
|
||||||
|
|
||||||
|
if (driver.menu_ctx && driver.menu_ctx->context_destroy)
|
||||||
|
driver.menu_ctx->context_destroy(driver.menu);
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
if (!driver.menu_data_own)
|
if (!driver.menu_data_own)
|
||||||
|
{
|
||||||
menu_free(driver.menu);
|
menu_free(driver.menu);
|
||||||
|
driver.menu = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uninit_video_input();
|
uninit_video_input();
|
||||||
|
4
driver.h
4
driver.h
@ -418,8 +418,8 @@ typedef struct menu_ctx_driver
|
|||||||
void (*frame)(void);
|
void (*frame)(void);
|
||||||
void* (*init)(void);
|
void* (*init)(void);
|
||||||
void (*free)(void*);
|
void (*free)(void*);
|
||||||
void (*init_assets)(void*);
|
void (*context_reset)(void*);
|
||||||
void (*free_assets)(void*);
|
void (*context_destroy)(void*);
|
||||||
void (*populate_entries)(void*, unsigned);
|
void (*populate_entries)(void*, unsigned);
|
||||||
void (*iterate)(void*, unsigned);
|
void (*iterate)(void*, unsigned);
|
||||||
int (*input_postprocess)(uint64_t);
|
int (*input_postprocess)(uint64_t);
|
||||||
|
@ -1019,7 +1019,7 @@ static GLuint png_texture_load(const char * file_name, int * width, int * height
|
|||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lakka_free_assets(void *data)
|
static void lakka_context_destroy(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
@ -1036,7 +1036,7 @@ static void lakka_free_assets(void *data)
|
|||||||
free(tweens);
|
free(tweens);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lakka_init_assets(void *data)
|
static void lakka_context_reset(void *data)
|
||||||
{
|
{
|
||||||
char path[256], dirpath[256];;
|
char path[256], dirpath[256];;
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||||
@ -1190,13 +1190,10 @@ static void lakka_init_items(int i, menu_category_t *category, core_info_t *info
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void lakka_free(void *data)
|
static void lakka_free(void *data)
|
||||||
{
|
{
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||||
|
|
||||||
lakka_free_assets(rgui);
|
|
||||||
|
|
||||||
if (rgui->alloc_font)
|
if (rgui->alloc_font)
|
||||||
free((uint8_t*)rgui->font);
|
free((uint8_t*)rgui->font);
|
||||||
}
|
}
|
||||||
@ -1246,7 +1243,6 @@ static void *lakka_init(void)
|
|||||||
init_font(gl, g_settings.video.font_path, g_settings.video.font_size, gl->win_width, gl->win_height);
|
init_font(gl, g_settings.video.font_path, g_settings.video.font_size, gl->win_width, gl->win_height);
|
||||||
|
|
||||||
lakka_init_core_info(rgui);
|
lakka_init_core_info(rgui);
|
||||||
lakka_init_assets(rgui);
|
|
||||||
|
|
||||||
if (categories)
|
if (categories)
|
||||||
{
|
{
|
||||||
@ -1358,8 +1354,8 @@ const menu_ctx_driver_t menu_ctx_lakka = {
|
|||||||
lakka_frame,
|
lakka_frame,
|
||||||
lakka_init,
|
lakka_init,
|
||||||
lakka_free,
|
lakka_free,
|
||||||
lakka_init_assets,
|
lakka_context_reset,
|
||||||
lakka_free_assets,
|
lakka_context_destroy,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
lakka_input_postprocess,
|
lakka_input_postprocess,
|
||||||
|
@ -450,7 +450,7 @@ void rmenu_set_texture(void *data, bool enable)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmenu_init_assets(void *data)
|
static void rmenu_context_reset(void *data)
|
||||||
{
|
{
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||||
|
|
||||||
@ -476,19 +476,16 @@ static void *rmenu_init(void)
|
|||||||
if (!rgui)
|
if (!rgui)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
rmenu_init_assets(rgui);
|
|
||||||
|
|
||||||
return rgui;
|
return rgui;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmenu_free_assets(void *data)
|
static void rmenu_context_destroy(void *data)
|
||||||
{
|
{
|
||||||
texture_image_free(driver.video_data, menu_texture);
|
texture_image_free(driver.video_data, menu_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmenu_free(void *data)
|
static void rmenu_free(void *data)
|
||||||
{
|
{
|
||||||
rmenu_free_assets(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rmenu_input_postprocess(uint64_t old_state)
|
static int rmenu_input_postprocess(uint64_t old_state)
|
||||||
@ -524,8 +521,8 @@ const menu_ctx_driver_t menu_ctx_rmenu = {
|
|||||||
NULL,
|
NULL,
|
||||||
rmenu_init,
|
rmenu_init,
|
||||||
rmenu_free,
|
rmenu_free,
|
||||||
rmenu_init_assets,
|
rmenu_context_reset,
|
||||||
rmenu_free_assets,
|
rmenu_context_destroy,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
rmenu_input_postprocess,
|
rmenu_input_postprocess,
|
||||||
|
@ -1963,6 +1963,10 @@ static void check_savestates(bool immutable)
|
|||||||
|
|
||||||
void rarch_set_fullscreen(bool fullscreen)
|
void rarch_set_fullscreen(bool fullscreen)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_MENU
|
||||||
|
driver.menu_data_own = true; // Don't reinit menu for something trivial.
|
||||||
|
#endif
|
||||||
|
|
||||||
g_settings.video.fullscreen = fullscreen;
|
g_settings.video.fullscreen = fullscreen;
|
||||||
driver.video_cache_context = g_extern.system.hw_render_callback.cache_context;
|
driver.video_cache_context = g_extern.system.hw_render_callback.cache_context;
|
||||||
driver.video_cache_context_ack = false;
|
driver.video_cache_context_ack = false;
|
||||||
@ -1973,6 +1977,10 @@ void rarch_set_fullscreen(bool fullscreen)
|
|||||||
// Poll input to avoid possibly stale data to corrupt things.
|
// Poll input to avoid possibly stale data to corrupt things.
|
||||||
if (driver.input)
|
if (driver.input)
|
||||||
input_poll_func();
|
input_poll_func();
|
||||||
|
|
||||||
|
#ifdef HAVE_MENU
|
||||||
|
driver.menu_data_own = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rarch_check_fullscreen(void)
|
bool rarch_check_fullscreen(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user