forked from len0rd/rockbox
skin_engine: Add a debug screen to display skin ram usage
Change-Id: Ida9c33211d9360ac88e30a2cf8df9f191bee8b45
This commit is contained in:
parent
69228f92db
commit
aaf30651df
7 changed files with 110 additions and 9 deletions
|
@ -86,6 +86,7 @@
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "scrollbar.h"
|
||||
#include "peakmeter.h"
|
||||
#include "skin_engine/skin_engine.h"
|
||||
#endif
|
||||
#include "logfdisp.h"
|
||||
#include "core_alloc.h"
|
||||
|
@ -555,8 +556,6 @@ static int bf_action_cb(int action, struct gui_synclist* list)
|
|||
}
|
||||
action = ACTION_REDRAW;
|
||||
}
|
||||
else if (action == ACTION_NONE)
|
||||
action = ACTION_REDRAW;
|
||||
return action;
|
||||
}
|
||||
|
||||
|
@ -566,7 +565,7 @@ static bool dbg_buflib_allocs(void)
|
|||
simplelist_info_init(&info, "mem allocs", core_get_num_blocks(), NULL);
|
||||
info.get_name = bf_getname;
|
||||
info.action_callback = bf_action_cb;
|
||||
info.timeout = TIMEOUT_BLOCK;
|
||||
info.timeout = HZ;
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
|
||||
|
@ -2185,6 +2184,57 @@ static bool dbg_pic(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
static bool dbg_skin_engine(void)
|
||||
{
|
||||
struct simplelist_info info;
|
||||
int i, ref_count, total = 0;
|
||||
char *path;
|
||||
size_t bytes;
|
||||
int path_prefix_len = strlen(ROCKBOX_DIR "/wps/");
|
||||
simplelist_info_init(&info, "Skin engine usage", 0, NULL);
|
||||
simplelist_set_line_count(0);
|
||||
info.hide_selection = true;
|
||||
FOR_NB_SCREENS(j) {
|
||||
#if NB_SCREENS > 1
|
||||
simplelist_addline("%s display:",
|
||||
j == 0 ? "Main" : "Remote");
|
||||
#endif
|
||||
for (i = 0; i < skin_get_num_skins(); i++) {
|
||||
struct skin_stats *stats = skin_get_stats(i, j);
|
||||
if (stats->buflib_handles)
|
||||
{
|
||||
simplelist_addline("Skin ID: %d, %d allocations",
|
||||
i, stats->buflib_handles);
|
||||
simplelist_addline("\tskin: %d bytes",
|
||||
stats->tree_size);
|
||||
simplelist_addline("\tImages: %d bytes",
|
||||
stats->images_size);
|
||||
simplelist_addline("\tTotal: %d bytes",
|
||||
stats->tree_size + stats->images_size);
|
||||
total += stats->tree_size + stats->images_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
simplelist_addline("Skin total usage: %d bytes", total);
|
||||
simplelist_addline("Backdrop Images:");
|
||||
i = 0;
|
||||
while (skin_backdrop_get_debug(i++, &path, &ref_count, &bytes)) {
|
||||
if (ref_count > 0) {
|
||||
|
||||
if (!strncasecmp(path, ROCKBOX_DIR "/wps/", path_prefix_len))
|
||||
path += path_prefix_len;
|
||||
simplelist_addline("%s", path);
|
||||
simplelist_addline("\tref_count: %d", ref_count);
|
||||
simplelist_addline("\tsize: %d", bytes);
|
||||
total += bytes;
|
||||
}
|
||||
}
|
||||
simplelist_addline("Total usage: %d bytes", total);
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/****** The menu *********/
|
||||
static const struct {
|
||||
|
@ -2232,6 +2282,7 @@ static const struct {
|
|||
#ifndef APPLICATION
|
||||
{ "Screendump", dbg_screendump },
|
||||
#endif
|
||||
{ "Skin Engine Ram usage", dbg_skin_engine },
|
||||
#endif
|
||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||
{ "View HW info", dbg_hw_info },
|
||||
|
|
|
@ -277,6 +277,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
|
|||
list_icons.x += indent;
|
||||
list_text_vp->x += indent;
|
||||
}
|
||||
list_icons.width -= indent;
|
||||
list_text_vp->width -= indent;
|
||||
}
|
||||
|
||||
|
@ -392,6 +393,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
|
|||
list_icons.x -= indent;
|
||||
list_text_vp->x -= indent;
|
||||
}
|
||||
list_icons.width += indent;
|
||||
list_text_vp->width += indent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,25 @@ static struct skin_backdrop {
|
|||
static int handle_being_loaded;
|
||||
static int current_lcd_backdrop[NB_SCREENS];
|
||||
|
||||
bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *size)
|
||||
{
|
||||
|
||||
if (index + 1 >= NB_BDROPS)
|
||||
return false;
|
||||
|
||||
*path = backdrops[index].name;
|
||||
*ref_count = backdrops[index].ref_count;
|
||||
|
||||
#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
|
||||
enum screen_type screen = backdrops[index].screen;
|
||||
if (screen == SCREEN_REMOTE)
|
||||
*size = REMOTE_LCD_BACKDROP_BYTES;
|
||||
else
|
||||
#endif
|
||||
*size = LCD_BACKDROP_BYTES;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int buflib_move_callback(int handle, void* current, void* new)
|
||||
{
|
||||
if (handle == handle_being_loaded)
|
||||
|
|
|
@ -65,11 +65,21 @@ static struct gui_skin_helper {
|
|||
static struct gui_skin {
|
||||
struct gui_wps gui_wps;
|
||||
struct wps_data data;
|
||||
struct skin_stats stats;
|
||||
bool failsafe_loaded;
|
||||
|
||||
bool needs_full_update;
|
||||
} skins[SKINNABLE_SCREENS_COUNT][NB_SCREENS];
|
||||
|
||||
int skin_get_num_skins(void)
|
||||
{
|
||||
return SKINNABLE_SCREENS_COUNT;
|
||||
}
|
||||
|
||||
struct skin_stats *skin_get_stats(int number, int screen)
|
||||
{
|
||||
return &skins[number][screen].stats;
|
||||
}
|
||||
|
||||
static void gui_skin_reset(struct gui_skin *skin)
|
||||
{
|
||||
|
@ -167,12 +177,14 @@ void skin_load(enum skinnable_screens skin, enum screen_type screen,
|
|||
skin_helpers[skin].preproccess(screen, &skins[skin][screen].data);
|
||||
|
||||
if (buf && *buf)
|
||||
loaded = skin_data_load(screen, &skins[skin][screen].data, buf, isfile);
|
||||
loaded = skin_data_load(screen, &skins[skin][screen].data, buf, isfile,
|
||||
&skins[skin][screen].stats);
|
||||
|
||||
if (!loaded && skin_helpers[skin].default_skin)
|
||||
{
|
||||
loaded = skin_data_load(screen, &skins[skin][screen].data,
|
||||
skin_helpers[skin].default_skin(screen), false);
|
||||
skin_helpers[skin].default_skin(screen), false,
|
||||
&skins[skin][screen].stats);
|
||||
skins[skin][screen].failsafe_loaded = loaded;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ void skin_update(enum skinnable_screens skin, enum screen_type screen,
|
|||
* or from a skinfile (isfile = true)
|
||||
*/
|
||||
bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
|
||||
const char *buf, bool isfile);
|
||||
const char *buf, bool isfile, struct skin_stats *stats);
|
||||
|
||||
bool skin_has_sbs(enum screen_type screen, struct wps_data *data);
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ static char* skin_buffer = NULL;
|
|||
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
|
||||
static char *backdrop_filename;
|
||||
#endif
|
||||
static struct skin_stats *_stats = NULL;
|
||||
|
||||
static bool isdefault(struct skin_tag_parameter *param)
|
||||
{
|
||||
|
@ -1770,6 +1771,8 @@ static int load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char*
|
|||
close(fd);
|
||||
return handle;
|
||||
}
|
||||
_stats->buflib_handles++;
|
||||
_stats->images_size += buf_size;
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
lock_handle(handle);
|
||||
bitmap->data = core_get_data(handle);
|
||||
|
@ -2282,7 +2285,7 @@ static int skin_element_callback(struct skin_element* element, void* data)
|
|||
/* to setup up the wps-data from a format-buffer (isfile = false)
|
||||
from a (wps-)file (isfile = true)*/
|
||||
bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
|
||||
const char *buf, bool isfile)
|
||||
const char *buf, bool isfile, struct skin_stats *stats)
|
||||
{
|
||||
char *wps_buffer = NULL;
|
||||
if (!wps_data || !buf)
|
||||
|
@ -2315,7 +2318,8 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
_stats = stats;
|
||||
skin_clear_stats(stats);
|
||||
/* get buffer space from the plugin buffer */
|
||||
size_t buffersize = 0;
|
||||
wps_buffer = (char *)plugin_get_buffer(&buffersize);
|
||||
|
@ -2426,6 +2430,8 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
|
|||
wps_data->wps_loaded = true;
|
||||
memcpy(core_get_data(wps_data->buflib_handle), skin_buffer,
|
||||
skin_buffer_usage());
|
||||
stats->buflib_handles++;
|
||||
stats->tree_size = skin_buffer_usage();
|
||||
}
|
||||
#else
|
||||
wps_data->wps_loaded = wps_data->tree >= 0;
|
||||
|
|
|
@ -31,6 +31,17 @@
|
|||
#include "core_alloc.h"
|
||||
#endif
|
||||
|
||||
struct skin_stats {
|
||||
size_t buflib_handles;
|
||||
size_t tree_size;
|
||||
size_t images_size;
|
||||
};
|
||||
|
||||
int skin_get_num_skins(void);
|
||||
struct skin_stats *skin_get_stats(int number, int screen);
|
||||
#define skin_clear_stats(stats) memset(stats, 0, sizeof(struct skin_stats))
|
||||
bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *size);
|
||||
|
||||
/* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
|
||||
(possibly with a decimal fraction) but stored as integer values.
|
||||
E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue