[mutter] renderer: Add API to check whether renderer is hardware accelerated



commit 3e6a55aff09eb7fa65a97b947c9c25ad1e7afe1d
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Oct 1 11:53:57 2019 +0200

    renderer: Add API to check whether renderer is hardware accelerated
    
    Also expose an introspected variant via the MetaBackend.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/838

 src/backends/meta-backend.c  | 15 +++++++++++++++
 src/backends/meta-renderer.c | 27 +++++++++++++++++++++++++++
 src/backends/meta-renderer.h |  2 ++
 src/meta/meta-backend.h      |  3 +++
 4 files changed, 47 insertions(+)
---
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 9690d8b65..6295c8b7e 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -1032,6 +1032,21 @@ meta_backend_get_remote_access_controller (MetaBackend *backend)
 #endif
 }
 
+/**
+ * meta_backend_is_rendering_hardware_accelerated:
+ * @backend: A #MetaBackend
+ *
+ * Returns: %TRUE if the rendering is hardware accelerated, otherwise
+ * %FALSE.
+ */
+gboolean
+meta_backend_is_rendering_hardware_accelerated (MetaBackend *backend)
+{
+  MetaRenderer *renderer = meta_backend_get_renderer (backend);
+
+  return meta_renderer_is_hardware_accelerated (renderer);
+}
+
 /**
  * meta_backend_grab_device: (skip)
  */
diff --git a/src/backends/meta-renderer.c b/src/backends/meta-renderer.c
index 06b32ca2e..24688577c 100644
--- a/src/backends/meta-renderer.c
+++ b/src/backends/meta-renderer.c
@@ -186,6 +186,33 @@ meta_renderer_get_view_from_logical_monitor (MetaRenderer       *renderer,
   return NULL;
 }
 
+gboolean
+meta_renderer_is_hardware_accelerated (MetaRenderer *renderer)
+{
+  MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
+  MetaBackend *backend = priv->backend;
+  ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
+  CoglContext *cogl_context =
+    clutter_backend_get_cogl_context (clutter_backend);
+  CoglGpuInfo *info = &cogl_context->gpu;
+
+  switch (info->architecture)
+    {
+    case COGL_GPU_INFO_ARCHITECTURE_UNKNOWN:
+    case COGL_GPU_INFO_ARCHITECTURE_SANDYBRIDGE:
+    case COGL_GPU_INFO_ARCHITECTURE_SGX:
+    case COGL_GPU_INFO_ARCHITECTURE_MALI:
+      return TRUE;
+    case COGL_GPU_INFO_ARCHITECTURE_LLVMPIPE:
+    case COGL_GPU_INFO_ARCHITECTURE_SOFTPIPE:
+    case COGL_GPU_INFO_ARCHITECTURE_SWRAST:
+      return FALSE;
+    }
+
+  g_assert_not_reached ();
+  return FALSE;
+}
+
 static void
 meta_renderer_get_property (GObject    *object,
                             guint       prop_id,
diff --git a/src/backends/meta-renderer.h b/src/backends/meta-renderer.h
index 5be5d4521..f5182e0eb 100644
--- a/src/backends/meta-renderer.h
+++ b/src/backends/meta-renderer.h
@@ -61,4 +61,6 @@ GList * meta_renderer_get_views (MetaRenderer *renderer);
 MetaRendererView * meta_renderer_get_view_from_logical_monitor (MetaRenderer       *renderer,
                                                                 MetaLogicalMonitor *logical_monitor);
 
+gboolean meta_renderer_is_hardware_accelerated (MetaRenderer *renderer);
+
 #endif /* META_RENDERER_H */
diff --git a/src/meta/meta-backend.h b/src/meta/meta-backend.h
index aaa6aae97..8edc0bf2c 100644
--- a/src/meta/meta-backend.h
+++ b/src/meta/meta-backend.h
@@ -64,6 +64,9 @@ MetaSettings *meta_backend_get_settings (MetaBackend *backend);
 META_EXPORT
 MetaRemoteAccessController * meta_backend_get_remote_access_controller (MetaBackend *backend);
 
+META_EXPORT
+gboolean meta_backend_is_rendering_hardware_accelerated (MetaBackend *backend);
+
 META_EXPORT
 void meta_clutter_init (void);
 


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