diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c index eaa5c6f9b..94aa24fd9 100644 --- a/clutter/clutter/clutter-paint-nodes.c +++ b/clutter/clutter/clutter-paint-nodes.c @@ -1081,6 +1081,99 @@ clutter_clip_node_new (void) return _clutter_paint_node_create (CLUTTER_TYPE_CLIP_NODE); } +/* + * ClutterActorNode + */ + +struct _ClutterActorNode +{ + ClutterPaintNode parent_instance; + + ClutterActor *actor; +}; + +struct _ClutterActorNodeClass +{ + ClutterPaintNodeClass parent_class; +}; + +G_DEFINE_TYPE (ClutterActorNode, clutter_actor_node, CLUTTER_TYPE_PAINT_NODE) + +static gboolean +clutter_actor_node_pre_draw (ClutterPaintNode *node) +{ + return TRUE; +} + +static void +clutter_actor_node_draw (ClutterPaintNode *node) +{ + ClutterActorNode *actor_node = CLUTTER_ACTOR_NODE (node); + + clutter_actor_continue_paint (actor_node->actor); +} + +static JsonNode * +clutter_actor_node_serialize (ClutterPaintNode *node) +{ + ClutterActorNode *actor_node = CLUTTER_ACTOR_NODE (node); + g_autoptr (JsonBuilder) builder = NULL; + const char *debug_name; + + debug_name = _clutter_actor_get_debug_name (actor_node->actor); + + builder = json_builder_new (); + + json_builder_begin_object (builder); + json_builder_set_member_name (builder, "actor"); + json_builder_add_string_value (builder, debug_name); + json_builder_end_object (builder); + + return json_builder_get_root (builder); +} +static void +clutter_actor_node_class_init (ClutterActorNodeClass *klass) +{ + ClutterPaintNodeClass *node_class; + + node_class = CLUTTER_PAINT_NODE_CLASS (klass); + node_class->pre_draw = clutter_actor_node_pre_draw; + node_class->draw = clutter_actor_node_draw; + node_class->serialize = clutter_actor_node_serialize; +} + +static void +clutter_actor_node_init (ClutterActorNode *self) +{ +} + +/* + * clutter_actor_node_new: + * @actor: the actor to paint + * + * Creates a new #ClutterActorNode. + * + * The actor is painted together with any effects + * applied to it. Children of this node will draw + * over the actor contents. + * + * Return value: (transfer full): the newly created #ClutterActorNode. + * Use clutter_paint_node_unref() when done. + */ +ClutterPaintNode * +clutter_actor_node_new (ClutterActor *actor) +{ + ClutterActorNode *res; + + g_assert (actor != NULL); + + res = _clutter_paint_node_create (CLUTTER_TYPE_ACTOR_NODE); + res->actor = actor; + + return (ClutterPaintNode *) res; +} + + /* * ClutterLayerNode */ diff --git a/clutter/clutter/clutter-paint-nodes.h b/clutter/clutter/clutter-paint-nodes.h index 03f45600f..235f4bc45 100644 --- a/clutter/clutter/clutter-paint-nodes.h +++ b/clutter/clutter/clutter-paint-nodes.h @@ -143,6 +143,25 @@ CLUTTER_EXPORT ClutterPaintNode * clutter_text_node_new (PangoLayout *layout, const ClutterColor *color); +#define CLUTTER_TYPE_ACTOR_NODE (clutter_actor_node_get_type ()) +#define CLUTTER_ACTOR_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ACTOR_NODE, ClutterActorNode)) +#define CLUTTER_IS_ACTOR_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ACTOR_NODE)) + +/** + * ClutterActorNode: + * + * The #ClutterActorNode structure is an opaque + * type whose members cannot be directly accessed. + */ +typedef struct _ClutterActorNode ClutterActorNode; +typedef struct _ClutterActorNode ClutterActorNodeClass; + +CLUTTER_EXPORT +GType clutter_actor_node_get_type (void) G_GNUC_CONST; + +CLUTTER_EXPORT +ClutterPaintNode * clutter_actor_node_new (ClutterActor *actor); + #define CLUTTER_TYPE_ROOT_NODE (clutter_root_node_get_type ()) #define CLUTTER_ROOT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ROOT_NODE, ClutterRootNode)) #define CLUTTER_IS_ROOT_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ROOT_NODE))