mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
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>
This commit is contained in:
parent
802e7eb56f
commit
986588ade2
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user