tests/wayland-test-clients: Use WaylandBuffer in draw_surcace

Most tests use the draw_surface function to draw a solid color to a
surface. This moves it from the shm-only path to WaylandBuffer which
makes all of those tests usable via dma-buf.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3350>
This commit is contained in:
Sebastian Wick 2023-12-12 16:47:52 +01:00 committed by Marge Bot
parent d842fe601d
commit 2c23a94be0

View File

@ -543,17 +543,20 @@ draw_surface (WaylandDisplay *display,
int height,
uint32_t color)
{
struct wl_buffer *buffer;
void *buffer_data;
int size;
WaylandBuffer *buffer;
if (!create_shm_buffer (display, width, height,
&buffer, &buffer_data, &size))
g_error ("Failed to create shm buffer");
buffer = wayland_buffer_create (display, NULL,
width, height,
DRM_FORMAT_ARGB8888,
NULL, 0,
GBM_BO_USE_LINEAR);
fill (buffer_data, width, height, color);
if (!buffer)
g_error ("Failed to create buffer");
wl_surface_attach (surface, buffer, 0, 0);
wayland_buffer_fill_color (buffer, color);
wl_surface_attach (surface, wayland_buffer_get_wl_buffer (buffer), 0, 0);
}
static void