mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
wayland/dma-buf: Add manager struct
It'll be used to store state related to DMA buffer Wayland support. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
This commit is contained in:
parent
7ce481bf69
commit
51308a9d78
@ -66,6 +66,11 @@
|
|||||||
|
|
||||||
#define META_WAYLAND_DMA_BUF_MAX_FDS 4
|
#define META_WAYLAND_DMA_BUF_MAX_FDS 4
|
||||||
|
|
||||||
|
struct _MetaWaylandDmaBufManager
|
||||||
|
{
|
||||||
|
MetaWaylandCompositor *compositor;
|
||||||
|
};
|
||||||
|
|
||||||
struct _MetaWaylandDmaBufBuffer
|
struct _MetaWaylandDmaBufBuffer
|
||||||
{
|
{
|
||||||
GObject parent;
|
GObject parent;
|
||||||
@ -713,17 +718,17 @@ send_modifiers (struct wl_resource *resource,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
dma_buf_bind (struct wl_client *client,
|
dma_buf_bind (struct wl_client *client,
|
||||||
void *data,
|
void *user_data,
|
||||||
uint32_t version,
|
uint32_t version,
|
||||||
uint32_t id)
|
uint32_t id)
|
||||||
{
|
{
|
||||||
MetaWaylandCompositor *compositor = data;
|
MetaWaylandDmaBufManager *dma_buf_manager = user_data;
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
|
||||||
resource = wl_resource_create (client, &zwp_linux_dmabuf_v1_interface,
|
resource = wl_resource_create (client, &zwp_linux_dmabuf_v1_interface,
|
||||||
version, id);
|
version, id);
|
||||||
wl_resource_set_implementation (resource, &dma_buf_implementation,
|
wl_resource_set_implementation (resource, &dma_buf_implementation,
|
||||||
compositor, NULL);
|
dma_buf_manager, NULL);
|
||||||
send_modifiers (resource, DRM_FORMAT_ARGB8888);
|
send_modifiers (resource, DRM_FORMAT_ARGB8888);
|
||||||
send_modifiers (resource, DRM_FORMAT_ABGR8888);
|
send_modifiers (resource, DRM_FORMAT_ABGR8888);
|
||||||
send_modifiers (resource, DRM_FORMAT_XRGB8888);
|
send_modifiers (resource, DRM_FORMAT_XRGB8888);
|
||||||
@ -740,38 +745,58 @@ dma_buf_bind (struct wl_client *client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_wayland_dma_buf_init:
|
* meta_wayland_dma_buf_manager_new:
|
||||||
* @compositor: The #MetaWaylandCompositor
|
* @compositor: The #MetaWaylandCompositor
|
||||||
*
|
*
|
||||||
* Creates the global Wayland object that exposes the linux-dmabuf protocol.
|
* Creates the global Wayland object that exposes the linux-dmabuf protocol.
|
||||||
*
|
*
|
||||||
* Returns: Whether the initialization was successful. If this is %FALSE,
|
* Returns: (transfer full): The MetaWaylandDmaBufManager instance.
|
||||||
* clients won't be able to use the linux-dmabuf protocol to pass buffers.
|
|
||||||
*/
|
*/
|
||||||
gboolean
|
MetaWaylandDmaBufManager *
|
||||||
meta_wayland_dma_buf_init (MetaWaylandCompositor *compositor)
|
meta_wayland_dma_buf_manager_new (MetaWaylandCompositor *compositor,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaEgl *egl = meta_backend_get_egl (backend);
|
MetaEgl *egl = meta_backend_get_egl (backend);
|
||||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||||
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||||
EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context);
|
EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context);
|
||||||
|
g_autoptr (GError) local_error = NULL;
|
||||||
|
g_autofree MetaWaylandDmaBufManager *dma_buf_manager = NULL;
|
||||||
|
|
||||||
g_assert (backend && egl && clutter_backend && cogl_context && egl_display);
|
g_assert (backend && egl && clutter_backend && cogl_context && egl_display);
|
||||||
|
|
||||||
if (!meta_egl_has_extensions (egl, egl_display, NULL,
|
if (!meta_egl_has_extensions (egl, egl_display, NULL,
|
||||||
"EGL_EXT_image_dma_buf_import_modifiers",
|
"EGL_EXT_image_dma_buf_import_modifiers",
|
||||||
NULL))
|
NULL))
|
||||||
return FALSE;
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||||
|
"Missing 'EGL_EXT_image_dma_buf_import_modifiers'");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dma_buf_manager = g_new0 (MetaWaylandDmaBufManager, 1);
|
||||||
|
|
||||||
if (!wl_global_create (compositor->wayland_display,
|
if (!wl_global_create (compositor->wayland_display,
|
||||||
&zwp_linux_dmabuf_v1_interface,
|
&zwp_linux_dmabuf_v1_interface,
|
||||||
META_ZWP_LINUX_DMABUF_V1_VERSION,
|
META_ZWP_LINUX_DMABUF_V1_VERSION,
|
||||||
compositor,
|
dma_buf_manager,
|
||||||
dma_buf_bind))
|
dma_buf_bind))
|
||||||
return FALSE;
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Failed to create zwp_linux_dmabuf_v1 global");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
dma_buf_manager->compositor = compositor;
|
||||||
|
|
||||||
|
return g_steal_pointer (&dma_buf_manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_wayland_dma_buf_manager_free (MetaWaylandDmaBufManager *dma_buf_manager)
|
||||||
|
{
|
||||||
|
g_free (dma_buf_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -39,7 +39,10 @@ G_DECLARE_FINAL_TYPE (MetaWaylandDmaBufBuffer, meta_wayland_dma_buf_buffer,
|
|||||||
|
|
||||||
typedef struct _MetaWaylandDmaBufBuffer MetaWaylandDmaBufBuffer;
|
typedef struct _MetaWaylandDmaBufBuffer MetaWaylandDmaBufBuffer;
|
||||||
|
|
||||||
gboolean meta_wayland_dma_buf_init (MetaWaylandCompositor *compositor);
|
MetaWaylandDmaBufManager * meta_wayland_dma_buf_manager_new (MetaWaylandCompositor *compositor,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
void meta_wayland_dma_buf_manager_free (MetaWaylandDmaBufManager *dma_buf_manager);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer,
|
meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer,
|
||||||
|
@ -100,6 +100,7 @@ struct _MetaWaylandCompositor
|
|||||||
GHashTable *scheduled_surface_associations;
|
GHashTable *scheduled_surface_associations;
|
||||||
|
|
||||||
MetaWaylandPresentationTime presentation_time;
|
MetaWaylandPresentationTime presentation_time;
|
||||||
|
MetaWaylandDmaBufManager *dma_buf_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define META_TYPE_WAYLAND_COMPOSITOR (meta_wayland_compositor_get_type ())
|
#define META_TYPE_WAYLAND_COMPOSITOR (meta_wayland_compositor_get_type ())
|
||||||
|
@ -63,4 +63,6 @@ typedef struct _MetaWaylandPointerClient MetaWaylandPointerClient;
|
|||||||
|
|
||||||
typedef struct _MetaWaylandActivation MetaWaylandActivation;
|
typedef struct _MetaWaylandActivation MetaWaylandActivation;
|
||||||
|
|
||||||
|
typedef struct _MetaWaylandDmaBufManager MetaWaylandDmaBufManager;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -437,6 +437,9 @@ meta_wayland_compositor_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
MetaWaylandCompositor *compositor = META_WAYLAND_COMPOSITOR (object);
|
MetaWaylandCompositor *compositor = META_WAYLAND_COMPOSITOR (object);
|
||||||
|
|
||||||
|
g_clear_pointer (&compositor->dma_buf_manager,
|
||||||
|
meta_wayland_dma_buf_manager_free);
|
||||||
|
|
||||||
g_clear_pointer (&compositor->seat, meta_wayland_seat_free);
|
g_clear_pointer (&compositor->seat, meta_wayland_seat_free);
|
||||||
|
|
||||||
g_clear_pointer (&compositor->display_name, g_free);
|
g_clear_pointer (&compositor->display_name, g_free);
|
||||||
@ -526,6 +529,29 @@ meta_wayland_init_egl (MetaWaylandCompositor *compositor)
|
|||||||
g_warning ("Failed to bind Wayland display: %s", error->message);
|
g_warning ("Failed to bind Wayland display: %s", error->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_dma_buf_support (MetaWaylandCompositor *compositor)
|
||||||
|
{
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
|
compositor->dma_buf_manager = meta_wayland_dma_buf_manager_new (compositor,
|
||||||
|
&error);
|
||||||
|
if (!compositor->dma_buf_manager)
|
||||||
|
{
|
||||||
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
|
||||||
|
{
|
||||||
|
meta_topic (META_DEBUG_WAYLAND,
|
||||||
|
"Wayland DMA buffer protocol support not enabled: %s",
|
||||||
|
error->message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_warning ("Wayland DMA buffer protocol support not enabled: %s",
|
||||||
|
error->message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MetaWaylandCompositor *
|
MetaWaylandCompositor *
|
||||||
meta_wayland_compositor_new (MetaContext *context)
|
meta_wayland_compositor_new (MetaContext *context)
|
||||||
{
|
{
|
||||||
@ -577,7 +603,7 @@ meta_wayland_compositor_new (MetaContext *context)
|
|||||||
meta_wayland_relative_pointer_init (compositor);
|
meta_wayland_relative_pointer_init (compositor);
|
||||||
meta_wayland_pointer_constraints_init (compositor);
|
meta_wayland_pointer_constraints_init (compositor);
|
||||||
meta_wayland_xdg_foreign_init (compositor);
|
meta_wayland_xdg_foreign_init (compositor);
|
||||||
meta_wayland_dma_buf_init (compositor);
|
init_dma_buf_support (compositor);
|
||||||
meta_wayland_keyboard_shortcuts_inhibit_init (compositor);
|
meta_wayland_keyboard_shortcuts_inhibit_init (compositor);
|
||||||
meta_wayland_surface_inhibit_shortcuts_dialog_init ();
|
meta_wayland_surface_inhibit_shortcuts_dialog_init ();
|
||||||
meta_wayland_text_input_init (compositor);
|
meta_wayland_text_input_init (compositor);
|
||||||
|
Loading…
Reference in New Issue
Block a user