[mutter/gbsneto/effects-paint-nodes: 87/96] Introduce ClutterEffectNode
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/effects-paint-nodes: 87/96] Introduce ClutterEffectNode
- Date: Tue, 1 Sep 2020 19:30:06 +0000 (UTC)
commit 2983fd2461344bf9172091ff86a4c9984a6520fc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jul 3 17:55:25 2020 -0300
Introduce ClutterEffectNode
ClutterEffectNode is a private ClutterPaintNode implementation
that does effectively nothing, but helps organizing the paint
node tree. It also helps debugging, since it can output the
effect class and name to the JSON debugging routines.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340
clutter/clutter/clutter-paint-node-private.h | 20 +++++++
clutter/clutter/clutter-paint-nodes.c | 84 ++++++++++++++++++++++++++++
2 files changed, 104 insertions(+)
---
diff --git a/clutter/clutter/clutter-paint-node-private.h b/clutter/clutter/clutter-paint-node-private.h
index faf5df23cf..561fa630ad 100644
--- a/clutter/clutter/clutter-paint-node-private.h
+++ b/clutter/clutter/clutter-paint-node-private.h
@@ -141,6 +141,26 @@ ClutterPaintNode * clutter_paint_node_get_last_child (Clutter
G_GNUC_INTERNAL
ClutterPaintNode * clutter_paint_node_get_parent (ClutterPaintNode *node);
+
+#define CLUTTER_TYPE_EFFECT_NODE (clutter_effect_node_get_type ())
+#define CLUTTER_EFFECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
CLUTTER_TYPE_EFFECT_NODE, ClutterEffectNode))
+#define CLUTTER_IS_EFFECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
CLUTTER_TYPE_EFFECT_NODE))
+
+/**
+ * ClutterEffectNode:
+ *
+ * The #ClutterEffectNode structure is an opaque
+ * type whose members cannot be directly accessed.
+ */
+typedef struct _ClutterEffectNode ClutterEffectNode;
+typedef struct _ClutterEffectNode ClutterEffectNodeClass;
+
+CLUTTER_EXPORT
+GType clutter_effect_node_get_type (void) G_GNUC_CONST;
+
+CLUTTER_EXPORT
+ClutterPaintNode * clutter_effect_node_new (ClutterEffect *actor);
+
G_END_DECLS
#endif /* __CLUTTER_PAINT_NODE_PRIVATE_H__ */
diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c
index 6301661da1..f39336c015 100644
--- a/clutter/clutter/clutter-paint-nodes.c
+++ b/clutter/clutter/clutter-paint-nodes.c
@@ -1216,6 +1216,90 @@ clutter_actor_node_new (ClutterActor *actor)
}
+/*
+ * ClutterEffectNode
+ */
+
+struct _ClutterEffectNode
+{
+ ClutterPaintNode parent_instance;
+
+ ClutterEffect *effect;
+};
+
+struct _ClutterEffectNodeClass
+{
+ ClutterPaintNodeClass parent_class;
+};
+
+G_DEFINE_TYPE (ClutterEffectNode, clutter_effect_node, CLUTTER_TYPE_PAINT_NODE)
+
+static JsonNode *
+clutter_effect_node_serialize (ClutterPaintNode *node)
+{
+ ClutterEffectNode *effect_node = CLUTTER_EFFECT_NODE (node);
+ ClutterActorMeta *effect_meta = CLUTTER_ACTOR_META (effect_node->effect);
+ g_autoptr (JsonBuilder) builder = NULL;
+ g_autoptr (GString) string = NULL;
+ const char *meta_name;
+
+ meta_name = clutter_actor_meta_get_name (effect_meta);
+
+ string = g_string_new (NULL);
+ g_string_append (string, G_OBJECT_TYPE_NAME (effect_node->effect));
+ g_string_append (string, " (");
+ if (meta_name)
+ g_string_append_printf (string, "\"%s\"", meta_name);
+ else
+ g_string_append (string, "unnamed");
+ g_string_append (string, ")");
+
+ builder = json_builder_new ();
+
+ json_builder_begin_object (builder);
+ json_builder_set_member_name (builder, "effect");
+ json_builder_add_string_value (builder, string->str);
+ json_builder_end_object (builder);
+
+ return json_builder_get_root (builder);
+}
+
+static void
+clutter_effect_node_class_init (ClutterEffectNodeClass *klass)
+{
+ ClutterPaintNodeClass *node_class;
+
+ node_class = CLUTTER_PAINT_NODE_CLASS (klass);
+ node_class->serialize = clutter_effect_node_serialize;
+}
+
+static void
+clutter_effect_node_init (ClutterEffectNode *self)
+{
+}
+
+/*
+ * clutter_effect_node_new:
+ * @actor: the actor to paint
+ *
+ * Creates a new #ClutterEffectNode.
+ *
+ * Return value: (transfer full): the newly created #ClutterEffectNode.
+ * Use clutter_paint_node_unref() when done.
+ */
+ClutterPaintNode *
+clutter_effect_node_new (ClutterEffect *effect)
+{
+ ClutterEffectNode *res;
+
+ g_assert (effect != NULL);
+
+ res = _clutter_paint_node_create (CLUTTER_TYPE_EFFECT_NODE);
+ res->effect = effect;
+
+ return (ClutterPaintNode *) res;
+}
+
/*
* ClutterLayerNode
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]