diff options
author | Akemi <der.richter@gmx.de> | 2018-02-25 14:35:13 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-02-28 00:48:44 -0800 |
commit | 38d614d8d668f1255f092f825ac4223f774f5991 (patch) | |
tree | 3db2740fd1413d7d831778af1d902f59ae9a2145 /video/out/cocoa-cb/window.swift | |
parent | 938ad6ebc037ebb32b41619a31b15f8ade712867 (diff) | |
download | mpv-38d614d8d668f1255f092f825ac4223f774f5991.tar.bz2 mpv-38d614d8d668f1255f092f825ac4223f774f5991.tar.xz |
cocoa-cb: fix stretched gl surface on window aspect ratio change
when resizing async it's possible that the layer, and the underlying gl
surface, is stretched on an aspect ratio change. to prevent that we do
an atomic resize (resize and draw at the same time). usually max one
unique frame should be dropped but it's possible, depending on the
performance, that more are dropped.
Diffstat (limited to 'video/out/cocoa-cb/window.swift')
-rw-r--r-- | video/out/cocoa-cb/window.swift | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/video/out/cocoa-cb/window.swift b/video/out/cocoa-cb/window.swift index bd94330dcb..f720205e5c 100644 --- a/video/out/cocoa-cb/window.swift +++ b/video/out/cocoa-cb/window.swift @@ -376,7 +376,22 @@ class Window: NSWindow, NSWindowDelegate { override func setFrame(_ frameRect: NSRect, display flag: Bool) { let newFrame = !isAnimating && isInFullscreen ? targetScreen!.frame : frameRect + let aspectRatioDiff = fabs( (newFrame.width/newFrame.height) - + (frame.width/frame.height) ) + + let isNotUserLiveResize = isAnimating || !(!isAnimating && inLiveResize) + if aspectRatioDiff > 0.005 && isNotUserLiveResize { + cocoaCB.layer.drawLock.lock() + cocoaCB.layer.atomicDrawingStart() + } + super.setFrame(newFrame, display: flag) + cocoaCB.layer.neededFlips += 1 + + if aspectRatioDiff > 0.005 && isNotUserLiveResize { + Swift.print("drawUnLock") + cocoaCB.layer.drawLock.unlock() + } if keepAspect { contentAspectRatio = unfsContentFrame!.size |