feat(GameBoy): restore integer scaling using full canvas API

- use lv_display_get_*_resolution to compute available area
- apply lv_image_set_scale 2x/3x + pivot center when display large enough
- removes previous comment hack 'avoid non-exported LVGL transform symbols'
- now requires firmware feature/gameboy-canvas-full-api (symbols exported)

SDK: 0.8.0-dev built with IDF 5.5.2, 0 missing symbols
This commit is contained in:
Adolfo
2026-07-20 00:21:01 -04:00
parent 6eb032cb53
commit e4d1d35da4
+19
View File
@@ -433,10 +433,29 @@ static void build_emu_ui(AppCtx* ctx, lv_obj_t* parent){
} }
if (ctx->fb_native){ if (ctx->fb_native){
// Integer scaling: use canvas as image source (LVGL canvas inherits lv_image)
// then scale via lv_image_set_scale (256 = 1x, 512 = 2x, etc)
lv_coord_t disp_w = lv_display_get_horizontal_resolution(NULL);
lv_coord_t disp_h = lv_display_get_vertical_resolution(NULL);
// available height for canvas = disp_h - toolbar - info_bar - controls (~110)
// Estimate usable: disp_h - 160 conservative
int avail_h = disp_h - 160;
int avail_w = disp_w - 8;
int scale = 1;
if (avail_w >= FRAME_W * 3 && avail_h >= FRAME_H * 3) scale = 3;
else if (avail_w >= FRAME_W * 2 && avail_h >= FRAME_H * 2) scale = 2;
ctx->canvas = lv_canvas_create(canvas_cont); ctx->canvas = lv_canvas_create(canvas_cont);
lv_canvas_set_buffer(ctx->canvas, ctx->fb_native, FRAME_W, FRAME_H, LV_COLOR_FORMAT_RGB565); lv_canvas_set_buffer(ctx->canvas, ctx->fb_native, FRAME_W, FRAME_H, LV_COLOR_FORMAT_RGB565);
if (scale > 1) {
// LVGL image scale is 256 = 1x
lv_image_set_scale(ctx->canvas, (uint32_t)(256 * scale));
// Center pivot for clean scaling
lv_image_set_pivot(ctx->canvas, FRAME_W / 2, FRAME_H / 2);
}
lv_obj_set_style_border_width(ctx->canvas, 1, 0); lv_obj_set_style_border_width(ctx->canvas, 1, 0);
lv_obj_set_style_border_color(ctx->canvas, lv_color_hex(0x444444), 0); lv_obj_set_style_border_color(ctx->canvas, lv_color_hex(0x444444), 0);
lv_obj_center(ctx->canvas);
} else { } else {
lv_obj_t* err=lv_label_create(canvas_cont); lv_label_set_text(err,"FB alloc failed"); lv_obj_set_style_text_color(err, lv_color_white(),0); lv_obj_t* err=lv_label_create(canvas_cont); lv_label_set_text(err,"FB alloc failed"); lv_obj_set_style_text_color(err, lv_color_white(),0);
} }