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.
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index bcd8aac..33bffae 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -732,6 +732,7 @@
 	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 @@
 {
 	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 @@
 	 * 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 fe595e6..5be5789 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1148,14 +1148,12 @@
 		}
 	}
 
-	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 5cc45da..ea6d82f 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -165,6 +165,7 @@
 	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 aa8d0c0..ba80ce5 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -101,6 +101,7 @@
 	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 @@
 
 	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 @@
 }
 
 struct weston_recorder {
+	struct weston_output *output;
 	uint32_t *frame, *rect;
 	uint32_t total;
 	int fd;
@@ -346,6 +349,7 @@
 	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 @@
 
 	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 @@
 	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 545689c..6168a8e 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2166,8 +2166,10 @@
 				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 abb6f4e..b9db926 100644
--- a/src/zoom.c
+++ b/src/zoom.c
@@ -123,8 +123,10 @@
 		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);