mirror of
https://github.com/mpv-player/mpv
synced 2025-03-20 10:17:31 +00:00
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:
parent
6016423427
commit
68c61fd89f
@ -23,7 +23,7 @@ class Common: NSObject {
|
|||||||
var log: LogHelper
|
var log: LogHelper
|
||||||
let queue: DispatchQueue = DispatchQueue(label: "io.mpv.queue")
|
let queue: DispatchQueue = DispatchQueue(label: "io.mpv.queue")
|
||||||
|
|
||||||
var window: Window?
|
@objc var window: Window?
|
||||||
var view: View?
|
var view: View?
|
||||||
var titleBar: TitleBar?
|
var titleBar: TitleBar?
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||||||
let animationLock: NSCondition = NSCondition()
|
let animationLock: NSCondition = NSCondition()
|
||||||
|
|
||||||
var unfsContentFramePixel: NSRect { get { return convertToBacking(unfsContentFrame ?? NSRect(x: 0, y: 0, width: 160, height: 90)) } }
|
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 {
|
var keepAspect: Bool = true {
|
||||||
didSet {
|
didSet {
|
||||||
|
@ -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,
|
override func displayLinkCallback(_ displayLink: CVDisplayLink,
|
||||||
_ inNow: UnsafePointer<CVTimeStamp>,
|
_ inNow: UnsafePointer<CVTimeStamp>,
|
||||||
_ inOutputTime: UnsafePointer<CVTimeStamp>,
|
_ inOutputTime: UnsafePointer<CVTimeStamp>,
|
||||||
@ -144,12 +138,7 @@ class MacCommon: Common {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func windowDidResize() {
|
override func windowDidResize() {
|
||||||
guard let window = window else {
|
flagEvents(VO_EVENT_RESIZE | VO_EVENT_EXPOSE)
|
||||||
log.sendWarning("No window available on window resize event")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
updateRenderSize(window.framePixel.size)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func windowDidChangeScreenProfile() {
|
override func windowDidChangeScreenProfile() {
|
||||||
|
@ -85,7 +85,14 @@ error:
|
|||||||
|
|
||||||
static bool resize(struct ra_ctx *ctx)
|
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)
|
static bool mac_vk_reconfig(struct ra_ctx *ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user