[clutter/wip/apocalypses/apocalypse-1: 33/92] actor: Provide a better get_paint_volume() implementation
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/apocalypses/apocalypse-1: 33/92] actor: Provide a better get_paint_volume() implementation
- Date: Tue, 3 Jan 2012 22:22:58 +0000 (UTC)
commit 2e45691f5b8bf5d40e81dc54a21fd509e9ef22f3
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Mon Dec 5 12:45:08 2011 +0000
actor: Provide a better get_paint_volume() implementation
ClutterActor can do better by default than just giving up immediately.
An actor can check for the clip region, and for its children's paint
volume, for instance.
Just these two should give us a better default implementation for newly
written code.
clutter/clutter-actor.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 1 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 14edfa2..ae8f436 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -4126,7 +4126,65 @@ static gboolean
clutter_actor_real_get_paint_volume (ClutterActor *self,
ClutterPaintVolume *volume)
{
- return FALSE;
+ ClutterActorPrivate *priv = self->priv;
+ gboolean res;
+ GList *l;
+
+ /* this is the default return value: we cannot know if a class
+ * is going to paint outside its allocation, so we take the
+ * conservative approach.
+ */
+ res = FALSE;
+
+ /* if the actor has a clip set then we have a pretty definite
+ * size for the paint volume: the actor cannot possibly paint
+ * outside the clip region.
+ */
+ if (priv->clip_to_allocation)
+ {
+ clutter_paint_volume_set_from_allocation (volume, self);
+
+ res = TRUE;
+ }
+ else if (priv->has_clip)
+ {
+ ClutterVertex origin;
+
+ origin.x = priv->clip[0];
+ origin.y = priv->clip[1];
+ origin.z = 0;
+
+ clutter_paint_volume_set_origin (volume, &origin);
+ clutter_paint_volume_set_width (volume, priv->clip[2]);
+ clutter_paint_volume_set_height (volume, priv->clip[3]);
+
+ res = TRUE;
+ }
+
+ /* if we don't have children we just bail out here */
+ if (priv->children == NULL)
+ return res;
+
+ /* but if we have children then we ask for their paint volume in
+ * our coordinates. if any of our children replies that it doesn't
+ * have a paint volume, we bail out
+ */
+ for (l = priv->children; l != NULL; l = l->next)
+ {
+ ClutterActor *child = l->data;
+ const ClutterPaintVolume *child_volume;
+
+ child_volume = clutter_actor_get_transformed_paint_volume (child, self);
+ if (child_volume == NULL)
+ {
+ res = FALSE;
+ break;
+ }
+
+ clutter_paint_volume_union (volume, child_volume);
+ }
+
+ return res;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]