[mutter] kms: Concentrate update processing in MetaKmsDevice



commit c35e8f5a51c6f04fcd0abe9d4cd6b98abf6dc72b
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Jun 24 12:30:00 2021 +0200

    kms: Concentrate update processing in MetaKmsDevice
    
    It was a bit scattered, with it being split between MetaKms and
    MetaKmsImpl, dealing with MetaKmsDevice and MetaKmsImplDevice
    differentation. Replace this by, for now, single entry point on
    MetaKmsDevice: meta_kms_device_process_update_sync() that does the right
    thing.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>

 src/backends/native/meta-kms-device-private.h |  3 --
 src/backends/native/meta-kms-device.c         | 35 +++++++++++++---
 src/backends/native/meta-kms-device.h         |  4 ++
 src/backends/native/meta-kms-impl-device.c    |  4 +-
 src/backends/native/meta-kms-impl-device.h    |  3 --
 src/backends/native/meta-kms-impl.c           | 17 --------
 src/backends/native/meta-kms-impl.h           |  4 --
 src/backends/native/meta-kms-types.h          |  7 ++++
 src/backends/native/meta-kms.c                | 58 +++------------------------
 src/backends/native/meta-kms.h                |  7 ----
 10 files changed, 50 insertions(+), 92 deletions(-)
---
diff --git a/src/backends/native/meta-kms-device-private.h b/src/backends/native/meta-kms-device-private.h
index f7d810af0d..ce5f91716a 100644
--- a/src/backends/native/meta-kms-device-private.h
+++ b/src/backends/native/meta-kms-device-private.h
@@ -29,9 +29,6 @@ MetaKmsUpdateChanges meta_kms_device_update_states_in_impl (MetaKmsDevice *devic
                                                             uint32_t       crtc_id,
                                                             uint32_t       connector_id);
 
-void meta_kms_device_predict_states_in_impl (MetaKmsDevice *device,
-                                             MetaKmsUpdate *update);
-
 void meta_kms_device_add_fake_plane_in_impl (MetaKmsDevice    *device,
                                              MetaKmsPlaneType  plane_type,
                                              MetaKmsCrtc      *crtc);
diff --git a/src/backends/native/meta-kms-device.c b/src/backends/native/meta-kms-device.c
index f44260a31f..f9d594eb7d 100644
--- a/src/backends/native/meta-kms-device.c
+++ b/src/backends/native/meta-kms-device.c
@@ -39,6 +39,7 @@
 #include "backends/native/meta-kms-impl.h"
 #include "backends/native/meta-kms-plane.h"
 #include "backends/native/meta-kms-private.h"
+#include "backends/native/meta-kms-update-private.h"
 
 struct _MetaKmsDevice
 {
@@ -259,15 +260,39 @@ meta_kms_device_update_states_in_impl (MetaKmsDevice *device,
   return changes;
 }
 
-void
-meta_kms_device_predict_states_in_impl (MetaKmsDevice *device,
-                                        MetaKmsUpdate *update)
+typedef struct
 {
+  MetaKmsUpdate *update;
+  MetaKmsUpdateFlag flags;
+} PostUpdateData;
+
+static gpointer
+process_update_in_impl (MetaKmsImpl  *impl,
+                        gpointer      user_data,
+                        GError      **error)
+{
+  PostUpdateData *data = user_data;
+  MetaKmsUpdate *update = data->update;
+  MetaKmsDevice *device = meta_kms_update_get_device (update);
   MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device);
 
-  meta_assert_in_kms_impl (device->kms);
+  return meta_kms_impl_device_process_update (impl_device, update, data->flags);
+}
+
+MetaKmsFeedback *
+meta_kms_device_process_update_sync (MetaKmsDevice     *device,
+                                     MetaKmsUpdate     *update,
+                                     MetaKmsUpdateFlag  flags)
+{
+  MetaKms *kms = META_KMS (meta_kms_device_get_kms (device));
+  PostUpdateData data;
 
-  meta_kms_impl_device_predict_states (impl_device, update);
+  data = (PostUpdateData) {
+    .update = update,
+    .flags = flags,
+  };
+  return meta_kms_run_impl_task_sync (kms, process_update_in_impl,
+                                      &data, NULL);
 }
 
 void
diff --git a/src/backends/native/meta-kms-device.h b/src/backends/native/meta-kms-device.h
index c504c2f480..026b7a2700 100644
--- a/src/backends/native/meta-kms-device.h
+++ b/src/backends/native/meta-kms-device.h
@@ -72,6 +72,10 @@ MetaKmsPlane * meta_kms_device_get_cursor_plane_for (MetaKmsDevice *device,
 
 GList * meta_kms_device_get_fallback_modes (MetaKmsDevice *device);
 
+MetaKmsFeedback * meta_kms_device_process_update_sync (MetaKmsDevice     *device,
+                                                       MetaKmsUpdate     *update,
+                                                       MetaKmsUpdateFlag  flags);
+
 MetaKmsDevice * meta_kms_device_new (MetaKms            *kms,
                                      const char         *path,
                                      MetaKmsDeviceFlag   flags,
diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c
index fe3adbb12e..c8b0fc9b73 100644
--- a/src/backends/native/meta-kms-impl-device.c
+++ b/src/backends/native/meta-kms-impl-device.c
@@ -772,7 +772,7 @@ err:
   return META_KMS_UPDATE_CHANGE_FULL;
 }
 
-void
+static void
 meta_kms_impl_device_predict_states (MetaKmsImplDevice *impl_device,
                                      MetaKmsUpdate     *update)
 {
@@ -816,6 +816,8 @@ meta_kms_impl_device_process_update (MetaKmsImplDevice *impl_device,
 
   meta_kms_impl_device_hold_fd (impl_device);
   feedback = klass->process_update (impl_device, update, flags);
+  if (!(flags & META_KMS_UPDATE_FLAG_TEST_ONLY))
+    meta_kms_impl_device_predict_states (impl_device, update);
   meta_kms_impl_device_unhold_fd (impl_device);
 
   return feedback;
diff --git a/src/backends/native/meta-kms-impl-device.h b/src/backends/native/meta-kms-impl-device.h
index 4710f00bde..48c3ac50bc 100644
--- a/src/backends/native/meta-kms-impl-device.h
+++ b/src/backends/native/meta-kms-impl-device.h
@@ -139,9 +139,6 @@ MetaKmsUpdateChanges meta_kms_impl_device_update_states (MetaKmsImplDevice *impl
                                                          uint32_t           crtc_id,
                                                          uint32_t           connector_id);
 
-void meta_kms_impl_device_predict_states (MetaKmsImplDevice *impl_device,
-                                          MetaKmsUpdate     *update);
-
 void meta_kms_impl_device_notify_modes_set (MetaKmsImplDevice *impl_device);
 
 MetaKmsPlane * meta_kms_impl_device_add_fake_plane (MetaKmsImplDevice *impl_device,
diff --git a/src/backends/native/meta-kms-impl.c b/src/backends/native/meta-kms-impl.c
index 0ad76e085b..5ccd80fc82 100644
--- a/src/backends/native/meta-kms-impl.c
+++ b/src/backends/native/meta-kms-impl.c
@@ -77,23 +77,6 @@ meta_kms_impl_remove_impl_device (MetaKmsImpl       *impl,
   priv->impl_devices = g_list_remove (priv->impl_devices, impl_device);
 }
 
-MetaKmsFeedback *
-meta_kms_impl_process_update (MetaKmsImpl       *impl,
-                              MetaKmsUpdate     *update,
-                              MetaKmsUpdateFlag  flags)
-{
-  MetaKmsImplPrivate *priv = meta_kms_impl_get_instance_private (impl);
-  MetaKmsDevice *device;
-  MetaKmsImplDevice *impl_device;
-
-  meta_assert_in_kms_impl (priv->kms);
-
-  device = meta_kms_update_get_device (update);
-  impl_device = meta_kms_device_get_impl_device (device);
-
-  return meta_kms_impl_device_process_update (impl_device, update, flags);
-}
-
 void
 meta_kms_impl_discard_pending_page_flips (MetaKmsImpl *impl)
 {
diff --git a/src/backends/native/meta-kms-impl.h b/src/backends/native/meta-kms-impl.h
index 58f03f81a6..c85320c9b6 100644
--- a/src/backends/native/meta-kms-impl.h
+++ b/src/backends/native/meta-kms-impl.h
@@ -31,10 +31,6 @@ G_DECLARE_FINAL_TYPE (MetaKmsImpl, meta_kms_impl,
 
 MetaKms * meta_kms_impl_get_kms (MetaKmsImpl *impl);
 
-MetaKmsFeedback * meta_kms_impl_process_update (MetaKmsImpl       *impl,
-                                                MetaKmsUpdate     *update,
-                                                MetaKmsUpdateFlag  flags);
-
 void meta_kms_impl_add_impl_device (MetaKmsImpl       *impl,
                                     MetaKmsImplDevice *impl_device);
 
diff --git a/src/backends/native/meta-kms-types.h b/src/backends/native/meta-kms-types.h
index 4ba2003a5e..f532f38218 100644
--- a/src/backends/native/meta-kms-types.h
+++ b/src/backends/native/meta-kms-types.h
@@ -73,6 +73,13 @@ typedef enum _MetaKmsUpdateChanges
   META_KMS_UPDATE_CHANGE_FULL = -1,
 } MetaKmsUpdateChanges;
 
+typedef enum _MetaKmsUpdateFlag
+{
+  META_KMS_UPDATE_FLAG_NONE = 0,
+  META_KMS_UPDATE_FLAG_PRESERVE_ON_ERROR = 1 << 0,
+  META_KMS_UPDATE_FLAG_TEST_ONLY = 1 << 1,
+} MetaKmsUpdateFlag;
+
 typedef enum _MetaKmsPlaneType MetaKmsPlaneType;
 
 typedef enum _MetaKmsPropType
diff --git a/src/backends/native/meta-kms.c b/src/backends/native/meta-kms.c
index beeb486a01..a8905fcc01 100644
--- a/src/backends/native/meta-kms.c
+++ b/src/backends/native/meta-kms.c
@@ -247,40 +247,12 @@ meta_kms_take_pending_update (MetaKms       *kms,
   return NULL;
 }
 
-typedef struct
-{
-  MetaKmsUpdate *update;
-  MetaKmsUpdateFlag flags;
-} PostUpdateData;
-
-static gpointer
-meta_kms_process_update_in_impl (MetaKmsImpl  *impl,
-                                 gpointer      user_data,
-                                 GError      **error)
-{
-  PostUpdateData *data = user_data;
-  MetaKmsUpdate *update = data->update;
-  MetaKmsFeedback *feedback;
-
-  feedback = meta_kms_impl_process_update (impl, data->update, data->flags);
-
-  if (!(data->flags & META_KMS_UPDATE_FLAG_TEST_ONLY))
-    {
-      MetaKmsDevice *device = meta_kms_update_get_device (update);
-
-      meta_kms_device_predict_states_in_impl (device, update);
-    }
-
-  return feedback;
-}
-
 MetaKmsFeedback *
 meta_kms_post_pending_update_sync (MetaKms           *kms,
                                    MetaKmsDevice     *device,
                                    MetaKmsUpdateFlag  flags)
 {
   MetaKmsUpdate *update;
-  PostUpdateData data;
   MetaKmsFeedback *feedback;
   GList *result_listeners;
   GList *l;
@@ -294,14 +266,7 @@ meta_kms_post_pending_update_sync (MetaKms           *kms,
 
   meta_kms_update_lock (update);
 
-  data = (PostUpdateData) {
-    .update = update,
-    .flags = flags,
-  };
-  feedback = meta_kms_run_impl_task_sync (kms,
-                                          meta_kms_process_update_in_impl,
-                                          &data,
-                                          NULL);
+  feedback = meta_kms_device_process_update_sync (device, update, flags);
 
   result_listeners = meta_kms_update_take_result_listeners (update);
 
@@ -340,32 +305,21 @@ meta_kms_post_pending_update_sync (MetaKms           *kms,
   return feedback;
 }
 
-static gpointer
-meta_kms_test_update_in_impl (MetaKmsImpl  *impl,
-                              gpointer      user_data,
-                              GError      **error)
-{
-  MetaKmsUpdate *update = user_data;
-  MetaKmsUpdateFlag flags;
-
-  flags = META_KMS_UPDATE_FLAG_TEST_ONLY;
-  return meta_kms_impl_process_update (impl, update, flags);
-}
-
 MetaKmsFeedback *
 meta_kms_post_test_update_sync (MetaKms       *kms,
                                 MetaKmsUpdate *update)
 {
+  MetaKmsDevice *device = meta_kms_update_get_device (update);
+  MetaKmsUpdateFlag flags;
+
   g_assert (!meta_kms_update_get_page_flip_listeners (update));
   g_assert (!meta_kms_update_get_mode_sets (update));
   g_assert (!meta_kms_update_get_connector_updates (update));
 
   meta_kms_update_lock (update);
 
-  return meta_kms_run_impl_task_sync (kms,
-                                      meta_kms_test_update_in_impl,
-                                      update,
-                                      NULL);
+  flags = META_KMS_UPDATE_FLAG_TEST_ONLY;
+  return meta_kms_device_process_update_sync (device, update, flags);
 }
 
 static gpointer
diff --git a/src/backends/native/meta-kms.h b/src/backends/native/meta-kms.h
index c95a2c4449..bd9fe5cead 100644
--- a/src/backends/native/meta-kms.h
+++ b/src/backends/native/meta-kms.h
@@ -31,13 +31,6 @@ typedef enum _MetaKmsFlags
   META_KMS_FLAG_NO_MODE_SETTING = 1 << 0,
 } MetaKmsFlags;
 
-typedef enum _MetaKmsUpdateFlag
-{
-  META_KMS_UPDATE_FLAG_NONE = 0,
-  META_KMS_UPDATE_FLAG_PRESERVE_ON_ERROR = 1 << 0,
-  META_KMS_UPDATE_FLAG_TEST_ONLY = 1 << 1,
-} MetaKmsUpdateFlag;
-
 #define META_TYPE_KMS (meta_kms_get_type ())
 G_DECLARE_FINAL_TYPE (MetaKms, meta_kms, META, KMS, GObject)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]