[mutter/gbsneto/dmabuf-screencast: 11/13] monitor-stream-src: Export DMA buffers for the current view framebuffer
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/dmabuf-screencast: 11/13] monitor-stream-src: Export DMA buffers for the current view framebuffer
- Date: Thu, 27 Feb 2020 18:31:31 +0000 (UTC)
commit 8be770b41d29c4cb503115e206bca87c031ced3d
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 view framebuffer
Add the vfunc overrides that actually consume the new Cogl API. Every
view that fits into the logical monitor is rendered.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
src/backends/meta-screen-cast-monitor-stream-src.c | 92 ++++++++++++++++++++++
1 file changed, 92 insertions(+)
---
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c
b/src/backends/meta-screen-cast-monitor-stream-src.c
index 902ae545b..4de4b5a2b 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -381,6 +381,94 @@ meta_screen_cast_monitor_stream_src_record_frame (MetaScreenCastStreamSrc *src,
return TRUE;
}
+static CoglDmaBufHandle *
+meta_screen_cast_monitor_stream_src_capture_dma_buf (MetaScreenCastStreamSrc *src)
+{
+ CoglContext *context =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ MetaScreenCastMonitorStreamSrc *monitor_src =
+ META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
+ g_autoptr (GError) error = NULL;
+ CoglDmaBufHandle *dmabuf_handle;
+ MetaMonitor *monitor;
+ MetaLogicalMonitor *logical_monitor;
+ MetaRectangle logical_monitor_layout;
+
+ monitor = get_monitor (monitor_src);
+ logical_monitor = meta_monitor_get_logical_monitor (monitor);
+ logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
+
+ dmabuf_handle = cogl_context_capture_dma_buf (context,
+ logical_monitor_layout.width,
+ logical_monitor_layout.height,
+ &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);
+ MetaMonitor *monitor;
+ MetaLogicalMonitor *logical_monitor;
+ MetaRectangle logical_monitor_layout;
+ GList *l;
+
+ monitor = get_monitor (monitor_src);
+ logical_monitor = meta_monitor_get_logical_monitor (monitor);
+ logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
+
+ cogl_framebuffer_clear4f (framebuffer,
+ COGL_BUFFER_BIT_COLOR,
+ 0.f, 0.f, 0.f, 1.f);
+
+ for (l = meta_renderer_get_views (renderer); l; l = l->next)
+ {
+ ClutterStageView *view = CLUTTER_STAGE_VIEW (l->data);
+ g_autoptr (GError) error = NULL;
+ CoglFramebuffer *view_framebuffer;
+ MetaRectangle view_layout;
+
+ clutter_stage_view_get_layout (view, &view_layout);
+
+ if (!meta_rectangle_overlap (&logical_monitor_layout, &view_layout))
+ continue;
+
+ view_framebuffer = clutter_stage_view_get_framebuffer (view);
+
+ cogl_blit_framebuffer (view_framebuffer,
+ framebuffer,
+ 0, 0,
+ view_layout.x - logical_monitor_layout.x,
+ view_layout.y - logical_monitor_layout.y,
+ cogl_framebuffer_get_width (view_framebuffer),
+ cogl_framebuffer_get_height (view_framebuffer),
+ &error);
+
+ if (error)
+ {
+ g_warning ("Error blitting onscreen into DMABuf framebuffer: %s",
+ error->message);
+ return FALSE;
+ }
+ }
+
+ cogl_framebuffer_finish (framebuffer);
+
+ return TRUE;
+}
+
static void
meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *src,
struct spa_meta_cursor *spa_meta_cursor)
@@ -502,6 +590,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_dma_buf =
+ meta_screen_cast_monitor_stream_src_capture_dma_buf;
+ 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]