/** * clutter_paint_node_remove_child: * @node: a #ClutterPaintNode * @child: the #ClutterPaintNode to remove * * Removes @child from the list of children of @node. * * This function will release the reference on @child acquired by * using clutter_paint_node_add_child(). * * */ void clutter_paint_node_remove_child (ClutterPaintNode *node, ClutterPaintNode *child) { ClutterPaintNode *prev, *next; g_return_if_fail (CLUTTER_IS_PAINT_NODE (node)); g_return_if_fail (CLUTTER_IS_PAINT_NODE (child)); g_return_if_fail (node != child); g_return_if_fail (child->parent == node); node->n_children -= 1; prev = child->prev_sibling; next = child->next_sibling; if (prev != NULL) prev->next_sibling = next; if (next != NULL) next->prev_sibling = prev; if (node->first_child == child) node->first_child = next; if (node->last_child == child) node->last_child = prev; child->prev_sibling = NULL; child->next_sibling = NULL; child->parent = NULL; clutter_paint_node_unref (child); }
static void clutter_canvas_paint_content (ClutterContent *content, ClutterActor *actor, ClutterPaintNode *root) { ClutterCanvas *self = CLUTTER_CANVAS (content); ClutterCanvasPrivate *priv = self->priv; ClutterPaintNode *node; if (priv->buffer == NULL) return; if (priv->dirty) g_clear_pointer (&priv->texture, cogl_object_unref); if (priv->texture == NULL) priv->texture = cogl_texture_new_from_bitmap (priv->buffer, COGL_TEXTURE_NO_SLICING, CLUTTER_CAIRO_FORMAT_ARGB32); if (priv->texture == NULL) return; node = clutter_actor_create_texture_paint_node (actor, priv->texture); clutter_paint_node_set_name (node, "Canvas Content"); clutter_paint_node_add_child (root, node); clutter_paint_node_unref (node); priv->dirty = FALSE; }
static void clutter_image_paint_content (ClutterContent *content, ClutterActor *actor, ClutterPaintNode *root) { ClutterImagePrivate *priv = CLUTTER_IMAGE (content)->priv; ClutterScalingFilter min_f, mag_f; ClutterContentRepeat repeat; ClutterPaintNode *node; ClutterActorBox box; ClutterColor color; guint8 paint_opacity; if (priv->texture == NULL) return; clutter_actor_get_content_box (actor, &box); paint_opacity = clutter_actor_get_paint_opacity (actor); clutter_actor_get_content_scaling_filters (actor, &min_f, &mag_f); repeat = clutter_actor_get_content_repeat (actor); /* ClutterTextureNode will premultiply the blend color, so we * want it to be white with the paint opacity */ color.red = 255; color.green = 255; color.blue = 255; color.alpha = paint_opacity; node = clutter_texture_node_new (priv->texture, &color, min_f, mag_f); clutter_paint_node_set_name (node, "Image"); if (repeat == CLUTTER_REPEAT_NONE) clutter_paint_node_add_rectangle (node, &box); else { float t_w = 1.f, t_h = 1.f; if ((repeat & CLUTTER_REPEAT_X_AXIS) != FALSE) t_w = (box.x2 - box.x1) / cogl_texture_get_width (priv->texture); if ((repeat & CLUTTER_REPEAT_Y_AXIS) != FALSE) t_h = (box.y2 - box.y1) / cogl_texture_get_height (priv->texture); clutter_paint_node_add_texture_rectangle (node, &box, 0.f, 0.f, t_w, t_h); } clutter_paint_node_add_child (root, node); clutter_paint_node_unref (node); }
/** * clutter_value_set_paint_node: * @value: a #GValue initialized with %CLUTTER_TYPE_PAINT_NODE * @node: (type Clutter.PaintNode) (allow-none): a #ClutterPaintNode, or %NULL * * Sets the contents of a #GValue initialized with %CLUTTER_TYPE_PAINT_NODE. * * This function increased the reference count of @node; if you do not wish * to increase the reference count, use clutter_value_take_paint_node() * instead. The reference count will be released by g_value_unset(). * * */ void clutter_value_set_paint_node (GValue *value, gpointer node) { ClutterPaintNode *old_node; g_return_if_fail (CLUTTER_VALUE_HOLDS_PAINT_NODE (value)); old_node = value->data[0].v_pointer; if (node != NULL) { g_return_if_fail (CLUTTER_IS_PAINT_NODE (node)); value->data[0].v_pointer = clutter_paint_node_ref (node); } else value->data[0].v_pointer = NULL; if (old_node != NULL) clutter_paint_node_unref (old_node); }
/** * clutter_paint_node_replace_child: * @node: a #ClutterPaintNode * @old_child: the child replaced by @new_child * @new_child: the child that replaces @old_child * * Atomically replaces @old_child with @new_child in the list of * children of @node. * * This function will release the reference on @old_child acquired * by @node, and will acquire a new reference on @new_child. * * */ void clutter_paint_node_replace_child (ClutterPaintNode *node, ClutterPaintNode *old_child, ClutterPaintNode *new_child) { ClutterPaintNode *prev, *next; g_return_if_fail (CLUTTER_IS_PAINT_NODE (node)); g_return_if_fail (CLUTTER_IS_PAINT_NODE (old_child)); g_return_if_fail (old_child->parent == node); g_return_if_fail (CLUTTER_IS_PAINT_NODE (new_child)); g_return_if_fail (new_child->parent == NULL); prev = old_child->prev_sibling; next = old_child->next_sibling; new_child->parent = node; new_child->prev_sibling = prev; new_child->next_sibling = next; clutter_paint_node_ref (new_child); if (prev != NULL) prev->next_sibling = new_child; if (next != NULL) next->prev_sibling = new_child; if (node->first_child == old_child) node->first_child = new_child; if (node->last_child == old_child) node->last_child = new_child; old_child->prev_sibling = NULL; old_child->next_sibling = NULL; old_child->parent = NULL; clutter_paint_node_unref (old_child); }
static void value_paint_node_free_value (GValue *value) { if (value->data[0].v_pointer != NULL) clutter_paint_node_unref (value->data[0].v_pointer); }