[mutter/gnome-3-34] cursor-renderer/native: Refactor init to per-gpu



commit 11da42b2f8ff87dbf9007c83cdbc8b6b71456f27
Author: Pekka Paalanen <pekka paalanen collabora com>
Date:   Mon Feb 24 15:13:42 2020 +0200

    cursor-renderer/native: Refactor init to per-gpu
    
    Extract the code to initialize a single GPU cursor support into its own
    function. The new function will be used by GPU hotplug in the future.
    
    This is a pure refactoring without any behavioral changes.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/1097
    
    Backported from 4cc29cfb619102a8e7cd32731205c8018d83544e.

 src/backends/native/meta-cursor-renderer-native.c | 53 +++++++++++++----------
 1 file changed, 30 insertions(+), 23 deletions(-)
---
diff --git a/src/backends/native/meta-cursor-renderer-native.c 
b/src/backends/native/meta-cursor-renderer-native.c
index e4b88e0c7..6c53a2a8b 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -1176,6 +1176,35 @@ on_monitors_changed (MetaMonitorManager       *monitors,
   force_update_hw_cursor (native);
 }
 
+static void
+init_hw_cursor_support_for_gpu (MetaGpuKms *gpu_kms)
+{
+  MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
+  int kms_fd;
+  struct gbm_device *gbm_device;
+  uint64_t width, height;
+
+  gbm_device = meta_gbm_device_from_gpu (gpu_kms);
+  if (!gbm_device)
+    return;
+
+  cursor_renderer_gpu_data =
+    meta_create_cursor_renderer_native_gpu_data (gpu_kms);
+
+  kms_fd = meta_gpu_kms_get_fd (gpu_kms);
+  if (drmGetCap (kms_fd, DRM_CAP_CURSOR_WIDTH, &width) == 0 &&
+      drmGetCap (kms_fd, DRM_CAP_CURSOR_HEIGHT, &height) == 0)
+    {
+      cursor_renderer_gpu_data->cursor_width = width;
+      cursor_renderer_gpu_data->cursor_height = height;
+    }
+  else
+    {
+      cursor_renderer_gpu_data->cursor_width = 64;
+      cursor_renderer_gpu_data->cursor_height = 64;
+    }
+}
+
 static void
 init_hw_cursor_support (MetaCursorRendererNative *cursor_renderer_native)
 {
@@ -1188,30 +1217,8 @@ init_hw_cursor_support (MetaCursorRendererNative *cursor_renderer_native)
   for (l = gpus; l; l = l->next)
     {
       MetaGpuKms *gpu_kms = l->data;
-      MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
-      int kms_fd;
-      struct gbm_device *gbm_device;
-      uint64_t width, height;
-
-      gbm_device = meta_gbm_device_from_gpu (gpu_kms);
-      if (!gbm_device)
-        continue;
 
-      cursor_renderer_gpu_data =
-        meta_create_cursor_renderer_native_gpu_data (gpu_kms);
-
-      kms_fd = meta_gpu_kms_get_fd (gpu_kms);
-      if (drmGetCap (kms_fd, DRM_CAP_CURSOR_WIDTH, &width) == 0 &&
-          drmGetCap (kms_fd, DRM_CAP_CURSOR_HEIGHT, &height) == 0)
-        {
-          cursor_renderer_gpu_data->cursor_width = width;
-          cursor_renderer_gpu_data->cursor_height = height;
-        }
-      else
-        {
-          cursor_renderer_gpu_data->cursor_width = 64;
-          cursor_renderer_gpu_data->cursor_height = 64;
-        }
+      init_hw_cursor_support_for_gpu (gpu_kms);
     }
 }
 


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