mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-26 07:55:58 +01:00
Change refresh logic and add tests in wlr_screencast.c
This commit is contained in:
parent
9d4193e5b2
commit
f23e9e4921
1 changed files with 14 additions and 3 deletions
|
@ -106,13 +106,13 @@ 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;
|
||||||
if (cast->simple_frame.buffer == NULL || cast->simple_frame.data == NULL || cast->simple_frame.width != width || cast->simple_frame.height != height || cast->simple_frame.stride != stride || cast->simple_frame.format != format) {
|
if (cast->simple_frame.width != width || cast->simple_frame.height != height || cast->simple_frame.stride != stride || cast->simple_frame.format != format) {
|
||||||
logprint(TRACE, "wlroots: buffer properties changed");
|
logprint(TRACE, "wlroots: buffer properties changed");
|
||||||
if (cast->simple_frame.data != NULL) {
|
if (cast->simple_frame.data != NULL) {
|
||||||
munmap(cast->simple_frame.data, cast->simple_frame.size);
|
munmap(cast->simple_frame.data, cast->simple_frame.size);
|
||||||
cast->simple_frame.data = NULL;
|
cast->simple_frame.data = NULL;
|
||||||
}
|
}
|
||||||
if (cast->simple_frame.data != NULL) {
|
if (cast->simple_frame.buffer != 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;
|
||||||
}
|
}
|
||||||
|
@ -121,8 +121,14 @@ static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,
|
||||||
cast->simple_frame.stride = stride;
|
cast->simple_frame.stride = stride;
|
||||||
cast->simple_frame.size = stride * height;
|
cast->simple_frame.size = stride * height;
|
||||||
cast->simple_frame.format = format;
|
cast->simple_frame.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cast->simple_frame.buffer == NULL && cast->simple_frame.data == NULL) {
|
||||||
|
logprint(DEBUG, "wlroots: create shm buffer");
|
||||||
cast->simple_frame.buffer = create_shm_buffer(cast, format, width, height,
|
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?
|
stride, &cast->simple_frame.data);
|
||||||
|
} else {
|
||||||
|
logprint(DEBUG,"wlroots: shm buffer or data exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cast->simple_frame.buffer == NULL) {
|
if (cast->simple_frame.buffer == NULL) {
|
||||||
|
@ -130,6 +136,11 @@ static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cast->simple_frame.data == NULL) {
|
||||||
|
logprint(ERROR, "wlroots: failed to map data");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
zwlr_screencopy_frame_v1_copy_with_damage(frame, cast->simple_frame.buffer);
|
zwlr_screencopy_frame_v1_copy_with_damage(frame, cast->simple_frame.buffer);
|
||||||
logprint(TRACE, "wlroots: frame copied");
|
logprint(TRACE, "wlroots: frame copied");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue