compositor: add repaint delay timer
This timer delays the output_repaint towards the end of the refresh
period, reducing the time from repaint to present.
The length of the repaint window can be set in weston.ini.
The call to weston_output_schedule_repaint_reset() is delayed by one
more period. If we exit the continuous repaint loop (set
output->repaint_scheduled to false) in finish_frame, we may call
start_repaint_loop() unnecessarily. The problem case was actually
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. This code now avoids the
problem.
Changes in v2:
- Rename repaint_delay_timer to repaint_timer and
output_repaint_delay_handler to output_repaint_timer_handler.
- When computing the delay, take the current time into account. The timer
uses a relative timeout, so we have to subtract any time already gone.
Note, that 'gone' may also be negative. DRM has a habit of predicting
the page flip timestamp so it may be still in the future when we get the
completion event.
- Do also a sanity check 'msec > 1000'. In the unlikely case that
something fails to provide a good timestamp, never delay for more than
one second.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
diff --git a/src/compositor.h b/src/compositor.h
index a05b208..24ed4fc 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -196,6 +196,7 @@
pixman_region32_t previous_damage;
int repaint_needed;
int repaint_scheduled;
+ struct wl_event_source *repaint_timer;
struct weston_output_zoom zoom;
int dirty;
struct wl_signal frame_signal;
@@ -683,6 +684,7 @@
int32_t kb_repeat_delay;
clockid_t presentation_clock;
+ int32_t repaint_msec;
int exit_code;
};