libsysprof-ui: start rendering mark data

This commit is contained in:
Christian Hergert
2019-05-12 23:56:02 -07:00
parent 0165005077
commit 00d910dc80
7 changed files with 326 additions and 8 deletions

View File

@ -29,6 +29,7 @@ struct _SysprofMarksModel
GObject parent_instance;
GStringChunk *chunks;
GArray *items;
gint64 max_end_time;
};
typedef struct
@ -276,11 +277,27 @@ cursor_foreach_cb (const SysprofCaptureFrame *frame,
item.group = g_string_chunk_insert_const (self->chunks, mark->group);
item.name = g_string_chunk_insert_const (self->chunks, mark->name);
if G_LIKELY (item.end_time > self->max_end_time)
self->max_end_time = item.end_time;
g_array_append_val (self->items, item);
return TRUE;
}
static gint
item_compare (gconstpointer a,
gconstpointer b)
{
const Item *ia = a;
const Item *ib = b;
if (ia->begin_time == ib->begin_time)
return ia->end_time - ib->end_time;
return ia->begin_time - ib->begin_time;
}
static void
sysprof_marks_model_new_worker (GTask *task,
gpointer source_object,
@ -303,6 +320,8 @@ sysprof_marks_model_new_worker (GTask *task,
sysprof_capture_cursor_add_condition (cursor, g_steal_pointer (&condition));
sysprof_capture_cursor_foreach (cursor, cursor_foreach_cb, self);
g_array_sort (self->items, item_compare);
g_task_return_pointer (task, g_steal_pointer (&self), g_object_unref);
}
@ -333,3 +352,22 @@ sysprof_marks_model_new_finish (GAsyncResult *result,
return g_task_propagate_pointer (G_TASK (result), error);
}
void
sysprof_marks_model_get_range (SysprofMarksModel *self,
gint64 *begin_time,
gint64 *end_time)
{
g_return_if_fail (SYSPROF_IS_MARKS_MODEL (self));
if (begin_time != NULL)
{
*begin_time = 0;
if (self->items->len > 0)
*begin_time = g_array_index (self->items, Item, 0).begin_time;
}
if (end_time != NULL)
*end_time = self->max_end_time;
}