video: truetype: Use pre-allocated buffer for glyph rendering
The TrueType console driver calls malloc/free for every character rendered, which causes significant memory fragmentation and allocation traffic. Add CONFIG_CONSOLE_TRUETYPE_GLYPH_BUF to enable a pre-allocated buffer in the driver's private data. The buffer starts at 4KB and grows via realloc() as needed. When rendering a glyph, use this buffer to avoid malloc/free for normal characters. The buffer is allocated lazily after relocation to avoid consuming early malloc space before the full heap is available. Add CONFIG_VIDEO_GLYPH_STATS (default y on sandbox) to track the number of glyphs rendered. Use 'font info' to view the count. Series-changes: 2 - Rename the Kconfig to just enable the feature: always allocate Co-developed-by: Claude Opus 4 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
24
cmd/font.c
24
cmd/font.c
@@ -11,6 +11,16 @@
|
||||
#include <video.h>
|
||||
#include <video_console.h>
|
||||
|
||||
#if CONFIG_IS_ENABLED(VIDEO_GLYPH_STATS)
|
||||
static int do_font_info(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
printf("glyphs rendered: %u\n", gd->glyph_count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
@@ -75,12 +85,22 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(VIDEO_GLYPH_STATS)
|
||||
#define FONT_INFO_HELP "\nfont info - show glyph rendering statistics"
|
||||
#define FONT_INFO_SUB , U_BOOT_SUBCMD_MKENT(info, 1, 1, do_font_info)
|
||||
#else
|
||||
#define FONT_INFO_HELP
|
||||
#define FONT_INFO_SUB
|
||||
#endif
|
||||
|
||||
U_BOOT_LONGHELP(font,
|
||||
"list - list available fonts\n"
|
||||
"font select <name> [<size>] - select font to use\n"
|
||||
"font size <size> - select font size to");
|
||||
"font size <size> - select font size to"
|
||||
FONT_INFO_HELP);
|
||||
|
||||
U_BOOT_CMD_WITH_SUBCMDS(font, "Fonts", font_help_text,
|
||||
U_BOOT_SUBCMD_MKENT(list, 1, 1, do_font_list),
|
||||
U_BOOT_SUBCMD_MKENT(select, 3, 1, do_font_select),
|
||||
U_BOOT_SUBCMD_MKENT(size, 2, 1, do_font_size));
|
||||
U_BOOT_SUBCMD_MKENT(size, 2, 1, do_font_size)
|
||||
FONT_INFO_SUB);
|
||||
|
||||
Reference in New Issue
Block a user