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:
@@ -98,3 +98,20 @@ static int font_test_base(struct unit_test_state *uts)
|
||||
}
|
||||
FONT_TEST(font_test_base, UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_CONSOLE |
|
||||
UTF_DM);
|
||||
|
||||
/* Test 'font info' command */
|
||||
static int font_test_info(struct unit_test_state *uts)
|
||||
{
|
||||
int count;
|
||||
|
||||
if (!CONFIG_IS_ENABLED(VIDEO_GLYPH_STATS))
|
||||
return -EAGAIN;
|
||||
|
||||
count = gd_glyph_count();
|
||||
ut_assertok(run_command("font info", 0));
|
||||
ut_assert_nextline("glyphs rendered: %u", count);
|
||||
ut_assert_console_end();
|
||||
|
||||
return 0;
|
||||
}
|
||||
FONT_TEST(font_test_info, UTF_CONSOLE);
|
||||
|
||||
Reference in New Issue
Block a user