tests/wayland-test-clients: Add gbm_device to WaylandDisplay
We'll use this later to allocate dma-bufs from. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3350>
This commit is contained in:
parent
8e7600322b
commit
24ef34f680
3 changed files with 28 additions and 4 deletions
|
@ -20,10 +20,6 @@ wayland_test_clients = [
|
|||
},
|
||||
{
|
||||
'name': 'dma-buf-scanout',
|
||||
'extra_deps': [
|
||||
libdrm_dep,
|
||||
libgbm_dep,
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'fractional-scale',
|
||||
|
@ -92,6 +88,8 @@ foreach test : wayland_test_clients
|
|||
glib_dep,
|
||||
gobject_dep,
|
||||
wayland_client_dep,
|
||||
libdrm_dep,
|
||||
libgbm_dep,
|
||||
m_dep,
|
||||
]
|
||||
if test.has_key('extra_deps')
|
||||
|
|
|
@ -107,6 +107,26 @@ create_anonymous_file (off_t size)
|
|||
return fd;
|
||||
}
|
||||
|
||||
static struct gbm_device *
|
||||
create_gbm_device (WaylandDisplay *display)
|
||||
{
|
||||
const char *gpu_path;
|
||||
int fd;
|
||||
|
||||
gpu_path = lookup_property_value (display, "gpu-path");
|
||||
if (!gpu_path)
|
||||
return NULL;
|
||||
|
||||
fd = open (gpu_path, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
g_error ("Failed to open drm render node %s: %s",
|
||||
gpu_path, g_strerror (errno));
|
||||
}
|
||||
|
||||
return gbm_create_device (fd);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_xdg_wm_base_ping (void *user_data,
|
||||
struct xdg_wm_base *xdg_wm_base,
|
||||
|
@ -261,6 +281,8 @@ wayland_display_new_full (WaylandDisplayCapabilities capabilities,
|
|||
|
||||
wl_display_roundtrip (display->display);
|
||||
|
||||
display->gbm_device = create_gbm_device (display);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <drm_fourcc.h>
|
||||
#include <gbm.h>
|
||||
#include <glib-object.h>
|
||||
#include <stdio.h>
|
||||
#include <wayland-client.h>
|
||||
|
@ -37,6 +39,8 @@ typedef struct _WaylandDisplay
|
|||
uint32_t sync_event_serial_next;
|
||||
|
||||
GHashTable *properties;
|
||||
|
||||
struct gbm_device *gbm_device;
|
||||
} WaylandDisplay;
|
||||
|
||||
#define WAYLAND_TYPE_DISPLAY (wayland_display_get_type ())
|
||||
|
|
Loading…
Reference in a new issue