mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
xrt: Move synchronized state test into oxr session
The compositor now moves immediately to visible/focused when polling. The state tracker will generate relevant openxr state changes once the session is synchronized. Properly working alternative toe03ee48dce
(reverted ine7643de8db
)
This commit is contained in:
parent
4709744d0a
commit
965fa60bff
|
@ -210,9 +210,6 @@ compositor_wait_frame(struct xrt_compositor *xc,
|
|||
*predicted_display_time = c->last_next_display_time;
|
||||
*out_frame_id = c->last_next_display_time;
|
||||
|
||||
if (c->state == COMP_STATE_PREPARED) {
|
||||
c->state = COMP_STATE_WAITED;
|
||||
}
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -246,9 +243,6 @@ compositor_wait_frame(struct xrt_compositor *xc,
|
|||
|
||||
c->last_next_display_time = next_display_time;
|
||||
|
||||
if (c->state == COMP_STATE_PREPARED) {
|
||||
c->state = COMP_STATE_WAITED;
|
||||
}
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -529,14 +523,15 @@ compositor_poll_events(struct xrt_compositor *xc,
|
|||
U_ZERO(out_xce);
|
||||
|
||||
switch (c->state) {
|
||||
case COMP_STATE_UNINITIALIZED:
|
||||
COMP_ERROR(c, "Polled uninitialized compositor");
|
||||
out_xce->state.type = XRT_COMPOSITOR_EVENT_NONE;
|
||||
break;
|
||||
case COMP_STATE_READY:
|
||||
out_xce->state.type = XRT_COMPOSITOR_EVENT_NONE;
|
||||
break;
|
||||
case COMP_STATE_PREPARED:
|
||||
out_xce->state.type = XRT_COMPOSITOR_EVENT_NONE;
|
||||
break;
|
||||
case COMP_STATE_WAITED:
|
||||
COMP_DEBUG(c, "WAITED -> VISIBLE");
|
||||
COMP_DEBUG(c, "PREPARED -> VISIBLE");
|
||||
out_xce->state.type = XRT_COMPOSITOR_EVENT_STATE_CHANGE;
|
||||
out_xce->state.visible = true;
|
||||
c->state = COMP_STATE_VISIBLE;
|
||||
|
@ -1373,6 +1368,8 @@ xrt_gfx_provider_create_native(struct xrt_device *xdev)
|
|||
|
||||
c->compositor_frame_times.debug_var = ft;
|
||||
|
||||
c->state = COMP_STATE_READY;
|
||||
|
||||
return &c->base;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,9 +127,9 @@ struct comp_layer_slot
|
|||
*/
|
||||
enum comp_state
|
||||
{
|
||||
COMP_STATE_READY = 0,
|
||||
COMP_STATE_PREPARED = 1,
|
||||
COMP_STATE_WAITED = 2,
|
||||
COMP_STATE_UNINITIALIZED = 0,
|
||||
COMP_STATE_READY = 1,
|
||||
COMP_STATE_PREPARED = 2,
|
||||
COMP_STATE_VISIBLE = 3,
|
||||
COMP_STATE_FOCUSED = 4,
|
||||
};
|
||||
|
|
|
@ -1258,6 +1258,9 @@ struct oxr_session
|
|||
*/
|
||||
bool has_ended_once;
|
||||
|
||||
bool compositor_visible;
|
||||
bool compositor_focused;
|
||||
|
||||
bool frame_started;
|
||||
bool exiting;
|
||||
|
||||
|
|
|
@ -232,7 +232,8 @@ oxr_session_poll(struct oxr_logger *log, struct oxr_session *sess)
|
|||
return;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
bool read_more_events = true;
|
||||
while (read_more_events) {
|
||||
union xrt_compositor_event xce = {0};
|
||||
xc->poll_events(xc, &xce);
|
||||
|
||||
|
@ -240,29 +241,11 @@ oxr_session_poll(struct oxr_logger *log, struct oxr_session *sess)
|
|||
switch (xce.type) {
|
||||
case XRT_COMPOSITOR_EVENT_NONE:
|
||||
// No more events.
|
||||
return;
|
||||
read_more_events = false;
|
||||
break;
|
||||
case XRT_COMPOSITOR_EVENT_STATE_CHANGE:
|
||||
if (xce.state.visible &&
|
||||
sess->state == XR_SESSION_STATE_SYNCHRONIZED) {
|
||||
oxr_session_change_state(
|
||||
log, sess, XR_SESSION_STATE_VISIBLE);
|
||||
}
|
||||
if (xce.state.focused &&
|
||||
sess->state == XR_SESSION_STATE_VISIBLE) {
|
||||
oxr_session_change_state(
|
||||
log, sess, XR_SESSION_STATE_FOCUSED);
|
||||
}
|
||||
|
||||
if (!xce.state.focused &&
|
||||
sess->state == XR_SESSION_STATE_FOCUSED) {
|
||||
oxr_session_change_state(
|
||||
log, sess, XR_SESSION_STATE_VISIBLE);
|
||||
}
|
||||
if (!xce.state.visible &&
|
||||
sess->state == XR_SESSION_STATE_VISIBLE) {
|
||||
oxr_session_change_state(
|
||||
log, sess, XR_SESSION_STATE_SYNCHRONIZED);
|
||||
}
|
||||
sess->compositor_visible = xce.state.visible;
|
||||
sess->compositor_focused = xce.state.focused;
|
||||
break;
|
||||
case XRT_COMPOSITOR_EVENT_OVERLAY_CHANGE:
|
||||
oxr_event_push_XrEventDataMainSessionVisibilityChangedEXTX(
|
||||
|
@ -273,6 +256,16 @@ oxr_session_poll(struct oxr_logger *log, struct oxr_session *sess)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sess->state == XR_SESSION_STATE_SYNCHRONIZED &&
|
||||
sess->compositor_visible) {
|
||||
oxr_session_change_state(log, sess, XR_SESSION_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
if (sess->state == XR_SESSION_STATE_VISIBLE &&
|
||||
sess->compositor_focused) {
|
||||
oxr_session_change_state(log, sess, XR_SESSION_STATE_FOCUSED);
|
||||
}
|
||||
}
|
||||
|
||||
XrResult
|
||||
|
|
Loading…
Reference in a new issue