[vlc-devel] [PATCH v5 04/24] video_output: translate the mouse coordinates to display coordinates early

Rémi Denis-Courmont remi at remlab.net
Mon Aug 24 16:16:10 CEST 2020


Le maanantaina 24. elokuuta 2020, 10.41.45 EEST Steve Lhomme a écrit :
> We can do this in the UI thread, the processing is light.
> Locking the display_lock doesn't have a big impact on lag as it's only
> taking time when reloading a display module, which is very rare.
> ---
>  src/video_output/video_output.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/src/video_output/video_output.c
> b/src/video_output/video_output.c index 418e8c09032..7adbce19e7d 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -388,7 +388,14 @@ void vout_MouseState(vout_thread_t *vout, const
> vlc_mouse_t *mouse) assert(mouse);
>      vout_control_cmd_t cmd;
>      vout_control_cmd_Init(&cmd, VOUT_CONTROL_MOUSE_STATE);
> -    cmd.mouse = *mouse;
> +
> +    /* Translate window coordinates to video coordinates */
> +    vlc_mutex_lock(&sys->display_lock);
> +    if (sys->display)
> +        vout_display_TranslateMouseState(sys->display, &cmd.mouse, mouse);
> +    else
> +        cmd.mouse = *mouse;
> +    vlc_mutex_unlock(&sys->display_lock);

At some point, we should probably discard the event if there is no display.

>      vout_control_Push(&sys->control, &cmd);
>  }
> @@ -1624,17 +1631,13 @@ void vout_ChangeSpuRate(vout_thread_t *vout, size_t
> channel_id, float rate) static void
> ThreadProcessMouseState(vout_thread_sys_t *p_vout,
>                                      const vlc_mouse_t *win_mouse)
>  {
> -    vlc_mouse_t vid_mouse, tmp1, tmp2, *m;
> +    vlc_mouse_t tmp1, tmp2;
> +    const vlc_mouse_t *m;
>      vout_thread_t *vout = &p_vout->obj;
>      vout_thread_sys_t *sys = p_vout;
> 
> -    /* Translate window coordinates to video coordinates */
> -    vlc_mutex_lock(&sys->display_lock);
> -    vout_display_TranslateMouseState(sys->display, &vid_mouse, win_mouse);
> -    vlc_mutex_unlock(&sys->display_lock);
> -
> -    /* Then pass up the filter chains. */
> -    m = &vid_mouse;
> +    /* pass mouse coordinates in the filter chains. */
> +    m = win_mouse;
>      vlc_mutex_lock(&sys->filter.lock);
>      if (sys->filter.chain_static && sys->filter.chain_interactive) {
>          if (!filter_chain_MouseFilter(sys->filter.chain_interactive,

OK

-- 
Rémi Denis-Courmont
http://www.remlab.net/





More information about the vlc-devel mailing list