summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2015-08-24 09:59:16 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2015-08-24 09:59:16 +0100
commitcf7e37b53bb5f5a91d3a849e88e1cfeeada9aa0c (patch)
treec3e096b227936f62a106847570066f1ce0909125
parent6cc12adf4d1b3ab5475caa98a7c99a5b577459e1 (diff)
downloadclutter-cf7e37b53bb5f5a91d3a849e88e1cfeeada9aa0c.tar.gz
actor: Add internal "create textute node" function
To avoid excessive copy and paste. We could even consider making it public before release.
-rw-r--r--clutter/clutter-actor-private.h3
-rw-r--r--clutter/clutter-actor.c63
2 files changed, 66 insertions, 0 deletions
diff --git a/clutter/clutter-actor-private.h b/clutter/clutter-actor-private.h
index 5bced200f..4dc767b54 100644
--- a/clutter/clutter-actor-private.h
+++ b/clutter/clutter-actor-private.h
@@ -319,6 +319,9 @@ void _clutter_actor_queue_only_relayout
CoglFramebuffer * _clutter_actor_get_active_framebuffer (ClutterActor *actor);
+ClutterPaintNode * clutter_actor_create_texture_paint_node (ClutterActor *self,
+ CoglTexture *texture);
+
G_END_DECLS
#endif /* __CLUTTER_ACTOR_PRIVATE_H__ */
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index b3e7ed64b..1cbbd5c5f 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -21037,3 +21037,66 @@ clutter_actor_bind_model_with_properties (ClutterActor *self,
clutter_actor_bind_model (self, model, bind_child_with_properties, clos, bind_closure_free);
}
+
+/*< private >
+ * clutter_actor_create_texture_paint_node:
+ * @self: a #ClutterActor
+ * @texture: a #CoglTexture
+ *
+ * Creates a #ClutterPaintNode initialized using the state of the
+ * given #ClutterActor, ready to be used inside the implementation
+ * of the #ClutterActorClass.paint_node virtual function.
+ *
+ * The returned paint node has the geometry set to the size of the
+ * #ClutterActor:content-box property; it uses the filters specified
+ * in the #ClutterActor:minification-filter and #ClutterActor:magnification-filter
+ * properties; and respects the #ClutterActor:content-repeat property.
+ *
+ * Returns: (transfer full): The newly created #ClutterPaintNode
+ *
+ * Since: 1.24
+ */
+ClutterPaintNode *
+clutter_actor_create_texture_paint_node (ClutterActor *self,
+ CoglTexture *texture)
+{
+ ClutterActorPrivate *priv = clutter_actor_get_instance_private (self);
+ ClutterPaintNode *node;
+ ClutterActorBox box;
+ ClutterColor color;
+
+ g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
+ g_return_val_if_fail (texture != NULL, NULL);
+
+ clutter_actor_get_content_box (self, &box);
+
+ /* 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 = clutter_actor_get_paint_opacity_internal (self);
+
+ node = clutter_texture_node_new (texture, &color, priv->min_filter, priv->mag_filter);
+ clutter_paint_node_set_name (node, "Texture");
+
+ if (priv->content_repeat == CLUTTER_REPEAT_NONE)
+ clutter_paint_node_add_rectangle (node, &box);
+ else
+ {
+ float t_w = 1.f, t_h = 1.f;
+
+ if ((priv->content_repeat & CLUTTER_REPEAT_X_AXIS) != FALSE)
+ t_w = (box.x2 - box.x1) / cogl_texture_get_width (texture);
+
+ if ((priv->content_repeat & CLUTTER_REPEAT_Y_AXIS) != FALSE)
+ t_h = (box.y2 - box.y1) / cogl_texture_get_height (texture);
+
+ clutter_paint_node_add_texture_rectangle (node, &box,
+ 0.f, 0.f,
+ t_w, t_h);
+ }
+
+ return node;
+}