aboutsummaryrefslogtreecommitdiffhomepage
path: root/video
diff options
context:
space:
mode:
authorGravatar Akemi <der.richter@gmx.de>2018-02-22 23:56:49 +0100
committerGravatar Kevin Mitchell <kevmitch@gmail.com>2018-02-25 22:07:33 -0800
commit7fff1b6c10e53ba3139eb06a2598d1587c969741 (patch)
treeaf547c946c52f505f68b979de8d01459b4c9553d /video
parent1f2d8ed01cfc85fb910f21e9a7290265d0dcf11c (diff)
cocoa-cb: fix wrong drawing size on resize
on live resize, eg async resize, the layer's bounds size is not in sync with the actual surface size. this led to a wrongly sized frame and a perceived flicker. get and use the actual surface size instead.
Diffstat (limited to 'video')
-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) {