From 6d043e6a8ffbfd5a33b1021915381ad4f04223e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 22 Jun 2022 00:15:13 +0200 Subject: [PATCH] kms/impl-device: Let process() always take ownership of the update This allows more freedom how to handle the update in the backends. Part-of: --- src/backends/native/meta-kms-impl-device.c | 7 ++++++- src/backends/native/meta-kms.c | 6 +----- src/backends/native/meta-onscreen-native.c | 1 - src/tests/native-kms-device.c | 3 --- src/tests/native-kms-updates.c | 2 -- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 9f0a94c9d..4ce2bdb53 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -1013,7 +1013,10 @@ meta_kms_impl_device_process_update (MetaKmsImplDevice *impl_device, MetaKmsResourceChanges changes = META_KMS_RESOURCE_CHANGE_NONE; if (!ensure_device_file (impl_device, &error)) - return meta_kms_feedback_new_failed (NULL, g_steal_pointer (&error)); + { + meta_kms_update_free (update); + return meta_kms_feedback_new_failed (NULL, g_steal_pointer (&error)); + } meta_kms_impl_device_hold_fd (impl_device); feedback = klass->process_update (impl_device, update, flags); @@ -1021,6 +1024,8 @@ meta_kms_impl_device_process_update (MetaKmsImplDevice *impl_device, changes = meta_kms_impl_device_predict_states (impl_device, update); meta_kms_impl_device_unhold_fd (impl_device); + meta_kms_update_free (update); + if (changes != META_KMS_RESOURCE_CHANGE_NONE) { MetaKms *kms = meta_kms_device_get_kms (priv->device); diff --git a/src/backends/native/meta-kms.c b/src/backends/native/meta-kms.c index faaa87b5f..0c5ca0726 100644 --- a/src/backends/native/meta-kms.c +++ b/src/backends/native/meta-kms.c @@ -282,12 +282,8 @@ meta_kms_post_pending_update_sync (MetaKms *kms, if (!update) return; - feedback = meta_kms_device_process_update_sync (device, update, flags); - result_listeners = meta_kms_update_take_result_listeners (update); - - meta_kms_update_free (update); - + feedback = meta_kms_device_process_update_sync (device, update, flags); meta_kms_feedback_dispatch_result (feedback, kms, result_listeners); } diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index 93a8d7b59..49385c901 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -1276,7 +1276,6 @@ meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen, kms_feedback = meta_kms_device_process_update_sync (kms_device, test_update, META_KMS_UPDATE_FLAG_TEST_ONLY); - meta_kms_update_free (test_update); result = meta_kms_feedback_get_result (kms_feedback); return result == META_KMS_FEEDBACK_PASSED; diff --git a/src/tests/native-kms-device.c b/src/tests/native-kms-device.c index 6729fab66..5d0800362 100644 --- a/src/tests/native-kms-device.c +++ b/src/tests/native-kms-device.c @@ -285,7 +285,6 @@ meta_test_kms_device_mode_set (void) feedback = meta_kms_device_process_update_sync (device, update, META_KMS_UPDATE_FLAG_NONE); meta_kms_feedback_unref (feedback); - meta_kms_update_free (update); g_assert_nonnull (meta_kms_crtc_get_current_state (crtc)); crtc_state = copy_crtc_state (meta_kms_crtc_get_current_state (crtc)); @@ -350,7 +349,6 @@ meta_test_kms_device_power_save (void) feedback = meta_kms_device_process_update_sync (device, update, META_KMS_UPDATE_FLAG_NONE); meta_kms_feedback_unref (feedback); - meta_kms_update_free (update); g_assert_true (meta_kms_crtc_is_active (crtc)); @@ -388,7 +386,6 @@ meta_test_kms_device_power_save (void) feedback = meta_kms_device_process_update_sync (device, update, META_KMS_UPDATE_FLAG_NONE); meta_kms_feedback_unref (feedback); - meta_kms_update_free (update); g_assert_true (meta_kms_crtc_is_active (crtc)); connector_state = meta_kms_connector_get_current_state (connector); diff --git a/src/tests/native-kms-updates.c b/src/tests/native-kms-updates.c index e13d01cfa..c7ed68157 100644 --- a/src/tests/native-kms-updates.c +++ b/src/tests/native-kms-updates.c @@ -358,7 +358,6 @@ meta_test_kms_update_page_flip (void) meta_kms_device_process_update_sync (device, update, META_KMS_UPDATE_FLAG_NONE); meta_kms_feedback_unref (feedback); - meta_kms_update_free (update); g_main_loop_run (data.loop); g_assert_cmpint (data.state, ==, DESTROYED); @@ -383,7 +382,6 @@ meta_test_kms_update_page_flip (void) meta_kms_device_process_update_sync (device, update, META_KMS_UPDATE_FLAG_NONE); meta_kms_feedback_unref (feedback); - meta_kms_update_free (update); g_main_loop_run (data.loop); g_assert_cmpint (data.state, ==, DESTROYED);