render: trigger terminal refreshes in an FDM hook

In some cases, we end up calling render_refresh() multiple times in
the same FDM iteration. This means will render the first update
immediately, and then set the 'pending' flag, causing the updated
content to be rendered in the next frame.

This can cause flicker, or flashes, since we're presenting one or more
intermediate frames until the final content is shown.

Not to mention that it is inefficient to render multiple frames like
this.

Fix by:

* render_refresh() only sets a flag in the terminal

* install an FDM hook; this hook loops all terminals and executes what
  render_refresh() _used_ to do (that is, render immediately if we're
  not waiting for a frame callback, otherwise set 'pending' flag). for
  all terminals that have the 'refresh_needed' flag set.
This commit is contained in:
Daniel Eklöf 2020-01-04 19:49:26 +01:00
parent a3c18e72f5
commit 99f471d738
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 68 additions and 8 deletions

View file

@ -1,9 +1,12 @@
#pragma once
#include "terminal.h"
#include "fdm.h"
#include "wayland.h"
struct font *attrs_to_font(
const struct terminal *term, const struct attributes *attrs);
struct renderer;
struct renderer *render_init(struct fdm *fdm, struct wayland *wayl);
void render_destroy(struct renderer *renderer);
void grid_render(struct terminal *term);
void render_resize(struct terminal *term, int width, int height);