[mutter/gnome-40] cursor-renderer/native: Use MetaCrtcNative API to check capabilities



commit f70b7a85dd2afe4d7ed76c69febff12b78d02566
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Sep 6 10:42:32 2021 +0200

    cursor-renderer/native: Use MetaCrtcNative API to check capabilities
    
    The cursor renderer shouldn't assume all the CRTCs of a logical are KMS
    CRTC's, as we'll end up checking hardware capabilities for CRTC's of
    virtual monitors as well, when they were created to not embed the cursor
    image directly in the framebuffer.
    
    Instead, use the newly introduced API for checking CRTC cursor
    capabilities. This fixes a crash with the following backtrace:
    
     0) get_plane_with_type_for at ../src/backends/native/meta-kms-device.c:150
     1) meta_kms_device_get_cursor_plane_for at ../src/backends/native/meta-kms-device.c:173
     2) has_cursor_plane at ../src/backends/native/meta-cursor-renderer-native.c:678
     3) foreach_crtc at ../src/backends/meta-logical-monitor.c:247
     4) meta_monitor_mode_foreach_crtc at ../src/backends/meta-monitor.c:1920
     5) meta_logical_monitor_foreach_crtc at ../src/backends/meta-logical-monitor.c:274
     6) crtcs_has_cursor_planes at ../src/backends/native/meta-cursor-renderer-native.c:718
     7) should_have_hw_cursor at ../src/backends/native/meta-cursor-renderer-native.c:881
     8) meta_cursor_renderer_native_update_cursor at ../src/backends/native/meta-cursor-renderer-native.c:1085
     9) meta_cursor_renderer_update_cursor at ../src/backends/meta-cursor-renderer.c:411
    
    Related: https://bugzilla.redhat.com/show_bug.cgi?id=2000183
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1991>
    
    (cherry picked from commit 00c329a2e54ec638a4f8e172f2b5c602e1c2c2b2)

 src/backends/native/meta-cursor-renderer-native.c | 35 +++++++++++------------
 1 file changed, 16 insertions(+), 19 deletions(-)
---
diff --git a/src/backends/native/meta-cursor-renderer-native.c 
b/src/backends/native/meta-cursor-renderer-native.c
index 098ef24bdf..fcfe8eb986 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -664,24 +664,21 @@ get_current_relative_transform (MetaCursorSprite *cursor_sprite)
 }
 
 static void
-has_cursor_plane (MetaLogicalMonitor *logical_monitor,
-                  MetaMonitor        *monitor,
-                  MetaOutput         *output,
-                  MetaCrtc           *crtc,
-                  gpointer            user_data)
+crtc_supports_hw_cursor (MetaLogicalMonitor *logical_monitor,
+                         MetaMonitor        *monitor,
+                         MetaOutput         *output,
+                         MetaCrtc           *crtc,
+                         gpointer            user_data)
 {
-  gboolean *has_cursor_planes = user_data;
-  MetaCrtcKms *crtc_kms = META_CRTC_KMS (crtc);
-  MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
-  MetaKmsDevice *kms_device = meta_kms_crtc_get_device (kms_crtc);
+  gboolean *supports_hw_cursor = user_data;
+  MetaCrtcNative *crtc_native = META_CRTC_NATIVE (crtc);
 
-  *has_cursor_planes &= !!meta_kms_device_get_cursor_plane_for (kms_device,
-                                                                kms_crtc);
+  *supports_hw_cursor &= meta_crtc_native_is_hw_cursor_supported (crtc_native);
 }
 
 static gboolean
-crtcs_has_cursor_planes (MetaCursorRenderer *renderer,
-                         MetaCursorSprite   *cursor_sprite)
+crtcs_supports_hw_cursor (MetaCursorRenderer *renderer,
+                          MetaCursorSprite   *cursor_sprite)
 {
   MetaCursorRendererNative *cursor_renderer_native =
     META_CURSOR_RENDERER_NATIVE (renderer);
@@ -703,7 +700,7 @@ crtcs_has_cursor_planes (MetaCursorRenderer *renderer,
       MetaLogicalMonitor *logical_monitor = l->data;
       MetaRectangle logical_monitor_layout;
       graphene_rect_t logical_monitor_rect;
-      gboolean has_cursor_planes;
+      gboolean supports_hw_cursor;
 
       logical_monitor_layout =
         meta_logical_monitor_get_layout (logical_monitor);
@@ -714,11 +711,11 @@ crtcs_has_cursor_planes (MetaCursorRenderer *renderer,
                                        NULL))
         continue;
 
-      has_cursor_planes = TRUE;
+      supports_hw_cursor = TRUE;
       meta_logical_monitor_foreach_crtc (logical_monitor,
-                                         has_cursor_plane,
-                                         &has_cursor_planes);
-      if (!has_cursor_planes)
+                                         crtc_supports_hw_cursor,
+                                         &supports_hw_cursor);
+      if (!supports_hw_cursor)
         return FALSE;
     }
 
@@ -878,7 +875,7 @@ should_have_hw_cursor (MetaCursorRenderer *renderer,
         return FALSE;
     }
 
-  if (!crtcs_has_cursor_planes (renderer, cursor_sprite))
+  if (!crtcs_supports_hw_cursor (renderer, cursor_sprite))
     return FALSE;
 
   texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);


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