From 79af73e313c732ff9e5bb997a617d0a172844284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 3 Aug 2012 15:45:23 -0400 Subject: [PATCH] compositor-drm: Disable planes when zoomed or capturing When the entire output is transformed or we're capturing the output for screenshot or video, disable all output specific overlays (drm planes, hw cursors etc) and move all surfaces into the primary plane. --- src/compositor-drm.c | 3 +-- src/compositor.c | 12 +++++------- src/compositor.h | 1 + src/screenshooter.c | 6 ++++++ src/shell.c | 4 +++- src/zoom.c | 4 +++- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index bcd8aacb..33bffae4 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -732,6 +732,7 @@ drm_output_set_cursor(struct drm_output *output) unsigned char *s; int i, x, y; + output->cursor_surface = NULL; if (es == NULL) { drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0); return; @@ -773,7 +774,6 @@ drm_assign_planes(struct weston_output *output) { struct drm_compositor *c = (struct drm_compositor *) output->compositor; - struct drm_output *drm_output = (struct drm_output *) output; struct weston_surface *es, *next; pixman_region32_t overlap, surface_overlap; struct weston_plane *primary, *next_plane; @@ -792,7 +792,6 @@ drm_assign_planes(struct weston_output *output) * as we do for flipping full screen surfaces. */ pixman_region32_init(&overlap); - drm_output->cursor_surface = NULL; primary = &c->base.primary_plane; wl_list_for_each_safe(es, next, &c->base.surface_list, link) { pixman_region32_init(&surface_overlap); diff --git a/src/compositor.c b/src/compositor.c index fe595e6a..5be57892 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1148,14 +1148,12 @@ weston_output_repaint(struct weston_output *output, uint32_t msecs) } } - if (output->assign_planes) - /* - * This will queue flips for the fbs and sprites where - * applicable and clear the damage for those surfaces. - * The repaint loop below will repaint everything - * else. - */ + if (output->assign_planes && !output->disable_planes) output->assign_planes(output); + else + wl_list_for_each(es, &ec->surface_list, link) + weston_surface_move_to_plane(es, &ec->primary_plane); + pixman_region32_init(&opaque); diff --git a/src/compositor.h b/src/compositor.h index 5cc45daf..ea6d82f7 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -165,6 +165,7 @@ struct weston_output { int dirty; struct wl_signal frame_signal; uint32_t frame_time; + int disable_planes; char *make, *model; uint32_t subpixel; diff --git a/src/screenshooter.c b/src/screenshooter.c index aa8d0c06..ba80ce55 100644 --- a/src/screenshooter.c +++ b/src/screenshooter.c @@ -101,6 +101,7 @@ screenshooter_frame_notify(struct wl_listener *listener, void *data) int32_t stride; uint8_t *pixels, *d, *s; + output->disable_planes--; wl_list_remove(&listener->link); stride = l->buffer->width * 4; pixels = malloc(stride * l->buffer->height); @@ -165,6 +166,7 @@ screenshooter_shoot(struct wl_client *client, l->listener.notify = screenshooter_frame_notify; wl_signal_add(&output->frame_signal, &l->listener); + output->disable_planes++; weston_output_schedule_repaint(output); } @@ -212,6 +214,7 @@ screenshooter_binding(struct wl_seat *seat, uint32_t time, uint32_t key, } struct weston_recorder { + struct weston_output *output; uint32_t *frame, *rect; uint32_t total; int fd; @@ -346,6 +349,7 @@ weston_recorder_create(struct weston_output *output, const char *filename) recorder->rect = malloc(size); recorder->total = 0; recorder->count = 0; + recorder->output = output; memset(recorder->frame, 0, size); recorder->fd = open(filename, @@ -368,6 +372,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_damage(output); } @@ -378,6 +383,7 @@ weston_recorder_destroy(struct weston_recorder *recorder) close(recorder->fd); free(recorder->frame); free(recorder->rect); + recorder->output->disable_planes--; free(recorder); } diff --git a/src/shell.c b/src/shell.c index 545689c4..6168a8e0 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2166,8 +2166,10 @@ do_zoom(struct wl_seat *seat, uint32_t time, uint32_t key, uint32_t axis, output->zoom.level = 0.0; else if (output->zoom.level > output->zoom.max_level) output->zoom.level = output->zoom.max_level; - else + else { output->zoom.active = 1; + output->disable_planes++; + } output->zoom.spring_z.target = output->zoom.level; diff --git a/src/zoom.c b/src/zoom.c index abb6f4ec..b9db9263 100644 --- a/src/zoom.c +++ b/src/zoom.c @@ -123,8 +123,10 @@ weston_zoom_frame_z(struct weston_animation *animation, output->zoom.spring_z.current = 0.0; if (weston_spring_done(&output->zoom.spring_z)) { - if (output->zoom.level <= 0.0) + if (output->zoom.level <= 0.0) { output->zoom.active = 0; + output->disable_planes--; + } output->zoom.spring_z.current = output->zoom.level; wl_list_remove(&animation->link); wl_list_init(&animation->link);