[mutter/gbsneto/dmabuf-screencast: 7/8] monitor-stream-src: Export DMA buffers for the current onscreen
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/dmabuf-screencast: 7/8] monitor-stream-src: Export DMA buffers for the current onscreen
- Date: Mon, 24 Feb 2020 17:01:07 +0000 (UTC)
commit 9fda9106aff96cdc5fdfaa056dbd7a08026a4aa5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Dec 9 10:11:51 2019 -0300
monitor-stream-src: Export DMA buffers for the current onscreen
Add the vfunc overrides that actually consume the new CoglOnscreen
API, and cogl_freamebuffer_flush() as well.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1086
src/backends/meta-screen-cast-monitor-stream-src.c | 84 ++++++++++++++++++++++
1 file changed, 84 insertions(+)
---
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c
b/src/backends/meta-screen-cast-monitor-stream-src.c
index 5d9dadc8c..501ada7a1 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -358,6 +358,86 @@ meta_screen_cast_monitor_stream_src_record_frame (MetaScreenCastStreamSrc *src,
return TRUE;
}
+static CoglOnscreenDmabufHandle *
+meta_screen_cast_monitor_stream_src_capture_dmabuf (MetaScreenCastStreamSrc *src)
+{
+ MetaScreenCastMonitorStreamSrc *monitor_src =
+ META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
+ MetaBackend *backend = get_backend (monitor_src);
+ MetaRenderer *renderer = meta_backend_get_renderer (backend);
+ MetaRendererView *view;
+ CoglFramebuffer *onscreen;
+ MetaMonitor *monitor;
+ MetaLogicalMonitor *logical_monitor;
+ g_autoptr (GError) error = NULL;
+ CoglOnscreenDmabufHandle *dmabuf_handle;
+
+ monitor = get_monitor (monitor_src);
+ logical_monitor = meta_monitor_get_logical_monitor (monitor);
+
+ view = meta_renderer_get_view_from_logical_monitor (renderer, logical_monitor);
+ if (!view)
+ return NULL;
+
+ onscreen = clutter_stage_view_get_onscreen (CLUTTER_STAGE_VIEW (view));
+ if (!onscreen)
+ return NULL;
+
+ dmabuf_handle = cogl_onscreen_capture_dmabuf (COGL_ONSCREEN (onscreen),
+ &error);
+
+ if (error)
+ {
+ g_debug ("Error exporting DMA buffer handle: %s", error->message);
+ return NULL;
+ }
+
+ return dmabuf_handle;
+}
+
+static gboolean
+meta_screen_cast_monitor_stream_src_blit_to_framebuffer (MetaScreenCastStreamSrc *src,
+ CoglFramebuffer *framebuffer)
+{
+ MetaScreenCastMonitorStreamSrc *monitor_src =
+ META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
+ MetaBackend *backend = get_backend (monitor_src);
+ MetaRenderer *renderer = meta_backend_get_renderer (backend);
+ MetaRendererView *view;
+ CoglFramebuffer *onscreen;
+ MetaMonitor *monitor;
+ MetaLogicalMonitor *logical_monitor;
+ g_autoptr (GError) error = NULL;
+
+ monitor = get_monitor (monitor_src);
+ logical_monitor = meta_monitor_get_logical_monitor (monitor);
+ view = meta_renderer_get_view_from_logical_monitor (renderer, logical_monitor);
+ onscreen = clutter_stage_view_get_onscreen (CLUTTER_STAGE_VIEW (view));
+
+ cogl_framebuffer_clear4f (framebuffer,
+ COGL_BUFFER_BIT_COLOR,
+ 0.f, 0.f, 0.f, 1.f);
+
+ cogl_blit_framebuffer (onscreen,
+ framebuffer,
+ 0, 0,
+ 0, 0,
+ cogl_framebuffer_get_width (framebuffer),
+ cogl_framebuffer_get_height (framebuffer),
+ &error);
+
+ cogl_framebuffer_flush (framebuffer);
+
+ if (error)
+ {
+ g_warning ("Error blitting onscreen into DMABuf framebuffer: %s",
+ error->message);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *src,
struct spa_meta_cursor *spa_meta_cursor)
@@ -483,6 +563,10 @@ meta_screen_cast_monitor_stream_src_class_init (MetaScreenCastMonitorStreamSrcCl
src_class->enable = meta_screen_cast_monitor_stream_src_enable;
src_class->disable = meta_screen_cast_monitor_stream_src_disable;
src_class->record_frame = meta_screen_cast_monitor_stream_src_record_frame;
+ src_class->capture_dmabuf =
+ meta_screen_cast_monitor_stream_src_capture_dmabuf;
+ src_class->blit_to_framebuffer =
+ meta_screen_cast_monitor_stream_src_blit_to_framebuffer;
src_class->set_cursor_metadata =
meta_screen_cast_monitor_stream_src_set_cursor_metadata;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]