render: remove most of the special handling of cursor rendering

Previously, we had to explicitly render the old cursor cell *before*
applying scrolling damage.

We then rendered all the dirty rows, *without* rendering the cursor -
even if the cursor cell was among the dirty rows.

Finally, when everything else was done, we explicitly rendered the
cursor cell.

This meant a lot of code, and unnecessary render_cell() calls, along
with unnecessary wl_surface_damage_buffer() calls.

This was a necessary in the early design of foot, but not anymore.

We can simply mark both the old cursor cell, and the current one, as
dirty and let the normal rendering framework render it. All we need to
do is pass the cursor column to render_row(), so that it can pass
has_cursor=true in the appropriate call to render_cell(). We pass -1
here for all rows, except the cursor's row, where we pass the actual
cursor column.

With this, there's no need to calculate whether the cursor is visible
or not; just mark it's cell as dirty, and if that row is visible, the
normal rendering will take care of it.

This also simplifies the state needed to be saved between two frames;
we only need a row pointer, and the cursor column index.

Part of https://codeberg.org/dnkl/foot/issues/35
This commit is contained in:
Daniel Eklöf 2020-07-12 12:56:10 +02:00
parent 0bdbf45418
commit 2bdd0a7c80
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 52 additions and 83 deletions

View file

@ -378,9 +378,8 @@ struct terminal {
/* Last rendered cursor position */
struct {
struct coord actual; /* Absolute */
struct coord in_view; /* Offset by view */
struct row *row; /* Actual row TODO: remove */
struct row *row;
int col;
} last_cursor;
struct buffer *last_buf; /* Buffer we rendered to last time */