[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: caopengllayer: inline place picture

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Wed May 4 06:30:38 UTC 2022



Hugo Beauzée-Luyssen pushed to branch 3.0.x at VideoLAN / VLC


Commits:
9cfed305 by Alexandre Janniaux at 2022-05-04T06:15:42+00:00
caopengllayer: inline place picture

Store the current modified vout_display_cfg_t and inline the calls to
vout_display_PlacePicture.

Refs #26845
Refs #25264

Cherry-picked from commit 689b64b1aaba33efeea71d933a878febb81b5e81.

Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>

- - - - -
8ff56952 by Alexandre Janniaux at 2022-05-04T06:15:42+00:00
caopengllayer: ignore DISPLAY_SIZE controls

DISPLAY_SIZE controls are emitted by the windowing system to control the
display state, but the caopengllayer display module is handling its own
windowing state without window and doesn't need to react to those events.

Instead, store the new size into the internal vout_display_cfg_t and
avoid trying to report the size to itself.

Fixes #26845
Refs #25264

Cherry-picked from commit bd24889a0b7d0d223f751ea7c40598fd83f0b221.

Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>

- - - - -


1 changed file:

- modules/video_output/caopengllayer.m


Changes:

=====================================
modules/video_output/caopengllayer.m
=====================================
@@ -77,7 +77,6 @@ static int Control          (vout_display_t *vd, int query, va_list ap);
 }
 
 - (instancetype)initWithVoutDisplay:(vout_display_t *)vd;
-- (void)placePictureWithConfig:(const vout_display_cfg_t *)cfg;
 - (void)displayFromVout;
 - (void)reportCurrentLayerSize;
 - (void)reportCurrentLayerSizeWithScale:(CGFloat)scale;
@@ -117,6 +116,7 @@ struct vout_display_sys_t {
     vout_display_opengl_t *vgl;
 
     vout_display_place_t place;
+    vout_display_cfg_t cfg;
 
     atomic_bool is_ready;
 };
@@ -335,6 +335,13 @@ static int Open(vlc_object_t *this)
         var_SetAddress(vd->obj.parent, "macosx-glcontext", cgl_ctx);
 
         dispatch_sync(dispatch_get_main_queue(), ^{
+            // Reverse vertical alignment as the GL tex are Y inverted
+           sys->cfg = *vd->cfg;
+           if (sys->cfg.align.vertical == VOUT_DISPLAY_ALIGN_TOP)
+               sys->cfg.align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
+           else if (sys->cfg.align.vertical == VOUT_DISPLAY_ALIGN_BOTTOM)
+               sys->cfg.align.vertical = VOUT_DISPLAY_ALIGN_TOP;
+
             // Create video view
             sys->videoView = [[VLCVideoLayerView alloc] initWithVoutDisplay:vd];
             sys->videoLayer = (VLCCAOpenGLLayer*)[[sys->videoView layer] retain];
@@ -352,6 +359,8 @@ static int Open(vlc_object_t *this)
                 sys->videoView = nil;
                 sys->videoLayer = nil;
             }
+
+            vout_display_PlacePicture(&sys->place, &vd->source, &sys->cfg, false);
         });
 
         if (sys->videoView == nil) {
@@ -487,22 +496,37 @@ static int Control(vout_display_t *vd, int query, va_list ap)
     switch (query)
     {
         case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
+            return VLC_SUCCESS;
+
         case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
         case VOUT_DISPLAY_CHANGE_ZOOM:
         case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
         case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
         {
-            const vout_display_cfg_t *cfg;
-
-            if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT ||
-                query == VOUT_DISPLAY_CHANGE_SOURCE_CROP) {
-                cfg = vd->cfg;
-            } else {
-                cfg = (const vout_display_cfg_t*)va_arg (ap, const vout_display_cfg_t *);
+            @synchronized(sys->videoLayer)
+            {
+                vout_display_cfg_t cfg;
+
+                if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT ||
+                    query == VOUT_DISPLAY_CHANGE_SOURCE_CROP) {
+                    cfg = *vd->cfg;
+                } else {
+                    cfg = *(const vout_display_cfg_t*)va_arg (ap, const vout_display_cfg_t *);
+                }
+
+                cfg.display.width = sys->cfg.display.width;
+                cfg.display.height = sys->cfg.display.height;
+
+                // Reverse vertical alignment as the GL tex are Y inverted
+                if (cfg.align.vertical == VOUT_DISPLAY_ALIGN_TOP)
+                    cfg.align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
+                else if (cfg.align.vertical == VOUT_DISPLAY_ALIGN_BOTTOM)
+                    cfg.align.vertical = VOUT_DISPLAY_ALIGN_TOP;
+                sys->cfg = cfg;
+
+                vout_display_PlacePicture(&sys->place, &vd->source, &cfg, false);
             }
 
-            [sys->videoLayer placePictureWithConfig:cfg];
-
             // Note!
             // No viewport or aspect ratio is set here, as that needs to be set
             // when rendering. The viewport is always set to match the layer
@@ -784,25 +808,6 @@ shouldInheritContentsScale:(CGFloat)newScale
     [super dealloc];
 }
 
-- (void)placePictureWithConfig:(const vout_display_cfg_t *)cfg
-{
-    vout_display_sys_t *sys = _voutDisplay->sys;
-    vout_display_cfg_t tmp_cfg = *cfg;
-
-    // Reverse vertical alignment as the GL tex are Y inverted
-    if (tmp_cfg.align.vertical == VOUT_DISPLAY_ALIGN_TOP)
-        tmp_cfg.align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
-    else if (tmp_cfg.align.vertical == VOUT_DISPLAY_ALIGN_BOTTOM)
-        tmp_cfg.align.vertical = VOUT_DISPLAY_ALIGN_TOP;
-
-    // Synchronization not for _voutDisplay but for sys->place
-    // as this method can be called either from the Control()
-    // function or the layer draw method.
-    @synchronized(self) {
-        vout_display_PlacePicture(&sys->place, &_voutDisplay->source, &tmp_cfg, false);
-    }
-}
-
 - (void)layoutSublayers
 {
     [super layoutSublayers];
@@ -831,8 +836,11 @@ shouldInheritContentsScale:(CGFloat)newScale
         if (!_voutDisplay)
             return;
 
-        vout_display_SendEventDisplaySize(_voutDisplay,
-                                          newSize.width, newSize.height);
+        vout_display_sys_t *sys = _voutDisplay->sys;
+        @synchronized(sys->videoLayer) {
+            sys->cfg.display.width = newSize.width;
+            sys->cfg.display.height = newSize.height;
+        }
     }
 }
 
@@ -906,12 +914,13 @@ shouldInheritContentsScale:(CGFloat)newScale
                 newSize.height *= scale;
             }
 
-            vout_display_cfg_t cfg = *_voutDisplay->cfg;
+            @synchronized(sys->videoView)
+            {
+                sys->cfg.display.width = newSize.width;
+                sys->cfg.display.height = newSize.height;
 
-            cfg.display.width = newSize.width;
-            cfg.display.height = newSize.height;
-
-            [self placePictureWithConfig:&cfg];
+                vout_display_PlacePicture(&sys->place, &_voutDisplay->source, &sys->cfg, false);
+            }
         }
 
         // Ensure viewport and aspect ratio is correct



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/248450581f086486cb631be31b1e5800cde43c3b...8ff56952174af8e7a7d4ae61a413f88317c948a1

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/248450581f086486cb631be31b1e5800cde43c3b...8ff56952174af8e7a7d4ae61a413f88317c948a1
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list