[clutter] image: Use the actor's content repeat policy
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] image: Use the actor's content repeat policy
- Date: Fri, 8 Jun 2012 15:08:55 +0000 (UTC)
commit 92fc2c760cf788979a57bbca74321c490011f60f
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Jun 8 12:45:39 2012 +0100
image: Use the actor's content repeat policy
When painting we can now use the ClutterActor content-repeat property to
decide whether or not to repeat the texture data.
clutter/clutter-image.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/clutter/clutter-image.c b/clutter/clutter-image.c
index fb5738e..7ae9839 100644
--- a/clutter/clutter-image.c
+++ b/clutter/clutter-image.c
@@ -107,6 +107,7 @@ clutter_image_paint_content (ClutterContent *content,
{
ClutterImagePrivate *priv = CLUTTER_IMAGE (content)->priv;
ClutterScalingFilter min_f, mag_f;
+ ClutterContentRepeat repeat;
ClutterPaintNode *node;
ClutterActorBox box;
ClutterColor color;
@@ -118,6 +119,7 @@ clutter_image_paint_content (ClutterContent *content,
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);
color.red = paint_opacity;
color.green = paint_opacity;
@@ -126,7 +128,24 @@ clutter_image_paint_content (ClutterContent *content,
node = clutter_texture_node_new (priv->texture, &color, min_f, mag_f);
clutter_paint_node_set_name (node, "Image");
- clutter_paint_node_add_rectangle (node, &box);
+
+ 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]