mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-14 17:50:06 +00:00
ipc: Refactor native compositor creation
This commit is contained in:
parent
dd9a425202
commit
5d64b1d447
src/xrt/ipc/client
|
@ -202,18 +202,40 @@ ipc_client_xdev(struct xrt_device *xdev)
|
|||
/*!
|
||||
* Create an IPC client system compositor.
|
||||
*
|
||||
* It owns a special implementation of the @ref xrt_system_compositor interface.
|
||||
*
|
||||
* This actually creates an IPC client "native" compositor with deferred
|
||||
* initialization. The @ref ipc_client_create_native_compositor function
|
||||
* actually completes the deferred initialization of the compositor, effectively
|
||||
* finishing creation of a compositor IPC proxy.
|
||||
*
|
||||
* @param ipc_c IPC connection
|
||||
* @param xina Optional native image allocator for client-side allocation. Takes
|
||||
* ownership if one is supplied.
|
||||
* @param xdev Taken in but not used currently @todo remove this param?
|
||||
* @param[out] out_xcs Pointer to receive the created xrt_system_compositor.
|
||||
*/
|
||||
int
|
||||
xrt_result_t
|
||||
ipc_client_create_system_compositor(struct ipc_connection *ipc_c,
|
||||
struct xrt_image_native_allocator *xina,
|
||||
struct xrt_device *xdev,
|
||||
struct xrt_system_compositor **out_xcs);
|
||||
|
||||
/*!
|
||||
* Create a native compositor from a system compositor, this is used instead
|
||||
* of the normal xrt_system_compositor::create_native_compositor function
|
||||
* because it doesn't support events being generated on the app side. This will
|
||||
* also create the session on the service side.
|
||||
*
|
||||
* @param xsysc IPC created system compositor.
|
||||
* @param xsi Session information struct.
|
||||
* @param[out] out_xcn Pointer to receive the created xrt_compositor_native.
|
||||
*/
|
||||
xrt_result_t
|
||||
ipc_client_create_native_compositor(struct xrt_system_compositor *xsysc,
|
||||
const struct xrt_session_info *xsi,
|
||||
struct xrt_compositor_native **out_xcn);
|
||||
|
||||
struct xrt_device *
|
||||
ipc_client_hmd_create(struct ipc_connection *ipc_c, struct xrt_tracking_origin *xtrack, uint32_t device_id);
|
||||
|
||||
|
|
|
@ -993,20 +993,8 @@ ipc_syscomp_create_native_compositor(struct xrt_system_compositor *xsc,
|
|||
struct ipc_client_compositor *icc = container_of(xsc, struct ipc_client_compositor, system);
|
||||
xrt_result_t xret;
|
||||
|
||||
if (icc->compositor_created) {
|
||||
return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// Needs to be done before init.
|
||||
xret = ipc_call_session_create(icc->ipc_c, xsi);
|
||||
IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_session_create");
|
||||
|
||||
// Needs to be done after session create call.
|
||||
ipc_compositor_init(icc, out_xcn);
|
||||
|
||||
icc->compositor_created = true;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
xret = ipc_client_create_native_compositor(xsc, xsi, out_xcn);
|
||||
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_client_create_native_compositor");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1030,15 +1018,31 @@ ipc_syscomp_destroy(struct xrt_system_compositor *xsc)
|
|||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
*
|
||||
*
|
||||
* This actually creates an IPC client "native" compositor with deferred initialization.
|
||||
* It owns a special implementation of the @ref xrt_system_compositor interface
|
||||
* whose "create_native_compositor" method actually completes the deferred initialization
|
||||
* of the compositor, effectively finishing creation of a compositor IPC proxy.
|
||||
*/
|
||||
int
|
||||
xrt_result_t
|
||||
ipc_client_create_native_compositor(struct xrt_system_compositor *xsysc,
|
||||
const struct xrt_session_info *xsi,
|
||||
struct xrt_compositor_native **out_xcn)
|
||||
{
|
||||
struct ipc_client_compositor *icc = container_of(xsysc, struct ipc_client_compositor, system);
|
||||
xrt_result_t xret;
|
||||
|
||||
if (icc->compositor_created) {
|
||||
return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// Needs to be done before init.
|
||||
xret = ipc_call_session_create(icc->ipc_c, xsi);
|
||||
IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_session_create");
|
||||
|
||||
// Needs to be done after session create call.
|
||||
ipc_compositor_init(icc, out_xcn);
|
||||
|
||||
icc->compositor_created = true;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
xrt_result_t
|
||||
ipc_client_create_system_compositor(struct ipc_connection *ipc_c,
|
||||
struct xrt_image_native_allocator *xina,
|
||||
struct xrt_device *xdev,
|
||||
|
@ -1067,5 +1071,5 @@ ipc_client_create_system_compositor(struct ipc_connection *ipc_c,
|
|||
|
||||
*out_xcs = &c->system;
|
||||
|
||||
return 0;
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -95,21 +95,30 @@ create_system_compositor(struct ipc_client_instance *ii,
|
|||
{
|
||||
struct xrt_system_compositor *xsysc = NULL;
|
||||
struct xrt_image_native_allocator *xina = NULL;
|
||||
xrt_result_t xret;
|
||||
|
||||
#ifdef XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER
|
||||
// On Android, we allocate images natively on the client side.
|
||||
xina = android_ahardwarebuffer_allocator_create();
|
||||
#endif // XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER
|
||||
|
||||
int ret = ipc_client_create_system_compositor(&ii->ipc_c, xina, xdev, &xsysc);
|
||||
if (ret < 0 || xsysc == NULL) {
|
||||
xrt_images_destroy(&xina);
|
||||
return XRT_ERROR_IPC_FAILURE;
|
||||
xret = ipc_client_create_system_compositor(&ii->ipc_c, xina, xdev, &xsysc);
|
||||
IPC_CHK_WITH_GOTO(&ii->ipc_c, xret, "ipc_client_create_system_compositor", err_xina);
|
||||
|
||||
// Paranoia.
|
||||
if (xsysc == NULL) {
|
||||
xret = XRT_ERROR_IPC_FAILURE;
|
||||
IPC_ERROR(&ii->ipc_c, "Variable xsysc NULL!");
|
||||
goto err_xina;
|
||||
}
|
||||
|
||||
*out_xsysc = xsysc;
|
||||
|
||||
return 0;
|
||||
return XRT_SUCCESS;
|
||||
|
||||
err_xina:
|
||||
xrt_images_destroy(&xina);
|
||||
return xret;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue