Introduce wlr_output_damage

This commit is contained in:
emersion 2018-02-11 12:49:30 +01:00
parent 664d7bfe4e
commit ec837e3c9e
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
5 changed files with 230 additions and 97 deletions

View file

@ -4,13 +4,7 @@
#include <time.h>
#include <pixman.h>
#include <wayland-server.h>
/**
* 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 ROOTS_OUTPUT_PREVIOUS_DAMAGE_LEN 2
#include <wlr/types/wlr_output_damage.h>
struct roots_desktop;
@ -22,15 +16,9 @@ struct roots_output {
struct roots_view *fullscreen_view;
struct timespec last_frame;
pixman_region32_t damage; // in ouput-local coordinates
// circular queue for previous damage
pixman_region32_t previous_damage[ROOTS_OUTPUT_PREVIOUS_DAMAGE_LEN];
size_t previous_damage_idx;
struct wlr_output_damage *damage;
struct wl_listener frame;
struct wl_listener mode;
struct wl_listener needs_swap;
};
void output_add_notify(struct wl_listener *listener, void *data);

View file

@ -0,0 +1,45 @@
#ifndef WLR_TYPES_WLR_OUTPUT_DAMAGE_H
#define WLR_TYPES_WLR_OUTPUT_DAMAGE_H
#include <pixman.h>
/**
* 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
struct wlr_output_damage {
struct wlr_output *output;
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;
struct wl_listener output_mode;
struct wl_listener output_needs_swap;
struct wl_listener output_frame;
};
struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output);
void wlr_output_damage_destroy(struct wlr_output_damage *output_damage);
bool wlr_output_damage_make_current(struct wlr_output_damage *output_damage,
bool *needs_swap, pixman_region32_t *damage);
bool wlr_output_damage_swap_buffers(struct wlr_output_damage *output_damage,
struct timespec *when, pixman_region32_t *damage);
void wlr_output_damage_add(struct wlr_output_damage *output_damage,
pixman_region32_t *damage);
void wlr_output_damage_add_whole(struct wlr_output_damage *output_damage);
void wlr_output_damage_add_box(struct wlr_output_damage *output_damage,
struct wlr_box *box);
#endif