diff options
| author | Simon Ser <contact@emersion.fr> | 2020-06-01 19:49:32 +0200 | 
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2020-11-15 22:48:42 +0100 | 
| commit | b0a663d39d2de1dcfd9a0381cc822c4713da508e (patch) | |
| tree | 770628233efc28b72a6c37b6f8b01b5bf6de5550 /include/render | |
| parent | 7c6212a0f71eeab23a4ff4241cb266ec219fad2d (diff) | |
| download | wlroots-b0a663d39d2de1dcfd9a0381cc822c4713da508e.tar.xz | |
render: introduce wlr_swapchain
The swapchain maximum capacity is set to 4, so that we have enough room
for:
- A buffer currently displayed on screen
- A buffer queued for display (e.g. to KMS)
- A pending buffer that'll be queued next commit
- An additional pending buffer in case we want to invalidate the
  currently pending one
Diffstat (limited to 'include/render')
| -rw-r--r-- | include/render/swapchain.h | 41 | 
1 files changed, 41 insertions, 0 deletions
| diff --git a/include/render/swapchain.h b/include/render/swapchain.h new file mode 100644 index 00000000..57a0cd3f --- /dev/null +++ b/include/render/swapchain.h @@ -0,0 +1,41 @@ +#ifndef RENDER_SWAPCHAIN_H +#define 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 + +	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); + +#endif | 
