aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-11-17 18:41:46 +0100
committerAlexander Orzechowski <alex@ozal.ski>2023-11-29 14:45:10 -0500
commit20935646168f5b709947a3ec2402189ecbd35d91 (patch)
treef21f93d34d8d0c16cbf41e63c065462f9228a585 /include
parent62b6c492d59e956e30cb409c730b4f84d33f8f6e (diff)
damage_ring: add wlr_damage_ring_rotate_buffer()
This adds an alternate way to use wlr_damage_ring without the concept of buffer age. Buffer age is a concept inherited from EGL but there is no real reason why we should continue to use that in wlroots. Instead, use wlr_buffer pointers. Eventually, we should be able to remove the buffer age based functions.
Diffstat (limited to 'include')
-rw-r--r--include/wlr/types/wlr_damage_ring.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_damage_ring.h b/include/wlr/types/wlr_damage_ring.h
index d503a502..309d7ace 100644
--- a/include/wlr/types/wlr_damage_ring.h
+++ b/include/wlr/types/wlr_damage_ring.h
@@ -13,12 +13,22 @@
#include <stddef.h>
#include <stdint.h>
#include <pixman.h>
+#include <wayland-server-core.h>
/* For triple buffering, a history of two frames is required. */
#define WLR_DAMAGE_RING_PREVIOUS_LEN 2
+/* Keep track of as many buffers as a swapchain can hold */
+#define WLR_DAMAGE_RING_BUFFERS_LEN 4
struct wlr_box;
+struct wlr_damage_ring_buffer {
+ struct wlr_buffer *buffer;
+ struct wl_listener destroy;
+ pixman_region32_t damage;
+ uint64_t seq;
+};
+
struct wlr_damage_ring {
int32_t width, height;
@@ -29,6 +39,9 @@ struct wlr_damage_ring {
pixman_region32_t previous[WLR_DAMAGE_RING_PREVIOUS_LEN];
size_t previous_idx;
+
+ uint64_t last_buffer_seq;
+ struct wlr_damage_ring_buffer buffers[WLR_DAMAGE_RING_BUFFERS_LEN];
};
void wlr_damage_ring_init(struct wlr_damage_ring *ring);
@@ -81,4 +94,17 @@ void wlr_damage_ring_rotate(struct wlr_damage_ring *ring);
void wlr_damage_ring_get_buffer_damage(struct wlr_damage_ring *ring,
int buffer_age, pixman_region32_t *damage);
+/**
+ * Get accumulated buffer damage and rotate the damage ring.
+ *
+ * The accumulated buffer damage is the difference between the to-be-painted
+ * buffer and the passed-in buffer. In other words, this is the region that
+ * needs to be redrawn.
+ *
+ * Users should damage the ring if an error occurs while rendering or
+ * submitting the new buffer to the backend.
+ */
+void wlr_damage_ring_rotate_buffer(struct wlr_damage_ring *ring,
+ struct wlr_buffer *buffer, pixman_region32_t *damage);
+
#endif