fps: discover gtk FPS counter and add visualizer row

This commit is contained in:
Christian Hergert
2018-05-17 20:31:56 +01:00
parent 138f08d4fe
commit 12f627a7bd

View File

@ -43,7 +43,8 @@ typedef struct
{
SpCaptureCursor *cursor;
GHashTable *mark_groups;
gboolean has_cpu;
guint fps_counter;
guint has_cpu : 1;
} Discovery;
enum {
@ -212,11 +213,20 @@ discover_new_rows_frame_cb (const SpCaptureFrame *frame,
g_hash_table_add (state->mark_groups, g_strdup (mark->group));
}
/* TODO: Make this look for CPU define. Currently it is the
* only thing that uses it. So...
*/
if (frame->type == SP_CAPTURE_FRAME_CTRDEF)
state->has_cpu = TRUE;
{
const SpCaptureFrameCounterDefine *def = (const SpCaptureFrameCounterDefine *)frame;
for (guint i = 0; i < def->n_counters; i++)
{
const SpCaptureCounter *ctr = &def->counters[i];
if (strstr (ctr->category, "CPU Percent") != NULL)
state->has_cpu = TRUE;
else if (strstr (ctr->category, "gtk") != NULL && strstr (ctr->name, "fps") != NULL)
state->fps_counter = ctr->id;
}
}
return TRUE;
}
@ -264,6 +274,22 @@ handle_capture_results (GObject *object,
gtk_container_add (GTK_CONTAINER (self), row);
}
if (state->fps_counter)
{
GdkRGBA rgba;
GtkWidget *row = g_object_new (SP_TYPE_LINE_VISUALIZER_ROW,
"title", _("FPS"),
"height-request", 50,
"selectable", FALSE,
"visible", TRUE,
"y-lower", 0.0,
"y-upper", 150.0,
NULL);
gdk_rgba_parse (&rgba, "#204a87");
sp_line_visualizer_row_add_counter (SP_LINE_VISUALIZER_ROW (row), state->fps_counter, &rgba);
gtk_container_add (GTK_CONTAINER (self), row);
}
if (g_hash_table_size (state->mark_groups) < 30)
{
GHashTableIter iter;