compositor: ignore views on other outputs during compositor_accumulate_damage()

compositor_accumulate_damage() is called for each output during repaint.
The DRM backend will only set keep_buffer for the surfaces that are visible on
the current output. So a buffer_ref is released that may still be needed. When
the output that shows the surface is repainted, the buffer_ref is gone and the
surface cannot be put on a plane.

Ignore all surfaces that are not visible on the current output to avoid this.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
diff --git a/libweston/compositor.c b/libweston/compositor.c
index a864d5a..57b2203 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -2491,8 +2491,9 @@
 }
 
 static void
-compositor_accumulate_damage(struct weston_compositor *ec)
+output_accumulate_damage(struct weston_output *output)
 {
+	struct weston_compositor *ec = output->compositor;
 	struct weston_plane *plane;
 	struct weston_view *ev;
 	pixman_region32_t opaque, clip;
@@ -2521,6 +2522,9 @@
 		ev->surface->touched = false;
 
 	wl_list_for_each(ev, &ec->view_list, link) {
+		/* Ignore views not visible on the current output */
+		if (!(ev->output_mask & (1u << output->id)))
+			continue;
 		if (ev->surface->touched)
 			continue;
 		ev->surface->touched = true;
@@ -2763,7 +2767,7 @@
 		}
 	}
 
-	compositor_accumulate_damage(ec);
+	output_accumulate_damage(output);
 
 	pixman_region32_init(&output_damage);
 	pixman_region32_intersect(&output_damage,