[mutter] renderer/native: Look up prefers-shadow cap via MetaKmsDevice



commit 86c4369f4184f39fd0b03c5125a89f53fc5bd771
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Mar 29 11:48:59 2021 +0200

    renderer/native: Look up prefers-shadow cap via MetaKmsDevice
    
    This eliminates the second last user of drmGetCap() from outside of
    MetaKmsImplDevice.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>

 src/backends/native/meta-kms-device.c      |  6 ++++++
 src/backends/native/meta-kms-device.h      |  2 ++
 src/backends/native/meta-kms-impl-device.c |  9 +++++++++
 src/backends/native/meta-kms-impl-device.h |  2 ++
 src/backends/native/meta-renderer-native.c | 22 ++--------------------
 5 files changed, 21 insertions(+), 20 deletions(-)
---
diff --git a/src/backends/native/meta-kms-device.c b/src/backends/native/meta-kms-device.c
index 4f0793ece2..49516bde64 100644
--- a/src/backends/native/meta-kms-device.c
+++ b/src/backends/native/meta-kms-device.c
@@ -121,6 +121,12 @@ meta_kms_device_get_cursor_size (MetaKmsDevice *device,
     }
 }
 
+gboolean
+meta_kms_device_prefers_shadow_buffer (MetaKmsDevice *device)
+{
+  return device->caps.prefers_shadow_buffer;
+}
+
 GList *
 meta_kms_device_get_connectors (MetaKmsDevice *device)
 {
diff --git a/src/backends/native/meta-kms-device.h b/src/backends/native/meta-kms-device.h
index 682140ff88..c8bf948435 100644
--- a/src/backends/native/meta-kms-device.h
+++ b/src/backends/native/meta-kms-device.h
@@ -45,6 +45,8 @@ gboolean meta_kms_device_get_cursor_size (MetaKmsDevice *device,
                                           uint64_t      *out_cursor_width,
                                           uint64_t      *out_cursor_height);
 
+gboolean meta_kms_device_prefers_shadow_buffer (MetaKmsDevice *device);
+
 GList * meta_kms_device_get_connectors (MetaKmsDevice *device);
 
 GList * meta_kms_device_get_crtcs (MetaKmsDevice *device);
diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c
index f43eaa5c65..4194b9ffa2 100644
--- a/src/backends/native/meta-kms-impl-device.c
+++ b/src/backends/native/meta-kms-impl-device.c
@@ -300,6 +300,7 @@ init_caps (MetaKmsImplDevice *impl_device)
     meta_kms_impl_device_get_instance_private (impl_device);
   int fd;
   uint64_t cursor_width, cursor_height;
+  uint64_t prefer_shadow;
 
   fd = meta_device_file_get_fd (priv->device_file);
   if (drmGetCap (fd, DRM_CAP_CURSOR_WIDTH, &cursor_width) == 0 &&
@@ -309,6 +310,14 @@ init_caps (MetaKmsImplDevice *impl_device)
       priv->caps.cursor_width = cursor_width;
       priv->caps.cursor_height = cursor_height;
     }
+
+  if (drmGetCap (fd, DRM_CAP_DUMB_PREFER_SHADOW, &prefer_shadow) == 0)
+    {
+      if (prefer_shadow)
+        g_message ("Device '%s' prefers shadow buffer", priv->path);
+
+      priv->caps.prefers_shadow_buffer = prefer_shadow;
+    }
 }
 
 static void
diff --git a/src/backends/native/meta-kms-impl-device.h b/src/backends/native/meta-kms-impl-device.h
index 3136ccfd88..9e20705273 100644
--- a/src/backends/native/meta-kms-impl-device.h
+++ b/src/backends/native/meta-kms-impl-device.h
@@ -37,6 +37,8 @@ typedef struct _MetaKmsDeviceCaps
   gboolean has_cursor_size;
   uint64_t cursor_width;
   uint64_t cursor_height;
+
+  gboolean prefers_shadow_buffer;
 } MetaKmsDeviceCaps;
 
 typedef struct _MetaKmsProp MetaKmsProp;
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index ee58429698..90774ce366 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -978,8 +978,7 @@ should_force_shadow_fb (MetaRendererNative *renderer_native,
   MetaRenderer *renderer = META_RENDERER (renderer_native);
   CoglContext *cogl_context =
     cogl_context_from_renderer_native (renderer_native);
-  int kms_fd;
-  uint64_t prefer_shadow = 0;
+  MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (primary_gpu);
 
   if (meta_renderer_is_hardware_accelerated (renderer))
     return FALSE;
@@ -987,24 +986,7 @@ should_force_shadow_fb (MetaRendererNative *renderer_native,
   if (!cogl_has_feature (cogl_context, COGL_FEATURE_ID_BLIT_FRAMEBUFFER))
     return FALSE;
 
-  kms_fd = meta_gpu_kms_get_fd (primary_gpu);
-  if (drmGetCap (kms_fd, DRM_CAP_DUMB_PREFER_SHADOW, &prefer_shadow) == 0)
-    {
-      if (prefer_shadow)
-        {
-          static gboolean logged_once = FALSE;
-
-          if (!logged_once)
-            {
-              g_message ("Forcing shadow framebuffer");
-              logged_once = TRUE;
-            }
-
-          return TRUE;
-        }
-    }
-
-  return FALSE;
+  return meta_kms_device_prefers_shadow_buffer (kms_device);
 }
 
 static CoglFramebuffer *


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