From 93dde245ee52ceed374eefca7f8b20ad08be7cfa Mon Sep 17 00:00:00 2001 From: Ankit Nautiyal Date: Mon, 8 Jul 2019 11:46:42 +0530 Subject: [PATCH] libweston: Add functions to modify disable_planes counter for an output The member disable_planes of weston_output signifies the recording status of the output, and is incremented and decremented from various places. This patch provides helper functions to increment and decrement the counter. These functions can then be used to do processing, before and after the recording has started or stopped. Signed-off-by: Ankit Nautiyal --- compositor/screen-share.c | 4 ++-- libweston/backend-drm/drm.c | 4 ++-- libweston/compositor.c | 12 ++++++++++++ libweston/libweston-internal.h | 8 ++++++++ libweston/screenshooter.c | 8 ++++---- libweston/zoom.c | 4 ++-- tests/weston-test.c | 4 ++-- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/compositor/screen-share.c b/compositor/screen-share.c index d3f115ec..a5d6fbcf 100644 --- a/compositor/screen-share.c +++ b/compositor/screen-share.c @@ -1010,7 +1010,7 @@ shared_output_create(struct weston_output *output, int parent_fd) so->frame_listener.notify = shared_output_repainted; wl_signal_add(&output->frame_signal, &so->frame_listener); - output->disable_planes++; + weston_output_disable_planes_incr(output); weston_output_damage(output); return so; @@ -1031,7 +1031,7 @@ shared_output_destroy(struct shared_output *so) { struct ss_shm_buffer *buffer, *bnext; - so->output->disable_planes--; + weston_output_disable_planes_decr(so->output); wl_list_for_each_safe(buffer, bnext, &so->shm.buffers, link) ss_shm_buffer_destroy(buffer); diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 57c3c057..ebb56c40 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -2942,7 +2942,7 @@ recorder_destroy(struct drm_output *output) vaapi_recorder_destroy(output->recorder); output->recorder = NULL; - output->base.disable_planes--; + weston_output_disable_planes_decr(&output->base); wl_list_remove(&output->recorder_frame_listener.link); weston_log("[libva recorder] done\n"); @@ -3024,7 +3024,7 @@ recorder_binding(struct weston_keyboard *keyboard, const struct timespec *time, return; } - output->base.disable_planes++; + weston_output_disable_planes_incr(&output->base); output->recorder_frame_listener.notify = recorder_frame_notify; wl_signal_add(&output->base.frame_signal, diff --git a/libweston/compositor.c b/libweston/compositor.c index 85327159..3f5d0966 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -7752,3 +7752,15 @@ weston_buffer_send_server_error(struct weston_buffer *buffer, "server error with " "wl_buffer@%u: %s", id, msg); } + +WL_EXPORT void +weston_output_disable_planes_incr(struct weston_output *output) +{ + output->disable_planes++; +} + +WL_EXPORT void +weston_output_disable_planes_decr(struct weston_output *output) +{ + output->disable_planes--; +} diff --git a/libweston/libweston-internal.h b/libweston/libweston-internal.h index 0f10a43f..c804120b 100644 --- a/libweston/libweston-internal.h +++ b/libweston/libweston-internal.h @@ -148,6 +148,14 @@ weston_compositor_xkb_destroy(struct weston_compositor *ec); int weston_input_init(struct weston_compositor *compositor); +/* weston_output */ + +void +weston_output_disable_planes_incr(struct weston_output *output); + +void +weston_output_disable_planes_decr(struct weston_output *output); + /* weston_plane */ void diff --git a/libweston/screenshooter.c b/libweston/screenshooter.c index 8952b397..e741d48f 100644 --- a/libweston/screenshooter.c +++ b/libweston/screenshooter.c @@ -124,7 +124,7 @@ screenshooter_frame_notify(struct wl_listener *listener, void *data) int32_t stride; uint8_t *pixels, *d, *s; - output->disable_planes--; + weston_output_disable_planes_decr(output); wl_list_remove(&listener->link); stride = l->buffer->width * (PIXMAN_FORMAT_BPP(compositor->read_format) / 8); pixels = malloc(stride * l->buffer->height); @@ -206,7 +206,7 @@ weston_screenshooter_shoot(struct weston_output *output, l->data = data; l->listener.notify = screenshooter_frame_notify; wl_signal_add(&output->frame_signal, &l->listener); - output->disable_planes++; + weston_output_disable_planes_incr(output); weston_output_damage(output); return 0; @@ -445,7 +445,7 @@ weston_recorder_create(struct weston_output *output, const char *filename) recorder->frame_listener.notify = weston_recorder_frame_notify; wl_signal_add(&output->frame_signal, &recorder->frame_listener); - output->disable_planes++; + weston_output_disable_planes_incr(output); weston_output_damage(output); return recorder; @@ -460,7 +460,7 @@ weston_recorder_destroy(struct weston_recorder *recorder) { wl_list_remove(&recorder->frame_listener.link); close(recorder->fd); - recorder->output->disable_planes--; + weston_output_disable_planes_decr(recorder->output); weston_recorder_free(recorder); } diff --git a/libweston/zoom.c b/libweston/zoom.c index 87e98e8a..064d6a84 100644 --- a/libweston/zoom.c +++ b/libweston/zoom.c @@ -55,7 +55,7 @@ weston_zoom_frame_z(struct weston_animation *animation, if (output->zoom.active && output->zoom.level <= 0.0) { output->zoom.active = false; output->zoom.seat = NULL; - output->disable_planes--; + weston_output_disable_planes_decr(output); wl_list_remove(&output->zoom.motion_listener.link); } output->zoom.spring_z.current = output->zoom.level; @@ -161,7 +161,7 @@ weston_output_activate_zoom(struct weston_output *output, output->zoom.active = true; output->zoom.seat = seat; - output->disable_planes++; + weston_output_disable_planes_incr(output); wl_signal_add(&pointer->motion_signal, &output->zoom.motion_listener); } diff --git a/tests/weston-test.c b/tests/weston-test.c index d58bcdbe..38505f0b 100644 --- a/tests/weston-test.c +++ b/tests/weston-test.c @@ -443,7 +443,7 @@ test_screenshot_frame_notify(struct wl_listener *listener, void *data) int32_t stride; uint8_t *pixels, *d, *s; - output->disable_planes--; + weston_output_disable_planes_decr(output); wl_list_remove(&listener->link); stride = l->buffer->width * (PIXMAN_FORMAT_BPP(compositor->read_format) / 8); pixels = malloc(stride * l->buffer->height); @@ -539,7 +539,7 @@ weston_test_screenshot_shoot(struct weston_output *output, wl_signal_add(&output->frame_signal, &l->listener); /* Fire off a repaint */ - output->disable_planes++; + weston_output_disable_planes_incr(output); weston_output_schedule_repaint(output); return true;