mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 08:00:53 +00:00
fps: discover gtk FPS counter and add visualizer row
This commit is contained in:
@ -43,7 +43,8 @@ typedef struct
|
|||||||
{
|
{
|
||||||
SpCaptureCursor *cursor;
|
SpCaptureCursor *cursor;
|
||||||
GHashTable *mark_groups;
|
GHashTable *mark_groups;
|
||||||
gboolean has_cpu;
|
guint fps_counter;
|
||||||
|
guint has_cpu : 1;
|
||||||
} Discovery;
|
} Discovery;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -212,11 +213,20 @@ discover_new_rows_frame_cb (const SpCaptureFrame *frame,
|
|||||||
g_hash_table_add (state->mark_groups, g_strdup (mark->group));
|
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)
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -264,6 +274,22 @@ handle_capture_results (GObject *object,
|
|||||||
gtk_container_add (GTK_CONTAINER (self), row);
|
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)
|
if (g_hash_table_size (state->mark_groups) < 30)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
|
|||||||
Reference in New Issue
Block a user