mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-25 23:45:58 +01:00
Only recreate simple_frame on change in wlr_screencast.c
This commit is contained in:
parent
e57beee43d
commit
4c20660f74
1 changed files with 14 additions and 9 deletions
|
@ -22,10 +22,10 @@
|
||||||
void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) {
|
void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) {
|
||||||
zwlr_screencopy_frame_v1_destroy(cast->wlr_frame);
|
zwlr_screencopy_frame_v1_destroy(cast->wlr_frame);
|
||||||
cast->wlr_frame = NULL;
|
cast->wlr_frame = NULL;
|
||||||
munmap(cast->simple_frame.data, cast->simple_frame.size);
|
|
||||||
cast->simple_frame.data = NULL;
|
|
||||||
// TODO: reuse this buffer unless we quit or error out
|
// TODO: reuse this buffer unless we quit or error out
|
||||||
if (cast->quit || cast->err) {
|
if (cast->quit || cast->err) {
|
||||||
|
munmap(cast->simple_frame.data, cast->simple_frame.size);
|
||||||
|
cast->simple_frame.data = NULL;
|
||||||
wl_buffer_destroy(cast->simple_frame.buffer);
|
wl_buffer_destroy(cast->simple_frame.buffer);
|
||||||
cast->simple_frame.buffer = NULL;
|
cast->simple_frame.buffer = NULL;
|
||||||
logprint(TRACE, "wlroots: frame destroyed");
|
logprint(TRACE, "wlroots: frame destroyed");
|
||||||
|
@ -105,13 +105,18 @@ static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,
|
||||||
|
|
||||||
logprint(TRACE, "wlroots: buffer event handler");
|
logprint(TRACE, "wlroots: buffer event handler");
|
||||||
cast->wlr_frame = frame;
|
cast->wlr_frame = frame;
|
||||||
cast->simple_frame.width = width;
|
if (cast->simple_frame.buffer == NULL || cast->simple_frame.width != width || cast->simple_frame.height != height || cast->simple_frame.stride != stride || cast->simple_frame.format != format) {
|
||||||
cast->simple_frame.height = height;
|
logprint(TRACE, "wlroots: buffer properties changed");
|
||||||
cast->simple_frame.stride = stride;
|
munmap(cast->simple_frame.data, cast->simple_frame.size);
|
||||||
cast->simple_frame.size = stride * height;
|
cast->simple_frame.data = NULL;
|
||||||
cast->simple_frame.format = format;
|
cast->simple_frame.width = width;
|
||||||
cast->simple_frame.buffer = create_shm_buffer(cast, format, width, height,
|
cast->simple_frame.height = height;
|
||||||
stride, &cast->simple_frame.data);
|
cast->simple_frame.stride = stride;
|
||||||
|
cast->simple_frame.size = stride * height;
|
||||||
|
cast->simple_frame.format = format;
|
||||||
|
cast->simple_frame.buffer = create_shm_buffer(cast, format, width, height,
|
||||||
|
stride, &cast->simple_frame.data); //What happens, with simple_frame buffer? Does it get cleaned up? Detect change?
|
||||||
|
}
|
||||||
|
|
||||||
if (cast->simple_frame.buffer == NULL) {
|
if (cast->simple_frame.buffer == NULL) {
|
||||||
logprint(ERROR, "wlroots: failed to create buffer");
|
logprint(ERROR, "wlroots: failed to create buffer");
|
||||||
|
|
Loading…
Reference in a new issue