[mutter] monitor-manager: Refactor tiled monitor assembly code
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-manager: Refactor tiled monitor assembly code
- Date: Wed, 25 Jan 2017 08:32:18 +0000 (UTC)
commit 20b8743f210e690d45689691d7b0c1757921a7dd
Author: Jonas Ådahl <jadahl gmail com>
Date: Fri Dec 2 15:48:53 2016 +0800
monitor-manager: Refactor tiled monitor assembly code
Refactor the tiled monitor assembly code (that constructs a logical
monitor out of tiling information. Part of the reason is to move away
from array based storage, part is to make the code easier to follow,
and part is to separate logical monitor construction from list
manipulation.
https://bugzilla.gnome.org/show_bug.cgi?id=777732
src/backends/meta-monitor-manager.c | 148 ++++++++++++++++++-----------------
1 files changed, 77 insertions(+), 71 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index b67be4a..3eb3d46 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -71,98 +71,91 @@ meta_monitor_manager_init (MetaMonitorManager *manager)
{
}
-/*
- * rules for constructing a tiled monitor
- * 1. find a tile_group_id
- * 2. iterate over all outputs for that tile group id
- * 3. see if output has a crtc and if it is configured for the tile size
- * 4. calculate the total tile size
- * 5. set tile finished size
- * 6. check for more tile_group_id
-*/
+static gboolean
+is_main_tiled_monitor_output (MetaOutput *output)
+{
+ return output->tile_info.loc_h_tile == 0 && output->tile_info.loc_v_tile == 0;
+}
+
static void
-construct_tile_monitor (MetaMonitorManager *manager,
- GArray *logical_monitors,
- uint32_t tile_group_id)
+calculate_tiled_monitor_size (MetaMonitorManager *manager,
+ uint32_t tile_group_id,
+ int *out_width,
+ int *out_height)
{
- MetaLogicalMonitor new_logical_monitor;
- unsigned i;
+ int width, height;
+ unsigned int i;
- for (i = 0; i < logical_monitors->len; i++)
+ width = 0;
+ height = 0;
+ for (i = 0; i < manager->n_outputs; i++)
{
- MetaLogicalMonitor *logical_monitor = &g_array_index (logical_monitors,
- MetaLogicalMonitor,
- i);
+ MetaOutput *output = &manager->outputs[i];
+
+ if (output->tile_info.group_id != tile_group_id)
+ continue;
- if (logical_monitor->tile_group_id == tile_group_id)
- return;
+ if (output->tile_info.loc_v_tile == 0)
+ width += output->tile_info.tile_w;
+
+ if (output->tile_info.loc_h_tile == 0)
+ height += output->tile_info.tile_h;
}
- /* didn't find it */
- new_logical_monitor.number = logical_monitors->len;
- new_logical_monitor.tile_group_id = tile_group_id;
- new_logical_monitor.is_presentation = FALSE;
- new_logical_monitor.refresh_rate = 0.0;
- new_logical_monitor.width_mm = 0;
- new_logical_monitor.height_mm = 0;
- new_logical_monitor.is_primary = FALSE;
- new_logical_monitor.rect.x = INT_MAX;
- new_logical_monitor.rect.y = INT_MAX;
- new_logical_monitor.rect.width = 0;
- new_logical_monitor.rect.height = 0;
- new_logical_monitor.winsys_id = 0;
- new_logical_monitor.n_outputs = 0;
- new_logical_monitor.monitor_winsys_xid = 0;
+ *out_width = width;
+ *out_height = height;
+}
+
+static void
+add_tiled_monitor_outputs (MetaMonitorManager *manager,
+ MetaLogicalMonitor *logical_monitor,
+ uint32_t tile_group_id)
+{
+ unsigned int i;
for (i = 0; i < manager->n_outputs; i++)
{
MetaOutput *output = &manager->outputs[i];
- if (!output->tile_info.group_id)
- continue;
-
if (output->tile_info.group_id != tile_group_id)
continue;
- if (!output->crtc)
- continue;
-
- if (output->crtc->rect.width != (int)output->tile_info.tile_w ||
- output->crtc->rect.height != (int)output->tile_info.tile_h)
- continue;
-
- if (output->tile_info.loc_h_tile == 0 && output->tile_info.loc_v_tile == 0)
+ if (logical_monitor->n_outputs > META_MAX_OUTPUTS_PER_MONITOR)
{
- new_logical_monitor.refresh_rate = output->crtc->current_mode->refresh_rate;
- new_logical_monitor.width_mm = output->width_mm;
- new_logical_monitor.height_mm = output->height_mm;
- new_logical_monitor.winsys_id = output->winsys_id;
+ g_warning ("Couldn't add all outputs to monitor");
+ return;
}
- /* hack */
- if (output->crtc->rect.x < new_logical_monitor.rect.x)
- new_logical_monitor.rect.x = output->crtc->rect.x;
- if (output->crtc->rect.y < new_logical_monitor.rect.y)
- new_logical_monitor.rect.y = output->crtc->rect.y;
+ logical_monitor->outputs[logical_monitor->n_outputs] = output;
+ logical_monitor->n_outputs++;
+ }
+}
- if (output->tile_info.loc_h_tile == 0)
- new_logical_monitor.rect.height += output->tile_info.tile_h;
+static MetaLogicalMonitor *
+construct_tile_monitor (MetaMonitorManager *manager,
+ MetaOutput *output,
+ int monitor_number)
+{
+ MetaLogicalMonitor *logical_monitor = NULL;
- if (output->tile_info.loc_v_tile == 0)
- new_logical_monitor.rect.width += output->tile_info.tile_w;
+ logical_monitor = g_new0 (MetaLogicalMonitor, 1);
- if (new_logical_monitor.n_outputs > META_MAX_OUTPUTS_PER_MONITOR)
- continue;
+ logical_monitor->tile_group_id = output->tile_info.group_id;
+ logical_monitor->refresh_rate = output->crtc->current_mode->refresh_rate;
+ logical_monitor->width_mm = output->width_mm;
+ logical_monitor->height_mm = output->height_mm;
+ logical_monitor->winsys_id = output->winsys_id;
- new_logical_monitor.outputs[new_logical_monitor.n_outputs++] = output;
- }
+ logical_monitor->rect.x = output->crtc->rect.x;
+ logical_monitor->rect.y = output->crtc->rect.y;
+ calculate_tiled_monitor_size (manager, output->tile_info.group_id,
+ &logical_monitor->rect.width,
+ &logical_monitor->rect.height);
- /* if we don't have a winsys id, i.e. we haven't found tile 0,0
- don't try and add this to the monitor infos */
- if (!new_logical_monitor.winsys_id)
- return;
+ add_tiled_monitor_outputs (manager, logical_monitor,
+ output->tile_info.group_id);
- g_array_append_val (logical_monitors, new_logical_monitor);
+ return logical_monitor;
}
/*
@@ -191,9 +184,22 @@ make_logical_config (MetaMonitorManager *manager)
{
MetaOutput *output = &manager->outputs[i];
- if (output->tile_info.group_id)
- construct_tile_monitor (manager, logical_monitors,
- output->tile_info.group_id);
+ if (!output->crtc)
+ continue;
+
+ if (!output->tile_info.group_id)
+ continue;
+
+ if (is_main_tiled_monitor_output (output))
+ {
+ MetaLogicalMonitor *logical_monitor;
+
+ logical_monitor = construct_tile_monitor (manager,
+ output,
+ logical_monitors->len);
+
+ g_array_append_val (logical_monitors, logical_monitor);
+ }
}
for (i = 0; i < manager->n_crtcs; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]