[gtk] gl renderer: Add NodeSample
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] gl renderer: Add NodeSample
- Date: Sun, 2 Dec 2018 15:18:53 +0000 (UTC)
commit 9df9087a13d97abd451db2b9af007557404c6b49
Author: Timm Bäder <mail baedert org>
Date: Sun Dec 2 10:20:59 2018 +0100
gl renderer: Add NodeSample
As a quick way of checking what a particular sample of nodes (e.g. all
offset node children) are made up of.
gsk/gl/gskglnodesample.c | 51 +++++++++++++++++++++++++++++++++++++++++
gsk/gl/gskglnodesampleprivate.h | 28 ++++++++++++++++++++++
gsk/gl/gskglrenderer.c | 1 +
gsk/meson.build | 1 +
4 files changed, 81 insertions(+)
---
diff --git a/gsk/gl/gskglnodesample.c b/gsk/gl/gskglnodesample.c
new file mode 100644
index 0000000000..1ee64c7790
--- /dev/null
+++ b/gsk/gl/gskglnodesample.c
@@ -0,0 +1,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 = node->node_class->type_name;
+
+ 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);
+ }
+ }
+}
diff --git a/gsk/gl/gskglnodesampleprivate.h b/gsk/gl/gskglnodesampleprivate.h
new file mode 100644
index 0000000000..a1d09a098f
--- /dev/null
+++ b/gsk/gl/gskglnodesampleprivate.h
@@ -0,0 +1,28 @@
+
+#ifndef __GSK_GL_NODE_SAMPLE_PRIVATE_H__
+#define __GSK_GL_NODE_SAMPLE_PRIVATE_H__
+
+#include <glib.h>
+#include "gskenums.h"
+#include "gskrendernode.h"
+
+/* TODO: We have no other way for this...? */
+#define N_NODE_TYPES (GSK_DEBUG_NODE + 1)
+
+typedef struct
+{
+ struct {
+ const char *class_name;
+ guint count;
+ } nodes[N_NODE_TYPES];
+ guint count;
+} NodeSample;
+
+void node_sample_init (NodeSample *self);
+void node_sample_reset (NodeSample *self);
+void node_sample_add (NodeSample *self,
+ GskRenderNode *node);
+void node_sample_print (const NodeSample *self,
+ const char *prefix);
+
+#endif
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 81453b421a..28d475491d 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -14,6 +14,7 @@
#include "gskglrenderopsprivate.h"
#include "gskcairoblurprivate.h"
#include "gskglshadowcacheprivate.h"
+#include "gskglnodesampleprivate.h"
#include "gskprivate.h"
diff --git a/gsk/meson.build b/gsk/meson.build
index 8ad27f7de6..9b3db2beac 100644
--- a/gsk/meson.build
+++ b/gsk/meson.build
@@ -43,6 +43,7 @@ gsk_private_sources = files([
'gl/gskgldriver.c',
'gl/gskglrenderops.c',
'gl/gskglshadowcache.c',
+ 'gl/gskglnodesample.c',
])
gsk_public_headers = files([
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]