[PATCH weston 5/5] compositor: delay also exiting the continuous repaint loop

Pekka Paalanen ppaalanen at gmail.com
Thu Feb 12 05:30:17 PST 2015


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

If we exit the continuous repaint loop (set output->repaint_scheduled to
false) in finish_frame, we may call start_repaint_loop() unnecessarily.

This was observed with two outputs on the DRM backend at 60 Hz, and 7 ms
repaint-window. During a window move, one output was constantly falling
off the continuous repaint loop and introducing additional one frame
latency, leading to jerky window motion.

Fix this by exiting the continuous repaint loop only when about to call
weston_output_repaint(), instead of in finish_frame. That should keep
the continuous repaint loop active.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 src/compositor.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index aed6893..2632394 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2143,7 +2143,8 @@ output_repaint_delay_handler(void *data)
 	struct weston_output *output = data;
 	struct weston_compositor *compositor = output->compositor;
 
-	if (compositor->state != WESTON_COMPOSITOR_SLEEPING &&
+	if (output->repaint_needed &&
+	    compositor->state != WESTON_COMPOSITOR_SLEEPING &&
 	    compositor->state != WESTON_COMPOSITOR_OFFSCREEN &&
 	    weston_output_repaint(output) == 0)
 		return 0;
@@ -2160,6 +2161,7 @@ weston_output_finish_frame(struct weston_output *output,
 {
 	struct weston_compositor *compositor = output->compositor;
 	uint32_t refresh_nsec;
+	int msec;
 
 	TL_POINT("core_repaint_finished", TLP_OUTPUT(output),
 		 TLP_VBLANK(stamp), TLP_END);
@@ -2172,20 +2174,13 @@ weston_output_finish_frame(struct weston_output *output,
 
 	output->frame_time = stamp->tv_sec * 1000 + stamp->tv_nsec / 1000000;
 
-	if (output->repaint_needed &&
-	    compositor->state != WESTON_COMPOSITOR_SLEEPING &&
-	    compositor->state != WESTON_COMPOSITOR_OFFSCREEN) {
-		int msec = refresh_nsec / 1000000;
-
-		msec -= compositor->repaint_msec;
-		if (msec < 1)
-			output_repaint_delay_handler(output);
-		else
-			wl_event_source_timer_update(output->repaint_delay_timer, msec);
-		return;
-	}
-
-	weston_output_schedule_repaint_reset(output);
+	msec = refresh_nsec / 1000000;
+	msec -= compositor->repaint_msec;
+	if (msec < 1)
+		output_repaint_delay_handler(output);
+	else
+		wl_event_source_timer_update(output->repaint_delay_timer,
+					     msec);
 }
 
 static void
-- 
2.0.5



More information about the wayland-devel mailing list