mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-gtk: implement some basic depth chart drawing
This commit is contained in:
@ -55,29 +55,37 @@ sysprof_depth_layer_snapshot (GtkWidget *widget,
|
|||||||
g_assert (SYSPROF_IS_DEPTH_LAYER (self));
|
g_assert (SYSPROF_IS_DEPTH_LAYER (self));
|
||||||
g_assert (GTK_IS_SNAPSHOT (snapshot));
|
g_assert (GTK_IS_SNAPSHOT (snapshot));
|
||||||
|
|
||||||
if (self->series == NULL || self->color.alpha == 0)
|
width = gtk_widget_get_width (widget);
|
||||||
|
height = gtk_widget_get_height (widget);
|
||||||
|
|
||||||
|
if (width == 0 || height == 0 || self->color.alpha == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(values = sysprof_xy_series_get_values (self->series, &n_values)))
|
if (self->series == NULL ||
|
||||||
|
!(values = sysprof_xy_series_get_values (self->series, &n_values)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sysprof_xy_series_get_range (self->series, &min_x, NULL, &max_x, NULL);
|
sysprof_xy_series_get_range (self->series, &min_x, NULL, &max_x, NULL);
|
||||||
|
|
||||||
width = gtk_widget_get_width (widget);
|
/* NOTE: We might want to allow setting a "bucket size" for the
|
||||||
height = gtk_widget_get_width (widget);
|
* line width here so that units get joined together. For example,
|
||||||
|
* with stack traces, we would get nano-second precision due to time
|
||||||
line_width = MAX (1, (max_x - min_x) / width);
|
* being the X access, but that's not super helpful when you probably
|
||||||
|
* want some small quanta to be the width.
|
||||||
|
*/
|
||||||
|
line_width = MAX (1, width / (max_x - min_x));
|
||||||
|
|
||||||
for (guint i = 0; i < n_values; i++)
|
for (guint i = 0; i < n_values; i++)
|
||||||
{
|
{
|
||||||
const SysprofXYSeriesValue *v = &values[i];
|
const SysprofXYSeriesValue *v = &values[i];
|
||||||
|
int line_height = ceilf (v->y * height);
|
||||||
|
|
||||||
gtk_snapshot_append_color (snapshot,
|
gtk_snapshot_append_color (snapshot,
|
||||||
&self->color,
|
&self->color,
|
||||||
&GRAPHENE_RECT_INIT (v->x * width,
|
&GRAPHENE_RECT_INIT (v->x * width,
|
||||||
height,
|
height - line_height,
|
||||||
line_width,
|
line_width,
|
||||||
height - (v->y * height)));
|
line_height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user