From b33ab26fe7138f16dedd12ed360548e886408f30 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 20 Feb 2023 19:04:20 +0100 Subject: 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. --- backend/drm/drm.c | 1 - backend/drm/renderer.c | 2 +- backend/wayland/output.c | 1 - include/render/swapchain.h | 50 ------------------------------------------ include/wlr/render/swapchain.h | 50 ++++++++++++++++++++++++++++++++++++++++++ render/swapchain.c | 2 +- types/output/cursor.c | 2 +- types/output/output.c | 2 +- types/output/render.c | 2 +- 9 files changed, 55 insertions(+), 57 deletions(-) delete mode 100644 include/render/swapchain.h create mode 100644 include/wlr/render/swapchain.h diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 2c660b8e..7eacb2f0 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -27,7 +27,6 @@ #include "backend/drm/util.h" #include "render/pixel_format.h" #include "render/drm_format_set.h" -#include "render/swapchain.h" #include "render/wlr_renderer.h" #include "util/env.h" #include "config.h" diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 4a9181e4..c24ff73d 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -15,7 +16,6 @@ #include "render/drm_format_set.h" #include "render/allocator/allocator.h" #include "render/pixel_format.h" -#include "render/swapchain.h" #include "render/wlr_renderer.h" bool init_drm_renderer(struct wlr_drm_backend *drm, diff --git a/backend/wayland/output.c b/backend/wayland/output.c index fbbfc205..28567502 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -18,7 +18,6 @@ #include "backend/wayland.h" #include "render/pixel_format.h" -#include "render/swapchain.h" #include "render/wlr_renderer.h" #include "linux-dmabuf-unstable-v1-client-protocol.h" diff --git a/include/render/swapchain.h b/include/render/swapchain.h deleted file mode 100644 index 243f0404..00000000 --- a/include/render/swapchain.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef RENDER_SWAPCHAIN_H -#define RENDER_SWAPCHAIN_H - -#include -#include -#include - -#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 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 +#include +#include + +#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 diff --git a/render/swapchain.c b/render/swapchain.c index 8d3b55f0..943879bb 100644 --- a/render/swapchain.c +++ b/render/swapchain.c @@ -1,10 +1,10 @@ #include #include #include +#include #include #include "render/allocator/allocator.h" #include "render/drm_format_set.h" -#include "render/swapchain.h" static void swapchain_handle_allocator_destroy(struct wl_listener *listener, void *data) { diff --git a/types/output/cursor.c b/types/output/cursor.c index 2ddff8cd..6ab557b5 100644 --- a/types/output/cursor.c +++ b/types/output/cursor.c @@ -2,12 +2,12 @@ #include #include #include +#include #include #include #include #include #include "render/allocator/allocator.h" -#include "render/swapchain.h" #include "types/wlr_buffer.h" #include "types/wlr_output.h" diff --git a/types/output/output.c b/types/output/output.c index dc9aa6ad..c6b90a1d 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -4,12 +4,12 @@ #include #include #include +#include #include #include #include #include #include "render/allocator/allocator.h" -#include "render/swapchain.h" #include "types/wlr_output.h" #include "util/env.h" #include "util/global.h" diff --git a/types/output/render.c b/types/output/render.c index 8e0895a6..d3121af1 100644 --- a/types/output/render.c +++ b/types/output/render.c @@ -3,12 +3,12 @@ #include #include #include +#include #include #include #include "backend/backend.h" #include "render/allocator/allocator.h" #include "render/drm_format_set.h" -#include "render/swapchain.h" #include "render/wlr_renderer.h" #include "render/pixel_format.h" #include "types/wlr_output.h" -- cgit v1.2.3