xrt: Add get bounds rect function

This commit is contained in:
Yu Li 2024-03-21 12:08:36 +08:00 committed by Simon Zeni
parent a40de35486
commit e8d3b875f0
3 changed files with 40 additions and 0 deletions

View file

@ -138,6 +138,7 @@ u_pp_xrt_result(struct u_pp_delegate dg, xrt_result_t xret)
switch (xret) { switch (xret) {
case XRT_SUCCESS: DG("XRT_SUCCESS"); return; case XRT_SUCCESS: DG("XRT_SUCCESS"); return;
case XRT_TIMEOUT: DG("XRT_TIMEOUT"); return; case XRT_TIMEOUT: DG("XRT_TIMEOUT"); return;
case XRT_SPACE_BOUNDS_UNAVAILABLE: DG("XRT_SPACE_BOUNDS_UNAVAILABLE"); return;
case XRT_ERROR_IPC_FAILURE: DG("XRT_ERROR_IPC_FAILURE"); return; case XRT_ERROR_IPC_FAILURE: DG("XRT_ERROR_IPC_FAILURE"); return;
case XRT_ERROR_NO_IMAGE_AVAILABLE: DG("XRT_ERROR_NO_IMAGE_AVAILABLE"); return; case XRT_ERROR_NO_IMAGE_AVAILABLE: DG("XRT_ERROR_NO_IMAGE_AVAILABLE"); return;
case XRT_ERROR_VULKAN: DG("XRT_ERROR_VULKAN"); return; case XRT_ERROR_VULKAN: DG("XRT_ERROR_VULKAN"); return;
@ -167,6 +168,7 @@ u_pp_xrt_result(struct u_pp_delegate dg, xrt_result_t xret)
case XRT_ERROR_COMPOSITOR_NOT_SUPPORTED: DG("XRT_ERROR_COMPOSITOR_NOT_SUPPORTED"); return; case XRT_ERROR_COMPOSITOR_NOT_SUPPORTED: DG("XRT_ERROR_COMPOSITOR_NOT_SUPPORTED"); return;
case XRT_ERROR_IPC_COMPOSITOR_NOT_CREATED: DG("XRT_ERROR_IPC_COMPOSITOR_NOT_CREATED"); return; case XRT_ERROR_IPC_COMPOSITOR_NOT_CREATED: DG("XRT_ERROR_IPC_COMPOSITOR_NOT_CREATED"); return;
case XRT_ERROR_DEVICE_FUNCTION_NOT_IMPLEMENTED: DG("XRT_ERROR_DEVICE_FUNCTION_NOT_IMPLEMENTED"); return; case XRT_ERROR_DEVICE_FUNCTION_NOT_IMPLEMENTED: DG("XRT_ERROR_DEVICE_FUNCTION_NOT_IMPLEMENTED"); return;
case XRT_ERROR_COMPOSITOR_FUNCTION_NOT_IMPLEMENTED: DG("XRT_ERROR_COMPOSITOR_FUNCTION_NOT_IMPLEMENTED"); return;
} }
// clang-format on // clang-format on

View file

@ -1385,6 +1385,13 @@ struct xrt_compositor
enum xrt_perf_domain domain, enum xrt_perf_domain domain,
enum xrt_perf_set_level level); enum xrt_perf_set_level level);
/*!
* @brief Get the extents of the reference spaces bounds rectangle.
*/
xrt_result_t (*get_reference_bounds_rect)(struct xrt_compositor *xc,
enum xrt_reference_space_type reference_space_type,
struct xrt_vec2 *bounds);
/*! /*!
* Teardown the compositor. * Teardown the compositor.
* *
@ -1871,6 +1878,27 @@ xrt_comp_set_performance_level(struct xrt_compositor *xc, enum xrt_perf_domain d
return xc->set_performance_level(xc, domain, level); return xc->set_performance_level(xc, domain, level);
} }
/*!
* @copydoc xrt_compositor::get_reference_bounds_rect
*
* Helper for calling through the function pointer.
*
* @public @memberof xrt_compositor
*/
static inline xrt_result_t
xrt_comp_get_reference_bounds_rect(struct xrt_compositor *xc,
enum xrt_reference_space_type reference_space_type,
struct xrt_vec2 *bounds)
{
if (xc->get_reference_bounds_rect == NULL) {
bounds->x = 0.f;
bounds->y = 0.f;
return XRT_ERROR_COMPOSITOR_FUNCTION_NOT_IMPLEMENTED;
}
return xc->get_reference_bounds_rect(xc, reference_space_type, bounds);
}
/*! /*!
* @copydoc xrt_compositor::destroy * @copydoc xrt_compositor::destroy
* *

View file

@ -32,6 +32,11 @@ typedef enum xrt_result
*/ */
XRT_TIMEOUT = 2, XRT_TIMEOUT = 2,
/*!
* The spaces bounds are not known at the moment.
*/
XRT_SPACE_BOUNDS_UNAVAILABLE = 3,
/*! /*!
* A problem occurred either with the IPC transport itself, with invalid commands from the client, or with * A problem occurred either with the IPC transport itself, with invalid commands from the client, or with
* invalid responses from the server. * invalid responses from the server.
@ -181,4 +186,9 @@ typedef enum xrt_result
* error condition on bad code. * error condition on bad code.
*/ */
XRT_ERROR_DEVICE_FUNCTION_NOT_IMPLEMENTED = -29, XRT_ERROR_DEVICE_FUNCTION_NOT_IMPLEMENTED = -29,
/*!
* The function was not implemented in the compositor
*/
XRT_ERROR_COMPOSITOR_FUNCTION_NOT_IMPLEMENTED = -30,
} xrt_result_t; } xrt_result_t;