[vlc-commits] [Git][videolan/vlc][master] 4 commits: caopengllayer: fix wrong fullscreen size

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Wed May 25 08:13:14 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
3f012cc3 by Marvin Scholz at 2022-05-25T07:48:28+00:00
caopengllayer: fix wrong fullscreen size

When transitioning to fullscreen, the codepath for non-live
resize was used and did not trigger rendering here.
As the size if now handled by the window however, this resulted
in a wrong size as it was never actually updated. To prevent that,
always render with the proper size from the layer regardless
if we are in live-resize or not.

Fixes #26962

- - - - -
c7f4f114 by Marvin Scholz at 2022-05-25T07:48:28+00:00
caopengllayer: remove unnecessary size saving

The size saved here is always overwritten right before
rendering so it is not necessary at all, as nothing is
reported anymore here, this is handled by the window.

- - - - -
95bbd30f by Marvin Scholz at 2022-05-25T07:48:28+00:00
caopengllayer: remove unused variable

- - - - -
e08c1dfb by Marvin Scholz at 2022-05-25T07:48:28+00:00
caopengllayer: always use kCGLPFASupportsAutomaticGraphicsSwitching

VLC 4.0 targets macOS 10.11, so we can always assume this is available.

- - - - -


1 changed file:

- modules/video_output/caopengllayer.m


Changes:

=====================================
modules/video_output/caopengllayer.m
=====================================
@@ -78,8 +78,6 @@ static int Control          (vout_display_t *vd, int);
 
 - (instancetype)initWithVoutDisplay:(vout_display_t *)vd;
 - (void)displayFromVout;
-- (void)reportCurrentLayerSize;
-- (void)reportCurrentLayerSizeWithScale:(CGFloat)scale;
 - (void)vlcClose;
 @end
 
@@ -115,7 +113,6 @@ typedef struct vout_display_sys_t {
     vout_display_place_t place;
     vout_display_cfg_t cfg;
 
-    bool  b_frame_available;
     atomic_bool is_ready;
 } vout_display_sys_t;
 
@@ -143,16 +140,13 @@ CGLContextObj vlc_CreateCGLContext()
         kCGLPFAColorSize, 24,
         kCGLPFAAlphaSize, 8,
         kCGLPFADepthSize, 24,
-        0, // If ever extending this list, adjust the offset below!
-        0
-    };
 
-    if (@available(macOS 10.8, *)) {
         // Enable automatic graphics switching support, important on Macs
         // with dedicated GPUs, as it allows to not always use the dedicated
         // GPU which has more power consumption
-        attribs[10] = kCGLPFASupportsAutomaticGraphicsSwitching;
-    }
+        kCGLPFASupportsAutomaticGraphicsSwitching,
+        0
+    };
 
     err = CGLChoosePixelFormat(attribs, &pix, &npix);
     if (err != kCGLNoError || pix == NULL) {
@@ -362,7 +356,6 @@ static int Open (vout_display_t *vd,
                 NSView *containerView = container;
                 [containerView addSubview:sys->videoView];
                 [sys->videoView setFrame:containerView.bounds];
-                [sys->videoLayer reportCurrentLayerSize];
             } else {
                 [sys->videoView release];
                 [sys->videoLayer release];
@@ -570,9 +563,6 @@ static int Control (vout_display_t *vd, int query)
 - (void)viewDidEndLiveResize
 {
     [(VLCCAOpenGLLayer *)self.layer setAsynchronous:NO];
-
-    // After a live resize we need to tell the core about our new size
-    [(VLCCAOpenGLLayer *)self.layer reportCurrentLayerSize];
 }
 
 - (CALayer *)makeBackingLayer
@@ -594,17 +584,6 @@ static int Control (vout_display_t *vd, int query)
 shouldInheritContentsScale:(CGFloat)newScale
    fromWindow:(NSWindow *)window
 {
-    // If the scale changes, from the OpenGL point of view
-    // the size changes, so we need to indicate a resize
-    if (layer == self.layer) {
-        [(VLCCAOpenGLLayer *)self.layer
-            reportCurrentLayerSizeWithScale:newScale];
-        // FIXME
-        // For a brief moment the old image with a wrong scale
-        // is still visible, thats because the resize event is not
-        // processed immediately. Ideally this would be handled similar
-        // to how the live resize is done, to avoid this.
-    }
     return YES;
 }
 
@@ -783,48 +762,6 @@ shouldInheritContentsScale:(CGFloat)newScale
     [super dealloc];
 }
 
-
-- (void)layoutSublayers
-{
-    [super layoutSublayers];
-
-    if (self.asynchronous) {
-        // During live resize, the size is updated in the
-        // OpenGL draw callback, to ensure atomic size changes
-        // that are in sync with the real layer size.
-        // This bypasses the core but is needed for resizing
-        // without glitches or lags.
-        return;
-    }
-
-    [self reportCurrentLayerSize];
-}
-
-- (void)reportCurrentLayerSizeWithScale:(CGFloat)scale
-{
-    CGSize newSize = self.visibleRect.size;
-
-    // Calculate pixel values
-    newSize.width *= scale;
-    newSize.height *= scale;
-
-    @synchronized(self) {
-        if (!_voutDisplay)
-            return;
-        vout_display_sys_t *sys = _voutDisplay->sys;
-        @synchronized(sys->videoLayer) {
-            sys->cfg.display.width = newSize.width;
-            sys->cfg.display.height = newSize.height;
-        }
-    }
-}
-
-- (void)reportCurrentLayerSize
-{
-    CGFloat scale = self.contentsScale;
-    [self reportCurrentLayerSizeWithScale:scale];
-}
-
 - (void)display
 {
     [_displayLock lock];
@@ -878,25 +815,23 @@ shouldInheritContentsScale:(CGFloat)newScale
         if (vlc_gl_MakeCurrent(sys->gl))
             return;
 
-        if (self.asynchronous) {
-            GLint dims[4] = { 0, 0, 0, 0 };
-            glGetIntegerv(GL_VIEWPORT, dims);
-            NSSize newSize = NSMakeSize(dims[2], dims[3]);
+        GLint dims[4] = { 0, 0, 0, 0 };
+        glGetIntegerv(GL_VIEWPORT, dims);
+        NSSize newSize = NSMakeSize(dims[2], dims[3]);
 
-            if (NSEqualSizes(newSize, NSZeroSize)) {
-                newSize = self.bounds.size;
-                CGFloat scale = self.contentsScale;
-                newSize.width *= scale;
-                newSize.height *= scale;
-            }
+        if (NSEqualSizes(newSize, NSZeroSize)) {
+            newSize = self.bounds.size;
+            CGFloat scale = self.contentsScale;
+            newSize.width *= scale;
+            newSize.height *= scale;
+        }
 
-            @synchronized(sys->videoView)
-            {
-                sys->cfg.display.width = newSize.width;
-                sys->cfg.display.height = newSize.height;
+        @synchronized(sys->videoView)
+        {
+            sys->cfg.display.width = newSize.width;
+            sys->cfg.display.height = newSize.height;
 
-                vout_display_PlacePicture(&sys->place, _voutDisplay->source, &sys->cfg.display);
-            }
+            vout_display_PlacePicture(&sys->place, _voutDisplay->source, &sys->cfg.display);
         }
 
         // Ensure viewport and aspect ratio is correct



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/30430312611a37a4ee15694e83142071befab12b...e08c1dfb6eb15fef8f2c75850cce6f9750ded9f4

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/30430312611a37a4ee15694e83142071befab12b...e08c1dfb6eb15fef8f2c75850cce6f9750ded9f4
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