diff --git a/clutter/clutter/clutter-paint-node-private.h b/clutter/clutter/clutter-paint-node-private.h index faf5df23c..561fa630a 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 6301661da..f39336c01 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 */