2018-07-13 14:40:56 +02:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2022-11-08 17:58:33 +01:00
|
|
|
/*
|
|
|
|
* NOTE: wlr/types/wlr_output_damage.h is deprecated and will be removed in
|
|
|
|
* the next release. Use wlr/types/wlr_damage_ring.h instead.
|
|
|
|
*/
|
|
|
|
|
2018-02-11 12:49:30 +01:00
|
|
|
#ifndef WLR_TYPES_WLR_OUTPUT_DAMAGE_H
|
|
|
|
#define WLR_TYPES_WLR_OUTPUT_DAMAGE_H
|
|
|
|
|
|
|
|
#include <pixman.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <time.h>
|
2018-02-11 13:07:00 +01:00
|
|
|
#include <wlr/types/wlr_output.h>
|
2018-02-11 12:49:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Damage tracking requires to keep track of previous frames' damage. To allow
|
|
|
|
* damage tracking to work with triple buffering, a history of two frames is
|
|
|
|
* required.
|
|
|
|
*/
|
|
|
|
#define WLR_OUTPUT_DAMAGE_PREVIOUS_LEN 2
|
|
|
|
|
2021-07-01 22:36:01 +02:00
|
|
|
struct wlr_box;
|
|
|
|
|
2018-02-11 13:04:00 +01:00
|
|
|
/**
|
|
|
|
* Tracks damage for an output.
|
|
|
|
*
|
2019-04-23 19:16:08 +02:00
|
|
|
* 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
|
2022-05-24 18:46:59 +02:00
|
|
|
* wlr_output_damage_attach_render(), render and call wlr_output_commit(). No
|
2019-04-23 19:16:08 +02:00
|
|
|
* rendering should happen outside a `frame` event handler or before
|
2022-05-24 18:46:59 +02:00
|
|
|
* wlr_output_damage_attach_render().
|
2018-02-11 13:04:00 +01:00
|
|
|
*/
|
2018-02-11 12:49:30 +01:00
|
|
|
struct wlr_output_damage {
|
|
|
|
struct wlr_output *output;
|
2018-05-05 15:28:55 +02:00
|
|
|
int max_rects; // max number of damaged rectangles
|
2018-02-11 12:49:30 +01:00
|
|
|
|
|
|
|
pixman_region32_t current; // in output-local coordinates
|
|
|
|
|
|
|
|
// circular queue for previous damage
|
|
|
|
pixman_region32_t previous[WLR_OUTPUT_DAMAGE_PREVIOUS_LEN];
|
|
|
|
size_t previous_idx;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal frame;
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
|
|
|
|
|
|
|
struct wl_listener output_destroy;
|
2019-04-23 19:22:42 +02:00
|
|
|
struct wl_listener output_needs_frame;
|
2020-03-12 13:08:57 +01:00
|
|
|
struct wl_listener output_damage;
|
2018-02-11 12:49:30 +01:00
|
|
|
struct wl_listener output_frame;
|
2019-04-23 19:16:08 +02:00
|
|
|
struct wl_listener output_commit;
|
2018-02-11 12:49:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output);
|
|
|
|
void wlr_output_damage_destroy(struct wlr_output_damage *output_damage);
|
2018-02-11 13:04:00 +01:00
|
|
|
/**
|
2019-04-23 19:16:08 +02:00
|
|
|
* Attach the renderer's buffer to the output. Compositors must call this
|
|
|
|
* function before rendering. After they are done rendering, they should call
|
2022-05-24 18:46:59 +02:00
|
|
|
* wlr_output_set_damage() and wlr_output_commit() to submit the new frame.
|
2018-02-11 13:04:00 +01:00
|
|
|
*
|
2019-04-23 19:22:42 +02:00
|
|
|
* `needs_frame` will be set to true if a frame should be submitted. `damage`
|
2019-04-23 19:16:08 +02:00
|
|
|
* will be set to the region of the output that needs to be repainted, in
|
|
|
|
* output-buffer-local coordinates.
|
2019-04-25 18:49:59 +02:00
|
|
|
*
|
|
|
|
* The buffer damage region accumulates all damage since the buffer has last
|
|
|
|
* been swapped. This is not to be confused with the output surface damage,
|
|
|
|
* which only contains the changes between two frames.
|
2018-02-11 13:04:00 +01:00
|
|
|
*/
|
2019-04-23 19:16:08 +02:00
|
|
|
bool wlr_output_damage_attach_render(struct wlr_output_damage *output_damage,
|
2019-04-25 18:49:59 +02:00
|
|
|
bool *needs_frame, pixman_region32_t *buffer_damage);
|
2018-02-11 13:04:00 +01:00
|
|
|
/**
|
|
|
|
* Accumulates damage and schedules a `frame` event.
|
|
|
|
*/
|
2018-02-11 12:49:30 +01:00
|
|
|
void wlr_output_damage_add(struct wlr_output_damage *output_damage,
|
2022-10-24 12:58:23 +02:00
|
|
|
const pixman_region32_t *damage);
|
2018-02-11 13:04:00 +01:00
|
|
|
/**
|
|
|
|
* Damages the whole output and schedules a `frame` event.
|
|
|
|
*/
|
2018-02-11 12:49:30 +01:00
|
|
|
void wlr_output_damage_add_whole(struct wlr_output_damage *output_damage);
|
2018-02-11 13:04:00 +01:00
|
|
|
/**
|
|
|
|
* Accumulates damage from a box and schedules a `frame` event.
|
|
|
|
*/
|
2018-02-11 12:49:30 +01:00
|
|
|
void wlr_output_damage_add_box(struct wlr_output_damage *output_damage,
|
|
|
|
struct wlr_box *box);
|
|
|
|
|
|
|
|
#endif
|