mirror of
https://github.com/brl/mutter.git
synced 2025-08-04 07:34:53 +00:00
backend: Move GPU ownership from the monitor manager to the backend
Lets work towards making MetaMonitorManager about managing monitors, and not about managing GPUs. This changes other units to keep a pointer to the backend instead of a monitor manager, in case their ownership changed, or their main usage of the monitor manager was to look up GPUs. https://gitlab.gnome.org/GNOME/mutter/issues/548 https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
e7fd068a78
commit
5c500ad402
@@ -79,7 +79,7 @@ meta_test_headless_start (void)
|
||||
GList *gpus;
|
||||
MetaGpu *gpu;
|
||||
|
||||
gpus = meta_monitor_manager_get_gpus (monitor_manager);
|
||||
gpus = meta_backend_get_gpus (backend);
|
||||
g_assert_cmpint ((int) g_list_length (gpus), ==, 1);
|
||||
|
||||
gpu = gpus->data;
|
||||
|
@@ -66,6 +66,8 @@ unit_tests = executable('mutter-test-unit-tests',
|
||||
'boxes-tests.h',
|
||||
'meta-backend-test.c',
|
||||
'meta-backend-test.h',
|
||||
'meta-gpu-test.c',
|
||||
'meta-gpu-test.h',
|
||||
'meta-monitor-manager-test.c',
|
||||
'meta-monitor-manager-test.h',
|
||||
'monitor-config-migration-unit-tests.c',
|
||||
@@ -89,6 +91,8 @@ headless_start_test = executable('mutter-headless-start-test',
|
||||
'headless-start-test.c',
|
||||
'meta-backend-test.c',
|
||||
'meta-backend-test.h',
|
||||
'meta-gpu-test.c',
|
||||
'meta-gpu-test.h',
|
||||
'meta-monitor-manager-test.c',
|
||||
'meta-monitor-manager-test.h',
|
||||
'test-utils.c',
|
||||
|
@@ -21,12 +21,15 @@
|
||||
|
||||
#include "tests/meta-backend-test.h"
|
||||
|
||||
#include "tests/meta-gpu-test.h"
|
||||
#include "tests/meta-monitor-manager-test.h"
|
||||
|
||||
struct _MetaBackendTest
|
||||
{
|
||||
MetaBackendX11Nested parent;
|
||||
|
||||
MetaGpu *gpu;
|
||||
|
||||
gboolean is_lid_closed;
|
||||
};
|
||||
|
||||
@@ -39,6 +42,12 @@ meta_backend_test_set_is_lid_closed (MetaBackendTest *backend_test,
|
||||
backend_test->is_lid_closed = is_lid_closed;
|
||||
}
|
||||
|
||||
MetaGpu *
|
||||
meta_backend_test_get_gpu (MetaBackendTest *backend_test)
|
||||
{
|
||||
return backend_test->gpu;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_backend_test_is_lid_closed (MetaBackend *backend)
|
||||
{
|
||||
@@ -47,6 +56,17 @@ meta_backend_test_is_lid_closed (MetaBackend *backend)
|
||||
return backend_test->is_lid_closed;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_test_init_gpus (MetaBackendX11Nested *backend_x11_nested)
|
||||
{
|
||||
MetaBackendTest *backend_test = META_BACKEND_TEST (backend_x11_nested);
|
||||
|
||||
backend_test->gpu = g_object_new (META_TYPE_GPU_TEST,
|
||||
"backend", backend_test,
|
||||
NULL);
|
||||
meta_backend_add_gpu (META_BACKEND (backend_test), backend_test->gpu);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_test_init (MetaBackendTest *backend_test)
|
||||
{
|
||||
@@ -65,7 +85,11 @@ static void
|
||||
meta_backend_test_class_init (MetaBackendTestClass *klass)
|
||||
{
|
||||
MetaBackendClass *backend_class = META_BACKEND_CLASS (klass);
|
||||
MetaBackendX11NestedClass *backend_x11_nested_class =
|
||||
META_BACKEND_X11_NESTED_CLASS (klass);
|
||||
|
||||
backend_class->create_monitor_manager = meta_backend_test_create_monitor_manager;
|
||||
backend_class->is_lid_closed = meta_backend_test_is_lid_closed;
|
||||
|
||||
backend_x11_nested_class->init_gpus = meta_backend_test_init_gpus;
|
||||
}
|
||||
|
@@ -29,4 +29,6 @@ G_DECLARE_FINAL_TYPE (MetaBackendTest, meta_backend_test,
|
||||
void meta_backend_test_set_is_lid_closed (MetaBackendTest *backend_test,
|
||||
gboolean is_lid_closed);
|
||||
|
||||
MetaGpu * meta_backend_test_get_gpu (MetaBackendTest *backend_test);
|
||||
|
||||
#endif /* META_BACKEND_TEST_H */
|
||||
|
55
src/tests/meta-gpu-test.c
Normal file
55
src/tests/meta-gpu-test.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2018 Red Hat, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "tests/meta-gpu-test.h"
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "tests/meta-monitor-manager-test.h"
|
||||
|
||||
struct _MetaGpuTest
|
||||
{
|
||||
MetaGpu parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaGpuTest, meta_gpu_test, META_TYPE_GPU)
|
||||
|
||||
static gboolean
|
||||
meta_gpu_test_read_current (MetaGpu *gpu,
|
||||
GError **error)
|
||||
{
|
||||
MetaBackend *backend = meta_gpu_get_backend (gpu);
|
||||
MetaMonitorManager *manager = meta_backend_get_monitor_manager (backend);
|
||||
|
||||
meta_monitor_manager_test_read_current (manager);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_gpu_test_init (MetaGpuTest *gpu_test)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
meta_gpu_test_class_init (MetaGpuTestClass *klass)
|
||||
{
|
||||
MetaGpuClass *gpu_class = META_GPU_CLASS (klass);
|
||||
|
||||
gpu_class->read_current = meta_gpu_test_read_current;
|
||||
}
|
26
src/tests/meta-gpu-test.h
Normal file
26
src/tests/meta-gpu-test.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2018 Red Hat, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef META_GPU_TEST_H
|
||||
#define META_GPU_TEST_H
|
||||
|
||||
#include "backends/meta-gpu.h"
|
||||
|
||||
#define META_TYPE_GPU_TEST (meta_gpu_test_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (MetaGpuTest, meta_gpu_test, META, GPU_TEST, MetaGpu)
|
||||
|
||||
#endif /* META_GPU_TEST_H */
|
@@ -26,13 +26,12 @@
|
||||
#include "backends/meta-gpu.h"
|
||||
#include "backends/meta-monitor-config-manager.h"
|
||||
#include "backends/meta-output.h"
|
||||
#include "tests/meta-backend-test.h"
|
||||
|
||||
struct _MetaMonitorManagerTest
|
||||
{
|
||||
MetaMonitorManager parent;
|
||||
|
||||
MetaGpu *gpu;
|
||||
|
||||
gboolean handles_transforms;
|
||||
|
||||
int tiled_monitor_count;
|
||||
@@ -43,13 +42,6 @@ struct _MetaMonitorManagerTest
|
||||
G_DEFINE_TYPE (MetaMonitorManagerTest, meta_monitor_manager_test,
|
||||
META_TYPE_MONITOR_MANAGER)
|
||||
|
||||
struct _MetaGpuTest
|
||||
{
|
||||
MetaGpu parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaGpuTest, meta_gpu_test, META_TYPE_GPU)
|
||||
|
||||
static MetaMonitorTestSetup *_initial_test_setup = NULL;
|
||||
|
||||
void
|
||||
@@ -58,12 +50,6 @@ meta_monitor_manager_test_init_test_setup (MetaMonitorTestSetup *test_setup)
|
||||
_initial_test_setup = test_setup;
|
||||
}
|
||||
|
||||
MetaGpu *
|
||||
meta_monitor_manager_test_get_gpu (MetaMonitorManagerTest *manager_test)
|
||||
{
|
||||
return manager_test->gpu;
|
||||
}
|
||||
|
||||
void
|
||||
meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
|
||||
MetaMonitorTestSetup *test_setup)
|
||||
@@ -95,11 +81,13 @@ meta_monitor_manager_test_get_tiled_monitor_count (MetaMonitorManagerTest *manag
|
||||
return manager_test->tiled_monitor_count;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
meta_monitor_manager_test_read_current (MetaMonitorManager *manager)
|
||||
{
|
||||
MetaMonitorManagerTest *manager_test = META_MONITOR_MANAGER_TEST (manager);
|
||||
MetaGpu *gpu = manager_test->gpu;
|
||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||
MetaBackendTest *backend_test = META_BACKEND_TEST (backend);
|
||||
MetaGpu *gpu = meta_backend_test_get_gpu (backend_test);
|
||||
GList *l;
|
||||
|
||||
g_assert (manager_test->test_setup);
|
||||
@@ -109,14 +97,9 @@ meta_monitor_manager_test_read_current (MetaMonitorManager *manager)
|
||||
for (l = manager_test->test_setup->crtcs; l; l = l->next)
|
||||
META_CRTC (l->data)->gpu = gpu;
|
||||
|
||||
meta_gpu_take_modes (manager_test->gpu,
|
||||
manager_test->test_setup->modes);
|
||||
|
||||
meta_gpu_take_crtcs (manager_test->gpu,
|
||||
manager_test->test_setup->crtcs);
|
||||
|
||||
meta_gpu_take_outputs (manager_test->gpu,
|
||||
manager_test->test_setup->outputs);
|
||||
meta_gpu_take_modes (gpu, manager_test->test_setup->modes);
|
||||
meta_gpu_take_crtcs (gpu, manager_test->test_setup->crtcs);
|
||||
meta_gpu_take_outputs (gpu, manager_test->test_setup->outputs);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -143,7 +126,9 @@ apply_crtc_assignments (MetaMonitorManager *manager,
|
||||
MetaOutputInfo **outputs,
|
||||
unsigned int n_outputs)
|
||||
{
|
||||
MetaMonitorManagerTest *manager_test = META_MONITOR_MANAGER_TEST (manager);
|
||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||
MetaBackendTest *backend_test = META_BACKEND_TEST (backend);
|
||||
MetaGpu *gpu = meta_backend_test_get_gpu (backend_test);
|
||||
GList *l;
|
||||
unsigned int i;
|
||||
|
||||
@@ -209,7 +194,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
|
||||
}
|
||||
|
||||
/* Disable CRTCs not mentioned in the list */
|
||||
for (l = meta_gpu_get_crtcs (manager_test->gpu); l; l = l->next)
|
||||
for (l = meta_gpu_get_crtcs (gpu); l; l = l->next)
|
||||
{
|
||||
MetaCrtc *crtc = l->data;
|
||||
|
||||
@@ -229,7 +214,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
|
||||
}
|
||||
|
||||
/* Disable outputs not mentioned in the list */
|
||||
for (l = meta_gpu_get_outputs (manager_test->gpu); l; l = l->next)
|
||||
for (l = meta_gpu_get_outputs (gpu); l; l = l->next)
|
||||
{
|
||||
MetaOutput *output = l->data;
|
||||
|
||||
@@ -458,18 +443,11 @@ meta_monitor_manager_test_dispose (GObject *object)
|
||||
static void
|
||||
meta_monitor_manager_test_init (MetaMonitorManagerTest *manager_test)
|
||||
{
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_test);
|
||||
|
||||
g_assert (_initial_test_setup);
|
||||
|
||||
manager_test->handles_transforms = TRUE;
|
||||
|
||||
manager_test->test_setup = _initial_test_setup;
|
||||
|
||||
manager_test->gpu = g_object_new (META_TYPE_GPU_TEST,
|
||||
"monitor-manager", manager,
|
||||
NULL);
|
||||
meta_monitor_manager_add_gpu (manager, manager_test->gpu);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -491,27 +469,3 @@ meta_monitor_manager_test_class_init (MetaMonitorManagerTestClass *klass)
|
||||
manager_class->get_max_screen_size = meta_monitor_manager_test_get_max_screen_size;
|
||||
manager_class->get_default_layout_mode = meta_monitor_manager_test_get_default_layout_mode;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_gpu_test_read_current (MetaGpu *gpu,
|
||||
GError **error)
|
||||
{
|
||||
MetaMonitorManager *manager = meta_gpu_get_monitor_manager (gpu);
|
||||
|
||||
meta_monitor_manager_test_read_current (manager);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_gpu_test_init (MetaGpuTest *gpu_test)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
meta_gpu_test_class_init (MetaGpuTestClass *klass)
|
||||
{
|
||||
MetaGpuClass *gpu_class = META_GPU_CLASS (klass);
|
||||
|
||||
gpu_class->read_current = meta_gpu_test_read_current;
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#ifndef META_MONITOR_MANAGER_TEST_H
|
||||
#define META_MONITOR_MANAGER_TEST_H
|
||||
|
||||
#include "backends/meta-gpu.h"
|
||||
#include "backends/meta-monitor-manager-private.h"
|
||||
|
||||
typedef struct _MetaMonitorTestSetup
|
||||
@@ -39,12 +38,9 @@ typedef struct _MetaOutputTest
|
||||
G_DECLARE_FINAL_TYPE (MetaMonitorManagerTest, meta_monitor_manager_test,
|
||||
META, MONITOR_MANAGER_TEST, MetaMonitorManager)
|
||||
|
||||
#define META_TYPE_GPU_TEST (meta_gpu_test_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (MetaGpuTest, meta_gpu_test, META, GPU_TEST, MetaGpu)
|
||||
|
||||
void meta_monitor_manager_test_init_test_setup (MetaMonitorTestSetup *test_setup);
|
||||
|
||||
MetaGpu * meta_monitor_manager_test_get_gpu (MetaMonitorManagerTest *manager_test);
|
||||
void meta_monitor_manager_test_read_current (MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
|
||||
MetaMonitorTestSetup *test_setup);
|
||||
|
@@ -408,12 +408,10 @@ destroy_monitor_test_clients (void)
|
||||
}
|
||||
|
||||
static MetaOutput *
|
||||
output_from_winsys_id (MetaMonitorManager *monitor_manager,
|
||||
uint64_t winsys_id)
|
||||
output_from_winsys_id (MetaBackend *backend,
|
||||
uint64_t winsys_id)
|
||||
{
|
||||
MetaMonitorManagerTest *monitor_manager_test =
|
||||
META_MONITOR_MANAGER_TEST (monitor_manager);
|
||||
MetaGpu *gpu = meta_monitor_manager_test_get_gpu (monitor_manager_test);
|
||||
MetaGpu *gpu = meta_backend_test_get_gpu (META_BACKEND_TEST (backend));
|
||||
GList *l;
|
||||
|
||||
for (l = meta_gpu_get_outputs (gpu); l; l = l->next)
|
||||
@@ -429,7 +427,7 @@ output_from_winsys_id (MetaMonitorManager *monitor_manager,
|
||||
|
||||
typedef struct _CheckMonitorModeData
|
||||
{
|
||||
MetaMonitorManager *monitor_manager;
|
||||
MetaBackend *backend;
|
||||
MetaTestCaseMonitorCrtcMode *expect_crtc_mode_iter;
|
||||
} CheckMonitorModeData;
|
||||
|
||||
@@ -441,12 +439,12 @@ check_monitor_mode (MetaMonitor *monitor,
|
||||
GError **error)
|
||||
{
|
||||
CheckMonitorModeData *data = user_data;
|
||||
MetaMonitorManager *monitor_manager = data->monitor_manager;
|
||||
MetaBackend *backend = data->backend;
|
||||
MetaOutput *output;
|
||||
MetaCrtcMode *crtc_mode;
|
||||
int expect_crtc_mode_index;
|
||||
|
||||
output = output_from_winsys_id (monitor_manager,
|
||||
output = output_from_winsys_id (backend,
|
||||
data->expect_crtc_mode_iter->output);
|
||||
g_assert (monitor_crtc_mode->output == output);
|
||||
|
||||
@@ -489,11 +487,11 @@ check_current_monitor_mode (MetaMonitor *monitor,
|
||||
GError **error)
|
||||
{
|
||||
CheckMonitorModeData *data = user_data;
|
||||
MetaMonitorManager *monitor_manager = data->monitor_manager;
|
||||
MetaBackend *backend = data->backend;
|
||||
MetaOutput *output;
|
||||
MetaCrtc *crtc;
|
||||
|
||||
output = output_from_winsys_id (monitor_manager,
|
||||
output = output_from_winsys_id (backend,
|
||||
data->expect_crtc_mode_iter->output);
|
||||
crtc = meta_output_get_assigned_crtc (output);
|
||||
|
||||
@@ -661,7 +659,7 @@ check_monitor_configuration (MonitorTestCase *test_case)
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaMonitorManagerTest *monitor_manager_test =
|
||||
META_MONITOR_MANAGER_TEST (monitor_manager);
|
||||
MetaGpu *gpu = meta_monitor_manager_test_get_gpu (monitor_manager_test);
|
||||
MetaGpu *gpu = meta_backend_test_get_gpu (META_BACKEND_TEST (backend));
|
||||
int tiled_monitor_count;
|
||||
GList *monitors;
|
||||
GList *crtcs;
|
||||
@@ -716,8 +714,7 @@ check_monitor_configuration (MonitorTestCase *test_case)
|
||||
MetaOutput *output = l_output->data;
|
||||
uint64_t winsys_id = test_case->expect.monitors[i].outputs[j];
|
||||
|
||||
g_assert (output == output_from_winsys_id (monitor_manager,
|
||||
winsys_id));
|
||||
g_assert (output == output_from_winsys_id (backend, winsys_id));
|
||||
g_assert_cmpint (test_case->expect.monitors[i].is_underscanning,
|
||||
==,
|
||||
output->is_underscanning);
|
||||
@@ -763,7 +760,7 @@ check_monitor_configuration (MonitorTestCase *test_case)
|
||||
test_case->expect.monitors[i].modes[j].flags);
|
||||
|
||||
data = (CheckMonitorModeData) {
|
||||
.monitor_manager = monitor_manager,
|
||||
.backend = backend,
|
||||
.expect_crtc_mode_iter =
|
||||
test_case->expect.monitors[i].modes[j].crtc_modes
|
||||
};
|
||||
@@ -792,7 +789,7 @@ check_monitor_configuration (MonitorTestCase *test_case)
|
||||
CheckMonitorModeData data;
|
||||
|
||||
data = (CheckMonitorModeData) {
|
||||
.monitor_manager = monitor_manager,
|
||||
.backend = backend,
|
||||
.expect_crtc_mode_iter =
|
||||
test_case->expect.monitors[i].modes[expected_current_mode_index].crtc_modes
|
||||
};
|
||||
|
Reference in New Issue
Block a user