[mutter] render-device: Add API to import other buffers
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] render-device: Add API to import other buffers
- Date: Mon, 18 Oct 2021 16:45:45 +0000 (UTC)
commit 986588ade2ac8e48911bec5ca584b5629e9add96
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed May 5 15:38:22 2021 +0200
render-device: Add API to import other buffers
This more or less is a helper for creating MetaDrmBufferImport objects
with a bit more friendly API.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
src/backends/native/meta-render-device-gbm.c | 33 ++++++++++++++++++++++++
src/backends/native/meta-render-device-private.h | 3 +++
src/backends/native/meta-render-device.c | 17 ++++++++++++
src/backends/native/meta-render-device.h | 4 +++
4 files changed, 57 insertions(+)
---
diff --git a/src/backends/native/meta-render-device-gbm.c b/src/backends/native/meta-render-device-gbm.c
index e5fe9c733b..05f212bf2f 100644
--- a/src/backends/native/meta-render-device-gbm.c
+++ b/src/backends/native/meta-render-device-gbm.c
@@ -27,6 +27,7 @@
#include "backends/meta-backend-private.h"
#include "backends/native/meta-drm-buffer-gbm.h"
+#include "backends/native/meta-drm-buffer-import.h"
struct _MetaRenderDeviceGbm
{
@@ -77,6 +78,36 @@ initable_iface_init (GInitableIface *initable_iface)
initable_iface->init = meta_render_device_gbm_initable_init;
}
+static MetaDrmBuffer *
+meta_render_device_gbm_import_dma_buf (MetaRenderDevice *render_device,
+ MetaDrmBuffer *buffer,
+ GError **error)
+{
+ MetaRenderDeviceGbm *render_device_gbm =
+ META_RENDER_DEVICE_GBM (render_device);
+ MetaDeviceFile *device_file;
+ MetaDrmBufferGbm *buffer_gbm;
+ MetaDrmBufferImport *buffer_import;
+
+ if (!META_IS_DRM_BUFFER_GBM (buffer))
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ "Can only import gbm backed DMA buffers");
+ return NULL;
+ }
+
+ device_file = meta_render_device_get_device_file (render_device);
+ buffer_gbm = META_DRM_BUFFER_GBM (buffer);
+ buffer_import = meta_drm_buffer_import_new (device_file,
+ render_device_gbm->gbm_device,
+ buffer_gbm,
+ error);
+ if (!buffer_import)
+ return NULL;
+
+ return META_DRM_BUFFER (buffer_import);
+}
+
static EGLDisplay
meta_render_device_gbm_create_egl_display (MetaRenderDevice *render_device,
GError **error)
@@ -168,6 +199,8 @@ meta_render_device_gbm_class_init (MetaRenderDeviceGbmClass *klass)
meta_render_device_gbm_create_egl_display;
render_device_class->allocate_dma_buf =
meta_render_device_gbm_allocate_dma_buf;
+ render_device_class->import_dma_buf =
+ meta_render_device_gbm_import_dma_buf;
}
static void
diff --git a/src/backends/native/meta-render-device-private.h
b/src/backends/native/meta-render-device-private.h
index 8b917d501d..564be4faea 100644
--- a/src/backends/native/meta-render-device-private.h
+++ b/src/backends/native/meta-render-device-private.h
@@ -42,6 +42,9 @@ struct _MetaRenderDeviceClass
uint32_t format,
MetaDrmBufferFlags flags,
GError **error);
+ MetaDrmBuffer * (* import_dma_buf) (MetaRenderDevice *render_device,
+ MetaDrmBuffer *buffer,
+ GError **error);
};
#endif /* META_RENDER_DEVICE_PRIVATE_H */
diff --git a/src/backends/native/meta-render-device.c b/src/backends/native/meta-render-device.c
index 6a0a00e1e9..389724dd0b 100644
--- a/src/backends/native/meta-render-device.c
+++ b/src/backends/native/meta-render-device.c
@@ -364,3 +364,20 @@ meta_render_device_allocate_dma_buf (MetaRenderDevice *render_device,
return NULL;
}
+
+MetaDrmBuffer *
+meta_render_device_import_dma_buf (MetaRenderDevice *render_device,
+ MetaDrmBuffer *buffer,
+ GError **error)
+{
+ MetaRenderDeviceClass *klass = META_RENDER_DEVICE_GET_CLASS (render_device);
+
+ if (klass->import_dma_buf)
+ return klass->import_dma_buf (render_device, buffer, error);
+
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Render device '%s' doesn't importing DMA buffers",
+ meta_render_device_get_name (render_device));
+
+ return NULL;
+}
diff --git a/src/backends/native/meta-render-device.h b/src/backends/native/meta-render-device.h
index 48cc657c95..9428283b9e 100644
--- a/src/backends/native/meta-render-device.h
+++ b/src/backends/native/meta-render-device.h
@@ -48,4 +48,8 @@ MetaDrmBuffer * meta_render_device_allocate_dma_buf (MetaRenderDevice *render
MetaDrmBufferFlags flags,
GError **error);
+MetaDrmBuffer * meta_render_device_import_dma_buf (MetaRenderDevice *render_device,
+ MetaDrmBuffer *buffer,
+ GError **error);
+
#endif /* META_RENDER_DEVICE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]