From 5403f0335f94481f35a5a28e22bd30f52907d79e Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 20 Jun 2023 15:46:21 -0700 Subject: [PATCH] libsysprof-gtk: move some math to the GPU We can at least do the subtraction on the GPU by setting up the transformation instead of on every data point. It would be nice to do the rect as well but it looks like we might get culled do to the rect width. --- src/libsysprof-gtk/sysprof-column-layer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libsysprof-gtk/sysprof-column-layer.c b/src/libsysprof-gtk/sysprof-column-layer.c index b83f6153..db627129 100644 --- a/src/libsysprof-gtk/sysprof-column-layer.c +++ b/src/libsysprof-gtk/sysprof-column-layer.c @@ -48,6 +48,7 @@ sysprof_column_layer_snapshot (GtkWidget *widget, { SysprofColumnLayer *self = (SysprofColumnLayer *)widget; const SysprofXYSeriesValue *values; + graphene_matrix_t flip_y; guint n_values; double min_x, max_x; int line_width; @@ -67,6 +68,11 @@ sysprof_column_layer_snapshot (GtkWidget *widget, !(values = sysprof_xy_series_get_values (self->series, &n_values))) return; + gtk_snapshot_save (snapshot); + + graphene_matrix_init_from_2d (&flip_y, 1, 0, 0, -1, 0, height); + gtk_snapshot_transform_matrix (snapshot, &flip_y); + sysprof_xy_series_get_range (self->series, &min_x, NULL, &max_x, NULL); /* NOTE: We might want to allow setting a "bucket size" for the @@ -85,10 +91,12 @@ sysprof_column_layer_snapshot (GtkWidget *widget, gtk_snapshot_append_color (snapshot, &self->color, &GRAPHENE_RECT_INIT (v->x * width, - height - line_height, + 0, line_width, line_height)); } + + gtk_snapshot_restore (snapshot); } static const SysprofXYSeriesValue *