backend: add wlr_backend_{test,commit}()

This commit is contained in:
Simon Ser 2022-09-14 10:43:27 +02:00 committed by Kenny Levinsen
parent fc4996d853
commit 78c76ddd09
5 changed files with 135 additions and 29 deletions

View file

@ -22,4 +22,7 @@ bool output_cursor_set_texture(struct wlr_output_cursor *cursor,
void output_defer_present(struct wlr_output *output, struct wlr_output_event_present event);
bool output_prepare_commit(struct wlr_output *output, const struct wlr_output_state *state);
void output_apply_commit(struct wlr_output *output, const struct wlr_output_state *state);
#endif

View file

@ -10,10 +10,19 @@
#define WLR_BACKEND_H
#include <wayland-server-core.h>
#include <wlr/types/wlr_output.h>
struct wlr_session;
struct wlr_backend_impl;
/**
* Per-output state for wlr_backend_test() and wlr_backend_commit().
*/
struct wlr_backend_output_state {
struct wlr_output *output;
struct wlr_output_state base;
};
/**
* A backend provides a set of input and output devices.
*/
@ -62,4 +71,23 @@ void wlr_backend_destroy(struct wlr_backend *backend);
*/
int wlr_backend_get_drm_fd(struct wlr_backend *backend);
/**
* Atomically test a new configuration for multiple outputs.
*
* Some backends (e.g. DRM) have global backend-wide limitations. This function
* can be used to check whether changes across multiple outputs are supported by
* the backend.
*/
bool wlr_backend_test(struct wlr_backend *backend,
const struct wlr_backend_output_state *states, size_t states_len);
/**
* Atomically apply a new configuration for multiple outputs.
*
* There is no guarantee that the changes will be applied atomically. Users
* should call wlr_backend_test() first to check that the new state is supported
* by the backend.
*/
bool wlr_backend_commit(struct wlr_backend *backend,
const struct wlr_backend_output_state *states, size_t states_len);
#endif

View file

@ -12,11 +12,17 @@
#include <stdbool.h>
#include <wlr/backend.h>
struct wlr_output_state;
struct wlr_backend_impl {
bool (*start)(struct wlr_backend *backend);
void (*destroy)(struct wlr_backend *backend);
int (*get_drm_fd)(struct wlr_backend *backend);
uint32_t (*get_buffer_caps)(struct wlr_backend *backend);
bool (*test)(struct wlr_backend *backend,
const struct wlr_backend_output_state *states, size_t states_len);
bool (*commit)(struct wlr_backend *backend,
const struct wlr_backend_output_state *states, size_t states_len);
};
/**