[vlc-commits] opengl: fix vertical alignment on control events
    Romain Vimont 
    git at videolan.org
       
    Sat Jun 20 11:30:25 CEST 2020
    
    
  
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Jun 18 11:10:08 2020 +0200| [8d39f363da9465ec936fce38eb0cf49be83710c2] | committer: Alexandre Janniaux
opengl: fix vertical alignment on control events
The video can be top-aligned (--align=4) or bottom-aligned (--align=8)
in the window.
In OpenGL, the vertical alignment is reversed, because the default
OpenGL convention orients the Y axis upwards while VLC convention
orients it downwards.
It was correctly handled for some control events (e.g.
CHANGE_DISPLAY_SIZE), but not for others (e.g. CHANGE_SOURCE_CROP).
Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8d39f363da9465ec936fce38eb0cf49be83710c2
---
 modules/video_output/opengl/display.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index ebb313926a..f4e46f6f33 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -206,6 +206,16 @@ static void PictureDisplay (vout_display_t *vd, picture_t *pic)
     }
 }
 
+static void
+FlipVerticalAlign(vout_display_cfg_t *cfg)
+{
+    /* Reverse vertical alignment as the GL tex are Y inverted */
+    if (cfg->align.vertical == VLC_VIDEO_ALIGN_TOP)
+        cfg->align.vertical = VLC_VIDEO_ALIGN_BOTTOM;
+    else if (cfg->align.vertical == VLC_VIDEO_ALIGN_BOTTOM)
+        cfg->align.vertical = VLC_VIDEO_ALIGN_TOP;
+}
+
 static int Control (vout_display_t *vd, int query, va_list ap)
 {
     vout_display_sys_t *sys = vd->sys;
@@ -221,27 +231,25 @@ static int Control (vout_display_t *vd, int query, va_list ap)
       case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
       case VOUT_DISPLAY_CHANGE_ZOOM:
       {
-        vout_display_cfg_t c = *va_arg (ap, const vout_display_cfg_t *);
+        vout_display_cfg_t cfg = *va_arg(ap, const vout_display_cfg_t *);
         const video_format_t *src = &vd->source;
 
-        /* Reverse vertical alignment as the GL tex are Y inverted */
-        if (c.align.vertical == VLC_VIDEO_ALIGN_TOP)
-            c.align.vertical = VLC_VIDEO_ALIGN_BOTTOM;
-        else if (c.align.vertical == VLC_VIDEO_ALIGN_BOTTOM)
-            c.align.vertical = VLC_VIDEO_ALIGN_TOP;
+        FlipVerticalAlign(&cfg);
 
-        vout_display_PlacePicture(&sys->place, src, &c);
+        vout_display_PlacePicture(&sys->place, src, &cfg);
         sys->place_changed = true;
-        vlc_gl_Resize (sys->gl, c.display.width, c.display.height);
+        vlc_gl_Resize (sys->gl, cfg.display.width, cfg.display.height);
         return VLC_SUCCESS;
       }
 
       case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
       case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
       {
-        const vout_display_cfg_t *cfg = va_arg (ap, const vout_display_cfg_t *);
+        vout_display_cfg_t cfg = *va_arg(ap, const vout_display_cfg_t *);
+
+        FlipVerticalAlign(&cfg);
 
-        vout_display_PlacePicture(&sys->place, &vd->source, cfg);
+        vout_display_PlacePicture(&sys->place, &vd->source, &cfg);
         sys->place_changed = true;
         return VLC_SUCCESS;
       }
    
    
More information about the vlc-commits
mailing list