Blame SOURCES/0001-renderer-Add-API-to-check-whether-renderer-is-hardwa.patch

f15b50
From d107b52939ca0acb1f8dacf1275278edba64eebe Mon Sep 17 00:00:00 2001
f15b50
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
f15b50
Date: Tue, 1 Oct 2019 11:53:57 +0200
f15b50
Subject: [PATCH] renderer: Add API to check whether renderer is hardware
f15b50
 accelerated
f15b50
f15b50
Also expose an introspected variant via the MetaBackend.
f15b50
f15b50
https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
f15b50
---
f15b50
 src/backends/meta-backend.c  | 15 +++++++++++++++
f15b50
 src/backends/meta-renderer.c | 27 +++++++++++++++++++++++++++
f15b50
 src/backends/meta-renderer.h |  2 ++
f15b50
 src/meta/meta-backend.h      |  3 +++
f15b50
 4 files changed, 47 insertions(+)
f15b50
f15b50
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
f15b50
index 72cfbdaf3..e61181f9a 100644
f15b50
--- a/src/backends/meta-backend.c
f15b50
+++ b/src/backends/meta-backend.c
f15b50
@@ -985,6 +985,21 @@ meta_backend_get_remote_access_controller (MetaBackend *backend)
f15b50
 #endif
f15b50
 }
f15b50
 
f15b50
+/**
f15b50
+ * meta_backend_is_rendering_hardware_accelerated:
f15b50
+ * @backend: A #MetaBackend
f15b50
+ *
f15b50
+ * Returns: %TRUE if the rendering is hardware accelerated, otherwise
f15b50
+ * %FALSE.
f15b50
+ */
f15b50
+gboolean
f15b50
+meta_backend_is_rendering_hardware_accelerated (MetaBackend *backend)
f15b50
+{
f15b50
+  MetaRenderer *renderer = meta_backend_get_renderer (backend);
f15b50
+
f15b50
+  return meta_renderer_is_hardware_accelerated (renderer);
f15b50
+}
f15b50
+
f15b50
 /**
f15b50
  * meta_backend_grab_device: (skip)
f15b50
  */
f15b50
diff --git a/src/backends/meta-renderer.c b/src/backends/meta-renderer.c
f15b50
index 87ba9f9f0..470220fc8 100644
f15b50
--- a/src/backends/meta-renderer.c
f15b50
+++ b/src/backends/meta-renderer.c
f15b50
@@ -166,6 +166,33 @@ meta_renderer_get_view_from_logical_monitor (MetaRenderer       *renderer,
f15b50
   return NULL;
f15b50
 }
f15b50
 
f15b50
+gboolean
f15b50
+meta_renderer_is_hardware_accelerated (MetaRenderer *renderer)
f15b50
+{
f15b50
+  MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
f15b50
+  MetaBackend *backend = meta_get_backend ();
f15b50
+  ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
f15b50
+  CoglContext *cogl_context =
f15b50
+    clutter_backend_get_cogl_context (clutter_backend);
f15b50
+  CoglGpuInfo *info = &cogl_context->gpu;
f15b50
+
f15b50
+  switch (info->architecture)
f15b50
+    {
f15b50
+    case COGL_GPU_INFO_ARCHITECTURE_UNKNOWN:
f15b50
+    case COGL_GPU_INFO_ARCHITECTURE_SANDYBRIDGE:
f15b50
+    case COGL_GPU_INFO_ARCHITECTURE_SGX:
f15b50
+    case COGL_GPU_INFO_ARCHITECTURE_MALI:
f15b50
+      return TRUE;
f15b50
+    case COGL_GPU_INFO_ARCHITECTURE_LLVMPIPE:
f15b50
+    case COGL_GPU_INFO_ARCHITECTURE_SOFTPIPE:
f15b50
+    case COGL_GPU_INFO_ARCHITECTURE_SWRAST:
f15b50
+      return FALSE;
f15b50
+    }
f15b50
+
f15b50
+  g_assert_not_reached ();
f15b50
+  return FALSE;
f15b50
+}
f15b50
+
f15b50
 static void
f15b50
 meta_renderer_finalize (GObject *object)
f15b50
 {
f15b50
diff --git a/src/backends/meta-renderer.h b/src/backends/meta-renderer.h
f15b50
index 478baee91..97bf36860 100644
f15b50
--- a/src/backends/meta-renderer.h
f15b50
+++ b/src/backends/meta-renderer.h
f15b50
@@ -59,4 +59,6 @@ GList * meta_renderer_get_views (MetaRenderer *renderer);
f15b50
 MetaRendererView * meta_renderer_get_view_from_logical_monitor (MetaRenderer       *renderer,
f15b50
                                                                 MetaLogicalMonitor *logical_monitor);
f15b50
 
f15b50
+gboolean meta_renderer_is_hardware_accelerated (MetaRenderer *renderer);
f15b50
+
f15b50
 #endif /* META_RENDERER_H */
f15b50
diff --git a/src/meta/meta-backend.h b/src/meta/meta-backend.h
f15b50
index aaa6aae97..8edc0bf2c 100644
f15b50
--- a/src/meta/meta-backend.h
f15b50
+++ b/src/meta/meta-backend.h
f15b50
@@ -64,6 +64,9 @@ MetaSettings *meta_backend_get_settings (MetaBackend *backend);
f15b50
 META_EXPORT
f15b50
 MetaRemoteAccessController * meta_backend_get_remote_access_controller (MetaBackend *backend);
f15b50
 
f15b50
+META_EXPORT
f15b50
+gboolean meta_backend_is_rendering_hardware_accelerated (MetaBackend *backend);
f15b50
+
f15b50
 META_EXPORT
f15b50
 void meta_clutter_init (void);
f15b50
 
f15b50
-- 
f15b50
2.26.2
f15b50