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
This commit is contained in:
Jonas Ådahl 2019-10-01 11:53:57 +02:00
parent 704fea6323
commit 3e6a55aff0
4 changed files with 47 additions and 0 deletions

View File

@ -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)
*/

View File

@ -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,

View File

@ -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 */

View File

@ -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);