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.
This commit is contained in:
der richter 2024-03-06 22:02:43 +01:00 committed by Jan Ekström
parent 6016423427
commit 68c61fd89f
4 changed files with 11 additions and 15 deletions

View File

@ -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?

View File

@ -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 {

View File

@ -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() {

View File

@ -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)