compositor: introduce surface-synced objects

This commit is contained in:
Kirill Primak 2022-02-04 14:14:06 +03:00
parent c6b067779b
commit a3bfdcd5e1
2 changed files with 198 additions and 39 deletions

View file

@ -18,6 +18,13 @@
#include <wlr/util/addon.h>
#include <wlr/util/box.h>
struct wlr_surface_synced_state {
struct wlr_surface_synced *synced;
struct wl_list synced_link; // wlr_surface_state.synced
struct wl_list state_link; // wlr_surface_synced.states
};
enum wlr_surface_state_field {
WLR_SURFACE_STATE_BUFFER = 1 << 0,
WLR_SURFACE_STATE_SURFACE_DAMAGE = 1 << 1,
@ -65,11 +72,39 @@ struct wlr_surface_state {
int dst_width, dst_height; // in surface-local coordinates
} viewport;
struct wl_list synced; // wlr_surface_synced_state.synced_link
// Number of locks that prevent this surface state from being committed.
size_t n_locks;
struct wl_list link; // wlr_surface.states
};
struct wlr_surface_synced;
struct wlr_surface_synced_interface {
const char *name;
void (*destroy)(struct wlr_surface_synced *synced);
void (*squash_state)(struct wlr_surface_synced_state *dst,
struct wlr_surface_synced_state *src);
struct wlr_surface_synced_state *(*create_state)(void);
void (*destroy_state)(struct wlr_surface_synced_state *state);
void (*precommit)(struct wlr_surface_synced *synced,
struct wlr_surface_synced_state *state);
};
/**
* A surface-synced object is an object which has its double-buffered state flow
* synchronized with the surface state flow.
*/
struct wlr_surface_synced {
const struct wlr_surface_synced_interface *impl;
struct wl_list link; // wlr_surface.synced
// See wlr_surface
struct wlr_surface_synced_state *current, *pending;
struct wl_list states; // wlr_surface_synced_state.state_link
};
struct wlr_surface_role {
const char *name;
void (*commit)(struct wlr_surface *surface);
@ -152,6 +187,8 @@ struct wlr_surface {
// private state
struct wl_list synced; // wlr_surface_synced.link
/**
* The queue of all states the surface has. The current state is always
* the first and the pending state is always the last.
@ -186,6 +223,14 @@ struct wlr_compositor {
typedef void (*wlr_surface_iterator_func_t)(struct wlr_surface *surface,
int sx, int sy, void *data);
bool wlr_surface_synced_init(struct wlr_surface_synced *synced,
const struct wlr_surface_synced_interface *impl,
struct wlr_surface *surface,
struct wlr_surface_synced_state *current,
struct wlr_surface_synced_state *pending);
void wlr_surface_synced_finish(struct wlr_surface_synced *synced);
/**
* Set the lifetime role for this surface. Returns 0 on success or -1 if the
* role cannot be set.