diff options
author | Franklin Wei <franklin@rockbox.org> | 2020-07-07 17:23:38 -0400 |
---|---|---|
committer | Franklin Wei <franklin@rockbox.org> | 2020-07-14 23:04:46 -0400 |
commit | 987c6575b378a7df85868cd151c5b035b93d6679 (patch) | |
tree | 9f1a8947aaff7acf2bc41babaf2f33715aa27cd5 /apps/plugins | |
parent | 0e971323147af684b183d5954059cec535e643d6 (diff) | |
download | rockbox-987c6575b378a7df85868cd151c5b035b93d6679.tar.gz rockbox-987c6575b378a7df85868cd151c5b035b93d6679.zip |
puzzles: more verbose debug output in font loading
No functional changes.
Change-Id: I7baa7bf37b3bdd57064c654a72d0e4e0d5600245
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/puzzles/rockbox.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index cb357ac313..8e0be04cb1 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c | |||
@@ -374,7 +374,7 @@ static void zoom_alpha_bitmap(const unsigned char *bits, int x, int y, int w, in | |||
374 | * for sgt-puzzles, available from [1] or through Rockbox Utility. | 374 | * for sgt-puzzles, available from [1] or through Rockbox Utility. |
375 | * | 375 | * |
376 | * The font pack consists of 3 small-size fonts, and the Deja Vu | 376 | * The font pack consists of 3 small-size fonts, and the Deja Vu |
377 | * Sans/Mono fonts, rasterized in sizes from 10 to BUNDLE_MAX | 377 | * Sans/Mono fonts, rasterized in sizes from 10px to BUNDLE_MAX |
378 | * (currently 36). | 378 | * (currently 36). |
379 | * | 379 | * |
380 | * The font loading code below tries to be smart about loading fonts: | 380 | * The font loading code below tries to be smart about loading fonts: |
@@ -389,7 +389,12 @@ static void zoom_alpha_bitmap(const unsigned char *bits, int x, int y, int w, in | |||
389 | */ | 389 | */ |
390 | 390 | ||
391 | static struct bundled_font { | 391 | static struct bundled_font { |
392 | int status; /* -3 = never tried loading, or unloaded, -2 = failed to load, >= -1: loaded successfully */ | 392 | /* |
393 | * -3 = never tried loading, or unloaded, | ||
394 | * -2 = failed to load, | ||
395 | * [-1,): loaded successfully (FONT_SYSFIXED = -1) | ||
396 | */ | ||
397 | int status; | ||
393 | int last_use; | 398 | int last_use; |
394 | } *loaded_fonts = NULL; /* monospace are first, then proportional */ | 399 | } *loaded_fonts = NULL; /* monospace are first, then proportional */ |
395 | 400 | ||
@@ -446,6 +451,8 @@ static void font_path(char *buf, int type, int size) | |||
446 | 451 | ||
447 | static void rb_setfont(int type, int size) | 452 | static void rb_setfont(int type, int size) |
448 | { | 453 | { |
454 | LOGF("rb_setfont(type=%d, size=%d)", type, size); | ||
455 | |||
449 | /* | 456 | /* |
450 | * First, clamp to range. No puzzle should ever need this large of | 457 | * First, clamp to range. No puzzle should ever need this large of |
451 | * a font, anyways. | 458 | * a font, anyways. |
@@ -461,17 +468,29 @@ static void rb_setfont(int type, int size) | |||
461 | type = FONT_FIXED; | 468 | type = FONT_FIXED; |
462 | } | 469 | } |
463 | 470 | ||
471 | LOGF("target font type, size: %d, %d", type, size); | ||
472 | |||
464 | int font_idx = (type == FONT_FIXED ? 0 : BUNDLE_COUNT) + size - BUNDLE_MIN; | 473 | int font_idx = (type == FONT_FIXED ? 0 : BUNDLE_COUNT) + size - BUNDLE_MIN; |
474 | |||
475 | LOGF("font index: %d, status=%d", font_idx, loaded_fonts[font_idx].status); | ||
476 | |||
465 | switch(loaded_fonts[font_idx].status) | 477 | switch(loaded_fonts[font_idx].status) |
466 | { | 478 | { |
467 | case -3: | 479 | case -3: |
468 | { | 480 | { |
469 | /* never loaded */ | 481 | /* never loaded */ |
482 | LOGF("font %d is not resident, trying to load", font_idx); | ||
483 | |||
470 | char buf[MAX_PATH]; | 484 | char buf[MAX_PATH]; |
471 | font_path(buf, type, size); | 485 | font_path(buf, type, size); |
486 | |||
487 | LOGF("font should be at: %s", buf); | ||
488 | |||
472 | if(n_fonts >= MAX_FONTS) | 489 | if(n_fonts >= MAX_FONTS) |
473 | { | 490 | { |
474 | /* unload an old font */ | 491 | /* unload an old font */ |
492 | LOGF("too many resident fonts, evicting LRU"); | ||
493 | |||
475 | int oldest_use = -1, oldest_idx = -1; | 494 | int oldest_use = -1, oldest_idx = -1; |
476 | for(int i = 0; i < 2 * BUNDLE_COUNT; ++i) | 495 | for(int i = 0; i < 2 * BUNDLE_COUNT; ++i) |
477 | { | 496 | { |
@@ -482,6 +501,8 @@ static void rb_setfont(int type, int size) | |||
482 | } | 501 | } |
483 | } | 502 | } |
484 | assert(oldest_idx >= 0); | 503 | assert(oldest_idx >= 0); |
504 | |||
505 | LOGF("evicting %d", oldest_idx); | ||
485 | rb->font_unload(loaded_fonts[oldest_idx].status); | 506 | rb->font_unload(loaded_fonts[oldest_idx].status); |
486 | loaded_fonts[oldest_idx].status = -3; | 507 | loaded_fonts[oldest_idx].status = -3; |
487 | n_fonts--; | 508 | n_fonts--; |
@@ -489,7 +510,10 @@ static void rb_setfont(int type, int size) | |||
489 | 510 | ||
490 | loaded_fonts[font_idx].status = rb->font_load(buf); | 511 | loaded_fonts[font_idx].status = rb->font_load(buf); |
491 | if(loaded_fonts[font_idx].status < 0) | 512 | if(loaded_fonts[font_idx].status < 0) |
513 | { | ||
514 | LOGF("failed to load font %s", buf); | ||
492 | goto fallback; | 515 | goto fallback; |
516 | } | ||
493 | loaded_fonts[font_idx].last_use = access_counter++; | 517 | loaded_fonts[font_idx].last_use = access_counter++; |
494 | n_fonts++; | 518 | n_fonts++; |
495 | cur_font = loaded_fonts[font_idx].status; | 519 | cur_font = loaded_fonts[font_idx].status; |
@@ -509,9 +533,13 @@ static void rb_setfont(int type, int size) | |||
509 | return; | 533 | return; |
510 | 534 | ||
511 | fallback: | 535 | fallback: |
512 | cur_font = type == FONT_FIXED ? FONT_SYSFIXED : FONT_UI; | 536 | LOGF("could not load font of desired size; falling back to system font"); |
537 | |||
538 | cur_font = (type == FONT_FIXED) ? FONT_SYSFIXED : FONT_UI; | ||
513 | rb->lcd_setfont(cur_font); | 539 | rb->lcd_setfont(cur_font); |
514 | 540 | ||
541 | LOGF("set font to %d", cur_font); | ||
542 | |||
515 | return; | 543 | return; |
516 | } | 544 | } |
517 | 545 | ||
@@ -598,6 +626,8 @@ static void rb_draw_text(void *handle, int x, int y, int fonttype, | |||
598 | int w, h; | 626 | int w, h; |
599 | rb->font_getstringsize(text, &w, &h, cur_font); | 627 | rb->font_getstringsize(text, &w, &h, cur_font); |
600 | 628 | ||
629 | LOGF("getting string size of font %d: %dx%d\n", cur_font, w, h); | ||
630 | |||
601 | if(align & ALIGN_VNORMAL) | 631 | if(align & ALIGN_VNORMAL) |
602 | y -= h; | 632 | y -= h; |
603 | else if(align & ALIGN_VCENTRE) | 633 | else if(align & ALIGN_VCENTRE) |
@@ -3191,6 +3221,7 @@ static void exit_handler(void) | |||
3191 | /* try loading the fonts indicated in the on-disk font table */ | 3221 | /* try loading the fonts indicated in the on-disk font table */ |
3192 | static void load_fonts(void) | 3222 | static void load_fonts(void) |
3193 | { | 3223 | { |
3224 | LOGF("loading cached fonts from disk"); | ||
3194 | int fd = rb->open(FONT_TABLE, O_RDONLY); | 3225 | int fd = rb->open(FONT_TABLE, O_RDONLY); |
3195 | if(fd < 0) | 3226 | if(fd < 0) |
3196 | return; | 3227 | return; |
@@ -3209,6 +3240,7 @@ static void load_fonts(void) | |||
3209 | 3240 | ||
3210 | if(!strcmp(tok, midend_which_game(me)->name)) | 3241 | if(!strcmp(tok, midend_which_game(me)->name)) |
3211 | { | 3242 | { |
3243 | LOGF("successfully found game in table"); | ||
3212 | uint32_t left, right; | 3244 | uint32_t left, right; |
3213 | tok = rb->strtok_r(ptr, ":", &save); | 3245 | tok = rb->strtok_r(ptr, ":", &save); |
3214 | left = atoi(tok); | 3246 | left = atoi(tok); |
@@ -3234,6 +3266,9 @@ static void load_fonts(void) | |||
3234 | { | 3266 | { |
3235 | int size = (i > BUNDLE_COUNT ? i - BUNDLE_COUNT : i) + BUNDLE_MIN; | 3267 | int size = (i > BUNDLE_COUNT ? i - BUNDLE_COUNT : i) + BUNDLE_MIN; |
3236 | int type = i > BUNDLE_COUNT ? FONT_VARIABLE : FONT_FIXED; | 3268 | int type = i > BUNDLE_COUNT ? FONT_VARIABLE : FONT_FIXED; |
3269 | |||
3270 | LOGF("loading font type %d, size %d", type, size); | ||
3271 | |||
3237 | rb_setfont(type, size); | 3272 | rb_setfont(type, size); |
3238 | } | 3273 | } |
3239 | } | 3274 | } |