summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-03-06 22:02:43 +0100
committerJan Ekström <jeebjp@gmail.com>2024-03-06 23:37:32 +0200
commit68c61fd89f4c825ac559589458f406b4c92d04c6 (patch)
tree20995859f86a1f0f2a8fd5005515dbfe4c3bf403
parent6016423427ffdad29841093a588c57374c2ad108 (diff)
downloadmpv-68c61fd89f4c825ac559589458f406b4c92d04c6.tar.bz2
mpv-68c61fd89f4c825ac559589458f406b4c92d04c6.tar.xz
mac/vulkan: directly retrieve current render size without caching
the render size cached in ctx->vo->dwidth/dheight can be outdated in some circumstances at the time the context needs resizing. instead use the current render size.
-rw-r--r--video/out/mac/common.swift2
-rw-r--r--video/out/mac/window.swift2
-rw-r--r--video/out/mac_common.swift13
-rw-r--r--video/out/vulkan/context_mac.m9
4 files changed, 11 insertions, 15 deletions
diff --git a/video/out/mac/common.swift b/video/out/mac/common.swift
index 8e7aab75ec..7b6fa48b5d 100644
--- a/video/out/mac/common.swift
+++ b/video/out/mac/common.swift
@@ -23,7 +23,7 @@ class Common: NSObject {
var log: LogHelper
let queue: DispatchQueue = DispatchQueue(label: "io.mpv.queue")
- var window: Window?
+ @objc var window: Window?
var view: View?
var titleBar: TitleBar?
diff --git a/video/out/mac/window.swift b/video/out/mac/window.swift
index 8a8c56c76a..0829205da4 100644
--- a/video/out/mac/window.swift
+++ b/video/out/mac/window.swift
@@ -35,7 +35,7 @@ class Window: NSWindow, NSWindowDelegate {
let animationLock: NSCondition = NSCondition()
var unfsContentFramePixel: NSRect { get { return convertToBacking(unfsContentFrame ?? NSRect(x: 0, y: 0, width: 160, height: 90)) } }
- var framePixel: NSRect { get { return convertToBacking(frame) } }
+ @objc var framePixel: NSRect { get { return convertToBacking(frame) } }
var keepAspect: Bool = true {
didSet {
diff --git a/video/out/mac_common.swift b/video/out/mac_common.swift
index 211c535811..71659de8e5 100644
--- a/video/out/mac_common.swift
+++ b/video/out/mac_common.swift
@@ -93,12 +93,6 @@ class MacCommon: Common {
}
}
- func updateRenderSize(_ size: NSSize) {
- mpv?.vo.pointee.dwidth = Int32(size.width)
- mpv?.vo.pointee.dheight = Int32(size.height)
- flagEvents(VO_EVENT_RESIZE | VO_EVENT_EXPOSE)
- }
-
override func displayLinkCallback(_ displayLink: CVDisplayLink,
_ inNow: UnsafePointer<CVTimeStamp>,
_ inOutputTime: UnsafePointer<CVTimeStamp>,
@@ -144,12 +138,7 @@ class MacCommon: Common {
}
override func windowDidResize() {
- guard let window = window else {
- log.sendWarning("No window available on window resize event")
- return
- }
-
- updateRenderSize(window.framePixel.size)
+ flagEvents(VO_EVENT_RESIZE | VO_EVENT_EXPOSE)
}
override func windowDidChangeScreenProfile() {
diff --git a/video/out/vulkan/context_mac.m b/video/out/vulkan/context_mac.m
index 38b34ff029..5621e6dca3 100644
--- a/video/out/vulkan/context_mac.m
+++ b/video/out/vulkan/context_mac.m
@@ -85,7 +85,14 @@ error:
static bool resize(struct ra_ctx *ctx)
{
- return ra_vk_ctx_resize(ctx, ctx->vo->dwidth, ctx->vo->dheight);
+ struct priv *p = ctx->priv;
+
+ if (!p->vo_mac.window) {
+ return false;
+ }
+ CGSize size = p->vo_mac.window.framePixel.size;
+
+ return ra_vk_ctx_resize(ctx, (int)size.width, (int)size.height);
}
static bool mac_vk_reconfig(struct ra_ctx *ctx)