summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa-cb/video_layer.swift
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/cocoa-cb/video_layer.swift')
-rw-r--r--video/out/cocoa-cb/video_layer.swift29
1 files changed, 12 insertions, 17 deletions
diff --git a/video/out/cocoa-cb/video_layer.swift b/video/out/cocoa-cb/video_layer.swift
index ed259d04f5..2cea79bf3a 100644
--- a/video/out/cocoa-cb/video_layer.swift
+++ b/video/out/cocoa-cb/video_layer.swift
@@ -42,18 +42,14 @@ class VideoLayer: CAOpenGLLayer {
}
}
- let surfaceLock = NSLock()
var surfaceSize: NSSize?
var inLiveResize: Bool = false {
didSet {
if inLiveResize == false {
isAsynchronous = false
- display()
+ neededFlips += 1
} else {
- surfaceLock.lock()
- updateSurfaceSize()
- surfaceLock.unlock()
isAsynchronous = true
}
}
@@ -101,13 +97,8 @@ class VideoLayer: CAOpenGLLayer {
}
func draw(_ ctx: CGLContextObj) {
- surfaceLock.lock()
- if inLiveResize == false {
- updateSurfaceSize()
- }
-
+ updateSurfaceSize()
mpv.drawGLCB(surfaceSize!)
- surfaceLock.unlock()
CGLFlushDrawable(ctx)
if needsICCUpdate {
@@ -117,9 +108,15 @@ class VideoLayer: CAOpenGLLayer {
}
func updateSurfaceSize() {
- surfaceSize = bounds.size
- surfaceSize!.width *= contentsScale
- surfaceSize!.height *= contentsScale
+ var dims: [GLint] = [0, 0, 0, 0]
+ glGetIntegerv(GLenum(GL_VIEWPORT), &dims)
+ surfaceSize = NSMakeSize(CGFloat(dims[2]), CGFloat(dims[3]))
+
+ if NSEqualSizes(surfaceSize!, NSZeroSize) {
+ surfaceSize = bounds.size
+ surfaceSize!.width *= contentsScale
+ surfaceSize!.height *= contentsScale
+ }
}
override func copyCGLPixelFormat(forDisplayMask mask: UInt32) -> CGLPixelFormatObj {
@@ -179,9 +176,7 @@ class VideoLayer: CAOpenGLLayer {
override func display() {
super.display()
- if !isAsynchronous {
- CATransaction.flush()
- }
+ CATransaction.flush()
}
func setVideo(_ state: Bool) {