From 5010c24edc64fbe0bbb2c84645405eb9eceaca86 Mon Sep 17 00:00:00 2001 From: der richter Date: Wed, 19 Feb 2025 16:50:06 +0100 Subject: [PATCH] mac/vulkan: add support for visibility check for rendering --- video/out/mac_common.swift | 4 ++++ video/out/vulkan/context_mac.m | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/video/out/mac_common.swift b/video/out/mac_common.swift index db1a12866e..8e48d0f513 100644 --- a/video/out/mac_common.swift +++ b/video/out/mac_common.swift @@ -109,6 +109,10 @@ class MacCommon: Common { info.pointee.last_queue_display_time = next?.time ?? -1 } + @objc func isVisible() -> Bool { + return window?.occlusionState.contains(.visible) ?? false + } + override func displayLinkCallback(_ displayLink: CVDisplayLink, _ inNow: UnsafePointer, _ inOutputTime: UnsafePointer, diff --git a/video/out/vulkan/context_mac.m b/video/out/vulkan/context_mac.m index 18b928aa52..281a4bdf2f 100644 --- a/video/out/vulkan/context_mac.m +++ b/video/out/vulkan/context_mac.m @@ -55,6 +55,12 @@ static int mac_vk_color_depth(struct ra_ctx *ctx) return 0; } +static bool mac_vk_check_visible(struct ra_ctx *ctx) +{ + struct priv *p = ctx->priv; + return [p->vo_mac isVisible]; +} + static bool mac_vk_init(struct ra_ctx *ctx) { struct priv *p = ctx->priv = talloc_zero(ctx, struct priv); @@ -84,6 +90,7 @@ static bool mac_vk_init(struct ra_ctx *ctx) .swap_buffers = mac_vk_swap_buffers, .get_vsync = mac_vk_get_vsync, .color_depth = mac_vk_color_depth, + .check_visible = mac_vk_check_visible, }; VkInstance inst = vk->vkinst->instance;