vtgl

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

Commit: 106916dc7f689fcdf4961d3da1f57a52582ac88d
Parent: 143a28340bdc4536a904140577c247d99337f731
Author: Randy Palamar
Date:   Sun,  1 Dec 2024 21:48:12 -0700

simplify blit_lines a little

this is only called currently when we are refilling based
scrollback so we shouldn't be doing any of this extra handling.

Diffstat:
Mterminal.c | 16+++++++---------
Mutil.h | 9++++-----
Mvtgl.c | 16++++++++--------
3 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/terminal.c b/terminal.c @@ -1300,25 +1300,23 @@ get_line_idx(LineBuf *lb, size off) } static void -blit_lines(Term *t, Arena a, size line_count) +blit_lines(Term *t, Arena a) { BEGIN_TIMED_BLOCK(); - TermView *tv = t->views + t->view_idx; + ASSERT(t->gl.flags & NEEDS_REFILL); + term_reset(t); - if (t->gl.flags & NEEDS_FULL_REFILL) { - term_reset(t); - line_count = t->size.h - 1; - } - - size off = t->scroll_offset; + TermView *tv = t->views + t->view_idx; + size line_count = t->size.h - 1; + size off = t->scroll_offset; CLAMP(line_count, 0, tv->lines.filled); for (size idx = -line_count; idx <= 0; idx++) { size line_idx = get_line_idx(&tv->lines, idx - off); push_line(t, tv->lines.buf + line_idx, a); } - t->gl.flags &= ~(NEEDS_FULL_REFILL|NEEDS_REFILL); + t->gl.flags &= ~NEEDS_REFILL; END_TIMED_BLOCK(); } diff --git a/util.h b/util.h @@ -164,12 +164,11 @@ typedef struct { X(texslot) enum gl_flags { - NEEDS_RESIZE = 1 << 0, - NEEDS_REFILL = 1 << 1, - NEEDS_FULL_REFILL = 1 << 2, - UPDATE_RENDER_BUFFER = 1 << 3, + NEEDS_RESIZE = 1 << 0, + NEEDS_REFILL = 1 << 1, + UPDATE_RENDER_BUFFER = 1 << 2, - DRAW_DEBUG_OVERLAY = 1 << 30, + DRAW_DEBUG_OVERLAY = 1 << 30, }; enum shader_stages { diff --git a/vtgl.c b/vtgl.c @@ -259,7 +259,7 @@ resize_terminal(Term *t, PlatformAPI *platform, iv2 window_size) if (!equal_iv2(old_size, t->size)) { t->size = initialize_framebuffer(&t->views[0].fb, t->size); initialize_framebuffer(&t->views[1].fb, t->size); - t->gl.flags |= NEEDS_FULL_REFILL; + t->gl.flags |= NEEDS_REFILL; } platform->set_terminal_size(t->child, t->size.h, t->size.w, ws.w, ws.h); @@ -724,7 +724,7 @@ KEYBIND_FN(scroll) t->scroll_offset += a.i; CLAMP(t->scroll_offset, 0, tv->lines.filled - (t->size.h - 1)); - t->gl.flags |= NEEDS_FULL_REFILL; + t->gl.flags |= NEEDS_REFILL; return 1; } @@ -1330,7 +1330,7 @@ DEBUG_EXPORT VTGL_FRAME_STEP_FN(vtgl_frame_step) if (input->character_input.len) { if (t->scroll_offset) { t->scroll_offset = 0; - t->gl.flags |= NEEDS_FULL_REFILL; + t->gl.flags |= NEEDS_REFILL; } memory->platform_api.write(t->child, input->character_input, 0); } @@ -1338,6 +1338,11 @@ DEBUG_EXPORT VTGL_FRAME_STEP_FN(vtgl_frame_step) handle_interactions(t, input, &memory->platform_api); END_NAMED_BLOCK(mouse_and_keyboard_input); + if (t->gl.flags & NEEDS_REFILL) { + blit_lines(t, t->arena_for_frame); + t->gl.flags |= UPDATE_RENDER_BUFFER; + } + BEGIN_NAMED_BLOCK(input_from_child); if (input->data_available) { RingBuf *rb = &t->views[t->view_idx].log; @@ -1357,11 +1362,6 @@ DEBUG_EXPORT VTGL_FRAME_STEP_FN(vtgl_frame_step) } END_NAMED_BLOCK(input_from_child); - if (t->gl.flags & (NEEDS_REFILL|NEEDS_FULL_REFILL)) { - blit_lines(t, t->arena_for_frame, 0); - t->gl.flags |= UPDATE_RENDER_BUFFER; - } - end_temp_arena(t->temp_arena); BEGIN_NAMED_BLOCK(debug_end_frame);