diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2013-02-12 21:00:05 +1100 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2013-02-12 21:01:13 +1100 |
commit | aaf30651df27e0eb6fab876502fa1e6c084160bf (patch) | |
tree | 57601fbe5e54ed290bc6c966b059af801bd0d1bb | |
parent | 69228f92dbddc9940166c0d7af2b4c79d55f85e7 (diff) | |
download | rockbox-aaf30651df27e0eb6fab876502fa1e6c084160bf.tar.gz rockbox-aaf30651df27e0eb6fab876502fa1e6c084160bf.zip |
skin_engine: Add a debug screen to display skin ram usage
Change-Id: Ida9c33211d9360ac88e30a2cf8df9f191bee8b45
-rw-r--r-- | apps/debug_menu.c | 57 | ||||
-rw-r--r-- | apps/gui/bitmap/list.c | 2 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_backdrops.c | 19 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_engine.c | 16 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_engine.h | 2 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 12 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 11 |
7 files changed, 110 insertions, 9 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a00dd48648..11399f37ca 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -86,6 +86,7 @@ | |||
86 | #ifdef HAVE_LCD_BITMAP | 86 | #ifdef HAVE_LCD_BITMAP |
87 | #include "scrollbar.h" | 87 | #include "scrollbar.h" |
88 | #include "peakmeter.h" | 88 | #include "peakmeter.h" |
89 | #include "skin_engine/skin_engine.h" | ||
89 | #endif | 90 | #endif |
90 | #include "logfdisp.h" | 91 | #include "logfdisp.h" |
91 | #include "core_alloc.h" | 92 | #include "core_alloc.h" |
@@ -555,8 +556,6 @@ static int bf_action_cb(int action, struct gui_synclist* list) | |||
555 | } | 556 | } |
556 | action = ACTION_REDRAW; | 557 | action = ACTION_REDRAW; |
557 | } | 558 | } |
558 | else if (action == ACTION_NONE) | ||
559 | action = ACTION_REDRAW; | ||
560 | return action; | 559 | return action; |
561 | } | 560 | } |
562 | 561 | ||
@@ -566,7 +565,7 @@ static bool dbg_buflib_allocs(void) | |||
566 | simplelist_info_init(&info, "mem allocs", core_get_num_blocks(), NULL); | 565 | simplelist_info_init(&info, "mem allocs", core_get_num_blocks(), NULL); |
567 | info.get_name = bf_getname; | 566 | info.get_name = bf_getname; |
568 | info.action_callback = bf_action_cb; | 567 | info.action_callback = bf_action_cb; |
569 | info.timeout = TIMEOUT_BLOCK; | 568 | info.timeout = HZ; |
570 | return simplelist_show_list(&info); | 569 | return simplelist_show_list(&info); |
571 | } | 570 | } |
572 | 571 | ||
@@ -2185,6 +2184,57 @@ static bool dbg_pic(void) | |||
2185 | } | 2184 | } |
2186 | #endif | 2185 | #endif |
2187 | 2186 | ||
2187 | #ifdef HAVE_LCD_BITMAP | ||
2188 | static bool dbg_skin_engine(void) | ||
2189 | { | ||
2190 | struct simplelist_info info; | ||
2191 | int i, ref_count, total = 0; | ||
2192 | char *path; | ||
2193 | size_t bytes; | ||
2194 | int path_prefix_len = strlen(ROCKBOX_DIR "/wps/"); | ||
2195 | simplelist_info_init(&info, "Skin engine usage", 0, NULL); | ||
2196 | simplelist_set_line_count(0); | ||
2197 | info.hide_selection = true; | ||
2198 | FOR_NB_SCREENS(j) { | ||
2199 | #if NB_SCREENS > 1 | ||
2200 | simplelist_addline("%s display:", | ||
2201 | j == 0 ? "Main" : "Remote"); | ||
2202 | #endif | ||
2203 | for (i = 0; i < skin_get_num_skins(); i++) { | ||
2204 | struct skin_stats *stats = skin_get_stats(i, j); | ||
2205 | if (stats->buflib_handles) | ||
2206 | { | ||
2207 | simplelist_addline("Skin ID: %d, %d allocations", | ||
2208 | i, stats->buflib_handles); | ||
2209 | simplelist_addline("\tskin: %d bytes", | ||
2210 | stats->tree_size); | ||
2211 | simplelist_addline("\tImages: %d bytes", | ||
2212 | stats->images_size); | ||
2213 | simplelist_addline("\tTotal: %d bytes", | ||
2214 | stats->tree_size + stats->images_size); | ||
2215 | total += stats->tree_size + stats->images_size; | ||
2216 | } | ||
2217 | } | ||
2218 | } | ||
2219 | simplelist_addline("Skin total usage: %d bytes", total); | ||
2220 | simplelist_addline("Backdrop Images:"); | ||
2221 | i = 0; | ||
2222 | while (skin_backdrop_get_debug(i++, &path, &ref_count, &bytes)) { | ||
2223 | if (ref_count > 0) { | ||
2224 | |||
2225 | if (!strncasecmp(path, ROCKBOX_DIR "/wps/", path_prefix_len)) | ||
2226 | path += path_prefix_len; | ||
2227 | simplelist_addline("%s", path); | ||
2228 | simplelist_addline("\tref_count: %d", ref_count); | ||
2229 | simplelist_addline("\tsize: %d", bytes); | ||
2230 | total += bytes; | ||
2231 | } | ||
2232 | } | ||
2233 | simplelist_addline("Total usage: %d bytes", total); | ||
2234 | return simplelist_show_list(&info); | ||
2235 | } | ||
2236 | #endif | ||
2237 | |||
2188 | 2238 | ||
2189 | /****** The menu *********/ | 2239 | /****** The menu *********/ |
2190 | static const struct { | 2240 | static const struct { |
@@ -2232,6 +2282,7 @@ static const struct { | |||
2232 | #ifndef APPLICATION | 2282 | #ifndef APPLICATION |
2233 | { "Screendump", dbg_screendump }, | 2283 | { "Screendump", dbg_screendump }, |
2234 | #endif | 2284 | #endif |
2285 | { "Skin Engine Ram usage", dbg_skin_engine }, | ||
2235 | #endif | 2286 | #endif |
2236 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 2287 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
2237 | { "View HW info", dbg_hw_info }, | 2288 | { "View HW info", dbg_hw_info }, |
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 191446e186..ede0de8881 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c | |||
@@ -277,6 +277,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
277 | list_icons.x += indent; | 277 | list_icons.x += indent; |
278 | list_text_vp->x += indent; | 278 | list_text_vp->x += indent; |
279 | } | 279 | } |
280 | list_icons.width -= indent; | ||
280 | list_text_vp->width -= indent; | 281 | list_text_vp->width -= indent; |
281 | } | 282 | } |
282 | 283 | ||
@@ -392,6 +393,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
392 | list_icons.x -= indent; | 393 | list_icons.x -= indent; |
393 | list_text_vp->x -= indent; | 394 | list_text_vp->x -= indent; |
394 | } | 395 | } |
396 | list_icons.width += indent; | ||
395 | list_text_vp->width += indent; | 397 | list_text_vp->width += indent; |
396 | } | 398 | } |
397 | } | 399 | } |
diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c index 0d3c8b605f..4d0345c21d 100644 --- a/apps/gui/skin_engine/skin_backdrops.c +++ b/apps/gui/skin_engine/skin_backdrops.c | |||
@@ -44,6 +44,25 @@ static struct skin_backdrop { | |||
44 | static int handle_being_loaded; | 44 | static int handle_being_loaded; |
45 | static int current_lcd_backdrop[NB_SCREENS]; | 45 | static int current_lcd_backdrop[NB_SCREENS]; |
46 | 46 | ||
47 | bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *size) | ||
48 | { | ||
49 | |||
50 | if (index + 1 >= NB_BDROPS) | ||
51 | return false; | ||
52 | |||
53 | *path = backdrops[index].name; | ||
54 | *ref_count = backdrops[index].ref_count; | ||
55 | |||
56 | #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) | ||
57 | enum screen_type screen = backdrops[index].screen; | ||
58 | if (screen == SCREEN_REMOTE) | ||
59 | *size = REMOTE_LCD_BACKDROP_BYTES; | ||
60 | else | ||
61 | #endif | ||
62 | *size = LCD_BACKDROP_BYTES; | ||
63 | return true; | ||
64 | } | ||
65 | |||
47 | static int buflib_move_callback(int handle, void* current, void* new) | 66 | static int buflib_move_callback(int handle, void* current, void* new) |
48 | { | 67 | { |
49 | if (handle == handle_being_loaded) | 68 | if (handle == handle_being_loaded) |
diff --git a/apps/gui/skin_engine/skin_engine.c b/apps/gui/skin_engine/skin_engine.c index 3c3f3221b4..4c113e5c68 100644 --- a/apps/gui/skin_engine/skin_engine.c +++ b/apps/gui/skin_engine/skin_engine.c | |||
@@ -65,11 +65,21 @@ static struct gui_skin_helper { | |||
65 | static struct gui_skin { | 65 | static struct gui_skin { |
66 | struct gui_wps gui_wps; | 66 | struct gui_wps gui_wps; |
67 | struct wps_data data; | 67 | struct wps_data data; |
68 | struct skin_stats stats; | ||
68 | bool failsafe_loaded; | 69 | bool failsafe_loaded; |
69 | 70 | ||
70 | bool needs_full_update; | 71 | bool needs_full_update; |
71 | } skins[SKINNABLE_SCREENS_COUNT][NB_SCREENS]; | 72 | } skins[SKINNABLE_SCREENS_COUNT][NB_SCREENS]; |
72 | 73 | ||
74 | int skin_get_num_skins(void) | ||
75 | { | ||
76 | return SKINNABLE_SCREENS_COUNT; | ||
77 | } | ||
78 | |||
79 | struct skin_stats *skin_get_stats(int number, int screen) | ||
80 | { | ||
81 | return &skins[number][screen].stats; | ||
82 | } | ||
73 | 83 | ||
74 | static void gui_skin_reset(struct gui_skin *skin) | 84 | static void gui_skin_reset(struct gui_skin *skin) |
75 | { | 85 | { |
@@ -167,12 +177,14 @@ void skin_load(enum skinnable_screens skin, enum screen_type screen, | |||
167 | skin_helpers[skin].preproccess(screen, &skins[skin][screen].data); | 177 | skin_helpers[skin].preproccess(screen, &skins[skin][screen].data); |
168 | 178 | ||
169 | if (buf && *buf) | 179 | if (buf && *buf) |
170 | loaded = skin_data_load(screen, &skins[skin][screen].data, buf, isfile); | 180 | loaded = skin_data_load(screen, &skins[skin][screen].data, buf, isfile, |
181 | &skins[skin][screen].stats); | ||
171 | 182 | ||
172 | if (!loaded && skin_helpers[skin].default_skin) | 183 | if (!loaded && skin_helpers[skin].default_skin) |
173 | { | 184 | { |
174 | loaded = skin_data_load(screen, &skins[skin][screen].data, | 185 | loaded = skin_data_load(screen, &skins[skin][screen].data, |
175 | skin_helpers[skin].default_skin(screen), false); | 186 | skin_helpers[skin].default_skin(screen), false, |
187 | &skins[skin][screen].stats); | ||
176 | skins[skin][screen].failsafe_loaded = loaded; | 188 | skins[skin][screen].failsafe_loaded = loaded; |
177 | } | 189 | } |
178 | 190 | ||
diff --git a/apps/gui/skin_engine/skin_engine.h b/apps/gui/skin_engine/skin_engine.h index 07fafe6a10..59e00b5176 100644 --- a/apps/gui/skin_engine/skin_engine.h +++ b/apps/gui/skin_engine/skin_engine.h | |||
@@ -57,7 +57,7 @@ void skin_update(enum skinnable_screens skin, enum screen_type screen, | |||
57 | * or from a skinfile (isfile = true) | 57 | * or from a skinfile (isfile = true) |
58 | */ | 58 | */ |
59 | bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | 59 | bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, |
60 | const char *buf, bool isfile); | 60 | const char *buf, bool isfile, struct skin_stats *stats); |
61 | 61 | ||
62 | bool skin_has_sbs(enum screen_type screen, struct wps_data *data); | 62 | bool skin_has_sbs(enum screen_type screen, struct wps_data *data); |
63 | 63 | ||
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index adfda54335..cb185d88ba 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -83,6 +83,7 @@ static char* skin_buffer = NULL; | |||
83 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) | 83 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) |
84 | static char *backdrop_filename; | 84 | static char *backdrop_filename; |
85 | #endif | 85 | #endif |
86 | static struct skin_stats *_stats = NULL; | ||
86 | 87 | ||
87 | static bool isdefault(struct skin_tag_parameter *param) | 88 | static bool isdefault(struct skin_tag_parameter *param) |
88 | { | 89 | { |
@@ -1770,6 +1771,8 @@ static int load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* | |||
1770 | close(fd); | 1771 | close(fd); |
1771 | return handle; | 1772 | return handle; |
1772 | } | 1773 | } |
1774 | _stats->buflib_handles++; | ||
1775 | _stats->images_size += buf_size; | ||
1773 | lseek(fd, 0, SEEK_SET); | 1776 | lseek(fd, 0, SEEK_SET); |
1774 | lock_handle(handle); | 1777 | lock_handle(handle); |
1775 | bitmap->data = core_get_data(handle); | 1778 | bitmap->data = core_get_data(handle); |
@@ -2282,7 +2285,7 @@ static int skin_element_callback(struct skin_element* element, void* data) | |||
2282 | /* to setup up the wps-data from a format-buffer (isfile = false) | 2285 | /* to setup up the wps-data from a format-buffer (isfile = false) |
2283 | from a (wps-)file (isfile = true)*/ | 2286 | from a (wps-)file (isfile = true)*/ |
2284 | bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | 2287 | bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, |
2285 | const char *buf, bool isfile) | 2288 | const char *buf, bool isfile, struct skin_stats *stats) |
2286 | { | 2289 | { |
2287 | char *wps_buffer = NULL; | 2290 | char *wps_buffer = NULL; |
2288 | if (!wps_data || !buf) | 2291 | if (!wps_data || !buf) |
@@ -2315,8 +2318,9 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | |||
2315 | } | 2318 | } |
2316 | #endif | 2319 | #endif |
2317 | 2320 | ||
2318 | 2321 | _stats = stats; | |
2319 | /* get buffer space from the plugin buffer */ | 2322 | skin_clear_stats(stats); |
2323 | /* get buffer space from the plugin buffer */ | ||
2320 | size_t buffersize = 0; | 2324 | size_t buffersize = 0; |
2321 | wps_buffer = (char *)plugin_get_buffer(&buffersize); | 2325 | wps_buffer = (char *)plugin_get_buffer(&buffersize); |
2322 | 2326 | ||
@@ -2426,6 +2430,8 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | |||
2426 | wps_data->wps_loaded = true; | 2430 | wps_data->wps_loaded = true; |
2427 | memcpy(core_get_data(wps_data->buflib_handle), skin_buffer, | 2431 | memcpy(core_get_data(wps_data->buflib_handle), skin_buffer, |
2428 | skin_buffer_usage()); | 2432 | skin_buffer_usage()); |
2433 | stats->buflib_handles++; | ||
2434 | stats->tree_size = skin_buffer_usage(); | ||
2429 | } | 2435 | } |
2430 | #else | 2436 | #else |
2431 | wps_data->wps_loaded = wps_data->tree >= 0; | 2437 | wps_data->wps_loaded = wps_data->tree >= 0; |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 72bab9b668..c9d5429484 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -31,6 +31,17 @@ | |||
31 | #include "core_alloc.h" | 31 | #include "core_alloc.h" |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | struct skin_stats { | ||
35 | size_t buflib_handles; | ||
36 | size_t tree_size; | ||
37 | size_t images_size; | ||
38 | }; | ||
39 | |||
40 | int skin_get_num_skins(void); | ||
41 | struct skin_stats *skin_get_stats(int number, int screen); | ||
42 | #define skin_clear_stats(stats) memset(stats, 0, sizeof(struct skin_stats)) | ||
43 | bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *size); | ||
44 | |||
34 | /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds | 45 | /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds |
35 | (possibly with a decimal fraction) but stored as integer values. | 46 | (possibly with a decimal fraction) but stored as integer values. |
36 | E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units. | 47 | E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units. |