(Menu) Put selection_buf_old on stack too

This commit is contained in:
twinaphex 2020-08-24 16:08:09 +02:00
parent 4dec373edc
commit ecc54b4d4e
5 changed files with 66 additions and 121 deletions

View File

@ -589,7 +589,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
ozone->last_height = height;
ozone->last_scale_factor = gfx_display_get_dpi_scale(width, height);
ozone->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
file_list_initialize(&ozone->selection_buf_old);
ozone->draw_sidebar = true;
ozone->sidebar_offset = 0;
@ -748,15 +748,9 @@ error:
if (ozone)
{
ozone_free_list_nodes(&ozone->horizontal_list, false);
ozone_free_list_nodes(&ozone->selection_buf_old, false);
file_list_deinitialize(&ozone->horizontal_list);
if (ozone->selection_buf_old)
{
ozone_free_list_nodes(ozone->selection_buf_old, false);
file_list_free(ozone->selection_buf_old);
}
ozone->selection_buf_old = NULL;
file_list_deinitialize(&ozone->selection_buf_old);
}
if (menu)
@ -781,17 +775,11 @@ static void ozone_free(void *data)
font_driver_bind_block(NULL, NULL);
if (ozone->selection_buf_old)
{
ozone_free_list_nodes(ozone->selection_buf_old, false);
file_list_free(ozone->selection_buf_old);
}
ozone_free_list_nodes(&ozone->selection_buf_old, false);
ozone_free_list_nodes(&ozone->horizontal_list, false);
file_list_deinitialize(&ozone->selection_buf_old);
file_list_deinitialize(&ozone->horizontal_list);
ozone->selection_buf_old = NULL;
if (!string_is_empty(ozone->pending_message))
free(ozone->pending_message);
@ -2728,7 +2716,7 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
video_height,
(unsigned)ozone->selection_old_list,
(unsigned)ozone->selection_old_list,
ozone->selection_buf_old,
&ozone->selection_buf_old,
ozone->animations.list_alpha,
ozone->scroll_old,
ozone->is_playlist_old
@ -3270,13 +3258,15 @@ text_iterate:
y += node->height;
}
last -= 1;
last += first;
last -= 1;
last += first;
first_node = (ozone_node_t*) file_list_get_userdata_at_offset(selection_buf, first);
first_node = (ozone_node_t*)file_list_get_userdata_at_offset(
selection_buf, first);
ozone->old_list_offset_y = first_node->position_y;
ozone_list_deep_copy(selection_buf, ozone->selection_buf_old, first, last);
ozone_list_deep_copy(selection_buf,
&ozone->selection_buf_old, first, last);
}
static int ozone_environ_cb(enum menu_environ_cb type, void *data, void *userdata)

View File

@ -112,8 +112,8 @@ struct ozone_handle
ozone_theme_t *theme;
gfx_thumbnail_path_data_t *thumbnail_path_data;
file_list_t *selection_buf_old;
char *pending_message;
file_list_t selection_buf_old; /* ptr alignment */
file_list_t horizontal_list; /* console tabs */ /* ptr alignment */
struct

View File

@ -459,7 +459,7 @@ void ozone_draw_entries(
enum gfx_animation_ticker_type
menu_ticker_type = (enum gfx_animation_ticker_type)
settings->uints.menu_ticker_type;
bool old_list = selection_buf == ozone->selection_buf_old;
bool old_list = selection_buf == &ozone->selection_buf_old;
int x_offset = 0;
size_t selection_y = 0; /* 0 means no selection (we assume that no entry has y = 0) */
size_t old_selection_y = 0;

View File

@ -259,8 +259,8 @@ typedef struct stripes_handle
char *left_thumbnail_file_path;
char *bg_file_path;
file_list_t *selection_buf_old;
file_list_t *horizontal_list;
file_list_t selection_buf_old; /* ptr alignment */
file_list_t horizontal_list; /* ptr alignment */
struct
{
@ -503,9 +503,7 @@ static size_t stripes_list_get_size(void *data, enum menu_list_type type)
case MENU_LIST_PLAIN:
return menu_entries_get_stack_size(0);
case MENU_LIST_HORIZONTAL:
if (stripes && stripes->horizontal_list)
return file_list_get_size(stripes->horizontal_list);
break;
return file_list_get_size(&stripes->horizontal_list);
case MENU_LIST_TABS:
return stripes->system_tab_end;
}
@ -530,10 +528,9 @@ static void *stripes_list_get_entry(void *data,
}
break;
case MENU_LIST_HORIZONTAL:
if (stripes && stripes->horizontal_list)
list_size = file_list_get_size(stripes->horizontal_list);
list_size = file_list_get_size(&stripes->horizontal_list);
if (i < list_size)
return (void*)&stripes->horizontal_list->list[i];
return (void*)&stripes->horizontal_list.list[i];
break;
default:
break;
@ -1432,10 +1429,10 @@ static stripes_node_t *stripes_node_allocate_userdata(
}
tmp = (stripes_node_t*)file_list_get_userdata_at_offset(
stripes->horizontal_list, i);
&stripes->horizontal_list, i);
stripes_free_node(tmp);
file_list_set_userdata(stripes->horizontal_list, i, node);
file_list_set_userdata(&stripes->horizontal_list, i, node);
return node;
}
@ -1444,7 +1441,7 @@ static stripes_node_t* stripes_get_userdata_from_horizontal_list(
stripes_handle_t *stripes, unsigned i)
{
return (stripes_node_t*)
file_list_get_userdata_at_offset(stripes->horizontal_list, i);
file_list_get_userdata_at_offset(&stripes->horizontal_list, i);
}
static void stripes_push_animations(stripes_node_t *node,
@ -1592,7 +1589,7 @@ static void stripes_set_title(stripes_handle_t *stripes)
{
const char *path = NULL;
menu_entries_get_at_offset(
stripes->horizontal_list,
&stripes->horizontal_list,
stripes->categories_selection_ptr - (stripes->system_tab_end + 1),
&path, NULL, NULL, NULL, NULL);
@ -1740,7 +1737,8 @@ static void stripes_list_switch(stripes_handle_t *stripes)
if (stripes->categories_selection_ptr > stripes->categories_selection_ptr_old)
dir = 1;
stripes_list_switch_old(stripes, stripes->selection_buf_old,
stripes_list_switch_old(stripes,
&stripes->selection_buf_old,
dir, stripes->selection_ptr_old);
/* Check if we are to have horizontal animations. */
@ -1824,7 +1822,7 @@ static void stripes_context_destroy_horizontal_list(stripes_handle_t *stripes)
if (!node)
continue;
file_list_get_at_offset(stripes->horizontal_list, i,
file_list_get_at_offset(&stripes->horizontal_list, i,
&path, NULL, NULL, NULL);
if (!path || !string_ends_with_size(path, ".lpl",
@ -1843,7 +1841,7 @@ static void stripes_init_horizontal_list(stripes_handle_t *stripes)
menu_displaylist_info_init(&info);
info.list = stripes->horizontal_list;
info.list = &stripes->horizontal_list;
info.path = strdup(
settings->paths.directory_playlist);
#if 0
@ -1860,7 +1858,7 @@ static void stripes_init_horizontal_list(stripes_handle_t *stripes)
if (menu_displaylist_ctl(DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL, &info))
{
size_t i;
for (i = 0; i < stripes->horizontal_list->size; i++)
for (i = 0; i < stripes->horizontal_list.size; i++)
stripes_node_allocate_userdata(stripes, (unsigned)i);
menu_displaylist_process(&info);
}
@ -1923,7 +1921,7 @@ static void stripes_context_reset_horizontal_list(
continue;
}
file_list_get_at_offset(stripes->horizontal_list, i,
file_list_get_at_offset(&stripes->horizontal_list, i,
&path, NULL, NULL, NULL);
if (!path || !string_ends_with_size(path, ".lpl",
@ -1989,20 +1987,12 @@ static void stripes_context_reset_horizontal_list(
static void stripes_refresh_horizontal_list(stripes_handle_t *stripes)
{
stripes_context_destroy_horizontal_list(stripes);
if (stripes->horizontal_list)
{
stripes_free_list_nodes(stripes->horizontal_list, false);
file_list_free(stripes->horizontal_list);
}
stripes->horizontal_list = NULL;
stripes_free_list_nodes(stripes->horizontal_list, false);
file_list_deinitialize(&stripes->horizontal_list);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
stripes->horizontal_list = (file_list_t*)
calloc(1, sizeof(file_list_t));
if (stripes->horizontal_list)
stripes_init_horizontal_list(stripes);
stripes_init_horizontal_list(stripes);
stripes_context_reset_horizontal_list(stripes);
}
@ -2053,7 +2043,8 @@ static void stripes_list_open(stripes_handle_t *stripes)
stripes_list_open_horizontal_list(stripes);
stripes_list_open_old(stripes, stripes->selection_buf_old,
stripes_list_open_old(stripes,
&stripes->selection_buf_old,
dir, stripes->selection_ptr_old);
stripes_list_open_new(stripes, selection_buf,
dir, selection);
@ -2642,7 +2633,7 @@ static void stripes_draw_items(
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
if (list == stripes->selection_buf_old)
if (list == &stripes->selection_buf_old)
{
stripes_node_t *node = (stripes_node_t*)
file_list_get_userdata_at_offset(list, current);
@ -2996,7 +2987,7 @@ static void stripes_frame(void *data, video_frame_info_t *video_info)
video_height,
xmb_shadows_enable,
stripes,
stripes->selection_buf_old,
&stripes->selection_buf_old,
stripes->selection_ptr_old,
(stripes_list_get_size(stripes, MENU_LIST_PLAIN) > 1)
? stripes->categories_selection_ptr :
@ -3289,14 +3280,14 @@ static void stripes_layout(stripes_handle_t *stripes)
return;
current = (unsigned)stripes->selection_ptr_old;
end = (unsigned)file_list_get_size(stripes->selection_buf_old);
end = (unsigned)file_list_get_size(&stripes->selection_buf_old);
for (i = 0; i < end; i++)
{
float ia = 0;
float iz = stripes->items_passive_zoom;
stripes_node_t *node = (stripes_node_t*)file_list_get_userdata_at_offset(
stripes->selection_buf_old, i);
&stripes->selection_buf_old, i);
if (!node)
continue;
@ -3366,9 +3357,7 @@ static void *stripes_init(void **userdata, bool video_is_threaded)
*userdata = stripes;
stripes->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
if (!stripes->selection_buf_old)
if (!file_list_initialize(&stripes->selection_buf_old))
goto error;
stripes->categories_active_idx = 0;
@ -3417,10 +3406,8 @@ static void *stripes_init(void **userdata, bool video_is_threaded)
gfx_display_allocate_white_texture();
stripes->horizontal_list = (file_list_t*)calloc(1, sizeof(file_list_t));
if (stripes->horizontal_list)
stripes_init_horizontal_list(stripes);
file_list_initialize(&stripes->horizontal_list);
stripes_init_horizontal_list(stripes);
return menu;
@ -3430,15 +3417,10 @@ error:
if (stripes)
{
if (stripes->selection_buf_old)
free(stripes->selection_buf_old);
stripes->selection_buf_old = NULL;
if (stripes->horizontal_list)
{
stripes_free_list_nodes(stripes->horizontal_list, false);
file_list_free(stripes->horizontal_list);
}
stripes->horizontal_list = NULL;
stripes_free_list_nodes(&stripes->selection_buf_old, false);
stripes_free_list_nodes(&stripes->horizontal_list, false);
file_list_deinitialize(&stripes->selection_buf_old);
file_list_deinitialize(&stripes->horizontal_list);
}
return NULL;
}
@ -3449,20 +3431,10 @@ static void stripes_free(void *data)
if (stripes)
{
if (stripes->selection_buf_old)
{
stripes_free_list_nodes(stripes->selection_buf_old, false);
file_list_free(stripes->selection_buf_old);
}
if (stripes->horizontal_list)
{
stripes_free_list_nodes(stripes->horizontal_list, false);
file_list_free(stripes->horizontal_list);
}
stripes->selection_buf_old = NULL;
stripes->horizontal_list = NULL;
stripes_free_list_nodes(&stripes->selection_buf_old, false);
stripes_free_list_nodes(&stripes->horizontal_list, false);
file_list_deinitialize(&stripes->selection_buf_old);
file_list_deinitialize(&stripes->horizontal_list);
video_coord_array_free(&stripes->raster_block.carr);
video_coord_array_free(&stripes->raster_block2.carr);
@ -3956,7 +3928,8 @@ static void stripes_list_cache(void *data, enum menu_list_type type, unsigned ac
stripes_calculate_visible_range(stripes, height, selection_buf->size,
stripes->selection_ptr_old, &first, &last);
stripes_list_deep_copy(selection_buf, stripes->selection_buf_old, first, last);
stripes_list_deep_copy(selection_buf,
&stripes->selection_buf_old, first, last);
stripes->selection_ptr_old -= first;
last -= first;

View File

@ -266,8 +266,8 @@ typedef struct xmb_handle
char *box_message;
char *bg_file_path;
file_list_t *selection_buf_old;
file_list_t horizontal_list; /* ptr alignment */
file_list_t selection_buf_old; /* ptr alignment */
file_list_t horizontal_list; /* ptr alignment */
xmb_node_t main_menu_node;
#ifdef HAVE_IMAGEVIEWER
@ -2019,7 +2019,7 @@ static void xmb_list_switch(xmb_handle_t *xmb)
if (xmb->categories_selection_ptr > xmb->categories_selection_ptr_old)
dir = 1;
xmb_list_switch_old(xmb, xmb->selection_buf_old,
xmb_list_switch_old(xmb, &xmb->selection_buf_old,
dir, xmb->selection_ptr_old);
/* Check if we are to have horizontal animations. */
@ -2329,7 +2329,7 @@ static void xmb_list_open(xmb_handle_t *xmb)
xmb_list_open_horizontal_list(xmb);
xmb_list_open_old(xmb, xmb->selection_buf_old,
xmb_list_open_old(xmb, &xmb->selection_buf_old,
dir, xmb->selection_ptr_old);
xmb_list_open_new(xmb, selection_buf,
dir, selection);
@ -3472,7 +3472,7 @@ static void xmb_draw_items(
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
if (list == xmb->selection_buf_old)
if (list == &xmb->selection_buf_old)
{
xmb_node_t *node = (xmb_node_t*)
file_list_get_userdata_at_offset(list, current);
@ -5032,7 +5032,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
video_height,
xmb_shadows_enable,
xmb,
xmb->selection_buf_old,
&xmb->selection_buf_old,
xmb->selection_ptr_old,
(xmb_list_get_size(xmb, MENU_LIST_PLAIN) > 1)
? xmb->categories_selection_ptr :
@ -5275,14 +5275,14 @@ static void xmb_layout(xmb_handle_t *xmb)
return;
current = (unsigned)xmb->selection_ptr_old;
end = (unsigned)file_list_get_size(xmb->selection_buf_old);
end = (unsigned)file_list_get_size(&xmb->selection_buf_old);
for (i = 0; i < end; i++)
{
float ia = 0;
float iz = xmb->items_passive_zoom;
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(
xmb->selection_buf_old, i);
&xmb->selection_buf_old, i);
if (!node)
continue;
@ -5418,15 +5418,7 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
*userdata = xmb;
xmb->selection_buf_old = (file_list_t*)
malloc(sizeof(file_list_t));
if (!xmb->selection_buf_old)
goto error;
xmb->selection_buf_old->list = NULL;
xmb->selection_buf_old->capacity = 0;
xmb->selection_buf_old->size = 0;
file_list_initialize(&xmb->selection_buf_old);
xmb->categories_active_idx = 0;
xmb->categories_active_idx_old = 0;
@ -5481,9 +5473,7 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
gfx_display_allocate_white_texture();
xmb->horizontal_list.list = NULL;
xmb->horizontal_list.capacity = 0;
xmb->horizontal_list.size = 0;
file_list_initialize(&xmb->horizontal_list);
xmb_init_horizontal_list(xmb);
@ -5518,11 +5508,8 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
error:
free(menu);
if (xmb->selection_buf_old)
free(xmb->selection_buf_old);
xmb->selection_buf_old = NULL;
xmb_free_list_nodes(&xmb->horizontal_list, false);
file_list_deinitialize(&xmb->selection_buf_old);
file_list_deinitialize(&xmb->horizontal_list);
gfx_animation_unset_update_time_cb();
return NULL;
@ -5534,17 +5521,11 @@ static void xmb_free(void *data)
if (xmb)
{
if (xmb->selection_buf_old)
{
xmb_free_list_nodes(xmb->selection_buf_old, false);
file_list_free(xmb->selection_buf_old);
}
xmb_free_list_nodes(&xmb->selection_buf_old, false);
xmb_free_list_nodes(&xmb->horizontal_list, false);
file_list_deinitialize(&xmb->selection_buf_old);
file_list_deinitialize(&xmb->horizontal_list);
xmb->selection_buf_old = NULL;
video_coord_array_free(&xmb->raster_block.carr);
video_coord_array_free(&xmb->raster_block2.carr);
@ -6261,7 +6242,8 @@ static void xmb_list_cache(void *data, enum menu_list_type type, unsigned action
xmb_calculate_visible_range(xmb, height, selection_buf->size,
(unsigned)xmb->selection_ptr_old, &first, &last);
xmb_list_deep_copy(selection_buf, xmb->selection_buf_old, first, last);
xmb_list_deep_copy(selection_buf,
&xmb->selection_buf_old, first, last);
xmb->selection_ptr_old -= first;
last -= first;