forked from swaywm/wlroots
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
surface-damage: add a helper to track surface damage
One remaining major pain point when implementing damage tracking is tracking damage from surfaces and all of their children. Compositors need to add new listeners for each view child type, with the appropriate new data structures. This commit adds a new helper to ease damage tracking: wlr_surface_damage. It tracks damage from a surface and all its children and reports it via a "damage" event in surface-local coordinates. This way, compositors just need to add one listener for the whole view. There is one function per shell to create a wlr_surface_damage, just like other helpers like wlr_surface_for_each_surface. Additional functions are provided to allow compositors to manually damage surfaces. wlr_surface_damage_add_whole will damage the whole surface and all its children, this is useful when moving a view. Of course, this helper is optional, and damage tracking done entirely in the compositor will still work. Fixes swaywm#1543
- Loading branch information
Showing
12 changed files
with
482 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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 | ||
|
||
#ifndef WLR_TYPES_WLR_SURFACE_DAMAGE_H | ||
#define WLR_TYPES_WLR_SURFACE_DAMAGE_H | ||
|
||
#include <pixman.h> | ||
#include <wayland-server.h> | ||
#include <wlr/types/wlr_surface.h> | ||
|
||
struct wlr_surface_damage; | ||
|
||
struct wlr_surface_damage_interface { | ||
void (*destroy)(struct wlr_surface_damage *surface_damage); | ||
void (*add_children)(struct wlr_surface_damage *surface_damage); | ||
}; | ||
|
||
void wlr_surface_damage_init(struct wlr_surface_damage *surface_damage, | ||
struct wlr_surface *surface, | ||
const struct wlr_surface_damage_interface *impl); | ||
void wlr_surface_damage_add(struct wlr_surface_damage *surface_damage, | ||
int32_t sx, int32_t sy, pixman_region32_t *damage); | ||
|
||
/** | ||
* Tracks damage coming from a surface and its children. | ||
* | ||
* When a surface maps, unmaps or commits, the `damage` event will be emitted. | ||
*/ | ||
struct wlr_surface_damage { | ||
struct wlr_surface *surface; | ||
const struct wlr_surface_damage_interface *impl; | ||
|
||
struct { | ||
struct wl_signal destroy; | ||
struct wl_signal damage; // wlr_surface_damage_event | ||
} events; | ||
|
||
struct wl_list subsurfaces; | ||
|
||
struct wl_listener surface_destroy; | ||
struct wl_listener surface_commit; | ||
struct wl_listener surface_new_subsurface; | ||
|
||
void *data; | ||
}; | ||
|
||
struct wlr_surface_damage_event { | ||
struct wlr_surface_damage *surface_damage; | ||
int32_t sx, sy; | ||
pixman_region32_t *damage; | ||
}; | ||
|
||
/** | ||
* Tracks damage from a surface and its children subsurfaces. | ||
*/ | ||
struct wlr_surface_damage *wlr_surface_damage_create( | ||
struct wlr_surface *surface); | ||
void wlr_surface_damage_destroy(struct wlr_surface_damage *surface_damage); | ||
/** | ||
* Damage the whole surface and all its children. | ||
*/ | ||
void wlr_surface_damage_add_whole(struct wlr_surface_damage *surface_damage); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.