sysprof: attempt to highlight to root of flamegraph

This commit is contained in:
Christian Hergert
2023-08-28 15:44:41 -07:00
parent 279e8ae397
commit 8aa55a7b2d

View File

@ -114,6 +114,7 @@ find_node_at_coord (SysprofFlameGraph *self,
double y)
{
FlameSearch search;
FlameRectangle *ret;
if (self->nodes == NULL)
return NULL;
@ -122,7 +123,17 @@ find_node_at_coord (SysprofFlameGraph *self,
search.point.y = y;
search.width = gtk_widget_get_width (GTK_WIDGET (self));
return bsearch (&search, self->nodes->data, self->nodes->len, sizeof (FlameRectangle), search_compare);
ret = bsearch (&search, self->nodes->data, self->nodes->len, sizeof (FlameRectangle), search_compare);
if (ret == NULL)
{
/* Try to recover from pointer inbetween rows */
search.point.y -= 1;
ret = bsearch (&search, self->nodes->data, self->nodes->len, sizeof (FlameRectangle), search_compare);
}
return ret;
}
static void
@ -266,15 +277,16 @@ sysprof_flame_graph_snapshot (GtkWidget *widget,
g_object_unref (layout);
}
if (self->motion_x || self->motion_y)
{
if (highlight == NULL)
highlight = find_node_at_coord (self, self->motion_x, self->motion_y);
}
gtk_snapshot_append_node (snapshot, self->rendered);
if (highlight)
if (self->motion_x || self->motion_y)
{
double y = self->motion_y;
if (highlight == NULL)
highlight = find_node_at_coord (self, self->motion_x, y);
while (highlight)
{
graphene_rect_t area;
@ -284,6 +296,10 @@ sysprof_flame_graph_snapshot (GtkWidget *widget,
highlight->h);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) {1,1,1,.25}, &area);
y += ROW_HEIGHT + 1;
highlight = find_node_at_coord (self, self->motion_x, y);
}
}
}