From 1abdae5b64c2abc8f5b7d88fa0e4cf829254af32 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 28 Oct 2019 20:56:33 +0000 Subject: [PATCH] xrt: Add helper functions for xrt_compositor --- src/xrt/include/xrt/xrt_compositor.h | 136 +++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index a32042ac5..43fac005e 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -209,6 +209,142 @@ struct xrt_compositor void (*destroy)(struct xrt_compositor *xc); }; +/*! + * Helper for xrt_compositor::create_swapchain + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static struct xrt_swapchain * +xrt_comp_create_swapchain(struct xrt_compositor *xc, + enum xrt_swapchain_create_flags create, + enum xrt_swapchain_usage_bits bits, + int64_t format, + uint32_t sample_count, + uint32_t width, + uint32_t height, + uint32_t face_count, + uint32_t array_size, + uint32_t mip_count) +{ + return xc->create_swapchain(xc, create, bits, format, sample_count, + width, height, face_count, array_size, + mip_count); +} + +/*! + * Helper for xrt_compositor::poll_events + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_poll_events(struct xrt_compositor *xc, uint64_t *WIP) +{ + xc->poll_events(xc, WIP); +} + +/*! + * Helper for xrt_compositor::prepare_session + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_prepare_session(struct xrt_compositor *xc) +{ + xc->prepare_session(xc); +} + +/*! + * Helper for xrt_compositor::begin_session + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_begin_session(struct xrt_compositor *xc, enum xrt_view_type view_type) +{ + xc->begin_session(xc, view_type); +} + +/*! + * Helper for xrt_compositor::end_session + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_end_session(struct xrt_compositor *xc) +{ + xc->end_session(xc); +} + +/*! + * Helper for xrt_compositor::wait_frame + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_wait_frame(struct xrt_compositor *xc, + int64_t *predicted_display_time, + int64_t *predicted_display_period) +{ + xc->wait_frame(xc, predicted_display_time, predicted_display_period); +} + +/*! + * Helper for xrt_compositor::begin_frame + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_begin_frame(struct xrt_compositor *xc) +{ + xc->begin_frame(xc); +} + +/*! + * Helper for xrt_compositor::discard_frame + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_discard_frame(struct xrt_compositor *xc) +{ + xc->discard_frame(xc); +} + +/*! + * Helper for xrt_compositor::end_frame + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_end_frame(struct xrt_compositor *xc, + enum xrt_blend_mode blend_mode, + struct xrt_swapchain **xscs, + const uint32_t *image_index, + uint32_t *layers, + uint32_t num_swapchains) +{ + xc->end_frame(xc, blend_mode, xscs, image_index, layers, + num_swapchains); +} + +/*! + * Helper for xrt_compositor::destroy, does a null check and sets xc_ptr to + * null if freed. + * + * @ingroup xrt_iface + */ +XRT_MAYBE_UNUSED static void +xrt_comp_destroy(struct xrt_compositor **xc_ptr) +{ + struct xrt_compositor *xc = *xc_ptr; + if (xc == NULL) { + return; + } + + xc->destroy(xc); + *xc_ptr = NULL; +} + /* *