Change refresh logic and add tests in wlr_screencast.c

This commit is contained in:
columbarius 2020-08-04 18:51:09 +02:00 committed by Simon Ser
parent 9d4193e5b2
commit f23e9e4921
1 changed files with 14 additions and 3 deletions

View File

@ -106,13 +106,13 @@ static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,
logprint(TRACE, "wlroots: buffer event handler");
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");
if (cast->simple_frame.data != NULL) {
munmap(cast->simple_frame.data, cast->simple_frame.size);
cast->simple_frame.data = NULL;
}
if (cast->simple_frame.data != NULL) {
if (cast->simple_frame.buffer != NULL) {
wl_buffer_destroy(cast->simple_frame.buffer);
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.size = stride * height;
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,
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) {
@ -130,6 +136,11 @@ static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,
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);
logprint(TRACE, "wlroots: frame copied");
}