From aa9c559f96ba09196770d4c771f3f0ff3a035f64 Mon Sep 17 00:00:00 2001 From: Jarvis Huang Date: Wed, 15 Mar 2023 17:13:06 +0800 Subject: [PATCH] xrt: Add new API in xrt_multi_compositor_control interface --- src/xrt/include/xrt/xrt_compositor.h | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index c3e927860..18806c2d9 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -642,6 +642,8 @@ enum xrt_compositor_event_type XRT_COMPOSITOR_EVENT_NONE = 0, XRT_COMPOSITOR_EVENT_STATE_CHANGE = 1, XRT_COMPOSITOR_EVENT_OVERLAY_CHANGE = 2, + XRT_COMPOSITOR_EVENT_LOSS_PENDING = 3, + XRT_COMPOSITOR_EVENT_LOST = 4 }; /*! @@ -663,6 +665,23 @@ struct xrt_compositor_event_overlay bool primary_focused; }; +/*! + * Loss pending event. + */ +struct xrt_compositor_event_loss_pending +{ + enum xrt_compositor_event_type type; + uint64_t loss_time_ns; +}; + +/*! + * Lost event. + */ +struct xrt_compositor_event_lost +{ + enum xrt_compositor_event_type type; +}; + /*! * Compositor events union. */ @@ -670,6 +689,8 @@ union xrt_compositor_event { enum xrt_compositor_event_type type; struct xrt_compositor_event_state_change state; struct xrt_compositor_event_state_change overlay; + struct xrt_compositor_event_loss_pending loss_pending; + struct xrt_compositor_event_lost lost; }; @@ -1963,6 +1984,20 @@ struct xrt_multi_compositor_control xrt_result_t (*set_main_app_visibility)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible); + + /*! + * Notify this client/session if the compositor is going to lose the ability of rendering. + * + * @param loss_time_ns System monotonic timestamps, such as returned by os_monotonic_get_ns(). + */ + xrt_result_t (*notify_loss_pending)(struct xrt_system_compositor *xsc, + struct xrt_compositor *xc, + uint64_t loss_time_ns); + + /*! + * Notify this client/session if the compositor lost the ability of rendering. + */ + xrt_result_t (*notify_lost)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc); }; /*! @@ -2074,6 +2109,46 @@ xrt_syscomp_set_main_app_visibility(struct xrt_system_compositor *xsc, struct xr return xsc->xmcc->set_main_app_visibility(xsc, xc, visible); } +/*! + * @copydoc xrt_multi_compositor_control::notify_loss_pending + * + * Helper for calling through the function pointer. + * + * If the system compositor @p xsc does not implement @ref xrt_multi_composition_control, + * this returns @ref XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED. + * + * @public @memberof xrt_system_compositor + */ +static inline xrt_result_t +xrt_syscomp_notify_loss_pending(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, uint64_t loss_time_ns) +{ + if (xsc->xmcc == NULL) { + return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED; + } + + return xsc->xmcc->notify_loss_pending(xsc, xc, loss_time_ns); +} + +/*! + * @copydoc xrt_multi_compositor_control::notify_lost + * + * Helper for calling through the function pointer. + * + * If the system compositor @p xsc does not implement @ref xrt_multi_composition_control, + * this returns @ref XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED. + * + * @public @memberof xrt_system_compositor + */ +static inline xrt_result_t +xrt_syscomp_notify_lost(struct xrt_system_compositor *xsc, struct xrt_compositor *xc) +{ + if (xsc->xmcc == NULL) { + return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED; + } + + return xsc->xmcc->notify_lost(xsc, xc); +} + /*! * @copydoc xrt_system_compositor::create_native_compositor *