mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-04 07:15:29 -04:00
shm: replace 'locked' attribute with a ref-counter
The initial ref-count is either 1 or 0, depending on whether the buffer is supposed to be released "immeidately" (meaning, as soon as the compositor releases it). Two new user facing functions have been added: shm_addref() and shm_unref(). Our renderer now uses these two functions instead of manually setting and clearing the 'locked' attribute. shm_unref() will decrement the ref-counter, and destroy the buffer when the counter reaches zero. Except if the buffer is currently "busy" (compositor owned), in which case destruction is deferred to the release event. The buffer is still removed from the list though.
This commit is contained in:
parent
69260dd960
commit
232fb20269
4 changed files with 60 additions and 53 deletions
5
shm.h
5
shm.h
|
|
@ -10,8 +10,6 @@
|
|||
struct damage;
|
||||
|
||||
struct buffer {
|
||||
bool locked; /* Caller owned, shm won’t destroy it */
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int stride;
|
||||
|
|
@ -23,6 +21,7 @@ struct buffer {
|
|||
size_t pix_instances;
|
||||
|
||||
unsigned age;
|
||||
|
||||
struct damage *scroll_damage;
|
||||
size_t scroll_damage_count;
|
||||
pixman_region32_t dirty;
|
||||
|
|
@ -74,6 +73,8 @@ bool shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows,
|
|||
int top_margin, int top_keep_rows,
|
||||
int bottom_margin, int bottom_keep_rows);
|
||||
|
||||
void shm_addref(struct buffer *buf);
|
||||
void shm_unref(struct buffer *buf);
|
||||
void shm_purge(struct wl_shm *shm, unsigned long cookie);
|
||||
|
||||
struct terminal;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue