wsi/wayland: Move buffer name string into common code

Push this into the loader bits so it will be available to egl when we
add profiling later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32757>
This commit is contained in:
Derek Foreman
2024-12-12 09:47:14 -06:00
parent 6946758682
commit aefd3d835e
3 changed files with 26 additions and 22 deletions
+16
View File
@@ -22,6 +22,8 @@
#include <poll.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "util/perf/cpu_trace.h"
@@ -164,6 +166,17 @@ loader_wayland_dispatch(struct wl_display *wl_display,
&remaining_timeout);
}
static char *
stringify_wayland_id(uint32_t id)
{
char *out;
if (asprintf(&out, "wl%d", id) < 0)
return strdup("Wayland buffer");
return out;
}
void
loader_wayland_wrap_buffer(struct loader_wayland_buffer *lwb,
struct wl_buffer *wl_buffer)
@@ -171,6 +184,7 @@ loader_wayland_wrap_buffer(struct loader_wayland_buffer *lwb,
lwb->buffer = wl_buffer;
lwb->id = wl_proxy_get_id((struct wl_proxy *)wl_buffer);
lwb->flow_id = 0;
lwb->name = stringify_wayland_id(lwb->id);
}
void
@@ -180,6 +194,8 @@ loader_wayland_buffer_destroy(struct loader_wayland_buffer *lwb)
lwb->buffer = NULL;
lwb->id = 0;
lwb->flow_id = 0;
free(lwb->name);
lwb->name = NULL;
}
void
+1
View File
@@ -30,6 +30,7 @@ struct loader_wayland_buffer {
struct wl_buffer *buffer;
uint32_t id;
uint64_t flow_id;
char *name;
};
#ifndef HAVE_WL_DISPATCH_QUEUE_TIMEOUT