vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: de9cb651aa6eabfd3e2dd83c07ddd10be667df2f
Parent: 772e6da78767e7a795130b40ef9d7fc9f5ca0b94
Author: Randy Palamar
Date:   Sun, 29 Sep 2024 12:38:29 -0600

make sure render_glyph & split_lines cycle counts finish

Diffstat:
Mfont.c | 6++++--
Mterminal.c | 5+++--
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/font.c b/font.c @@ -123,6 +123,7 @@ static u32 * render_glyph(Arena *a, FontAtlas *fa, u32 cp, enum face_style style, CachedGlyph **out_glyph, u32 *out_idx) { BEGIN_CYCLE_COUNT(CC_RENDER_GLYPH); + u32 *rgba_bitmap = NULL; /* NOTE: first check if glyph is in the cache and valid */ /* NOTE: 8 MSB are not used for UTF8 so we can use that to store the style of the glyph */ @@ -132,7 +133,7 @@ render_glyph(Arena *a, FontAtlas *fa, u32 cp, enum face_style style, CachedGlyph *out_idx = idx; *out_glyph = cg; if (cg->uploaded_to_gpu) - return NULL; + goto end; i32 glyph_idx = 0; i32 font_idx = 0; @@ -163,7 +164,7 @@ render_glyph(Arena *a, FontAtlas *fa, u32 cp, enum face_style style, CachedGlyph stbtt_MakeGlyphBitmapSubpixel(*a, &f->font_info, render_buf, cg->g.size.w, cg->g.size.h, cg->g.size.w, scale, scale, 0, 0, glyph_idx); - u32 *rgba_bitmap = alloc(a, u32, cg->g.size.w * cg->g.size.h); + rgba_bitmap = alloc(a, u32, cg->g.size.w * cg->g.size.h); for (u32 i = 0; i < cg->g.size.h; i++) { for (u32 j = 0; j < cg->g.size.w; j++) { /* TODO: handled coloured glyphs */ @@ -179,6 +180,7 @@ render_glyph(Arena *a, FontAtlas *fa, u32 cp, enum face_style style, CachedGlyph /* NOTE: ' ' has 0 size in freetype but we need it to have a width! */ if (cp == ' ') cg->g.size.w = fa->info.w; +end: END_CYCLE_COUNT(CC_RENDER_GLYPH); return rgba_bitmap; diff --git a/terminal.c b/terminal.c @@ -1105,7 +1105,7 @@ split_raw_input_to_lines(Term *t, s8 raw) switch (check_if_escape_moves_cursor(t, &raw)) { case EMC_NEEDS_MORE_BYTES: t->unprocessed_bytes = old.len; - return parsed_lines; + goto end; case EMC_CURSOR_MOVED: if (line_length(tv->lines.buf + tv->lines.widx)) { parsed_lines++; @@ -1137,7 +1137,7 @@ split_raw_input_to_lines(Term *t, s8 raw) if (get_utf8(&raw) == (u32)-1) { /* NOTE: Need More Bytes! */ t->unprocessed_bytes = old_len; - return parsed_lines; + goto end; } } else { raw = consume(raw, 1); @@ -1153,6 +1153,7 @@ split_raw_input_to_lines(Term *t, s8 raw) } t->unprocessed_bytes = 0; +end: END_CYCLE_COUNT(CC_SPLIT_LINES); return parsed_lines;