timeline-perfetto: Store disambiguator globally

This way we can use the same ID when for perfetto counters to allow
to identify clients much easier.

Also, renamed "surface" with "unlabelled surface" when get_label function
is not set.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2025-02-27 16:19:36 +02:00
parent af95899121
commit ad3957ddf8
3 changed files with 7 additions and 5 deletions

View file

@ -1559,6 +1559,7 @@ struct weston_compositor {
struct wl_list debug_binding_list;
bool view_list_needs_rebuild;
int global_weston_surface_disambiguator; /* surface ids to avoid using PID-reuse */
uint32_t state;
struct wl_event_source *idle_source;
@ -2071,6 +2072,7 @@ struct weston_surface {
bool is_mapped, is_unmapping, is_mapping;
bool is_opaque;
uint32_t s_id;
/* An list of per seat pointer constraints. */
struct wl_list pointer_constraints;

View file

@ -1010,6 +1010,9 @@ weston_surface_create(struct weston_compositor *compositor)
surface->compositor = compositor;
surface->ref_count = 1;
compositor->global_weston_surface_disambiguator++;
surface->s_id =
compositor->global_weston_surface_disambiguator;
surface->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
surface->buffer_viewport.buffer.scale = 1;

View file

@ -57,7 +57,6 @@ weston_perfetto_ensure_output_ids(struct weston_output *output)
static void
build_track_name(struct weston_surface *surface, char *name, int size)
{
static int disambiguator = 0;
char surface_label[512];
/* Make sure we only call this once, so we don't accidentally
@ -70,12 +69,10 @@ build_track_name(struct weston_surface *surface, char *name, int size)
uint32_t res_id;
res_id = wl_resource_get_id(surface->resource);
snprintf(surface_label, sizeof(surface_label), "surface %d", res_id);
snprintf(surface_label, sizeof(surface_label), "unlabelled surface %d", res_id);
}
disambiguator++;
snprintf(name, size, "%s #%d", surface_label, disambiguator);
snprintf(name, size, "%s #%d", surface_label, surface->s_id);
}
static void