[vlc-devel] [PATCH] vout/opengl: Store and restore last viewport

Thomas Guillem thomas at gllm.fr
Mon Aug 12 09:37:03 CEST 2019



On Sat, Aug 10, 2019, at 19:56, Marvin Scholz wrote:
> Between the call to vout_display_opengl_Viewport and the call to
> vout_display_opengl_Display the viewport can be changed by the OS
> causing the picture to render incorrectly.
> 
> To prevent that, store the last set viewport and restore it in the
> display function.
> 
> Fix #21357
> Fix #22209
> ---
>  modules/video_output/opengl/vout_helper.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/modules/video_output/opengl/vout_helper.c 
> b/modules/video_output/opengl/vout_helper.c
> index b37b653257..2a8ec9cc12 100644
> --- a/modules/video_output/opengl/vout_helper.c
> +++ b/modules/video_output/opengl/vout_helper.c
> @@ -166,6 +166,13 @@ struct vout_display_opengl_t {
>      float f_fovy; /* to avoid recalculating them when needed.      */
>      float f_z;    /* Position of the camera on the shpere radius 
> vector */
>      float f_sar;
> +
> +    struct {
> +        GLint i_x;
> +        GLint i_y;
> +        GLint i_width;
> +        GLint i_height;
> +    } last_viewport;
>  };
>  
>  static const vlc_fourcc_t gl_subpicture_chromas[] = {
> @@ -1021,6 +1028,10 @@ void 
> vout_display_opengl_SetWindowAspectRatio(vout_display_opengl_t *vgl,
>  void vout_display_opengl_Viewport(vout_display_opengl_t *vgl, int x, 
> int y,
>                                    unsigned width, unsigned height)
>  {
> +    vgl->last_viewport.i_x = x;
> +    vgl->last_viewport.i_y = y;
> +    vgl->last_viewport.i_width = width;
> +    vgl->last_viewport.i_height = height;
>      vgl->vt.Viewport(x, y, width, height);

So, why not removing this vgl->vt.Viewport(x, y, width, height) call ?

>  }
>  
> @@ -1564,6 +1575,12 @@ int 
> vout_display_opengl_Display(vout_display_opengl_t *vgl,
>  {
>      GL_ASSERT_NOERROR();
>  
> +    // Restore Viewport
> +    vgl->vt.Viewport(vgl->last_viewport.i_x,
> +                     vgl->last_viewport.i_y,
> +                     vgl->last_viewport.i_width,
> +                     vgl->last_viewport.i_height);


And set the viewport only here.

> +
>      /* Why drawing here and not in Render()? Because this way, the
>         OpenGL providers can call vout_display_opengl_Display to force redraw.
>         Currently, the OS X provider uses it to get a smooth window resizing */
> -- 
> 2.19.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list