[PATCH weston 2/6] compositors: Wrap clock_gettime() usage

Bryce Harrington bryce at osg.samsung.com
Fri Dec 19 12:29:07 PST 2014


On Fri, Dec 19, 2014 at 12:45:46PM -0600, Derek Foreman wrote:
> In preparation for a future patch which allows test clients to control
> the presentation clock, we wrap any clock_gettime() of the presentation
> clock in weston_compositor_presentation_clock_gettime().
> 
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
>  src/compositor-drm.c      |  2 +-
>  src/compositor-fbdev.c    |  2 +-
>  src/compositor-headless.c |  2 +-
>  src/compositor-rdp.c      |  2 +-
>  src/compositor-x11.c      |  2 +-
>  src/compositor.c          | 12 ++++++++++++
>  src/compositor.h          |  5 +++++
>  7 files changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 9b4d4dc..9c9a9e2 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -721,7 +721,7 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
>  
>  finish_frame:
>  	/* if we cannot page-flip, immediately finish frame */
> -	clock_gettime(compositor->base.presentation_clock, &ts);
> +	weston_compositor_presentation_clock_gettime(&compositor->base, &ts);
>  	weston_output_finish_frame(output_base, &ts);
>  }
>  
> diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
> index 65bb035..514ec83 100644
> --- a/src/compositor-fbdev.c
> +++ b/src/compositor-fbdev.c
> @@ -116,7 +116,7 @@ fbdev_output_start_repaint_loop(struct weston_output *output)
>  {
>  	struct timespec ts;
>  
> -	clock_gettime(output->compositor->presentation_clock, &ts);
> +	weston_compositor_presentation_clock_gettime(output->compositor, &ts);
>  	weston_output_finish_frame(output, &ts);
>  }
>  
> diff --git a/src/compositor-headless.c b/src/compositor-headless.c
> index 945c84b..a023e45 100644
> --- a/src/compositor-headless.c
> +++ b/src/compositor-headless.c
> @@ -57,7 +57,7 @@ headless_output_start_repaint_loop(struct weston_output *output)
>  {
>  	struct timespec ts;
>  
> -	clock_gettime(output->compositor->presentation_clock, &ts);
> +	weston_compositor_presentation_clock_gettime(output->compositor, &ts);
>  	weston_output_finish_frame(output, &ts);
>  }
>  
> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> index 2048f8f..e808572 100644
> --- a/src/compositor-rdp.c
> +++ b/src/compositor-rdp.c
> @@ -307,7 +307,7 @@ rdp_output_start_repaint_loop(struct weston_output *output)
>  {
>  	struct timespec ts;
>  
> -	clock_gettime(output->compositor->presentation_clock, &ts);
> +	weston_compositor_presentation_clock_gettime(output->compositor, &ts);
>  	weston_output_finish_frame(output, &ts);
>  }
>  
> diff --git a/src/compositor-x11.c b/src/compositor-x11.c
> index 29f2119..166d61b 100644
> --- a/src/compositor-x11.c
> +++ b/src/compositor-x11.c
> @@ -340,7 +340,7 @@ x11_output_start_repaint_loop(struct weston_output *output)
>  {
>  	struct timespec ts;
>  
> -	clock_gettime(output->compositor->presentation_clock, &ts);
> +	weston_compositor_presentation_clock_gettime(output->compositor, &ts);
>  	weston_output_finish_frame(output, &ts);
>  }
>  
> diff --git a/src/compositor.c b/src/compositor.c
> index 833cf51..6109eb5 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4221,6 +4221,18 @@ weston_compositor_set_default_pointer_grab(struct weston_compositor *ec,
>  }
>  

doxygen comment needed for this.  Basically just needs to explain why
we're wrappering clock_gettime, and the behavior when in test mode.

>  WL_EXPORT int
> +weston_compositor_presentation_clock_gettime(
> +					 struct weston_compositor *compositor,
> +					 struct timespec *ts)

Can compositor be const in the above?

> +{
> +	if (compositor->test_mode) {
> +		*ts = compositor->test_time;
> +		return 0;
> +	}
> +	return clock_gettime(compositor->presentation_clock, ts);
> +}
> +
> +WL_EXPORT int
>  weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
>  					 clockid_t clk_id)
>  {
> diff --git a/src/compositor.h b/src/compositor.h
> index 2b99225..924e354 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -671,6 +671,7 @@ struct weston_compositor {
>  	int exit_code;
>  
>  	bool test_mode;
> +	struct timespec test_time;
>  };
>  
>  struct weston_buffer {
> @@ -1276,6 +1277,10 @@ weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
>  int
>  weston_compositor_set_presentation_clock_software(
>  					struct weston_compositor *compositor);
> +int
> +weston_compositor_presentation_clock_gettime(
> +					 struct weston_compositor *compositor,
> +					 struct timespec *ts);
>  void
>  weston_compositor_shutdown(struct weston_compositor *ec);
>  void
> -- 
> 2.1.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list