A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

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

+157 -142
-53
apps/debug_menu.c
··· 2509 2509 } 2510 2510 #endif 2511 2511 2512 - static bool dbg_skin_engine(void) 2513 - { 2514 - struct simplelist_info info; 2515 - int i, total = 0; 2516 - #if defined(HAVE_BACKDROP_IMAGE) 2517 - int ref_count; 2518 - char *path; 2519 - size_t bytes; 2520 - int path_prefix_len = strlen(ROCKBOX_DIR "/wps/"); 2521 - #endif 2522 - simplelist_info_init(&info, "Skin engine usage", 0, NULL); 2523 - simplelist_set_line_count(0); 2524 - FOR_NB_SCREENS(j) { 2525 - #if NB_SCREENS > 1 2526 - simplelist_addline("%s display:", 2527 - j == 0 ? "Main" : "Remote"); 2528 - #endif 2529 - for (i = 0; i < skin_get_num_skins(); i++) { 2530 - struct skin_stats *stats = skin_get_stats(i, j); 2531 - if (stats->buflib_handles) 2532 - { 2533 - simplelist_addline("Skin ID: %d, %d allocations", 2534 - i, stats->buflib_handles); 2535 - simplelist_addline("\tskin: %d bytes", 2536 - stats->tree_size); 2537 - simplelist_addline("\tImages: %d bytes", 2538 - stats->images_size); 2539 - simplelist_addline("\tTotal: %d bytes", 2540 - stats->tree_size + stats->images_size); 2541 - total += stats->tree_size + stats->images_size; 2542 - } 2543 - } 2544 - } 2545 - simplelist_addline("Skin total usage: %d bytes", total); 2546 - #if defined(HAVE_BACKDROP_IMAGE) 2547 - simplelist_addline("Backdrop Images:"); 2548 - i = 0; 2549 - while (skin_backdrop_get_debug(i++, &path, &ref_count, &bytes)) { 2550 - if (ref_count > 0) { 2551 - 2552 - if (!strncasecmp(path, ROCKBOX_DIR "/wps/", path_prefix_len)) 2553 - path += path_prefix_len; 2554 - simplelist_addline("%s", path); 2555 - simplelist_addline("\tref_count: %d", ref_count); 2556 - simplelist_addline("\tsize: %d", bytes); 2557 - total += bytes; 2558 - } 2559 - } 2560 - simplelist_addline("Total usage: %d bytes", total); 2561 - #endif 2562 - return simplelist_show_list(&info); 2563 - } 2564 - 2565 2512 #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) 2566 2513 static bool dbg_boot_data(void) 2567 2514 {
+1 -10
apps/gui/list.h
··· 229 229 */ 230 230 extern bool gui_synclist_do_button(struct gui_synclist * lists, int *action); 231 231 #if !defined(PLUGIN) 232 - struct listitem_viewport_cfg { 233 - struct wps_data *data; 234 - OFFSETTYPE(char *) label; 235 - int width; 236 - int height; 237 - int xmargin; 238 - int ymargin; 239 - bool tile; 240 - struct skin_viewport selected_item_vp; 241 - }; 232 + struct listitem_viewport_cfg; 242 233 243 234 bool skinlist_get_item(struct screen *display, struct gui_synclist *list, int x, int y, int *item); 244 235 bool skinlist_draw(struct screen *display, struct gui_synclist *list);
+71
apps/gui/skin_engine/skin_display.c
··· 46 46 #include "tagcache.h" 47 47 #include "list.h" 48 48 #include "option_select.h" 49 + #include "buffering.h" 49 50 50 51 #include "peakmeter.h" 51 52 /* Image stuff */ ··· 633 634 peak_meter_screen(gwps->display, 0, peak_meter_y, 634 635 MIN(h, viewport->y+viewport->height - peak_meter_y)); 635 636 } 637 + } 638 + } 639 + 640 + /* Draw the album art bitmap from the given handle ID onto the given WPS. 641 + Call with clear = true to clear the bitmap instead of drawing it. */ 642 + void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear) 643 + { 644 + if (!gwps || !gwps->data || !gwps->display || handle_id < 0) 645 + return; 646 + 647 + struct wps_data *data = gwps->data; 648 + struct skin_albumart *aa = SKINOFFSETTOPTR(get_skin_buffer(data), data->albumart); 649 + 650 + if (!aa) 651 + return; 652 + 653 + struct bitmap *bmp; 654 + if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0) 655 + return; 656 + 657 + short x = aa->x; 658 + short y = aa->y; 659 + short width = bmp->width; 660 + short height = bmp->height; 661 + 662 + if (aa->width > 0) 663 + { 664 + /* Crop if the bitmap is too wide */ 665 + width = MIN(bmp->width, aa->width); 666 + 667 + /* Align */ 668 + if (aa->xalign & WPS_ALBUMART_ALIGN_RIGHT) 669 + x += aa->width - width; 670 + else if (aa->xalign & WPS_ALBUMART_ALIGN_CENTER) 671 + x += (aa->width - width) / 2; 672 + } 673 + 674 + if (aa->height > 0) 675 + { 676 + /* Crop if the bitmap is too high */ 677 + height = MIN(bmp->height, aa->height); 678 + 679 + /* Align */ 680 + if (aa->yalign & WPS_ALBUMART_ALIGN_BOTTOM) 681 + y += aa->height - height; 682 + else if (aa->yalign & WPS_ALBUMART_ALIGN_CENTER) 683 + y += (aa->height - height) / 2; 684 + } 685 + 686 + if (!clear) 687 + { 688 + /* Draw the bitmap */ 689 + gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0, 690 + STRIDE(gwps->display->screen_type, 691 + bmp->width, bmp->height), 692 + x, y, width, height); 693 + #ifdef HAVE_LCD_INVERT 694 + if (global_settings.invert) { 695 + gwps->display->set_drawmode(DRMODE_COMPLEMENT); 696 + gwps->display->fillrect(x, y, width, height); 697 + gwps->display->set_drawmode(DRMODE_SOLID); 698 + } 699 + #endif 700 + } 701 + else 702 + { 703 + /* Clear the bitmap */ 704 + gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 705 + gwps->display->fillrect(x, y, width, height); 706 + gwps->display->set_drawmode(DRMODE_SOLID); 636 707 } 637 708 } 638 709
+4
apps/gui/skin_engine/skin_display.h
··· 54 54 int line, bool scroll, struct line_desc *line_desc); 55 55 void draw_peakmeters(struct gui_wps *gwps, int line_number, 56 56 struct viewport *viewport); 57 + /* Draw the album art bitmap from the given handle ID onto the given Skin. 58 + Call with clear = true to clear the bitmap instead of drawing it. */ 59 + void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear); 60 + 57 61 #endif
+55
apps/gui/skin_engine/skin_engine.c
··· 34 34 #if CONFIG_TUNER 35 35 #include "radio.h" 36 36 #endif 37 + #include "gui/list.h" 37 38 #include "skin_engine.h" 38 39 #include "skin_buffer.h" 39 40 #include "statusbar-skinned.h" 41 + #include "wps_internals.h" 40 42 41 43 #define FAILSAFENAME "rockbox_failsafe" 42 44 ··· 334 336 FOR_NB_SCREENS(i) 335 337 skins[skin][i].needs_full_update = true; 336 338 } 339 + 340 + bool dbg_skin_engine(void) 341 + { 342 + struct simplelist_info info; 343 + int i, total = 0; 344 + #if defined(HAVE_BACKDROP_IMAGE) 345 + int ref_count; 346 + char *path; 347 + size_t bytes; 348 + int path_prefix_len = strlen(ROCKBOX_DIR "/wps/"); 349 + #endif 350 + simplelist_info_init(&info, "Skin engine usage", 0, NULL); 351 + simplelist_set_line_count(0); 352 + FOR_NB_SCREENS(j) { 353 + #if NB_SCREENS > 1 354 + simplelist_addline("%s display:", 355 + j == 0 ? "Main" : "Remote"); 356 + #endif 357 + for (i = 0; i < skin_get_num_skins(); i++) { 358 + struct skin_stats *stats = skin_get_stats(i, j); 359 + if (stats->buflib_handles) 360 + { 361 + simplelist_addline("Skin ID: %d, %d allocations", 362 + i, stats->buflib_handles); 363 + simplelist_addline("\tskin: %d bytes", 364 + stats->tree_size); 365 + simplelist_addline("\tImages: %d bytes", 366 + stats->images_size); 367 + simplelist_addline("\tTotal: %d bytes", 368 + stats->tree_size + stats->images_size); 369 + total += stats->tree_size + stats->images_size; 370 + } 371 + } 372 + } 373 + simplelist_addline("Skin total usage: %d bytes", total); 374 + #if defined(HAVE_BACKDROP_IMAGE) 375 + simplelist_addline("Backdrop Images:"); 376 + i = 0; 377 + while (skin_backdrop_get_debug(i++, &path, &ref_count, &bytes)) { 378 + if (ref_count > 0) { 379 + 380 + if (!strncasecmp(path, ROCKBOX_DIR "/wps/", path_prefix_len)) 381 + path += path_prefix_len; 382 + simplelist_addline("%s", path); 383 + simplelist_addline("\tref_count: %d", ref_count); 384 + simplelist_addline("\tsize: %d", bytes); 385 + total += bytes; 386 + } 387 + } 388 + simplelist_addline("Total usage: %d bytes", total); 389 + #endif 390 + return simplelist_show_list(&info); 391 + }
+8 -2
apps/gui/skin_engine/skin_engine.h
··· 26 26 #ifndef PLUGIN 27 27 28 28 #include "tag_table.h" 29 - 30 - #include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */ 29 + #include "screen_access.h" 31 30 32 31 enum skinnable_screens { 33 32 CUSTOM_STATUSBAR, ··· 38 37 39 38 SKINNABLE_SCREENS_COUNT 40 39 }; 40 + 41 + struct skin_stats; 42 + struct skin_viewport; 43 + struct touchregion; 44 + struct wps_data; 41 45 42 46 #ifdef HAVE_TOUCHSCREEN 43 47 int skin_get_touchaction(struct wps_data *data, int* edge_offset, ··· 88 92 89 93 bool skin_do_full_update(enum skinnable_screens skin, enum screen_type screen); 90 94 void skin_request_full_update(enum skinnable_screens skin); 95 + 96 + bool dbg_skin_engine(void); 91 97 92 98 #endif /* !PLUGIN */ 93 99 #endif
+2
apps/gui/skin_engine/skin_render.c
··· 74 74 int offset; /* used by the playlist viewer */ 75 75 }; 76 76 77 + extern void sb_set_info_vp(enum screen_type screen, OFFSETTYPE(char*) label); 78 + 77 79 typedef bool (*skin_render_func)(struct skin_element* alternator, struct skin_draw_info *info); 78 80 bool skin_render_alternator(struct skin_element* alternator, struct skin_draw_info *info); 79 81
+11
apps/gui/skin_engine/wps_internals.h
··· 313 313 short offset; 314 314 }; 315 315 316 + struct listitem_viewport_cfg { 317 + struct wps_data *data; 318 + OFFSETTYPE(char *) label; 319 + int width; 320 + int height; 321 + int xmargin; 322 + int ymargin; 323 + bool tile; 324 + struct skin_viewport selected_item_vp; 325 + }; 326 + 316 327 #ifdef HAVE_SKIN_VARIABLES 317 328 struct skin_var { 318 329 OFFSETTYPE(const char *) label;
+2
apps/gui/statusbar-skinned.c
··· 53 53 static enum themable_icons sbs_icon[NB_SCREENS]; 54 54 static bool sbs_loaded[NB_SCREENS] = { false }; 55 55 56 + void sb_set_info_vp(enum screen_type screen, OFFSETTYPE(char*) label); 57 + 56 58 bool sb_set_title_text(const char* title, enum themable_icons icon, enum screen_type screen) 57 59 { 58 60 sbs_title[screen] = title;
-1
apps/gui/statusbar-skinned.h
··· 34 34 35 35 char* sb_create_from_settings(enum screen_type screen); 36 36 void sb_skin_init(void) INIT_ATTR; 37 - void sb_set_info_vp(enum screen_type screen, OFFSETTYPE(char*) label); 38 37 struct viewport *sb_skin_get_info_vp(enum screen_type screen); 39 38 void sb_skin_update(enum screen_type screen, bool force); 40 39
+1
apps/gui/wps.c
··· 61 61 #include "playlist_viewer.h" 62 62 #include "wps.h" 63 63 #include "statusbar-skinned.h" 64 + #include "skin_engine/wps_internals.h" 64 65 65 66 #define RESTORE_WPS_INSTANTLY 0l 66 67 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
+1
apps/radio/radio.c
··· 56 56 #include "statusbar-skinned.h" 57 57 #include "playback.h" 58 58 #include "presets.h" 59 + #include "skin_engine/wps_internals.h" 59 60 60 61 #if CONFIG_TUNER 61 62
+1
apps/radio/radio_skin.c
··· 36 36 #include "sound.h" 37 37 #include "misc.h" 38 38 #endif 39 + #include "skin_engine/wps_internals.h" 39 40 40 41 41 42 char* default_radio_skin(enum screen_type screen)
-70
apps/recorder/albumart.c
··· 297 297 return search_albumart_files(id3, size_string, buf, buflen); 298 298 } 299 299 300 - /* Draw the album art bitmap from the given handle ID onto the given WPS. 301 - Call with clear = true to clear the bitmap instead of drawing it. */ 302 - void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear) 303 - { 304 - if (!gwps || !gwps->data || !gwps->display || handle_id < 0) 305 - return; 306 - 307 - struct wps_data *data = gwps->data; 308 - struct skin_albumart *aa = SKINOFFSETTOPTR(get_skin_buffer(data), data->albumart); 309 - 310 - if (!aa) 311 - return; 312 - 313 - struct bitmap *bmp; 314 - if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0) 315 - return; 316 - 317 - short x = aa->x; 318 - short y = aa->y; 319 - short width = bmp->width; 320 - short height = bmp->height; 321 - 322 - if (aa->width > 0) 323 - { 324 - /* Crop if the bitmap is too wide */ 325 - width = MIN(bmp->width, aa->width); 326 - 327 - /* Align */ 328 - if (aa->xalign & WPS_ALBUMART_ALIGN_RIGHT) 329 - x += aa->width - width; 330 - else if (aa->xalign & WPS_ALBUMART_ALIGN_CENTER) 331 - x += (aa->width - width) / 2; 332 - } 333 - 334 - if (aa->height > 0) 335 - { 336 - /* Crop if the bitmap is too high */ 337 - height = MIN(bmp->height, aa->height); 338 - 339 - /* Align */ 340 - if (aa->yalign & WPS_ALBUMART_ALIGN_BOTTOM) 341 - y += aa->height - height; 342 - else if (aa->yalign & WPS_ALBUMART_ALIGN_CENTER) 343 - y += (aa->height - height) / 2; 344 - } 345 - 346 - if (!clear) 347 - { 348 - /* Draw the bitmap */ 349 - gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0, 350 - STRIDE(gwps->display->screen_type, 351 - bmp->width, bmp->height), 352 - x, y, width, height); 353 - #ifdef HAVE_LCD_INVERT 354 - if (global_settings.invert) { 355 - gwps->display->set_drawmode(DRMODE_COMPLEMENT); 356 - gwps->display->fillrect(x, y, width, height); 357 - gwps->display->set_drawmode(DRMODE_SOLID); 358 - } 359 - #endif 360 - } 361 - else 362 - { 363 - /* Clear the bitmap */ 364 - gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 365 - gwps->display->fillrect(x, y, width, height); 366 - gwps->display->set_drawmode(DRMODE_SOLID); 367 - } 368 - } 369 - 370 300 #endif /* PLUGIN */
-6
apps/recorder/albumart.h
··· 35 35 bool find_albumart(const struct mp3entry *id3, char *buf, int buflen, 36 36 const struct dim *dim); 37 37 38 - #ifndef PLUGIN 39 - /* Draw the album art bitmap from the given handle ID onto the given Skin. 40 - Call with clear = true to clear the bitmap instead of drawing it. */ 41 - void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear); 42 - #endif 43 - 44 38 bool search_albumart_files(const struct mp3entry *id3, const char *size_string, 45 39 char *buf, int buflen); 46 40