compositor: add surface transactions

This commit is contained in:
Kirill Primak 2024-01-09 19:59:40 +03:00
parent a3af71b996
commit 8fa8df47e5
2 changed files with 356 additions and 29 deletions

View file

@ -72,6 +72,10 @@ struct wlr_surface_state {
// Sync'ed object states, one per struct wlr_surface_synced
struct wl_array synced; // void *
// private state
struct wlr_surface_state_group *group;
};
struct wlr_surface_state_lock {
@ -81,6 +85,11 @@ struct wlr_surface_state_lock {
struct wl_listener surface_destroy;
};
struct wlr_surface_transaction {
// private state
struct wl_array *surfaces; // struct wlr_surface *
};
struct wlr_surface_role {
const char *name;
/**
@ -202,7 +211,7 @@ struct wlr_surface {
* The commit may not be applied immediately, in which case it's marked
* as "cached" and put into a queue. See wlr_surface_lock_pending().
*/
struct wl_signal client_commit;
struct wl_signal client_commit; // struct wlr_surface_client_commit_event
/**
* Signals that a commit has been applied.
*
@ -270,6 +279,13 @@ struct wlr_surface {
struct wl_resource *pending_buffer_resource;
struct wl_listener pending_buffer_resource_destroy;
struct wlr_surface_state *txn_state; // NULL if not added to a transaction
struct wl_array txn_buffer;
};
struct wlr_surface_client_commit_event {
struct wlr_surface_transaction *transaction;
};
struct wlr_renderer;
@ -475,6 +491,41 @@ void wlr_surface_state_lock_release(struct wlr_surface_state_lock *lock);
*/
bool wlr_surface_state_lock_locked(struct wlr_surface_state_lock *lock);
/**
* Initialize a surface transaction with an existing buffer.
*
* After the transaction is committed or dropped, the buffer can be reused.
*/
void wlr_surface_transaction_init(struct wlr_surface_transaction *txn, struct wl_array *buffer);
/**
* Add a state lock to the transaction. If the locked state is a part of a state
* group, the group is treated as a set of locks which are added individually
* instead.
*
* Adding locks for different states of the same surface is not allowed.
*
* On success, the lock is moved to the transaction, and true is returned.
* On failure, false is returned.
*/
bool wlr_surface_transaction_add_lock(struct wlr_surface_transaction *txn,
struct wlr_surface_state_lock *lock);
/**
* Drop the transaction, releasing all its locks.
*/
void wlr_surface_transaction_drop(struct wlr_surface_transaction *txn);
/**
* Commit the transaction, releasing all its locks. The corresponding states are
* added into a state group, which is committed only once all its states can be
* committed.
*
* On success, true is returned.
* On failure, the transaction is dropped, and false is returned.
*/
bool wlr_surface_transaction_commit(struct wlr_surface_transaction *txn);
/**
* Set the preferred buffer scale for the surface.
*