[mutter/gnome-40] crtc/native: Add API to check whether the CRTC supports hardware cursors



commit 44088587fc5259d9c373948b307635414d61972f
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Sep 6 10:40:17 2021 +0200

    crtc/native: Add API to check whether the CRTC supports hardware cursors
    
    On a KMS backed CRTC, hardware cursor are supported when there are
    cursor planes to assign them to. Note that when using legacy mode
    setting, fake cursor planes are added when adequate.
    
    On virtual CRTCs, used with virtual monitors, the equivalent of hardware
    cursor are always supported, as they are sent using embedded PipeWire
    stream metadata.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1991>
    
    (cherry picked from commit e82685d04944026389ac0436bfc87550dfe48c82)

 src/backends/native/meta-crtc-kms.c     | 11 +++++++++++
 src/backends/native/meta-crtc-native.c  |  8 ++++++++
 src/backends/native/meta-crtc-native.h  |  3 +++
 src/backends/native/meta-crtc-virtual.c |  8 ++++++++
 4 files changed, 30 insertions(+)
---
diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c
index f1bc79146a..d03fdd533b 100644
--- a/src/backends/native/meta-crtc-kms.c
+++ b/src/backends/native/meta-crtc-kms.c
@@ -94,6 +94,16 @@ meta_crtc_kms_is_transform_handled (MetaCrtcNative       *crtc_native,
   return is_transform_handled (crtc_kms, transform);
 }
 
+static gboolean
+meta_crtc_kms_is_hw_cursor_supported (MetaCrtcNative *crtc_native)
+{
+  MetaCrtcKms *crtc_kms = META_CRTC_KMS (crtc_native);
+  MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
+  MetaKmsDevice *kms_device = meta_kms_crtc_get_device (kms_crtc);
+
+  return !!meta_kms_device_get_cursor_plane_for (kms_device, kms_crtc);
+}
+
 void
 meta_crtc_kms_apply_transform (MetaCrtcKms            *crtc_kms,
                                MetaKmsPlaneAssignment *kms_plane_assignment)
@@ -383,4 +393,5 @@ meta_crtc_kms_class_init (MetaCrtcKmsClass *klass)
   object_class->dispose = meta_crtc_kms_dispose;
 
   crtc_native_class->is_transform_handled = meta_crtc_kms_is_transform_handled;
+  crtc_native_class->is_hw_cursor_supported = meta_crtc_kms_is_hw_cursor_supported;
 }
diff --git a/src/backends/native/meta-crtc-native.c b/src/backends/native/meta-crtc-native.c
index 5e5751780f..44e8d50883 100644
--- a/src/backends/native/meta-crtc-native.c
+++ b/src/backends/native/meta-crtc-native.c
@@ -33,6 +33,14 @@ meta_crtc_native_is_transform_handled (MetaCrtcNative       *crtc_native,
   return klass->is_transform_handled (crtc_native, transform);
 }
 
+gboolean
+meta_crtc_native_is_hw_cursor_supported (MetaCrtcNative *crtc_native)
+{
+  MetaCrtcNativeClass *klass = META_CRTC_NATIVE_GET_CLASS (crtc_native);
+
+  return klass->is_hw_cursor_supported (crtc_native);
+}
+
 static void
 meta_crtc_native_init (MetaCrtcNative *crtc_native)
 {
diff --git a/src/backends/native/meta-crtc-native.h b/src/backends/native/meta-crtc-native.h
index 0c16e58959..c373604ee0 100644
--- a/src/backends/native/meta-crtc-native.h
+++ b/src/backends/native/meta-crtc-native.h
@@ -33,9 +33,12 @@ struct _MetaCrtcNativeClass
 
   gboolean (* is_transform_handled) (MetaCrtcNative       *crtc_native,
                                      MetaMonitorTransform  monitor_transform);
+  gboolean (* is_hw_cursor_supported) (MetaCrtcNative *crtc_native);
 };
 
 gboolean meta_crtc_native_is_transform_handled (MetaCrtcNative       *crtc_native,
                                                 MetaMonitorTransform  transform);
 
+gboolean meta_crtc_native_is_hw_cursor_supported (MetaCrtcNative *crtc_native);
+
 #endif /* META_CRTC_NATIVE_H */
diff --git a/src/backends/native/meta-crtc-virtual.c b/src/backends/native/meta-crtc-virtual.c
index eee346a233..60b59a3f29 100644
--- a/src/backends/native/meta-crtc-virtual.c
+++ b/src/backends/native/meta-crtc-virtual.c
@@ -45,6 +45,12 @@ meta_crtc_virtual_is_transform_handled (MetaCrtcNative       *crtc_native,
   return transform == META_MONITOR_TRANSFORM_NORMAL;
 }
 
+static gboolean
+meta_crtc_virtual_is_hw_cursor_supported (MetaCrtcNative *crtc_native)
+{
+  return TRUE;
+}
+
 static void
 meta_crtc_virtual_init (MetaCrtcVirtual *crtc_virtual)
 {
@@ -57,4 +63,6 @@ meta_crtc_virtual_class_init (MetaCrtcVirtualClass *klass)
 
   crtc_native_class->is_transform_handled =
     meta_crtc_virtual_is_transform_handled;
+  crtc_native_class->is_hw_cursor_supported =
+    meta_crtc_virtual_is_hw_cursor_supported;
 }


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