From b2d2a9de490a140e8f2c5c2fba739662b340fb3b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 8 Mar 2023 15:52:11 -0800 Subject: [PATCH] altos/draw: Have each font declare ao_glyph_temp as .comm Create temporary glyph drawing space by having every glyph declare how much space it needs and letting the linker allocate the largest possible space. Signed-off-by: Keith Packard --- src/draw/ao_text.c | 13 +++++++------ src/draw/font-convert | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/draw/ao_text.c b/src/draw/ao_text.c index cc43b362..c20f2399 100644 --- a/src/draw/ao_text.c +++ b/src/draw/ao_text.c @@ -18,6 +18,12 @@ #include #include +extern uint32_t ao_glyph_temp[]; + +static struct ao_bitmap src_bitmap = { + .base = ao_glyph_temp, +}; + void ao_text(struct ao_bitmap *dst, const struct ao_font *font, @@ -28,16 +34,11 @@ ao_text(struct ao_bitmap *dst, uint8_t rop) { int16_t glyph_stride = ao_stride(font->max_width); - uint32_t src[glyph_stride * font->max_height]; char c; int h; int16_t x_off = 0, y_off = 0, advance = 0; int16_t byte_width = 0; - struct ao_bitmap src_bitmap = { - .base = src, - }; - rop = (rop & 3) | 0x4; if ((fill&1) == 0) @@ -67,7 +68,7 @@ ao_text(struct ao_bitmap *dst, } for (h = 0; h < src_bitmap.height; h++) - memcpy(&src[h * src_bitmap.stride], &bytes[h * byte_width], (size_t) byte_width); + memcpy(&ao_glyph_temp[h * src_bitmap.stride], &bytes[h * byte_width], (size_t) byte_width); ao_copy(dst, x + x_off, y - y_off, src_bitmap.width, src_bitmap.height, diff --git a/src/draw/font-convert b/src/draw/font-convert index 89133129..8feafe52 100755 --- a/src/draw/font-convert +++ b/src/draw/font-convert @@ -195,6 +195,8 @@ void print_font(file out, font_t font, string font_name) { fprintf(out, "\t.max_height = %d,\n", max_height); fprintf(out, "\t.ascent = %d,\n", font.ascent); fprintf(out, "};\n"); + int max_stride = (max_width + 31) >> 5; + fprintf(out, "__asm__(\".balign 4\\n.comm ao_glyph_temp 0x%x\");\n", max_stride * max_height * 4); } string -- 2.30.2