From 5e6766a165bd4bc71f1dc24c4348f7be0f020ddd Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 23 Apr 2019 20:16:08 +0300 Subject: output-damage: refactor API wlr_output_damage_make_current has been renamed to wlr_output_damage_attach_render, since it's just a wrapper for wlr_output_attach_render. wlr_output_damage_swap_buffers has been removed completely. Instead, wlr_output_damage now listens to successful wlr_output commits and updates its internal state accordingly. --- include/wlr/types/wlr_output.h | 4 +++- include/wlr/types/wlr_output_damage.h | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index e50f9ba3..b0965245 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -111,8 +111,10 @@ struct wlr_output { // Emitted when buffers need to be swapped (because software cursors or // fullscreen damage or because of backend-specific logic) struct wl_signal needs_commit; - // Emitted right before buffer commit + // Emitted right before commit struct wl_signal precommit; // wlr_output_event_precommit + // Emitted right after commit + struct wl_signal commit; // Emitted right after the buffer has been presented to the user struct wl_signal present; // wlr_output_event_present struct wl_signal enable; diff --git a/include/wlr/types/wlr_output_damage.h b/include/wlr/types/wlr_output_damage.h index 68f518d9..bc29ebdf 100644 --- a/include/wlr/types/wlr_output_damage.h +++ b/include/wlr/types/wlr_output_damage.h @@ -24,10 +24,13 @@ /** * Tracks damage for an output. * - * When a `frame` event is emitted, `wlr_output_damage_make_current` should be - * called. If necessary, the output should be repainted and - * `wlr_output_damage_swap_buffers` should be called. No rendering should happen - * outside a `frame` event handler. + * The `frame` event will be emitted when it is a good time for the compositor + * to submit a new frame. + * + * To render a new frame, compositors should call + * `wlr_output_damage_attach_render`, render and call `wlr_output_commit`. No + * rendering should happen outside a `frame` event handler or before + * `wlr_output_damage_attach_render`. */ struct wlr_output_damage { struct wlr_output *output; @@ -50,25 +53,22 @@ struct wlr_output_damage { struct wl_listener output_scale; struct wl_listener output_needs_commit; struct wl_listener output_frame; + struct wl_listener output_commit; }; struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output); void wlr_output_damage_destroy(struct wlr_output_damage *output_damage); /** - * Makes the output rendering context current. `needs_swap` is set to true if - * `wlr_output_damage_swap_buffers` needs to be called. The region of the output - * that needs to be repainted is added to `damage`. - */ -bool wlr_output_damage_make_current(struct wlr_output_damage *output_damage, - bool *needs_swap, pixman_region32_t *damage); -/** - * Swaps the output buffers. If the time of the frame isn't known, set `when` to - * NULL. + * Attach the renderer's buffer to the output. Compositors must call this + * function before rendering. After they are done rendering, they should call + * `wlr_output_set_damage` and `wlr_output_commit` to submit the new frame. * - * Swapping buffers schedules a `frame` event. + * `needs_commit` will be set to true if a frame should be submitted. `damage` + * will be set to the region of the output that needs to be repainted, in + * output-buffer-local coordinates. */ -bool wlr_output_damage_swap_buffers(struct wlr_output_damage *output_damage, - struct timespec *when, pixman_region32_t *damage); +bool wlr_output_damage_attach_render(struct wlr_output_damage *output_damage, + bool *needs_commit, pixman_region32_t *damage); /** * Accumulates damage and schedules a `frame` event. */ -- cgit v1.2.3