(gfx_display/gfx_animation) Use flags instead of bools (#14488)
* (gfx_display/gfx_animation) Use flags instead of bools * (task_save) Use flags instead of bools
This commit is contained in:
parent
4f071e47c7
commit
91119d038f
|
@ -1776,7 +1776,7 @@ void command_event_reinit(const int flags)
|
||||||
command_event(CMD_EVENT_GAME_FOCUS_TOGGLE, &game_focus_cmd);
|
command_event(CMD_EVENT_GAME_FOCUS_TOGGLE, &game_focus_cmd);
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
p_disp->framebuf_dirty = true;
|
p_disp->flags |= GFX_DISP_FLAG_FB_DIRTY;
|
||||||
if (video_fullscreen)
|
if (video_fullscreen)
|
||||||
video_driver_hide_mouse();
|
video_driver_hide_mouse();
|
||||||
if ( menu_st->alive
|
if ( menu_st->alive
|
||||||
|
|
|
@ -66,10 +66,7 @@ static gfx_animation_t anim_st = {
|
||||||
NULL, /* list */
|
NULL, /* list */
|
||||||
NULL, /* pending */
|
NULL, /* pending */
|
||||||
0.0f, /* delta_time */
|
0.0f, /* delta_time */
|
||||||
false, /* pending_deletes */
|
0 /* flags */
|
||||||
false, /* in_update */
|
|
||||||
false, /* animation_is_active */
|
|
||||||
false /* ticker_is_active */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
gfx_animation_t *anim_get_ptr(void)
|
gfx_animation_t *anim_get_ptr(void)
|
||||||
|
@ -1175,7 +1172,7 @@ bool gfx_animation_push(gfx_animation_ctx_entry_t *entry)
|
||||||
if (!t.easing || t.duration == 0 || t.initial_value == t.target_value)
|
if (!t.easing || t.duration == 0 || t.initial_value == t.target_value)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (p_anim->in_update)
|
if (p_anim->flags & GFX_ANIM_FLAG_IN_UPDATE)
|
||||||
RBUF_PUSH(p_anim->pending, t);
|
RBUF_PUSH(p_anim->pending, t);
|
||||||
else
|
else
|
||||||
RBUF_PUSH(p_anim->list, t);
|
RBUF_PUSH(p_anim->list, t);
|
||||||
|
@ -1192,7 +1189,7 @@ bool gfx_animation_update(
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
gfx_animation_t *p_anim = &anim_st;
|
gfx_animation_t *p_anim = &anim_st;
|
||||||
const bool ticker_is_active = p_anim->ticker_is_active;
|
const bool ticker_is_active = p_anim->flags & GFX_ANIM_FLAG_TICKER_IS_ACTIVE;
|
||||||
|
|
||||||
static retro_time_t last_clock_update = 0;
|
static retro_time_t last_clock_update = 0;
|
||||||
static retro_time_t last_ticker_update = 0;
|
static retro_time_t last_ticker_update = 0;
|
||||||
|
@ -1227,7 +1224,7 @@ bool gfx_animation_update(
|
||||||
if (((p_anim->cur_time - last_clock_update) > 1000000) /* 1000000 us == 1 second */
|
if (((p_anim->cur_time - last_clock_update) > 1000000) /* 1000000 us == 1 second */
|
||||||
&& timedate_enable)
|
&& timedate_enable)
|
||||||
{
|
{
|
||||||
p_anim->animation_is_active = true;
|
p_anim->flags |= GFX_ANIM_FLAG_IS_ACTIVE;
|
||||||
last_clock_update = p_anim->cur_time;
|
last_clock_update = p_anim->cur_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1296,8 +1293,8 @@ bool gfx_animation_update(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p_anim->in_update = true;
|
p_anim->flags |= GFX_ANIM_FLAG_IN_UPDATE;
|
||||||
p_anim->pending_deletes = false;
|
p_anim->flags &= ~GFX_ANIM_FLAG_PENDING_DELETES;
|
||||||
|
|
||||||
for (i = 0; i < RBUF_LEN(p_anim->list); i++)
|
for (i = 0; i < RBUF_LEN(p_anim->list); i++)
|
||||||
{
|
{
|
||||||
|
@ -1326,7 +1323,7 @@ bool gfx_animation_update(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_anim->pending_deletes)
|
if (p_anim->flags & GFX_ANIM_FLAG_PENDING_DELETES)
|
||||||
{
|
{
|
||||||
for (i = 0; i < RBUF_LEN(p_anim->list); i++)
|
for (i = 0; i < RBUF_LEN(p_anim->list); i++)
|
||||||
{
|
{
|
||||||
|
@ -1337,7 +1334,7 @@ bool gfx_animation_update(
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p_anim->pending_deletes = false;
|
p_anim->flags &= ~GFX_ANIM_FLAG_PENDING_DELETES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RBUF_LEN(p_anim->pending) > 0)
|
if (RBUF_LEN(p_anim->pending) > 0)
|
||||||
|
@ -1350,10 +1347,13 @@ bool gfx_animation_update(
|
||||||
RBUF_CLEAR(p_anim->pending);
|
RBUF_CLEAR(p_anim->pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_anim->in_update = false;
|
p_anim->flags &= ~GFX_ANIM_FLAG_IN_UPDATE;
|
||||||
p_anim->animation_is_active = RBUF_LEN(p_anim->list) > 0;
|
if (RBUF_LEN(p_anim->list) > 0)
|
||||||
|
p_anim->flags |= GFX_ANIM_FLAG_IS_ACTIVE;
|
||||||
|
else
|
||||||
|
p_anim->flags &= ~GFX_ANIM_FLAG_IS_ACTIVE;
|
||||||
|
|
||||||
return p_anim->animation_is_active;
|
return ((p_anim->flags & GFX_ANIM_FLAG_IS_ACTIVE) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build_ticker_loop_string(
|
static void build_ticker_loop_string(
|
||||||
|
@ -1491,7 +1491,7 @@ bool gfx_animation_ticker(gfx_animation_ctx_ticker_t *ticker)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
p_anim->ticker_is_active = true;
|
p_anim->flags |= GFX_ANIM_FLAG_TICKER_IS_ACTIVE;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1636,7 +1636,7 @@ static bool gfx_animation_ticker_smooth_fw(
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
is_active = true;
|
is_active = true;
|
||||||
p_anim->ticker_is_active = true;
|
p_anim->flags |= GFX_ANIM_FLAG_TICKER_IS_ACTIVE;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (!success)
|
if (!success)
|
||||||
|
@ -1859,7 +1859,7 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker)
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
is_active = true;
|
is_active = true;
|
||||||
p_anim->ticker_is_active = true;
|
p_anim->flags |= GFX_ANIM_FLAG_TICKER_IS_ACTIVE;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
|
@ -1965,7 +1965,7 @@ bool gfx_animation_line_ticker(gfx_animation_ctx_line_ticker_t *line_ticker)
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
is_active = true;
|
is_active = true;
|
||||||
p_anim->ticker_is_active = true;
|
p_anim->flags |= GFX_ANIM_FLAG_TICKER_IS_ACTIVE;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
|
@ -2159,7 +2159,7 @@ bool gfx_animation_line_ticker_smooth(gfx_animation_ctx_line_ticker_smooth_t *li
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
is_active = true;
|
is_active = true;
|
||||||
p_anim->ticker_is_active = true;
|
p_anim->flags |= GFX_ANIM_FLAG_TICKER_IS_ACTIVE;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
|
@ -2213,10 +2213,10 @@ bool gfx_animation_kill_by_tag(uintptr_t *tag)
|
||||||
* > Cannot modify p_anim->list now, so schedule a
|
* > Cannot modify p_anim->list now, so schedule a
|
||||||
* delete for when the gfx_animation_update() loop
|
* delete for when the gfx_animation_update() loop
|
||||||
* is complete */
|
* is complete */
|
||||||
if (p_anim->in_update)
|
if (p_anim->flags & GFX_ANIM_FLAG_IN_UPDATE)
|
||||||
{
|
{
|
||||||
t->deleted = true;
|
t->deleted = true;
|
||||||
p_anim->pending_deletes = true;
|
p_anim->flags |= GFX_ANIM_FLAG_PENDING_DELETES;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2230,7 +2230,7 @@ bool gfx_animation_kill_by_tag(uintptr_t *tag)
|
||||||
* (otherwise any entries that are simultaneously added
|
* (otherwise any entries that are simultaneously added
|
||||||
* and deleted inside gfx_animation_update() won't get
|
* and deleted inside gfx_animation_update() won't get
|
||||||
* deleted at all, producing utter chaos) */
|
* deleted at all, producing utter chaos) */
|
||||||
if (p_anim->in_update)
|
if (p_anim->flags & GFX_ANIM_FLAG_IN_UPDATE)
|
||||||
{
|
{
|
||||||
for (i = 0; i < RBUF_LEN(p_anim->pending); ++i)
|
for (i = 0; i < RBUF_LEN(p_anim->pending); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,19 +29,10 @@ RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
#define TICKER_SPACER_DEFAULT " | "
|
#define TICKER_SPACER_DEFAULT " | "
|
||||||
|
|
||||||
#define ANIM_IS_ACTIVE(_p) ((_p)->animation_is_active || (_p)->ticker_is_active)
|
#define ANIM_IS_ACTIVE(_p) (((_p)->flags & (GFX_ANIM_FLAG_IS_ACTIVE)) || ((_p)->flags & GFX_ANIM_FLAG_TICKER_IS_ACTIVE))
|
||||||
|
|
||||||
#define GFX_ANIMATION_CLEAR_ACTIVE(anim) \
|
#define GFX_ANIMATION_CLEAR_ACTIVE(anim) ((anim)->flags &= ~(GFX_ANIM_FLAG_IS_ACTIVE | GFX_ANIM_FLAG_TICKER_IS_ACTIVE))
|
||||||
{ \
|
#define GFX_ANIMATION_SET_ACTIVE(anim) ((anim)->flags |= (GFX_ANIM_FLAG_IS_ACTIVE | GFX_ANIM_FLAG_TICKER_IS_ACTIVE))
|
||||||
(anim)->animation_is_active = false; \
|
|
||||||
(anim)->ticker_is_active = false; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GFX_ANIMATION_SET_ACTIVE(anim) \
|
|
||||||
{ \
|
|
||||||
(anim)->animation_is_active = true; \
|
|
||||||
(anim)->ticker_is_active = true; \
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef void (*tween_cb) (void*);
|
typedef void (*tween_cb) (void*);
|
||||||
|
|
||||||
|
@ -209,6 +200,14 @@ struct tween
|
||||||
bool deleted;
|
bool deleted;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum gfx_animation_flags
|
||||||
|
{
|
||||||
|
GFX_ANIM_FLAG_PENDING_DELETES = (1 << 0),
|
||||||
|
GFX_ANIM_FLAG_IN_UPDATE = (1 << 1),
|
||||||
|
GFX_ANIM_FLAG_IS_ACTIVE = (1 << 2),
|
||||||
|
GFX_ANIM_FLAG_TICKER_IS_ACTIVE = (1 << 3)
|
||||||
|
};
|
||||||
|
|
||||||
struct gfx_animation
|
struct gfx_animation
|
||||||
{
|
{
|
||||||
uint64_t ticker_idx; /* updated every TICKER_SPEED us */
|
uint64_t ticker_idx; /* updated every TICKER_SPEED us */
|
||||||
|
@ -224,10 +223,7 @@ struct gfx_animation
|
||||||
|
|
||||||
float delta_time;
|
float delta_time;
|
||||||
|
|
||||||
bool pending_deletes;
|
uint8_t flags;
|
||||||
bool in_update;
|
|
||||||
bool animation_is_active;
|
|
||||||
bool ticker_is_active;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct gfx_animation gfx_animation_t;
|
typedef struct gfx_animation gfx_animation_t;
|
||||||
|
|
|
@ -1258,12 +1258,13 @@ void gfx_display_free(void)
|
||||||
gfx_display_t *p_disp = &dispgfx_st;
|
gfx_display_t *p_disp = &dispgfx_st;
|
||||||
video_coord_array_free(&p_disp->dispca);
|
video_coord_array_free(&p_disp->dispca);
|
||||||
|
|
||||||
p_disp->msg_force = false;
|
p_disp->flags &= ~(GFX_DISP_FLAG_MSG_FORCE
|
||||||
|
| GFX_DISP_FLAG_HAS_WINDOWED
|
||||||
|
);
|
||||||
p_disp->header_height = 0;
|
p_disp->header_height = 0;
|
||||||
p_disp->framebuf_width = 0;
|
p_disp->framebuf_width = 0;
|
||||||
p_disp->framebuf_height = 0;
|
p_disp->framebuf_height = 0;
|
||||||
p_disp->framebuf_pitch = 0;
|
p_disp->framebuf_pitch = 0;
|
||||||
p_disp->has_windowed = false;
|
|
||||||
p_disp->dispctx = NULL;
|
p_disp->dispctx = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,7 +1273,10 @@ void gfx_display_init(void)
|
||||||
gfx_display_t *p_disp = &dispgfx_st;
|
gfx_display_t *p_disp = &dispgfx_st;
|
||||||
video_coord_array_t *p_dispca = &p_disp->dispca;
|
video_coord_array_t *p_dispca = &p_disp->dispca;
|
||||||
|
|
||||||
p_disp->has_windowed = video_driver_has_windowed();
|
if (video_driver_has_windowed())
|
||||||
|
p_disp->flags |= GFX_DISP_FLAG_HAS_WINDOWED;
|
||||||
|
else
|
||||||
|
p_disp->flags &= ~GFX_DISP_FLAG_HAS_WINDOWED;
|
||||||
p_dispca->allocated = 0;
|
p_dispca->allocated = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,13 @@
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
enum gfx_display_flags
|
||||||
|
{
|
||||||
|
GFX_DISP_FLAG_HAS_WINDOWED = (1 << 0),
|
||||||
|
GFX_DISP_FLAG_MSG_FORCE = (1 << 1),
|
||||||
|
GFX_DISP_FLAG_FB_DIRTY = (1 << 2)
|
||||||
|
};
|
||||||
|
|
||||||
#define GFX_SHADOW_ALPHA 0.50f
|
#define GFX_SHADOW_ALPHA 0.50f
|
||||||
|
|
||||||
/* Number of pixels corner-to-corner on a 1080p
|
/* Number of pixels corner-to-corner on a 1080p
|
||||||
|
@ -65,7 +72,7 @@ RETRO_BEGIN_DECLS
|
||||||
* so that we don't have to render the display graphics per-frame
|
* so that we don't have to render the display graphics per-frame
|
||||||
* unless a change has happened.
|
* unless a change has happened.
|
||||||
* */
|
* */
|
||||||
#define GFX_DISPLAY_GET_UPDATE_PENDING(p_anim, p_disp) (ANIM_IS_ACTIVE(p_anim) || p_disp->framebuf_dirty)
|
#define GFX_DISPLAY_GET_UPDATE_PENDING(p_anim, p_disp) (ANIM_IS_ACTIVE(p_anim) || (p_disp->flags & GFX_DISP_FLAG_FB_DIRTY))
|
||||||
|
|
||||||
enum menu_driver_id_type
|
enum menu_driver_id_type
|
||||||
{
|
{
|
||||||
|
@ -207,9 +214,7 @@ struct gfx_display
|
||||||
|
|
||||||
enum menu_driver_id_type menu_driver_id;
|
enum menu_driver_id_type menu_driver_id;
|
||||||
|
|
||||||
bool has_windowed;
|
uint8_t flags;
|
||||||
bool msg_force;
|
|
||||||
bool framebuf_dirty;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void gfx_display_free(void);
|
void gfx_display_free(void);
|
||||||
|
|
|
@ -2024,7 +2024,7 @@ static int generic_action_ok(const char *path,
|
||||||
bool config_save_on_exit = settings->bools.config_save_on_exit;
|
bool config_save_on_exit = settings->bools.config_save_on_exit;
|
||||||
flush_type = MENU_SETTINGS;
|
flush_type = MENU_SETTINGS;
|
||||||
|
|
||||||
disp_get_ptr()->msg_force = true;
|
disp_get_ptr()->flags |= GFX_DISP_FLAG_MSG_FORCE;
|
||||||
|
|
||||||
if (config_replace(config_save_on_exit, action_path))
|
if (config_replace(config_save_on_exit, action_path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -4870,7 +4870,7 @@ static void rgui_render(void *data,
|
||||||
|
|
||||||
if (!rgui->force_redraw)
|
if (!rgui->force_redraw)
|
||||||
{
|
{
|
||||||
msg_force = p_disp->msg_force;
|
msg_force = p_disp->flags & GFX_DISP_FLAG_MSG_FORCE;
|
||||||
|
|
||||||
if (menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL)
|
if (menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL)
|
||||||
&& !msg_force)
|
&& !msg_force)
|
||||||
|
@ -4920,7 +4920,7 @@ static void rgui_render(void *data,
|
||||||
if (rgui->bg_modified)
|
if (rgui->bg_modified)
|
||||||
rgui->bg_modified = false;
|
rgui->bg_modified = false;
|
||||||
|
|
||||||
p_disp->framebuf_dirty = true;
|
p_disp->flags |= GFX_DISP_FLAG_FB_DIRTY;
|
||||||
GFX_ANIMATION_CLEAR_ACTIVE(p_anim);
|
GFX_ANIMATION_CLEAR_ACTIVE(p_anim);
|
||||||
|
|
||||||
rgui->force_redraw = false;
|
rgui->force_redraw = false;
|
||||||
|
@ -6373,13 +6373,13 @@ static void rgui_set_texture(void *data)
|
||||||
rgui_t *rgui = (rgui_t*)data;
|
rgui_t *rgui = (rgui_t*)data;
|
||||||
|
|
||||||
/* Framebuffer is dirty and needs to be updated? */
|
/* Framebuffer is dirty and needs to be updated? */
|
||||||
if (!rgui || !p_disp->framebuf_dirty)
|
if (!rgui || !(p_disp->flags & GFX_DISP_FLAG_FB_DIRTY))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fb_width = p_disp->framebuf_width;
|
fb_width = p_disp->framebuf_width;
|
||||||
fb_height = p_disp->framebuf_height;
|
fb_height = p_disp->framebuf_height;
|
||||||
|
|
||||||
p_disp->framebuf_dirty = false;
|
p_disp->flags &= ~GFX_DISP_FLAG_FB_DIRTY;
|
||||||
|
|
||||||
if (internal_upscale_level == RGUI_UPSCALE_NONE)
|
if (internal_upscale_level == RGUI_UPSCALE_NONE)
|
||||||
video_driver_set_texture_frame(rgui->frame_buf.data,
|
video_driver_set_texture_frame(rgui->frame_buf.data,
|
||||||
|
@ -7123,11 +7123,11 @@ static int rgui_environ(enum menu_environ_cb type,
|
||||||
{
|
{
|
||||||
case MENU_ENVIRON_ENABLE_MOUSE_CURSOR:
|
case MENU_ENVIRON_ENABLE_MOUSE_CURSOR:
|
||||||
rgui->show_mouse = true;
|
rgui->show_mouse = true;
|
||||||
p_disp->framebuf_dirty = true;
|
p_disp->flags |= GFX_DISP_FLAG_FB_DIRTY;
|
||||||
break;
|
break;
|
||||||
case MENU_ENVIRON_DISABLE_MOUSE_CURSOR:
|
case MENU_ENVIRON_DISABLE_MOUSE_CURSOR:
|
||||||
rgui->show_mouse = false;
|
rgui->show_mouse = false;
|
||||||
p_disp->framebuf_dirty = false;
|
p_disp->flags &= ~GFX_DISP_FLAG_FB_DIRTY;
|
||||||
break;
|
break;
|
||||||
case MENU_ENVIRON_ENABLE_SCREENSAVER:
|
case MENU_ENVIRON_ENABLE_SCREENSAVER:
|
||||||
rgui->show_screensaver = true;
|
rgui->show_screensaver = true;
|
||||||
|
|
|
@ -6875,7 +6875,7 @@ static enum runloop_state_enum runloop_check_state(
|
||||||
list_info.action = 0;
|
list_info.action = 0;
|
||||||
menu_driver_list_cache(&list_info);
|
menu_driver_list_cache(&list_info);
|
||||||
|
|
||||||
p_disp->msg_force = true;
|
p_disp->flags |= GFX_DISP_FLAG_MSG_FORCE;
|
||||||
|
|
||||||
generic_action_ok_displaylist_push("", NULL,
|
generic_action_ok_displaylist_push("", NULL,
|
||||||
"", 0, 0, 0, ACTION_OK_DL_CONTENT_SETTINGS);
|
"", 0, 0, 0, ACTION_OK_DL_CONTENT_SETTINGS);
|
||||||
|
@ -6919,7 +6919,7 @@ static enum runloop_state_enum runloop_check_state(
|
||||||
BIT64_SET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER);
|
BIT64_SET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER);
|
||||||
|
|
||||||
if (BIT64_GET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER))
|
if (BIT64_GET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER))
|
||||||
p_disp->framebuf_dirty = true;
|
p_disp->flags |= GFX_DISP_FLAG_FB_DIRTY;
|
||||||
|
|
||||||
if (BIT64_GET(menu->state, MENU_STATE_RENDER_MESSAGEBOX)
|
if (BIT64_GET(menu->state, MENU_STATE_RENDER_MESSAGEBOX)
|
||||||
&& !string_is_empty(menu->menu_state_msg))
|
&& !string_is_empty(menu->menu_state_msg))
|
||||||
|
|
|
@ -99,6 +99,18 @@ struct sram_block
|
||||||
unsigned type;
|
unsigned type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum save_task_state_flags
|
||||||
|
{
|
||||||
|
SAVE_TASK_FLAG_LOAD_TO_BACKUP_BUFF = (1 << 0),
|
||||||
|
SAVE_TASK_FLAG_AUTOLOAD = (1 << 1),
|
||||||
|
SAVE_TASK_FLAG_AUTOSAVE = (1 << 2),
|
||||||
|
SAVE_TASK_FLAG_UNDO_SAVE = (1 << 3),
|
||||||
|
SAVE_TASK_FLAG_MUTE = (1 << 4),
|
||||||
|
SAVE_TASK_FLAG_THUMBNAIL_ENABLE = (1 << 5),
|
||||||
|
SAVE_TASK_FLAG_HAS_VALID_FB = (1 << 6),
|
||||||
|
SAVE_TASK_FLAG_COMPRESS_FILES = (1 << 7)
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
intfstream_t *file;
|
intfstream_t *file;
|
||||||
|
@ -109,15 +121,8 @@ typedef struct
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
ssize_t bytes_read;
|
ssize_t bytes_read;
|
||||||
int state_slot;
|
int state_slot;
|
||||||
|
uint8_t flags;
|
||||||
char path[PATH_MAX_LENGTH];
|
char path[PATH_MAX_LENGTH];
|
||||||
bool load_to_backup_buffer;
|
|
||||||
bool autoload;
|
|
||||||
bool autosave;
|
|
||||||
bool undo_save;
|
|
||||||
bool mute;
|
|
||||||
bool thumbnail_enable;
|
|
||||||
bool has_valid_framebuffer;
|
|
||||||
bool compress_files;
|
|
||||||
} save_task_state_t;
|
} save_task_state_t;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
|
@ -592,7 +597,8 @@ static void task_save_handler_finished(retro_task_t *task,
|
||||||
|
|
||||||
if (state->data)
|
if (state->data)
|
||||||
{
|
{
|
||||||
if (state->undo_save && state->data == undo_save_buf.data)
|
if ( (state->flags & SAVE_TASK_FLAG_UNDO_SAVE)
|
||||||
|
&& (state->data == undo_save_buf.data))
|
||||||
undo_save_buf.data = NULL;
|
undo_save_buf.data = NULL;
|
||||||
free(state->data);
|
free(state->data);
|
||||||
state->data = NULL;
|
state->data = NULL;
|
||||||
|
@ -723,7 +729,7 @@ static void task_save_handler(retro_task_t *task)
|
||||||
|
|
||||||
if (!state->file)
|
if (!state->file)
|
||||||
{
|
{
|
||||||
if (state->compress_files)
|
if (state->flags & SAVE_TASK_FLAG_COMPRESS_FILES)
|
||||||
state->file = intfstream_open_rzip_file(
|
state->file = intfstream_open_rzip_file(
|
||||||
state->path, RETRO_VFS_FILE_ACCESS_WRITE);
|
state->path, RETRO_VFS_FILE_ACCESS_WRITE);
|
||||||
else
|
else
|
||||||
|
@ -758,7 +764,7 @@ static void task_save_handler(retro_task_t *task)
|
||||||
size_t err_size = 8192 * sizeof(char);
|
size_t err_size = 8192 * sizeof(char);
|
||||||
char *err = (char*)malloc(err_size);
|
char *err = (char*)malloc(err_size);
|
||||||
|
|
||||||
if (state->undo_save)
|
if (state->flags & SAVE_TASK_FLAG_UNDO_SAVE)
|
||||||
{
|
{
|
||||||
const char *failed_undo_str = msg_hash_to_str(
|
const char *failed_undo_str = msg_hash_to_str(
|
||||||
MSG_FAILED_TO_UNDO_SAVE_STATE);
|
MSG_FAILED_TO_UNDO_SAVE_STATE);
|
||||||
|
@ -789,7 +795,7 @@ static void task_save_handler(retro_task_t *task)
|
||||||
|
|
||||||
task_free_title(task);
|
task_free_title(task);
|
||||||
|
|
||||||
if (state->undo_save)
|
if (state->flags & SAVE_TASK_FLAG_UNDO_SAVE)
|
||||||
msg = strdup(msg_hash_to_str(MSG_RESTORED_OLD_SAVE_STATE));
|
msg = strdup(msg_hash_to_str(MSG_RESTORED_OLD_SAVE_STATE));
|
||||||
else if (state->state_slot < 0)
|
else if (state->state_slot < 0)
|
||||||
msg = strdup(msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT_AUTO));
|
msg = strdup(msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT_AUTO));
|
||||||
|
@ -840,13 +846,13 @@ static bool task_push_undo_save_state(const char *path, void *data, size_t size)
|
||||||
strlcpy(state->path, path, sizeof(state->path));
|
strlcpy(state->path, path, sizeof(state->path));
|
||||||
state->data = data;
|
state->data = data;
|
||||||
state->size = size;
|
state->size = size;
|
||||||
state->undo_save = true;
|
state->flags |= SAVE_TASK_FLAG_UNDO_SAVE;
|
||||||
state->state_slot = settings->ints.state_slot;
|
state->state_slot = settings->ints.state_slot;
|
||||||
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
|
if (video_driver_cached_frame_has_valid_framebuffer())
|
||||||
|
state->flags |= SAVE_TASK_FLAG_HAS_VALID_FB;
|
||||||
#if defined(HAVE_ZLIB)
|
#if defined(HAVE_ZLIB)
|
||||||
state->compress_files = settings->bools.savestate_file_compression;
|
if (settings->bools.savestate_file_compression)
|
||||||
#else
|
state->flags |= SAVE_TASK_FLAG_COMPRESS_FILES;
|
||||||
state->compress_files = false;
|
|
||||||
#endif
|
#endif
|
||||||
task->type = TASK_TYPE_BLOCKING;
|
task->type = TASK_TYPE_BLOCKING;
|
||||||
task->state = state;
|
task->state = state;
|
||||||
|
@ -969,7 +975,7 @@ static void task_load_handler(retro_task_t *task)
|
||||||
|
|
||||||
if (task_get_cancelled(task) || bytes_read != remaining)
|
if (task_get_cancelled(task) || bytes_read != remaining)
|
||||||
{
|
{
|
||||||
if (state->autoload)
|
if (state->flags & SAVE_TASK_FLAG_AUTOLOAD)
|
||||||
{
|
{
|
||||||
char *msg = (char*)malloc(8192 * sizeof(char));
|
char *msg = (char*)malloc(8192 * sizeof(char));
|
||||||
|
|
||||||
|
@ -1000,7 +1006,7 @@ static void task_load_handler(retro_task_t *task)
|
||||||
size_t msg_size = 8192 * sizeof(char);
|
size_t msg_size = 8192 * sizeof(char);
|
||||||
char *msg = (char*)malloc(msg_size);
|
char *msg = (char*)malloc(msg_size);
|
||||||
|
|
||||||
if (state->autoload)
|
if (state->flags & SAVE_TASK_FLAG_AUTOLOAD)
|
||||||
{
|
{
|
||||||
msg[0] = '\0';
|
msg[0] = '\0';
|
||||||
snprintf(msg,
|
snprintf(msg,
|
||||||
|
@ -1158,7 +1164,7 @@ static void content_load_state_cb(retro_task_t *task,
|
||||||
/* This means we're backing up the file in memory,
|
/* This means we're backing up the file in memory,
|
||||||
* so content_undo_save_state()
|
* so content_undo_save_state()
|
||||||
* can restore it */
|
* can restore it */
|
||||||
if (load_data->load_to_backup_buffer)
|
if (load_data->flags & SAVE_TASK_FLAG_LOAD_TO_BACKUP_BUFF)
|
||||||
{
|
{
|
||||||
/* If we were previously backing up a file, let go of it first */
|
/* If we were previously backing up a file, let go of it first */
|
||||||
if (undo_save_buf.data)
|
if (undo_save_buf.data)
|
||||||
|
@ -1283,9 +1289,10 @@ static void save_state_cb(retro_task_t *task,
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
const char *dir_screenshot = settings->paths.directory_screenshot;
|
const char *dir_screenshot = settings->paths.directory_screenshot;
|
||||||
|
|
||||||
if (state->thumbnail_enable)
|
if (state->flags & SAVE_TASK_FLAG_THUMBNAIL_ENABLE)
|
||||||
take_screenshot(dir_screenshot,
|
take_screenshot(dir_screenshot,
|
||||||
path, true, state->has_valid_framebuffer, false, true);
|
path, true,
|
||||||
|
state->flags & SAVE_TASK_FLAG_HAS_VALID_FB, false, true);
|
||||||
free(path);
|
free(path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1312,15 +1319,18 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool
|
||||||
strlcpy(state->path, path, sizeof(state->path));
|
strlcpy(state->path, path, sizeof(state->path));
|
||||||
state->data = data;
|
state->data = data;
|
||||||
state->size = size;
|
state->size = size;
|
||||||
state->autosave = autosave;
|
/* Don't show OSD messages if we are auto-saving */
|
||||||
state->mute = autosave; /* don't show OSD messages if we are auto-saving */
|
if (autosave)
|
||||||
state->thumbnail_enable = settings->bools.savestate_thumbnail_enable;
|
state->flags |= (SAVE_TASK_FLAG_AUTOSAVE |
|
||||||
|
SAVE_TASK_FLAG_MUTE);
|
||||||
|
if (settings->bools.savestate_thumbnail_enable)
|
||||||
|
state->flags |= SAVE_TASK_FLAG_THUMBNAIL_ENABLE;
|
||||||
state->state_slot = settings->ints.state_slot;
|
state->state_slot = settings->ints.state_slot;
|
||||||
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
|
if (video_driver_cached_frame_has_valid_framebuffer())
|
||||||
|
state->flags |= SAVE_TASK_FLAG_HAS_VALID_FB;
|
||||||
#if defined(HAVE_ZLIB)
|
#if defined(HAVE_ZLIB)
|
||||||
state->compress_files = settings->bools.savestate_file_compression;
|
if (settings->bools.savestate_file_compression)
|
||||||
#else
|
state->flags |= SAVE_TASK_FLAG_COMPRESS_FILES;
|
||||||
state->compress_files = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
task->type = TASK_TYPE_BLOCKING;
|
task->type = TASK_TYPE_BLOCKING;
|
||||||
|
@ -1328,7 +1338,7 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool
|
||||||
task->handler = task_save_handler;
|
task->handler = task_save_handler;
|
||||||
task->callback = save_state_cb;
|
task->callback = save_state_cb;
|
||||||
task->title = strdup(msg_hash_to_str(MSG_SAVING_STATE));
|
task->title = strdup(msg_hash_to_str(MSG_SAVING_STATE));
|
||||||
task->mute = state->mute;
|
task->mute = state->flags & SAVE_TASK_FLAG_MUTE;
|
||||||
|
|
||||||
if (!task_queue_push(task))
|
if (!task_queue_push(task))
|
||||||
{
|
{
|
||||||
|
@ -1370,7 +1380,7 @@ static void content_load_and_save_state_cb(retro_task_t *task,
|
||||||
char *path = strdup(load_data->path);
|
char *path = strdup(load_data->path);
|
||||||
void *data = load_data->undo_data;
|
void *data = load_data->undo_data;
|
||||||
size_t size = load_data->undo_size;
|
size_t size = load_data->undo_size;
|
||||||
bool autosave = load_data->autosave;
|
bool autosave = load_data->flags & SAVE_TASK_FLAG_AUTOSAVE;
|
||||||
|
|
||||||
content_load_state_cb(task, task_data, user_data, error);
|
content_load_state_cb(task, task_data, user_data, error);
|
||||||
|
|
||||||
|
@ -1408,21 +1418,22 @@ static void task_push_load_and_save_state(const char *path, void *data,
|
||||||
|
|
||||||
|
|
||||||
strlcpy(state->path, path, sizeof(state->path));
|
strlcpy(state->path, path, sizeof(state->path));
|
||||||
state->load_to_backup_buffer = load_to_backup_buffer;
|
if (load_to_backup_buffer)
|
||||||
|
state->flags |= SAVE_TASK_FLAG_LOAD_TO_BACKUP_BUFF;
|
||||||
state->undo_size = size;
|
state->undo_size = size;
|
||||||
state->undo_data = data;
|
state->undo_data = data;
|
||||||
state->autosave = autosave;
|
/* Don't show OSD messages if we are auto-saving */
|
||||||
state->mute = autosave; /* don't show OSD messages if we
|
if (autosave)
|
||||||
are auto-saving */
|
state->flags |= (SAVE_TASK_FLAG_AUTOSAVE |
|
||||||
|
SAVE_TASK_FLAG_MUTE);
|
||||||
if (load_to_backup_buffer)
|
if (load_to_backup_buffer)
|
||||||
state->mute = true;
|
state->flags |= SAVE_TASK_FLAG_MUTE;
|
||||||
state->state_slot = settings->ints.state_slot;
|
state->state_slot = settings->ints.state_slot;
|
||||||
state->has_valid_framebuffer =
|
if (video_driver_cached_frame_has_valid_framebuffer())
|
||||||
video_driver_cached_frame_has_valid_framebuffer();
|
state->flags |= SAVE_TASK_FLAG_HAS_VALID_FB;
|
||||||
#if defined(HAVE_ZLIB)
|
#if defined(HAVE_ZLIB)
|
||||||
state->compress_files = settings->bools.savestate_file_compression;
|
if (settings->bools.savestate_file_compression)
|
||||||
#else
|
state->flags |= SAVE_TASK_FLAG_COMPRESS_FILES;
|
||||||
state->compress_files = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
task->state = state;
|
task->state = state;
|
||||||
|
@ -1430,7 +1441,7 @@ static void task_push_load_and_save_state(const char *path, void *data,
|
||||||
task->handler = task_load_handler;
|
task->handler = task_load_handler;
|
||||||
task->callback = content_load_and_save_state_cb;
|
task->callback = content_load_and_save_state_cb;
|
||||||
task->title = strdup(msg_hash_to_str(MSG_LOADING_STATE));
|
task->title = strdup(msg_hash_to_str(MSG_LOADING_STATE));
|
||||||
task->mute = state->mute;
|
task->mute = state->flags & SAVE_TASK_FLAG_MUTE;
|
||||||
|
|
||||||
if (!task_queue_push(task))
|
if (!task_queue_push(task))
|
||||||
{
|
{
|
||||||
|
@ -1602,15 +1613,16 @@ bool content_load_state(const char *path,
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
strlcpy(state->path, path, sizeof(state->path));
|
strlcpy(state->path, path, sizeof(state->path));
|
||||||
state->load_to_backup_buffer = load_to_backup_buffer;
|
if (load_to_backup_buffer)
|
||||||
state->autoload = autoload;
|
state->flags |= SAVE_TASK_FLAG_LOAD_TO_BACKUP_BUFF;
|
||||||
|
if (autoload)
|
||||||
|
state->flags |= SAVE_TASK_FLAG_AUTOLOAD;
|
||||||
state->state_slot = settings->ints.state_slot;
|
state->state_slot = settings->ints.state_slot;
|
||||||
state->has_valid_framebuffer =
|
if (video_driver_cached_frame_has_valid_framebuffer())
|
||||||
video_driver_cached_frame_has_valid_framebuffer();
|
state->flags |= SAVE_TASK_FLAG_HAS_VALID_FB;
|
||||||
#if defined(HAVE_ZLIB)
|
#if defined(HAVE_ZLIB)
|
||||||
state->compress_files = settings->bools.savestate_file_compression;
|
if (settings->bools.savestate_file_compression)
|
||||||
#else
|
state->flags |= SAVE_TASK_FLAG_COMPRESS_FILES;
|
||||||
state->compress_files = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
task->type = TASK_TYPE_BLOCKING;
|
task->type = TASK_TYPE_BLOCKING;
|
||||||
|
|
Loading…
Reference in New Issue