diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-20 19:04:20 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-02-21 17:14:31 +0100 |
commit | b33ab26fe7138f16dedd12ed360548e886408f30 (patch) | |
tree | b6b5d94b5ea9b8cc75aa9043bdd2b154ac30cbdb /include/wlr | |
parent | c667e64892a554b9f8610997e690a6d3adb739a2 (diff) |
render/swapchain: make public
We've had this struct for a while. It'd be useful for compositors
if they want to manage the swap chains themselves instead of being
forced to use wlr_output's. Some compositors might also want to use
a swapchain without an output.
Diffstat (limited to 'include/wlr')
-rw-r--r-- | include/wlr/render/swapchain.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/include/wlr/render/swapchain.h b/include/wlr/render/swapchain.h new file mode 100644 index 00000000..38b1fb8b --- /dev/null +++ b/include/wlr/render/swapchain.h @@ -0,0 +1,50 @@ +#ifndef WLR_RENDER_SWAPCHAIN_H +#define WLR_RENDER_SWAPCHAIN_H + +#include <stdbool.h> +#include <wayland-server-core.h> +#include <wlr/render/drm_format_set.h> + +#define WLR_SWAPCHAIN_CAP 4 + +struct wlr_swapchain_slot { + struct wlr_buffer *buffer; + bool acquired; // waiting for release + int age; + + struct wl_listener release; +}; + +struct wlr_swapchain { + struct wlr_allocator *allocator; // NULL if destroyed + + int width, height; + struct wlr_drm_format *format; + + struct wlr_swapchain_slot slots[WLR_SWAPCHAIN_CAP]; + + struct wl_listener allocator_destroy; +}; + +struct wlr_swapchain *wlr_swapchain_create( + struct wlr_allocator *alloc, int width, int height, + const struct wlr_drm_format *format); +void wlr_swapchain_destroy(struct wlr_swapchain *swapchain); +/** + * Acquire a buffer from the swap chain. + * + * The returned buffer is locked. When the caller is done with it, they must + * unlock it by calling wlr_buffer_unlock. + */ +struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain, + int *age); +/** + * Mark the buffer as submitted for presentation. This needs to be called by + * swap chain users on frame boundaries. + * + * If the buffer hasn't been created via the swap chain, the call is ignored. + */ +void wlr_swapchain_set_buffer_submitted(struct wlr_swapchain *swapchain, + struct wlr_buffer *buffer); + +#endif |