wayland: release unused buffers after buffer swap

When the surface attaches to a buffer, all other buffers are available.
Export the function used to release a buffer, track the buffer used by
the surface, and release unused buffers when a new buffer is attached.
This commit is contained in:
Richard Acayan 2024-04-22 19:15:47 -04:00
parent 1c606d0274
commit d43f61ec76
4 changed files with 35 additions and 13 deletions

View file

@ -105,6 +105,7 @@ struct ufkbd_wl_surface {
unsigned int scale;
size_t stride;
int used_buf;
struct ufkbd_wl_buffer bufs[2];
};
@ -126,6 +127,7 @@ int ufkbd_wl_buffer_consume(struct ufkbd_wl_buffer *ctx,
struct wl_buffer **buf, void **ptr);
int ufkbd_wl_buffer_resize(struct ufkbd_wl_buffer *ctx,
uint32_t width, uint32_t height);
void ufkbd_wl_buffer_release(struct ufkbd_wl_buffer *ctx);
int ufkbd_wl_buffer_init(struct ufkbd_wl_buffer *ctx,
struct ufkbd_input_wayland *ufkbd_wl,
unsigned int id);
@ -133,6 +135,7 @@ void ufkbd_wl_buffer_uninit(struct ufkbd_wl_buffer *ctx);
int ufkbd_wl_surface_consume_buffer(struct ufkbd_wl_surface *ctx,
struct wl_buffer **buf, void **ptr);
void ufkbd_wl_surface_release_unused(struct ufkbd_wl_surface *ctx);
int ufkbd_wl_surface_init(struct ufkbd_input_wayland *ufkbd_wl,
struct ufkbd_wl_surface **out);
void ufkbd_wl_surface_uninit(struct ufkbd_wl_surface *ctx);