[vlc-commits] vout: rationalize alignment type

Rémi Denis-Courmont git at videolan.org
Tue Dec 11 18:11:13 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 10 23:01:27 2018 +0200| [843654e8921960551a8a14900fee929010470f3f] | committer: Rémi Denis-Courmont

vout: rationalize alignment type

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=843654e8921960551a8a14900fee929010470f3f
---

 include/vlc_vout_display.h            | 25 +++++++++++--------------
 modules/video_output/caopengllayer.m  |  8 ++++----
 modules/video_output/macosx.m         |  8 ++++----
 modules/video_output/opengl/display.c |  8 ++++----
 modules/video_output/win32/common.c   |  8 ++++----
 src/video_output/display.c            |  8 ++++----
 src/video_output/video_output.c       | 20 ++++++++++----------
 7 files changed, 41 insertions(+), 44 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 226d55f782..0ca8f3cfe1 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -51,16 +51,16 @@ typedef struct vout_display_owner_t vout_display_owner_t;
 /**
  * Possible alignments for vout_display.
  */
-typedef enum
-{
-    VOUT_DISPLAY_ALIGN_CENTER,
-    /* */
-    VOUT_DISPLAY_ALIGN_LEFT,
-    VOUT_DISPLAY_ALIGN_RIGHT,
-    /* */
-    VOUT_DISPLAY_ALIGN_TOP,
-    VOUT_DISPLAY_ALIGN_BOTTOM,
-} vout_display_align_t;
+#define VLC_VIDEO_ALIGN_CENTER 0
+#define VLC_VIDEO_ALIGN_LEFT   1
+#define VLC_VIDEO_ALIGN_RIGHT  2
+#define VLC_VIDEO_ALIGN_TOP    1
+#define VLC_VIDEO_ALIGN_BOTTOM 2
+
+typedef struct vlc_video_align {
+    char horizontal;
+    char vertical;
+} vlc_video_align_t;
 
 /**
  * Initial/Current configuration for a vout_display_t
@@ -82,10 +82,7 @@ typedef struct {
     } display;
 
     /* Alignment of the picture inside the display */
-    struct {
-        int horizontal;
-        int vertical;
-    } align;
+    vlc_video_align_t align;
 
     /* Do we fill up the display with the video */
     bool is_display_filled;
diff --git a/modules/video_output/caopengllayer.m b/modules/video_output/caopengllayer.m
index 8170b2d0de..0bbc07ee2f 100644
--- a/modules/video_output/caopengllayer.m
+++ b/modules/video_output/caopengllayer.m
@@ -340,10 +340,10 @@ static int Control (vout_display_t *vd, int query, va_list ap)
             cfg_tmp.display.height = bounds.size.height;
 
             /* Reverse vertical alignment as the GL tex are Y inverted */
-            if (cfg_tmp.align.vertical == VOUT_DISPLAY_ALIGN_TOP)
-                cfg_tmp.align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
-            else if (cfg_tmp.align.vertical == VOUT_DISPLAY_ALIGN_BOTTOM)
-                cfg_tmp.align.vertical = VOUT_DISPLAY_ALIGN_TOP;
+            if (cfg_tmp.align.vertical == VLC_VIDEO_ALIGN_TOP)
+                cfg_tmp.align.vertical = VLC_VIDEO_ALIGN_BOTTOM;
+            else if (cfg_tmp.align.vertical == VLC_VIDEO_ALIGN_BOTTOM)
+                cfg_tmp.align.vertical = VLC_VIDEO_ALIGN_TOP;
 
             vout_display_place_t place;
             vout_display_PlacePicture (&place, &vd->source, &cfg_tmp, false);
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 8e85d6139d..27d1b2503e 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -374,10 +374,10 @@ static int Control (vout_display_t *vd, int query, va_list ap)
                 vout_display_cfg_t cfg_tmp = *cfg;
 
                 /* Reverse vertical alignment as the GL tex are Y inverted */
-                if (cfg_tmp.align.vertical == VOUT_DISPLAY_ALIGN_TOP)
-                    cfg_tmp.align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
-                else if (cfg_tmp.align.vertical == VOUT_DISPLAY_ALIGN_BOTTOM)
-                    cfg_tmp.align.vertical = VOUT_DISPLAY_ALIGN_TOP;
+                if (cfg_tmp.align.vertical == VLC_VIDEO_ALIGN_TOP)
+                    cfg_tmp.align.vertical = VLC_VIDEO_ALIGN_BOTTOM;
+                else if (cfg_tmp.align.vertical == VLC_VIDEO_ALIGN_BOTTOM)
+                    cfg_tmp.align.vertical = VLC_VIDEO_ALIGN_TOP;
 
                 vout_display_place_t place;
                 vout_display_PlacePicture (&place, &vd->source, &cfg_tmp, false);
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index 7cc3c94b48..cae5623907 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -238,10 +238,10 @@ static int Control (vout_display_t *vd, int query, va_list ap)
         vout_display_place_t place;
 
         /* Reverse vertical alignment as the GL tex are Y inverted */
-        if (c.align.vertical == VOUT_DISPLAY_ALIGN_TOP)
-            c.align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
-        else if (c.align.vertical == VOUT_DISPLAY_ALIGN_BOTTOM)
-            c.align.vertical = VOUT_DISPLAY_ALIGN_TOP;
+        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;
 
         vout_display_PlacePicture (&place, src, &c, false);
         vlc_gl_Resize (sys->gl, c.display.width, c.display.height);
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index 1ad7eab806..b04ebbb47d 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -209,10 +209,10 @@ void UpdateRects(vout_display_t *vd, bool is_forced)
 
 #if (defined(MODULE_NAME_IS_glwin32))
     /* Reverse vertical alignment as the GL tex are Y inverted */
-    if (place_cfg.align.vertical == VOUT_DISPLAY_ALIGN_TOP)
-        place_cfg.align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
-    else if (place_cfg.align.vertical == VOUT_DISPLAY_ALIGN_BOTTOM)
-        place_cfg.align.vertical = VOUT_DISPLAY_ALIGN_TOP;
+    if (place_cfg.align.vertical == VLC_VIDEO_ALIGN_TOP)
+        place_cfg.align.vertical = VLC_VIDEO_ALIGN_BOTTOM;
+    else if (place_cfg.align.vertical == VLC_VIDEO_ALIGN_BOTTOM)
+        place_cfg.align.vertical = VLC_VIDEO_ALIGN_TOP;
 #endif
 
     vout_display_place_t place;
diff --git a/src/video_output/display.c b/src/video_output/display.c
index dd807bc893..3d42a380e6 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -268,10 +268,10 @@ void vout_display_PlacePicture(vout_display_place_t *place,
 
     /*  Compute position */
     switch (cfg->align.horizontal) {
-    case VOUT_DISPLAY_ALIGN_LEFT:
+    case VLC_VIDEO_ALIGN_LEFT:
         place->x = 0;
         break;
-    case VOUT_DISPLAY_ALIGN_RIGHT:
+    case VLC_VIDEO_ALIGN_RIGHT:
         place->x = cfg->display.width - place->width;
         break;
     default:
@@ -280,10 +280,10 @@ void vout_display_PlacePicture(vout_display_place_t *place,
     }
 
     switch (cfg->align.vertical) {
-    case VOUT_DISPLAY_ALIGN_TOP:
+    case VLC_VIDEO_ALIGN_TOP:
         place->y = 0;
         break;
-    case VOUT_DISPLAY_ALIGN_BOTTOM:
+    case VLC_VIDEO_ALIGN_BOTTOM:
         place->y = cfg->display.height - place->height;
         break;
     default:
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 2216bf78b8..bded014a4f 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -695,17 +695,17 @@ static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg)
     vlc_ureduce(&zoom_num, &zoom_den, zoom_num, zoom_den, 0);
     cfg->zoom.num = zoom_num;
     cfg->zoom.den = zoom_den;
-    cfg->align.vertical = VOUT_DISPLAY_ALIGN_CENTER;
-    cfg->align.horizontal = VOUT_DISPLAY_ALIGN_CENTER;
+    cfg->align.vertical = VLC_VIDEO_ALIGN_CENTER;
+    cfg->align.horizontal = VLC_VIDEO_ALIGN_CENTER;
     const int align_mask = var_GetInteger(vout, "align");
-    if (align_mask & 0x1)
-        cfg->align.horizontal = VOUT_DISPLAY_ALIGN_LEFT;
-    else if (align_mask & 0x2)
-        cfg->align.horizontal = VOUT_DISPLAY_ALIGN_RIGHT;
-    if (align_mask & 0x4)
-        cfg->align.vertical = VOUT_DISPLAY_ALIGN_TOP;
-    else if (align_mask & 0x8)
-        cfg->align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
+    if (align_mask & VOUT_ALIGN_LEFT)
+        cfg->align.horizontal = VLC_VIDEO_ALIGN_LEFT;
+    else if (align_mask & VOUT_ALIGN_RIGHT)
+        cfg->align.horizontal = VLC_VIDEO_ALIGN_RIGHT;
+    if (align_mask & VOUT_ALIGN_TOP)
+        cfg->align.vertical = VLC_VIDEO_ALIGN_TOP;
+    else if (align_mask & VOUT_ALIGN_BOTTOM)
+        cfg->align.vertical = VLC_VIDEO_ALIGN_BOTTOM;
 }
 
 /* */



More information about the vlc-commits mailing list