Make backends always specify output repaint time

Most backends relies on gettimeofday(2) for output repaint timestamps
but this is not a requirement. Before this patch repaints coming from
idle_repaint() always used gettimeofday(2) for timestamps. For backends
not using that time source this could cause large jumps between
timestamps.

To fix this, timestamps needs to always come from the backend. This
means that the backend needs to always be responsible of starting the
repaint loop in case that the repaint cannot start immediately.

The drm backend implementation is from the patch by Ander Conselvan de
Oliveira found here:
http://lists.freedesktop.org/archives/wayland-devel/2013-February/007393.html

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index a95c1fb..eb6e58b 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -326,6 +326,17 @@
 }
 
 static void
+x11_output_start_repaint_loop(struct weston_output *output)
+{
+	uint32_t msec;
+	struct timeval tv;
+
+	gettimeofday(&tv, NULL);
+	msec = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+	weston_output_finish_frame(output, msec);
+}
+
+static void
 x11_output_repaint_gl(struct weston_output *output_base,
 		      pixman_region32_t *damage)
 {
@@ -376,12 +387,8 @@
 finish_frame_handler(void *data)
 {
 	struct x11_output *output = data;
-	uint32_t msec;
-	struct timeval tv;
-	
-	gettimeofday(&tv, NULL);
-	msec = tv.tv_sec * 1000 + tv.tv_usec / 1000;
-	weston_output_finish_frame(&output->base, msec);
+
+	x11_output_start_repaint_loop(&output->base);
 
 	return 1;
 }
@@ -773,6 +780,7 @@
 		x11_output_wait_for_map(c, output);
 
 	output->base.origin = output->base.current;
+	output->base.start_repaint_loop = x11_output_start_repaint_loop;
 	if (c->use_pixman)
 		output->base.repaint = x11_output_repaint_shm;
 	else