aboutsummaryrefslogtreecommitdiff
path: root/shm.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-07-16 14:47:57 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-07-17 17:14:42 +0000
commit232fb20269b68157874f57d676c1b0b95c2386aa (patch)
treeca4de1f2c6dc21a8d0261c55e97b4ac8358be122 /shm.h
parentshm: we may exit with busy buffers remaining (seen on KDE) (diff)
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.
Diffstat (limited to 'shm.h')
-rw-r--r--shm.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/shm.h b/shm.h
index 435f9de4..18941588 100644
--- a/shm.h
+++ b/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;