Switch to global output repaint timer

In preparation for grouping output repaint together where possible,
switch the per-output repaint timer, to a global timer which iterates
across all outputs.

This is implemented by storing the absolute time for the next repaint
for each output locally, and maintaining a global timer which iterates
all of them, scheduling the repaint for the first available time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Pekka: The comment about 1 ms delay.]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 5fc25c4..9e7ac99 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -183,7 +183,10 @@
 		REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */
 	} repaint_status;
 
-	struct wl_event_source *repaint_timer;
+	/** If repaint_status is REPAINT_SCHEDULED, contains the time the
+	 *  next repaint should be run */
+	struct timespec next_repaint;
+
 	struct weston_output_zoom zoom;
 	int dirty;
 	struct wl_signal frame_signal;
@@ -856,6 +859,7 @@
 	struct wl_event_source *idle_source;
 	uint32_t idle_inhibit;
 	int idle_time;			/* timeout, s */
+	struct wl_event_source *repaint_timer;
 
 	const struct weston_pointer_grab_interface *default_pointer_grab;