From be9cf3d5f8cc6b8fa850c1352b73f8660d7fa45b Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 25 Aug 2023 11:15:14 -0700 Subject: [PATCH] sysprof: add stable alpha variation This is something that original flamegraphs do to aid in seeing adjacent towers. We want that too, but we need it to be stable across redraws. Use the hash of the symbol rather than g_random_double_range() for that. --- src/sysprof/sysprof-flame-graph.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sysprof/sysprof-flame-graph.c b/src/sysprof/sysprof-flame-graph.c index 54756e77..c67b67f5 100644 --- a/src/sysprof/sysprof-flame-graph.c +++ b/src/sysprof/sysprof-flame-graph.c @@ -148,11 +148,16 @@ sysprof_flame_graph_snapshot (GtkWidget *widget, { FlameRectangle *rect = &g_array_index (self->nodes, FlameRectangle, i); SysprofCallgraphCategory category = SYSPROF_CALLGRAPH_CATEGORY_UNMASK (rect->node->category); - const GdkRGBA *color = sysprof_callgraph_category_get_color (category); + const GdkRGBA *category_color = sysprof_callgraph_category_get_color (category); graphene_rect_t area; + GdkRGBA color; - if (color == NULL) - color = default_color; + if (category_color == NULL) + color = *default_color; + else + color = *category_color; + + color.alpha = .6 + (g_str_hash (rect->node->summary->symbol->name) % 1000) / 2500.; area = GRAPHENE_RECT_INIT (rect->x / (double)G_MAXUINT16 * width, rect->y, @@ -162,7 +167,7 @@ sysprof_flame_graph_snapshot (GtkWidget *widget, if (!highlight && graphene_rect_contains_point (&area, &point)) highlight = rect; - gtk_snapshot_append_color (child_snapshot, color, &area); + gtk_snapshot_append_color (child_snapshot, &color, &area); if (area.size.width > ROW_HEIGHT) {