blob: cf1afa5a6859344340490c1e6bdbca2f2aaf5084 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <glib/gprintf.h>
#include "gskglnodesampleprivate.h"
#include "gskrendernodeprivate.h"
void
node_sample_init (NodeSample *self)
{
memset (self->nodes, 0, sizeof (self->nodes));
self->count = 0;
}
void
node_sample_reset (NodeSample *self)
{
node_sample_init (self);
}
void
node_sample_add (NodeSample *self,
GskRenderNode *node)
{
const guint node_type = gsk_render_node_get_node_type (node);
g_assert (node_type <= N_NODE_TYPES);
if (self->nodes[node_type].class_name == NULL)
self->nodes[node_type].class_name = g_type_name_from_instance ((GTypeInstance *) node);
self->nodes[node_type].count ++;
self->count ++;
}
void
node_sample_print (const NodeSample *self,
const char *prefix)
{
guint i;
g_printf ("%s:\n", prefix);
for (i = 0; i < N_NODE_TYPES; i ++)
{
if (self->nodes[i].count > 0)
{
double p = (double)self->nodes[i].count / (double)self->count;
g_printf ("%s: %u (%.2f%%)\n", self->nodes[i].class_name, self->nodes[i].count, p * 100.0);
}
}
}
|