summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-10-02 18:02:27 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-10-17 14:29:12 +0100
commitc6ee9dc8833814bf628ea5ce53e91c60067c5a06 (patch)
tree9a4680c1e1eca4763e98c215acc39a99200fbed7
parent4bd97c653558bde62237f095a6b9810fb5d16491 (diff)
downloadrockbox-c6ee9dc883.tar.gz
rockbox-c6ee9dc883.zip
Limit exposure of skin engine internals
Drop wps_internals.h from skin_engine.h. The WPS and to a lesser extent the radio screen are too tightly integrated to drop their dependency on wps_internals.h, unfortunately. Skinned lists, for obvious reasons, also need access to the internals. Change-Id: I00a55aa423900f9ad22edccbe2fc1910af380e38
-rw-r--r--apps/debug_menu.c53
-rw-r--r--apps/gui/list.h11
-rw-r--r--apps/gui/skin_engine/skin_display.c71
-rw-r--r--apps/gui/skin_engine/skin_display.h4
-rw-r--r--apps/gui/skin_engine/skin_engine.c55
-rw-r--r--apps/gui/skin_engine/skin_engine.h10
-rw-r--r--apps/gui/skin_engine/skin_render.c2
-rw-r--r--apps/gui/skin_engine/wps_internals.h11
-rw-r--r--apps/gui/statusbar-skinned.c2
-rw-r--r--apps/gui/statusbar-skinned.h1
-rw-r--r--apps/gui/wps.c1
-rw-r--r--apps/radio/radio.c1
-rw-r--r--apps/radio/radio_skin.c1
-rw-r--r--apps/recorder/albumart.c70
-rw-r--r--apps/recorder/albumart.h6
15 files changed, 157 insertions, 142 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index d17668ade5..87a41920b9 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -2509,59 +2509,6 @@ static bool dbg_pic(void)
}
#endif
-static bool dbg_skin_engine(void)
-{
- struct simplelist_info info;
- int i, total = 0;
-#if defined(HAVE_BACKDROP_IMAGE)
- int ref_count;
- char *path;
- size_t bytes;
- int path_prefix_len = strlen(ROCKBOX_DIR "/wps/");
-#endif
- simplelist_info_init(&info, "Skin engine usage", 0, NULL);
- simplelist_set_line_count(0);
- 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);
-#if defined(HAVE_BACKDROP_IMAGE)
- 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);
-#endif
- return simplelist_show_list(&info);
-}
-
#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR)
static bool dbg_boot_data(void)
{
diff --git a/apps/gui/list.h b/apps/gui/list.h
index ede62d7b0a..15ee1df736 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -229,16 +229,7 @@ extern bool gui_synclist_keyclick_callback(int action, void* data);
*/
extern bool gui_synclist_do_button(struct gui_synclist * lists, int *action);
#if !defined(PLUGIN)
-struct listitem_viewport_cfg {
- struct wps_data *data;
- OFFSETTYPE(char *) label;
- int width;
- int height;
- int xmargin;
- int ymargin;
- bool tile;
- struct skin_viewport selected_item_vp;
-};
+struct listitem_viewport_cfg;
bool skinlist_get_item(struct screen *display, struct gui_synclist *list, int x, int y, int *item);
bool skinlist_draw(struct screen *display, struct gui_synclist *list);
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 2285a20b59..cef38892ff 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -46,6 +46,7 @@
#include "tagcache.h"
#include "list.h"
#include "option_select.h"
+#include "buffering.h"
#include "peakmeter.h"
/* Image stuff */
@@ -636,6 +637,76 @@ void draw_peakmeters(struct gui_wps *gwps, int line_number,
}
}
+/* Draw the album art bitmap from the given handle ID onto the given WPS.
+ Call with clear = true to clear the bitmap instead of drawing it. */
+void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear)
+{
+ if (!gwps || !gwps->data || !gwps->display || handle_id < 0)
+ return;
+
+ struct wps_data *data = gwps->data;
+ struct skin_albumart *aa = SKINOFFSETTOPTR(get_skin_buffer(data), data->albumart);
+
+ if (!aa)
+ return;
+
+ struct bitmap *bmp;
+ if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0)
+ return;
+
+ short x = aa->x;
+ short y = aa->y;
+ short width = bmp->width;
+ short height = bmp->height;
+
+ if (aa->width > 0)
+ {
+ /* Crop if the bitmap is too wide */
+ width = MIN(bmp->width, aa->width);
+
+ /* Align */
+ if (aa->xalign & WPS_ALBUMART_ALIGN_RIGHT)
+ x += aa->width - width;
+ else if (aa->xalign & WPS_ALBUMART_ALIGN_CENTER)
+ x += (aa->width - width) / 2;
+ }
+
+ if (aa->height > 0)
+ {
+ /* Crop if the bitmap is too high */
+ height = MIN(bmp->height, aa->height);
+
+ /* Align */
+ if (aa->yalign & WPS_ALBUMART_ALIGN_BOTTOM)
+ y += aa->height - height;
+ else if (aa->yalign & WPS_ALBUMART_ALIGN_CENTER)
+ y += (aa->height - height) / 2;
+ }
+
+ if (!clear)
+ {
+ /* Draw the bitmap */
+ gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0,
+ STRIDE(gwps->display->screen_type,
+ bmp->width, bmp->height),
+ x, y, width, height);
+#ifdef HAVE_LCD_INVERT
+ if (global_settings.invert) {
+ gwps->display->set_drawmode(DRMODE_COMPLEMENT);
+ gwps->display->fillrect(x, y, width, height);
+ gwps->display->set_drawmode(DRMODE_SOLID);
+ }
+#endif
+ }
+ else
+ {
+ /* Clear the bitmap */
+ gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
+ gwps->display->fillrect(x, y, width, height);
+ gwps->display->set_drawmode(DRMODE_SOLID);
+ }
+}
+
bool skin_has_sbs(enum screen_type screen, struct wps_data *data)
{
(void)screen;
diff --git a/apps/gui/skin_engine/skin_display.h b/apps/gui/skin_engine/skin_display.h
index de1b0b20b5..6226da3eec 100644
--- a/apps/gui/skin_engine/skin_display.h
+++ b/apps/gui/skin_engine/skin_display.h
@@ -54,4 +54,8 @@ void write_line(struct screen *display, struct align_pos *format_align,
int line, bool scroll, struct line_desc *line_desc);
void draw_peakmeters(struct gui_wps *gwps, int line_number,
struct viewport *viewport);
+/* Draw the album art bitmap from the given handle ID onto the given Skin.
+ Call with clear = true to clear the bitmap instead of drawing it. */
+void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear);
+
#endif
diff --git a/apps/gui/skin_engine/skin_engine.c b/apps/gui/skin_engine/skin_engine.c
index 8ba76e5739..a3ad85fd6e 100644
--- a/apps/gui/skin_engine/skin_engine.c
+++ b/apps/gui/skin_engine/skin_engine.c
@@ -34,9 +34,11 @@
#if CONFIG_TUNER
#include "radio.h"
#endif
+#include "gui/list.h"
#include "skin_engine.h"
#include "skin_buffer.h"
#include "statusbar-skinned.h"
+#include "wps_internals.h"
#define FAILSAFENAME "rockbox_failsafe"
@@ -334,3 +336,56 @@ void skin_request_full_update(enum skinnable_screens skin)
FOR_NB_SCREENS(i)
skins[skin][i].needs_full_update = true;
}
+
+bool dbg_skin_engine(void)
+{
+ struct simplelist_info info;
+ int i, total = 0;
+#if defined(HAVE_BACKDROP_IMAGE)
+ int ref_count;
+ char *path;
+ size_t bytes;
+ int path_prefix_len = strlen(ROCKBOX_DIR "/wps/");
+#endif
+ simplelist_info_init(&info, "Skin engine usage", 0, NULL);
+ simplelist_set_line_count(0);
+ 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);
+#if defined(HAVE_BACKDROP_IMAGE)
+ 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);
+#endif
+ return simplelist_show_list(&info);
+}
diff --git a/apps/gui/skin_engine/skin_engine.h b/apps/gui/skin_engine/skin_engine.h
index e26ec34d1f..d7efb5b888 100644
--- a/apps/gui/skin_engine/skin_engine.h
+++ b/apps/gui/skin_engine/skin_engine.h
@@ -26,8 +26,7 @@
#ifndef PLUGIN
#include "tag_table.h"
-
-#include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */
+#include "screen_access.h"
enum skinnable_screens {
CUSTOM_STATUSBAR,
@@ -39,6 +38,11 @@ enum skinnable_screens {
SKINNABLE_SCREENS_COUNT
};
+struct skin_stats;
+struct skin_viewport;
+struct touchregion;
+struct wps_data;
+
#ifdef HAVE_TOUCHSCREEN
int skin_get_touchaction(struct wps_data *data, int* edge_offset,
struct touchregion **retregion);
@@ -89,5 +93,7 @@ void skin_unload_all(void);
bool skin_do_full_update(enum skinnable_screens skin, enum screen_type screen);
void skin_request_full_update(enum skinnable_screens skin);
+bool dbg_skin_engine(void);
+
#endif /* !PLUGIN */
#endif
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
index 1f777b6672..2238bd9bec 100644
--- a/apps/gui/skin_engine/skin_render.c
+++ b/apps/gui/skin_engine/skin_render.c
@@ -74,6 +74,8 @@ struct skin_draw_info {
int offset; /* used by the playlist viewer */
};
+extern void sb_set_info_vp(enum screen_type screen, OFFSETTYPE(char*) label);
+
typedef bool (*skin_render_func)(struct skin_element* alternator, struct skin_draw_info *info);
bool skin_render_alternator(struct skin_element* alternator, struct skin_draw_info *info);
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index c220480f13..35d7b979fc 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -313,6 +313,17 @@ struct listitem {
short offset;
};
+struct listitem_viewport_cfg {
+ struct wps_data *data;
+ OFFSETTYPE(char *) label;
+ int width;
+ int height;
+ int xmargin;
+ int ymargin;
+ bool tile;
+ struct skin_viewport selected_item_vp;
+};
+
#ifdef HAVE_SKIN_VARIABLES
struct skin_var {
OFFSETTYPE(const char *) label;
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index cda3ec29c9..f1b8af015e 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -53,6 +53,8 @@ static const char* sbs_title[NB_SCREENS];
static enum themable_icons sbs_icon[NB_SCREENS];
static bool sbs_loaded[NB_SCREENS] = { false };
+void sb_set_info_vp(enum screen_type screen, OFFSETTYPE(char*) label);
+
bool sb_set_title_text(const char* title, enum themable_icons icon, enum screen_type screen)
{
sbs_title[screen] = title;
diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h
index 7f4d93e67e..c7b33d5908 100644
--- a/apps/gui/statusbar-skinned.h
+++ b/apps/gui/statusbar-skinned.h
@@ -34,7 +34,6 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile);
char* sb_create_from_settings(enum screen_type screen);
void sb_skin_init(void) INIT_ATTR;
-void sb_set_info_vp(enum screen_type screen, OFFSETTYPE(char*) label);
struct viewport *sb_skin_get_info_vp(enum screen_type screen);
void sb_skin_update(enum screen_type screen, bool force);
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 7554892451..01f6e5c77c 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -61,6 +61,7 @@
#include "playlist_viewer.h"
#include "wps.h"
#include "statusbar-skinned.h"
+#include "skin_engine/wps_internals.h"
#define RESTORE_WPS_INSTANTLY 0l
#define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
diff --git a/apps/radio/radio.c b/apps/radio/radio.c
index b74371413e..1764495c7f 100644
--- a/apps/radio/radio.c
+++ b/apps/radio/radio.c
@@ -56,6 +56,7 @@
#include "statusbar-skinned.h"
#include "playback.h"
#include "presets.h"
+#include "skin_engine/wps_internals.h"
#if CONFIG_TUNER
diff --git a/apps/radio/radio_skin.c b/apps/radio/radio_skin.c
index 4d90c4e241..388da2694c 100644
--- a/apps/radio/radio_skin.c
+++ b/apps/radio/radio_skin.c
@@ -36,6 +36,7 @@
#include "sound.h"
#include "misc.h"
#endif
+#include "skin_engine/wps_internals.h"
char* default_radio_skin(enum screen_type screen)
diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c
index 9ff9c72f80..e94ffcfb80 100644
--- a/apps/recorder/albumart.c
+++ b/apps/recorder/albumart.c
@@ -297,74 +297,4 @@ bool find_albumart(const struct mp3entry *id3, char *buf, int buflen,
return search_albumart_files(id3, size_string, buf, buflen);
}
-/* Draw the album art bitmap from the given handle ID onto the given WPS.
- Call with clear = true to clear the bitmap instead of drawing it. */
-void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear)
-{
- if (!gwps || !gwps->data || !gwps->display || handle_id < 0)
- return;
-
- struct wps_data *data = gwps->data;
- struct skin_albumart *aa = SKINOFFSETTOPTR(get_skin_buffer(data), data->albumart);
-
- if (!aa)
- return;
-
- struct bitmap *bmp;
- if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0)
- return;
-
- short x = aa->x;
- short y = aa->y;
- short width = bmp->width;
- short height = bmp->height;
-
- if (aa->width > 0)
- {
- /* Crop if the bitmap is too wide */
- width = MIN(bmp->width, aa->width);
-
- /* Align */
- if (aa->xalign & WPS_ALBUMART_ALIGN_RIGHT)
- x += aa->width - width;
- else if (aa->xalign & WPS_ALBUMART_ALIGN_CENTER)
- x += (aa->width - width) / 2;
- }
-
- if (aa->height > 0)
- {
- /* Crop if the bitmap is too high */
- height = MIN(bmp->height, aa->height);
-
- /* Align */
- if (aa->yalign & WPS_ALBUMART_ALIGN_BOTTOM)
- y += aa->height - height;
- else if (aa->yalign & WPS_ALBUMART_ALIGN_CENTER)
- y += (aa->height - height) / 2;
- }
-
- if (!clear)
- {
- /* Draw the bitmap */
- gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0,
- STRIDE(gwps->display->screen_type,
- bmp->width, bmp->height),
- x, y, width, height);
-#ifdef HAVE_LCD_INVERT
- if (global_settings.invert) {
- gwps->display->set_drawmode(DRMODE_COMPLEMENT);
- gwps->display->fillrect(x, y, width, height);
- gwps->display->set_drawmode(DRMODE_SOLID);
- }
-#endif
- }
- else
- {
- /* Clear the bitmap */
- gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
- gwps->display->fillrect(x, y, width, height);
- gwps->display->set_drawmode(DRMODE_SOLID);
- }
-}
-
#endif /* PLUGIN */
diff --git a/apps/recorder/albumart.h b/apps/recorder/albumart.h
index 80cacaf5f0..0d663d3d92 100644
--- a/apps/recorder/albumart.h
+++ b/apps/recorder/albumart.h
@@ -35,12 +35,6 @@
bool find_albumart(const struct mp3entry *id3, char *buf, int buflen,
const struct dim *dim);
-#ifndef PLUGIN
-/* Draw the album art bitmap from the given handle ID onto the given Skin.
- Call with clear = true to clear the bitmap instead of drawing it. */
-void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear);
-#endif
-
bool search_albumart_files(const struct mp3entry *id3, const char *size_string,
char *buf, int buflen);