kms/update: Merge connector updates too

This includes privacy screen updates, underscanning etc; this is needed
when merging mode set updates that happen to change these too, which is
rather likely.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2881>
This commit is contained in:
Jonas Ådahl 2023-03-02 22:09:16 +01:00
parent 907e17ac25
commit ffd1e8106c
3 changed files with 93 additions and 2 deletions

View File

@ -844,6 +844,69 @@ merge_crtc_color_updates_from (MetaKmsUpdate *update,
}
}
static GList *
find_connector_update_link_for (MetaKmsUpdate *update,
MetaKmsConnector *connector)
{
GList *l;
for (l = update->connector_updates; l; l = l->next)
{
MetaKmsConnectorUpdate *connector_update = l->data;
if (connector_update->connector == connector)
return l;
}
return NULL;
}
static void
merge_connector_updates_from (MetaKmsUpdate *update,
MetaKmsUpdate *other_update)
{
while (other_update->connector_updates)
{
GList *l = other_update->connector_updates;
MetaKmsConnectorUpdate *other_connector_update = l->data;
MetaKmsConnector *connector = other_connector_update->connector;
GList *el;
other_update->connector_updates =
g_list_remove_link (other_update->connector_updates, l);
el = find_connector_update_link_for (update, connector);
if (el)
{
MetaKmsConnectorUpdate *connector_update = el->data;
if (other_connector_update->underscanning.has_update)
{
connector_update->underscanning =
other_connector_update->underscanning;
}
if (other_connector_update->privacy_screen.has_update)
{
connector_update->privacy_screen =
other_connector_update->privacy_screen;
}
if (other_connector_update->max_bpc.has_update)
{
connector_update->max_bpc =
other_connector_update->max_bpc;
}
}
else
{
update->connector_updates =
g_list_insert_before_link (update->connector_updates,
update->connector_updates,
l);
}
}
}
static void
merge_custom_page_flip_from (MetaKmsUpdate *update,
MetaKmsUpdate *other_update)
@ -880,12 +943,11 @@ meta_kms_update_merge_from (MetaKmsUpdate *update,
MetaKmsUpdate *other_update)
{
g_return_if_fail (update->device == other_update->device);
g_return_if_fail (!update->connector_updates &&
!other_update->connector_updates);
merge_mode_sets (update, other_update);
merge_plane_assignments_from (update, other_update);
merge_crtc_color_updates_from (update, other_update);
merge_connector_updates_from (update, other_update);
merge_custom_page_flip_from (update, other_update);
merge_page_flip_listeners_from (update, other_update);
merge_result_listeners_from (update, other_update);

View File

@ -104,6 +104,7 @@ void meta_kms_update_free (MetaKmsUpdate *update);
META_EXPORT_TEST
MetaKmsDevice * meta_kms_update_get_device (MetaKmsUpdate *update);
META_EXPORT_TEST
void meta_kms_update_set_underscanning (MetaKmsUpdate *update,
MetaKmsConnector *connector,
uint64_t hborder,
@ -112,10 +113,12 @@ void meta_kms_update_set_underscanning (MetaKmsUpdate *update,
void meta_kms_update_unset_underscanning (MetaKmsUpdate *update,
MetaKmsConnector *connector);
META_EXPORT_TEST
void meta_kms_update_set_privacy_screen (MetaKmsUpdate *update,
MetaKmsConnector *connector,
gboolean enabled);
META_EXPORT_TEST
void meta_kms_update_set_max_bpc (MetaKmsUpdate *update,
MetaKmsConnector *connector,
uint64_t max_bpc);

View File

@ -413,6 +413,8 @@ meta_test_kms_update_merge (void)
GList *crtc_color_updates;
MetaKmsCrtcColorUpdate *crtc_color_update;
MetaGammaLut *crtc_gamma;
GList *connector_updates;
MetaKmsConnectorUpdate *connector_update;
device = meta_get_test_kms_device (test_context);
crtc = meta_get_test_kms_crtc (device);
@ -455,6 +457,11 @@ meta_test_kms_update_merge (void)
meta_kms_plane_assignment_set_cursor_hotspot (cursor_plane_assignment,
10, 11);
meta_kms_update_set_underscanning (update1,
connector,
123, 456);
meta_kms_update_set_privacy_screen (update1, connector, TRUE);
/*
* Create an update2 with a mode set and a cursor buffer 2
* on the cursor plane at at (32, 56), and a new CRTC gamma.
@ -486,6 +493,9 @@ meta_test_kms_update_merge (void)
meta_kms_plane_assignment_set_cursor_hotspot (cursor_plane_assignment,
9, 7);
meta_kms_update_set_privacy_screen (update2, connector, FALSE);
meta_kms_update_set_max_bpc (update2, connector, 8);
/*
* Merge and check result.
*/
@ -565,6 +575,22 @@ meta_test_kms_update_merge (void)
g_assert_cmpuint (crtc_gamma->blue[1], ==, 8);
g_assert_cmpuint (crtc_gamma->blue[2], ==, 9);
connector_updates = meta_kms_update_get_connector_updates (update1);
g_assert_cmpuint (g_list_length (connector_updates), ==, 1);
connector_update = connector_updates->data;
g_assert_nonnull (connector_update);
g_assert_true (connector_update->underscanning.has_update);
g_assert_true (connector_update->underscanning.is_active);
g_assert_cmpuint (connector_update->underscanning.hborder, ==, 123);
g_assert_cmpuint (connector_update->underscanning.vborder, ==, 456);
g_assert_true (connector_update->privacy_screen.has_update);
g_assert_false (connector_update->privacy_screen.is_enabled);
g_assert_true (connector_update->max_bpc.has_update);
g_assert_cmpuint (connector_update->max_bpc.value, ==, 8);
meta_kms_update_free (update1);
}