Commit 92dcdb1e authored by Pete Black's avatar Pete Black

minor cleanups

parent 96e66ed1
Pipeline #162030 passed with stages
in 1 minute and 39 seconds
......@@ -452,6 +452,8 @@ init_all(struct ipc_server *s)
u_var_add_bool(s, &s->exit_on_disconnect, "exit_on_disconnect");
u_var_add_bool(s, (void *)&s->running, "running");
return 0;
}
......@@ -651,10 +653,11 @@ _overlay_sort_func(const void *a, const void *b)
{
struct _z_sort_data *oa = (struct _z_sort_data *)a;
struct _z_sort_data *ob = (struct _z_sort_data *)b;
if (oa->z_order < ob->z_order)
if (oa->z_order < ob->z_order) {
return -1;
else if (oa->z_order > ob->z_order)
} else if (oa->z_order > ob->z_order) {
return 1;
}
return 0;
}
......@@ -665,22 +668,11 @@ _update_layers(struct comp_compositor *c,
{
struct _z_sort_data z_data[IPC_MAX_CLIENTS];
// init to -1
for (uint32_t i = 0; i < IPC_MAX_CLIENTS; i++) {
z_data[i].index = -1;
z_data[i].z_order = -1;
}
// ensure our primary application is rendered first in the stack
// i.e. under any overlay applications
if (s->active_client_index >= 0) {
z_data[s->active_client_index].index = s->active_client_index;
z_data[s->active_client_index].z_order = INT32_MIN;
}
// initialise, and fill in overlay app data
for (int32_t i = 0; i < IPC_MAX_CLIENTS; i++) {
struct ipc_client_state *ics = &s->thread_state[i];
z_data[i].index = -1;
z_data[i].z_order = -1;
// we need to create a list of overlay applications, sorted by z
if (ics->client_state.session_overlay) {
if (ics->client_state.session_active) {
......@@ -690,9 +682,18 @@ _update_layers(struct comp_compositor *c,
}
}
// ensure our primary application is enabled,
// and rendered first in the stack
if (s->active_client_index >= 0) {
z_data[s->active_client_index].index = s->active_client_index;
z_data[s->active_client_index].z_order = INT32_MIN;
}
// sort the stack array
qsort(z_data, IPC_MAX_CLIENTS, sizeof(struct _z_sort_data),
_overlay_sort_func);
// count the layers
uint32_t n = 0;
for (uint32_t i = 0; i < IPC_MAX_CLIENTS; i++) {
struct _z_sort_data *zd = &z_data[i];
......@@ -710,22 +711,18 @@ _update_layers(struct comp_compositor *c,
comp_renderer_allocate_layers(c->r, n);
}
// render the layer stack
uint32_t layer_id = 0;
// printf("start layer rendering\n");
for (uint32_t i = 0; i < IPC_MAX_CLIENTS; i++) {
struct _z_sort_data *zd = &z_data[i];
if (zd->index >= 0) {
struct ipc_client_state *ics =
&s->thread_state[zd->index];
// printf("rendering layers for client %d %d\n",
// zd->index,
// zd->z_order);
for (uint32_t j = 0; j < ics->render_state.num_layers;
j++) {
volatile struct ipc_layer_render_state *layer =
&ics->render_state.layers[j];
// printf("rendering layer %d\n", j);
switch (layer->type) {
case IPC_LAYER_STEREO_PROJECTION: {
_update_projection_layer(c, ics, layer,
......@@ -888,6 +885,25 @@ handle_focused_client_events(struct ipc_client_state *ics,
}
}
void
init_server_state(struct ipc_server *s)
{
// set up initial state for global vars, and each client state
s->active_client_index = -1; // we start off with no active client.
s->last_active_client_index = -1;
s->current_slot_index = 0;
for (uint32_t i = 0; i < IPC_MAX_CLIENTS; i++) {
struct ipc_client_state *cs = &s->thread_state[i];
cs->server = s;
cs->xc = s->xc;
cs->server_thread_index = -1;
}
}
/*
*
* Exported functions.
......@@ -899,7 +915,7 @@ update_server_state(struct ipc_server *s)
{
pthread_mutex_lock(&s->global_state_lock); // multiple threads could
// conceivably call this at
// call this at
// the same time
// if our client that is set to active is still active,
......@@ -930,6 +946,7 @@ update_server_state(struct ipc_server *s)
bool set_idle = true;
int fallback_active_application = -1;
// do we have a fallback application?
for (uint32_t i = 0; i < IPC_MAX_CLIENTS; i++) {
struct ipc_client_state *ics = &s->thread_state[i];
if (ics->client_state.session_overlay == false &&
......@@ -940,7 +957,7 @@ update_server_state(struct ipc_server *s)
}
}
// if our externally-set active application is not actually
// if our currentlly-set active primary application is not actually
// active/displayable, use the fallback application instead.
struct ipc_client_state *ics = &s->thread_state[s->active_client_index];
if (!(ics->client_state.session_overlay == false &&
......@@ -951,8 +968,7 @@ update_server_state(struct ipc_server *s)
// if we have no applications to fallback to, enable the idle
// wallpaper. no session events will be sent, as the absence of
// an active application implies no running sessions.
// wallpaper.
if (set_idle) {
s->active_client_index = -1;
}
......@@ -987,20 +1003,8 @@ ipc_server_main(int argc, char **argv)
free(s);
return ret;
}
// make sure all our client connections have a handle to the
// compositor and consistent initial state
s->active_client_index = -1; // we start off with no active client.
s->last_active_client_index = -1;
s->current_slot_index = 0;
for (uint32_t i = 0; i < IPC_MAX_CLIENTS; i++) {
struct ipc_client_state *cs = &s->thread_state[i];
cs->server = s;
cs->xc = s->xc;
cs->server_thread_index = -1;
}
update_server_state(s);
init_server_state(s);
ret = main_loop(s);
teardown_all(s);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment