mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-20 06:47:19 -04:00
Merge branch 'surface-transactions' into 'master'
Draft: compositor: add state transactions Closes #3787 See merge request wlroots/wlroots!4507
This commit is contained in:
commit
52781abd00
11 changed files with 645 additions and 73 deletions
|
|
@ -72,6 +72,22 @@ 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 {
|
||||
// private state
|
||||
struct wlr_surface *surface;
|
||||
uint32_t seq;
|
||||
struct wl_listener surface_destroy;
|
||||
};
|
||||
|
||||
struct wlr_surface_transaction {
|
||||
// private state
|
||||
struct wl_array *surfaces; // struct wlr_surface *
|
||||
};
|
||||
|
||||
struct wlr_surface_role {
|
||||
|
|
@ -195,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.
|
||||
*
|
||||
|
|
@ -263,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;
|
||||
|
|
@ -443,23 +466,65 @@ void wlr_surface_get_buffer_source_box(struct wlr_surface *surface,
|
|||
struct wlr_fbox *box);
|
||||
|
||||
/**
|
||||
* Acquire a lock for the pending surface state.
|
||||
* Acquire a lock for the pending surface state. The lock must be unlocked.
|
||||
*
|
||||
* The state won't be committed before the caller releases the lock. Instead,
|
||||
* the state becomes cached. The caller needs to use wlr_surface_unlock_cached()
|
||||
* to release the lock.
|
||||
*
|
||||
* Returns a surface commit sequence number for the cached state.
|
||||
* the state becomes cached. The caller needs to use
|
||||
* wlr_surface_state_lock_release() to release the lock.
|
||||
*/
|
||||
uint32_t wlr_surface_lock_pending(struct wlr_surface *surface);
|
||||
void wlr_surface_state_lock_acquire(struct wlr_surface_state_lock *lock,
|
||||
struct wlr_surface *surface);
|
||||
|
||||
/**
|
||||
* Release a lock for a cached state.
|
||||
* Release a lock for a surface state. If the lock is already unlocked,
|
||||
* this is no-op.
|
||||
*
|
||||
* Callers should not assume that the cached state will immediately be
|
||||
* committed. Another caller may still have an active lock.
|
||||
*/
|
||||
void wlr_surface_unlock_cached(struct wlr_surface *surface, uint32_t seq);
|
||||
void wlr_surface_state_lock_release(struct wlr_surface_state_lock *lock);
|
||||
|
||||
/**
|
||||
* Get the status of a lock.
|
||||
*
|
||||
* Returns true if the lock is locked, false otherwise.
|
||||
*/
|
||||
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.
|
||||
|
|
|
|||
23
include/wlr/types/wlr_dbg_txn.h
Normal file
23
include/wlr/types/wlr_dbg_txn.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* This an unstable interface of wlroots. No guarantees are made regarding the
|
||||
* future consistency of this API.
|
||||
*/
|
||||
#ifndef WLR_USE_UNSTABLE
|
||||
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||
#endif
|
||||
|
||||
#ifndef WLR_TYPES_WLR_DBG_TXN_H
|
||||
#define WLR_TYPES_WLR_DBG_TXN_H
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include "dbg-txn-protocol.h"
|
||||
|
||||
struct wlr_dbg_txn_manager {
|
||||
struct wl_global *global;
|
||||
|
||||
struct wl_listener display_destroy;
|
||||
};
|
||||
|
||||
struct wlr_dbg_txn_manager *wlr_dbg_txn_manager_create(struct wl_display *display);
|
||||
|
||||
#endif
|
||||
|
|
@ -35,13 +35,11 @@ struct wlr_subsurface {
|
|||
|
||||
struct wlr_subsurface_parent_state current, pending;
|
||||
|
||||
uint32_t cached_seq;
|
||||
bool has_cache;
|
||||
|
||||
bool synchronized;
|
||||
bool added;
|
||||
|
||||
struct wl_listener surface_client_commit;
|
||||
struct wl_listener parent_client_commit;
|
||||
struct wl_listener parent_destroy;
|
||||
|
||||
struct {
|
||||
|
|
@ -52,6 +50,8 @@ struct wlr_subsurface {
|
|||
|
||||
// private state
|
||||
|
||||
struct wlr_surface_state_lock cached_lock;
|
||||
|
||||
struct wlr_surface_synced parent_synced;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue