Merge branch 'wlr-output-commit' into 'master'

Introduce struct wlr_output_commit

Closes #3717

See merge request wlroots/wlroots!4330
This commit is contained in:
Alexander Orzechowski 2023-10-05 09:31:25 +00:00
commit 8eb0a8580f
15 changed files with 183 additions and 130 deletions

View file

@ -133,6 +133,7 @@ struct wlr_drm_connector_state {
struct wlr_drm_connector {
struct wlr_output output; // only valid if status != DISCONNECTED
struct wlr_output_commit commit;
struct wlr_drm_backend *backend;
char name[24];
@ -175,7 +176,7 @@ void scan_drm_connectors(struct wlr_drm_backend *state,
void scan_drm_leases(struct wlr_drm_backend *drm);
int handle_drm_event(int fd, uint32_t mask, void *data);
void destroy_drm_connector(struct wlr_drm_connector *conn);
bool drm_connector_commit_state(struct wlr_drm_connector *conn,
struct wlr_output_commit *drm_connector_commit_state(struct wlr_drm_connector *conn,
const struct wlr_output_state *state);
bool drm_connector_is_cursor_visible(struct wlr_drm_connector *conn);
bool drm_connector_supports_vrr(struct wlr_drm_connector *conn);

View file

@ -16,6 +16,7 @@ struct wlr_headless_backend {
struct wlr_headless_output {
struct wlr_output wlr_output;
struct wlr_output_commit commit;
struct wlr_headless_backend *backend;
struct wl_list link;

View file

@ -62,10 +62,11 @@ struct wlr_wl_buffer {
};
struct wlr_wl_presentation_feedback {
struct wlr_output_commit commit;
struct wlr_wl_output *output;
struct wl_list link;
struct wl_list link; // wlr_wl_output.presentation_feedbacks
struct wp_presentation_feedback *feedback;
uint32_t commit_seq;
};
struct wlr_wl_output_layer {
@ -80,8 +81,11 @@ struct wlr_wl_output_layer {
struct wlr_wl_output {
struct wlr_output wlr_output;
// commit used when output is disabled or presentation events are not supported
struct wlr_output_commit commit;
struct wlr_wl_backend *backend;
struct wl_list link;
struct wl_list link; // wlr_wl_backend.outputs
struct wl_surface *surface;
bool own_surface;
@ -89,7 +93,7 @@ struct wlr_wl_output {
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1;
struct wl_list presentation_feedbacks;
struct wl_list presentation_feedbacks; // wlr_wl_presentation_feedback.link
bool configured;
uint32_t enter_serial;

View file

@ -27,10 +27,17 @@
struct wlr_x11_backend;
struct wlr_x11_output_commit {
struct wl_list link; // wlr_x11_output::commits;
uint32_t serial;
struct wlr_output_commit commit;
};
struct wlr_x11_output {
struct wlr_output wlr_output;
struct wlr_x11_backend *x11;
struct wl_list link; // wlr_x11_backend.outputs
uint32_t serial;
xcb_window_t win;
xcb_present_event_t present_event_id;
@ -50,6 +57,8 @@ struct wlr_x11_output {
struct wlr_swapchain *swapchain;
xcb_render_picture_t pic;
} cursor;
struct wl_list commits; // wlr_x11_output_commit::link
};
struct wlr_x11_touchpoint {

View file

@ -21,6 +21,6 @@ bool output_cursor_set_texture(struct wlr_output_cursor *cursor,
int dst_width, int dst_height, enum wl_output_transform transform,
int32_t hotspot_x, int32_t hotspot_y);
void output_defer_present(struct wlr_output *output, struct wlr_output_event_present event);
void output_commit_defer_present(struct wlr_output_commit *commit);
#endif

View file

@ -65,7 +65,8 @@ struct wlr_output_impl {
*
* If a buffer has been attached, a frame event is scheduled.
*/
bool (*commit)(struct wlr_output *output, const struct wlr_output_state *state);
struct wlr_output_commit *(*commit)(struct wlr_output *output,
const struct wlr_output_state *state);
/**
* Get the maximum number of gamma LUT elements for each channel.
*
@ -114,13 +115,6 @@ void wlr_output_update_needs_frame(struct wlr_output *output);
* See wlr_output.events.frame.
*/
void wlr_output_send_frame(struct wlr_output *output);
/**
* Send a present event.
*
* See wlr_output.events.present.
*/
void wlr_output_send_present(struct wlr_output *output,
struct wlr_output_event_present *event);
/**
* Request the compositor to apply new state.
*/

View file

@ -160,9 +160,6 @@ struct wlr_output {
struct wlr_output_state pending;
// Commit sequence number. Incremented on each commit, may overflow.
uint32_t commit_seq;
struct {
// Request to render a frame
struct wl_signal frame;
@ -176,9 +173,6 @@ struct wlr_output {
struct wl_signal precommit; // struct wlr_output_event_precommit
// Emitted right after commit
struct wl_signal commit; // struct wlr_output_event_commit
// Emitted right after a commit has been presented to the user for
// enabled outputs
struct wl_signal present; // struct wlr_output_event_present
// Emitted after a client bound the wl_output global
struct wl_signal bind; // struct wlr_output_event_bind
struct wl_signal description;
@ -209,6 +203,11 @@ struct wlr_output {
struct wlr_addon_set addons;
void *data;
// private state
// used for when to create a new back buffer
bool not_committed;
};
struct wlr_output_event_damage {
@ -227,6 +226,7 @@ struct wlr_output_event_commit {
uint32_t committed; // bitmask of enum wlr_output_state_field
struct timespec *when;
struct wlr_buffer *buffer; // NULL if no buffer is committed
struct wlr_output_commit *commit;
};
enum wlr_output_present_flag {
@ -245,9 +245,6 @@ enum wlr_output_present_flag {
struct wlr_output_event_present {
struct wlr_output *output;
// Frame submission for which this presentation event is for (see
// wlr_output.commit_seq).
uint32_t commit_seq;
// Whether the frame was presented at all.
bool presented;
// Time when the content update turned into light the first time.
@ -270,8 +267,20 @@ struct wlr_output_event_request_state {
const struct wlr_output_state *state;
};
struct wlr_output_commit {
struct wlr_output *output;
struct {
struct wl_signal present; // struct wlr_output_event_present
} events;
};
struct wlr_surface;
void wlr_output_commit_init(struct wlr_output_commit *commit,
struct wlr_output *output);
/**
* Enables or disables the output. A disabled output is turned off and doesn't
* emit `frame` events.
@ -460,7 +469,7 @@ bool wlr_output_test(struct wlr_output *output);
*
* On failure, the pending changes are rolled back.
*/
bool wlr_output_commit(struct wlr_output *output);
struct wlr_output_commit *wlr_output_commit(struct wlr_output *output);
/**
* Discard the pending output state.
*/
@ -477,12 +486,13 @@ bool wlr_output_test_state(struct wlr_output *output,
/**
* Attempts to apply the state to this output. This function may fail for any
* reason and return false. If failed, none of the state would have been applied,
* this function is atomic. If the commit succeeded, true is returned.
* this function is atomic. If the commit succeeded, an wlr_output_commit struct
* is returned. If the commit failed, NULL is returned.
*
* Note: wlr_output_state_finish() would typically be called after the state
* has been committed.
*/
bool wlr_output_commit_state(struct wlr_output *output,
struct wlr_output_commit *wlr_output_commit_state(struct wlr_output *output,
const struct wlr_output_state *state);
/**
* Manually schedules a `frame` event. If a `frame` event is already pending,

View file

@ -36,8 +36,6 @@ struct wlr_presentation_feedback {
// Only when the wlr_presentation_surface_textured_on_output() or
// wlr_presentation_surface_scanned_out_on_output() helper has been called.
struct wlr_output *output;
bool output_committed;
uint32_t output_commit_seq;
bool zero_copy;
struct wl_listener output_commit;