From e82685d04944026389ac0436bfc87550dfe48c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 6 Sep 2021 10:40:17 +0200 Subject: [PATCH] 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: --- 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 fde648175..584a780ba 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) @@ -385,4 +395,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 5e5751780..44e8d5088 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 0c16e5895..c373604ee 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 eee346a23..60b59a3f2 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; }