Merge branch 'sunli1/wlroots-output_layers_v3' into 'master'

wlr_scene: Implement Output Layers

See merge request wlroots/wlroots!4348
This commit is contained in:
Leo Li 2023-10-30 06:13:22 +00:00
commit 51e76f9000
6 changed files with 581 additions and 66 deletions

View file

@ -15,4 +15,15 @@ void array_remove_at(struct wl_array *arr, size_t offset, size_t size);
*/
bool array_realloc(struct wl_array *arr, size_t size);
/**
* Returns a pointer to the first valid element in a reversed array.
*/
void *array_reversed_start(struct wl_array *arr);
/**
* Adds a new element to the array inserting them starting from a higher
* memory address effectively inserting them in reverse order.
*/
void *array_reversed_add(struct wl_array *arr, size_t size);
#endif

View file

@ -13,11 +13,20 @@
#include <stddef.h>
#include <stdint.h>
#include <pixman.h>
/* For triple buffering, a history of two frames is required. */
#define WLR_DAMAGE_RING_PREVIOUS_LEN 2
#include <wayland-server-core.h>
struct wlr_box;
struct wlr_buffer;
struct wlr_damage_ring_entry {
pixman_region32_t damage;
struct wlr_buffer *buffer;
struct wl_listener buffer_destroy;
struct wlr_damage_ring *ring;
struct wl_list link; // struct wlr_damage_ring.previous
};
struct wlr_damage_ring {
int32_t width, height;
@ -27,8 +36,7 @@ struct wlr_damage_ring {
// private state
pixman_region32_t previous[WLR_DAMAGE_RING_PREVIOUS_LEN];
size_t previous_idx;
struct wl_list previous; // struct wlr_damage_ring_entry.link
};
void wlr_damage_ring_init(struct wlr_damage_ring *ring);
@ -81,4 +89,14 @@ void wlr_damage_ring_rotate(struct wlr_damage_ring *ring);
void wlr_damage_ring_get_buffer_damage(struct wlr_damage_ring *ring,
int buffer_age, pixman_region32_t *damage);
/**
* Get the since accumulated damage for this buffer. These buffers should
* typically come from a wlr_swapchain. In the context of rendering, the
* damage is the region that needs to be redrawn.
*
* The damage ring is automatically rotated during invocation.
*/
void wlr_damage_ring_damage_for_buffer(struct wlr_damage_ring *ring,
struct wlr_buffer *buffer, pixman_region32_t *damage);
#endif

View file

@ -110,6 +110,8 @@ struct wlr_scene {
enum wlr_scene_debug_damage_option debug_damage_option;
bool direct_scanout;
bool calculate_visibility;
struct wl_array render_list;
};
/** A scene-graph node displaying a single surface. */
@ -204,6 +206,8 @@ struct wlr_scene_output {
// private state
pixman_region32_t pending_commit_damage;
uint8_t index;
bool prev_scanout;
@ -213,7 +217,7 @@ struct wlr_scene_output {
struct wl_list damage_highlight_regions;
struct wl_array render_list;
struct wl_array output_layers;
};
struct wlr_scene_timer {