|
|
99364f |
From 914fd2bec65c2e9928b03d5bc94930bc0151f998 Mon Sep 17 00:00:00 2001
|
|
|
99364f |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
99364f |
Date: Wed, 17 Jun 2020 17:48:05 +0200
|
|
|
99364f |
Subject: [PATCH 3/4] screen-cast: Move DMA buffer allocation to MetaScreenCast
|
|
|
99364f |
|
|
|
99364f |
The aim with centralizing it is to be able to apply global policy to DMA
|
|
|
99364f |
buffer allocations, e.g. disabling due to various hueristics.
|
|
|
99364f |
|
|
|
99364f |
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1318
|
|
|
99364f |
---
|
|
|
99364f |
src/backends/meta-screen-cast-stream-src.c | 18 ++++++--------
|
|
|
99364f |
src/backends/meta-screen-cast.c | 28 ++++++++++++++++++++++
|
|
|
99364f |
src/backends/meta-screen-cast.h | 4 ++++
|
|
|
99364f |
3 files changed, 39 insertions(+), 11 deletions(-)
|
|
|
99364f |
|
|
|
99364f |
diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
|
|
|
99364f |
index ff4af440c1..b77186415f 100644
|
|
|
99364f |
--- a/src/backends/meta-screen-cast-stream-src.c
|
|
|
99364f |
+++ b/src/backends/meta-screen-cast-stream-src.c
|
|
|
99364f |
@@ -649,10 +649,10 @@ on_stream_add_buffer (void *data,
|
|
|
99364f |
MetaScreenCastStreamSrc *src = data;
|
|
|
99364f |
MetaScreenCastStreamSrcPrivate *priv =
|
|
|
99364f |
meta_screen_cast_stream_src_get_instance_private (src);
|
|
|
99364f |
- CoglContext *context =
|
|
|
99364f |
- clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
|
|
99364f |
- CoglRenderer *renderer = cogl_context_get_renderer (context);
|
|
|
99364f |
- g_autoptr (GError) error = NULL;
|
|
|
99364f |
+ MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
|
|
|
99364f |
+ MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
|
|
|
99364f |
+ MetaScreenCast *screen_cast =
|
|
|
99364f |
+ meta_screen_cast_session_get_screen_cast (session);
|
|
|
99364f |
CoglDmaBufHandle *dmabuf_handle;
|
|
|
99364f |
struct spa_buffer *spa_buffer = buffer->buffer;
|
|
|
99364f |
struct spa_data *spa_data = spa_buffer->datas;
|
|
|
99364f |
@@ -664,13 +664,9 @@ on_stream_add_buffer (void *data,
|
|
|
99364f |
spa_data[0].mapoffset = 0;
|
|
|
99364f |
spa_data[0].maxsize = stride * priv->video_format.size.height;
|
|
|
99364f |
|
|
|
99364f |
- dmabuf_handle = cogl_renderer_create_dma_buf (renderer,
|
|
|
99364f |
- priv->stream_width,
|
|
|
99364f |
- priv->stream_height,
|
|
|
99364f |
- &error);
|
|
|
99364f |
-
|
|
|
99364f |
- if (error)
|
|
|
99364f |
- g_debug ("Error exporting DMA buffer handle: %s", error->message);
|
|
|
99364f |
+ dmabuf_handle = meta_screen_cast_create_dma_buf_handle (screen_cast,
|
|
|
99364f |
+ priv->stream_width,
|
|
|
99364f |
+ priv->stream_height);
|
|
|
99364f |
|
|
|
99364f |
if (dmabuf_handle)
|
|
|
99364f |
{
|
|
|
99364f |
diff --git a/src/backends/meta-screen-cast.c b/src/backends/meta-screen-cast.c
|
|
|
99364f |
index 46bc268389..5f1ca8b5ca 100644
|
|
|
99364f |
--- a/src/backends/meta-screen-cast.c
|
|
|
99364f |
+++ b/src/backends/meta-screen-cast.c
|
|
|
99364f |
@@ -94,6 +94,34 @@ meta_screen_cast_get_backend (MetaScreenCast *screen_cast)
|
|
|
99364f |
return screen_cast->backend;
|
|
|
99364f |
}
|
|
|
99364f |
|
|
|
99364f |
+CoglDmaBufHandle *
|
|
|
99364f |
+meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
|
|
99364f |
+ int width,
|
|
|
99364f |
+ int height)
|
|
|
99364f |
+{
|
|
|
99364f |
+ ClutterBackend *clutter_backend =
|
|
|
99364f |
+ meta_backend_get_clutter_backend (screen_cast->backend);
|
|
|
99364f |
+ CoglContext *cogl_context =
|
|
|
99364f |
+ clutter_backend_get_cogl_context (clutter_backend);
|
|
|
99364f |
+ CoglRenderer *cogl_renderer = cogl_context_get_renderer (cogl_context);
|
|
|
99364f |
+ g_autoptr (GError) error = NULL;
|
|
|
99364f |
+ CoglDmaBufHandle *dmabuf_handle;
|
|
|
99364f |
+
|
|
|
99364f |
+ dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
|
|
99364f |
+ width, height,
|
|
|
99364f |
+ &error);
|
|
|
99364f |
+ if (!dmabuf_handle)
|
|
|
99364f |
+ {
|
|
|
99364f |
+ g_warning ("Failed to allocate DMA buffer, "
|
|
|
99364f |
+ "disabling DMA buffer based screen casting: %s",
|
|
|
99364f |
+ error->message);
|
|
|
99364f |
+ screen_cast->disable_dma_bufs = TRUE;
|
|
|
99364f |
+ return NULL;
|
|
|
99364f |
+ }
|
|
|
99364f |
+
|
|
|
99364f |
+ return dmabuf_handle;
|
|
|
99364f |
+}
|
|
|
99364f |
+
|
|
|
99364f |
static gboolean
|
|
|
99364f |
register_remote_desktop_screen_cast_session (MetaScreenCastSession *session,
|
|
|
99364f |
const char *remote_desktop_session_id,
|
|
|
99364f |
diff --git a/src/backends/meta-screen-cast.h b/src/backends/meta-screen-cast.h
|
|
|
99364f |
index a3b650cd80..fb5a38f34f 100644
|
|
|
99364f |
--- a/src/backends/meta-screen-cast.h
|
|
|
99364f |
+++ b/src/backends/meta-screen-cast.h
|
|
|
99364f |
@@ -50,6 +50,10 @@ GDBusConnection * meta_screen_cast_get_connection (MetaScreenCast *screen_cast);
|
|
|
99364f |
|
|
|
99364f |
MetaBackend * meta_screen_cast_get_backend (MetaScreenCast *screen_cast);
|
|
|
99364f |
|
|
|
99364f |
+CoglDmaBufHandle * meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
|
|
99364f |
+ int width,
|
|
|
99364f |
+ int height);
|
|
|
99364f |
+
|
|
|
99364f |
MetaScreenCast * meta_screen_cast_new (MetaBackend *backend,
|
|
|
99364f |
MetaDbusSessionWatcher *session_watcher);
|
|
|
99364f |
|
|
|
99364f |
--
|
|
|
99364f |
2.26.2
|
|
|
99364f |
|