crtc-mode: Move away fields from public MetaCrtcMode struct

The ID and name are just moved into the instance private, while the rest
is moved to a `MetaCrtcModeInfo` struct which is used during
construction and retrieved via a getter. Opens up the possibility to
add actual sub types.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
This commit is contained in:
Jonas Ådahl
2020-02-27 00:08:58 +01:00
committed by Georges Basile Stavracas Neto
parent 980ece9a4b
commit 4b37c2e446
16 changed files with 373 additions and 108 deletions

View File

@ -119,6 +119,7 @@ meta_test_headless_monitor_connect (void)
META_MONITOR_MANAGER_TEST (monitor_manager);
MetaMonitorTestSetup *test_setup;
MetaCrtcMode **modes;
g_autoptr (MetaCrtcModeInfo) crtc_mode_info = NULL;
MetaCrtcMode *crtc_mode;
MetaGpu *gpu;
MetaCrtc *crtc;
@ -130,11 +131,15 @@ meta_test_headless_monitor_connect (void)
test_setup = g_new0 (MetaMonitorTestSetup, 1);
crtc_mode = g_object_new (META_TYPE_CRTC_MODE, NULL);
crtc_mode->mode_id = 1;
crtc_mode->width = 1024;
crtc_mode->height = 768;
crtc_mode->refresh_rate = 60.0;
crtc_mode_info = meta_crtc_mode_info_new ();
crtc_mode_info->width = 1024;
crtc_mode_info->height = 768;
crtc_mode_info->refresh_rate = 60.0;
crtc_mode = g_object_new (META_TYPE_CRTC_MODE,
"id", 1,
"info", crtc_mode_info,
NULL);
test_setup->modes = g_list_append (NULL, crtc_mode);
gpu = META_GPU (meta_backend_get_gpus (meta_get_backend ())->data);

View File

@ -148,14 +148,17 @@ check_monitor_mode (MetaMonitor *monitor,
if (crtc_mode)
{
const MetaCrtcModeInfo *crtc_mode_info =
meta_crtc_mode_get_info (crtc_mode);
float refresh_rate;
MetaCrtcModeFlag flags;
refresh_rate = meta_monitor_mode_get_refresh_rate (mode);
flags = meta_monitor_mode_get_flags (mode);
g_assert_cmpfloat (refresh_rate, ==, crtc_mode->refresh_rate);
g_assert_cmpint (flags, ==, (crtc_mode->flags & HANDLED_CRTC_MODE_FLAGS));
g_assert_cmpfloat (refresh_rate, ==, crtc_mode_info->refresh_rate);
g_assert_cmpint (flags, ==, (crtc_mode_info->flags &
HANDLED_CRTC_MODE_FLAGS));
}
data->expect_crtc_mode_iter++;
@ -543,14 +546,19 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
test_setup->modes = NULL;
for (i = 0; i < setup->n_modes; i++)
{
g_autoptr (MetaCrtcModeInfo) crtc_mode_info = NULL;
MetaCrtcMode *mode;
mode = g_object_new (META_TYPE_CRTC_MODE, NULL);
mode->mode_id = i;
mode->width = setup->modes[i].width;
mode->height = setup->modes[i].height;
mode->refresh_rate = setup->modes[i].refresh_rate;
mode->flags = setup->modes[i].flags;
crtc_mode_info = meta_crtc_mode_info_new ();
crtc_mode_info->width = setup->modes[i].width;
crtc_mode_info->height = setup->modes[i].height;
crtc_mode_info->refresh_rate = setup->modes[i].refresh_rate;
crtc_mode_info->flags = setup->modes[i].flags;
mode = g_object_new (META_TYPE_CRTC_MODE,
"id", i,
"info", crtc_mode_info,
NULL);
test_setup->modes = g_list_append (test_setup->modes, mode);
}