summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa-cb/video_layer.swift
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2018-03-05 02:11:25 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-03-04 19:08:45 -0800
commit8bfeecbc6ff1c95682b908a7e4beb87dd83fb3b7 (patch)
treed7ea113b48d896437ab4e7c8f0135e3a05e8fade /video/out/cocoa-cb/video_layer.swift
parent33cffdcbac354179756db732c03b87026f710e8e (diff)
downloadmpv-8bfeecbc6ff1c95682b908a7e4beb87dd83fb3b7.tar.bz2
mpv-8bfeecbc6ff1c95682b908a7e4beb87dd83fb3b7.tar.xz
cocoa-cb: change handling of window aspect ratio changes
i tried being smart and handle aspect ratio differences manually via atomic drawing and resizing to aspect fitted frames. there were a few issues with that. like unexpected visibility of certain System GUI elements on entering fullscreen or visually dropped frames due to the atomic drawing. now we rely on system mechanics to keep the proper aspect ratio of our layer, the recommended way. as a side effect it also fixes a segfault. Fixes #5581
Diffstat (limited to 'video/out/cocoa-cb/video_layer.swift')
-rw-r--r--video/out/cocoa-cb/video_layer.swift23
1 files changed, 8 insertions, 15 deletions
diff --git a/video/out/cocoa-cb/video_layer.swift b/video/out/cocoa-cb/video_layer.swift
index c5604b88f7..8cdb692ae5 100644
--- a/video/out/cocoa-cb/video_layer.swift
+++ b/video/out/cocoa-cb/video_layer.swift
@@ -30,11 +30,10 @@ class VideoLayer: CAOpenGLLayer {
var hasVideo: Bool = false
var neededFlips: Int = 0
var cglContext: CGLContextObj? = nil
+ var surfaceSize: NSSize?
enum Draw: Int { case normal = 1, atomic, atomicEnd }
var draw: Draw = .normal
- let drawLock = NSLock()
- var surfaceSize: NSSize?
var canDrawOffScreen: Bool = false
var lastThread: Thread? = nil
@@ -49,10 +48,7 @@ class VideoLayer: CAOpenGLLayer {
var inLiveResize: Bool = false {
didSet {
- if inLiveResize == false {
- isAsynchronous = false
- neededFlips += 1
- } else {
+ if inLiveResize {
isAsynchronous = true
}
}
@@ -86,6 +82,9 @@ class VideoLayer: CAOpenGLLayer {
pixelFormat pf: CGLPixelFormatObj,
forLayerTime t: CFTimeInterval,
displayTime ts: UnsafePointer<CVTimeStamp>?) -> Bool {
+ if inLiveResize == false {
+ isAsynchronous = false
+ }
return mpv != nil && cocoaCB.backendState == .init
}
@@ -100,13 +99,7 @@ class VideoLayer: CAOpenGLLayer {
}
func draw(_ ctx: CGLContextObj) {
- drawLock.lock()
- updateSurfaceSize()
-
- let aspectRatioDiff = fabs( (surfaceSize!.width/surfaceSize!.height) -
- (bounds.size.width/bounds.size.height) )
-
- if aspectRatioDiff <= 0.005 && draw.rawValue >= Draw.atomic.rawValue {
+ if draw.rawValue >= Draw.atomic.rawValue {
if draw == .atomic {
draw = .atomicEnd
} else {
@@ -114,9 +107,9 @@ class VideoLayer: CAOpenGLLayer {
}
}
+ updateSurfaceSize()
mpv.drawRender(surfaceSize!)
CGLFlushDrawable(ctx)
- drawLock.unlock()
if needsICCUpdate {
needsICCUpdate = false
@@ -148,7 +141,7 @@ class VideoLayer: CAOpenGLLayer {
NSEnableScreenUpdates()
draw = .normal
}
- }
+ }
override func copyCGLPixelFormat(forDisplayMask mask: UInt32) -> CGLPixelFormatObj {
let glVersions: [CGLOpenGLProfile] = [