[clutter/wip/actor-content: 15/25] actor: Use ClutterContent to paint and pick
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/actor-content: 15/25] actor: Use ClutterContent to paint and pick
- Date: Thu, 14 Apr 2011 17:10:55 +0000 (UTC)
commit efabc4a082d3fb3d169994a98916653ccdc6e448
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Mon Dec 6 14:09:59 2010 +0000
actor: Use ClutterContent to paint and pick
Use the paint_content and the apply_mask methods for ::paint, and the
apply_mask for ::pick.
clutter/clutter-actor.c | 90 +++++++++++++++++++++++++++++++++++++++++++++-
clutter/clutter-actor.h | 4 ++
2 files changed, 92 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index b01e399..40f41bf 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -294,6 +294,7 @@
#include "clutter-behaviour.h"
#include "clutter-constraint.h"
#include "clutter-container.h"
+#include "clutter-content-private.h"
#include "clutter-debug.h"
#include "clutter-effect-private.h"
#include "clutter-enum-types.h"
@@ -480,6 +481,8 @@ struct _ClutterActorPrivate
ClutterPaintVolume last_paint_volume;
ClutterStageQueueRedrawEntry *queue_redraw_entry;
+
+ ClutterContent *content;
};
enum
@@ -566,10 +569,12 @@ enum
PROP_CONSTRAINTS,
PROP_EFFECT,
+ PROP_CONTENT,
+
PROP_LAST
};
-static GParamSpec *obj_props[PROP_LAST];
+static GParamSpec *obj_props[PROP_LAST] = { NULL, };
enum
{
@@ -1629,10 +1634,18 @@ static void
clutter_actor_real_pick (ClutterActor *self,
const ClutterColor *color)
{
+ ClutterActorPrivate *priv = self->priv;
+
/* the default implementation is just to paint a rectangle
* with the same size of the actor using the passed color
*/
- if (clutter_actor_should_pick_paint (self))
+
+ if (!clutter_actor_should_pick_paint (self))
+ return;
+
+ if (priv->content != NULL)
+ _clutter_content_pick_content (priv->content, self, color);
+ else
{
ClutterActorBox box = { 0, };
float width, height;
@@ -2797,6 +2810,13 @@ clutter_actor_paint (ClutterActor *self)
clutter_actor_shader_pre_paint (self, FALSE);
priv->propagated_one_redraw = FALSE;
+
+ if (priv->content != NULL)
+ {
+ clutter_content_paint_content (priv->content, self);
+ clutter_content_update_geometry (priv->content, self);
+ }
+
g_signal_emit (self, actor_signals[PAINT], 0);
if (effect_painted)
@@ -3479,6 +3499,13 @@ clutter_actor_dispose (GObject *object)
priv->effects = NULL;
}
+ if (priv->content != NULL)
+ {
+ _clutter_content_remove_actor (priv->content, self);
+ g_object_unref (priv->content);
+ priv->content = NULL;
+ }
+
g_signal_emit (self, actor_signals[DESTROY], 0);
G_OBJECT_CLASS (clutter_actor_parent_class)->dispose (object);
@@ -4425,6 +4452,15 @@ clutter_actor_class_init (ClutterActorClass *klass)
obj_props[PROP_EFFECT] = pspec;
g_object_class_install_property (object_class, PROP_EFFECT, pspec);
+ obj_props[PROP_CONTENT] =
+ g_param_spec_object ("content",
+ P_("Content"),
+ P_("The content object that should be painted"),
+ CLUTTER_TYPE_CONTENT,
+ CLUTTER_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_CONTENT,
+ obj_props[PROP_CONTENT]);
+
/**
* ClutterActor::destroy:
* @actor: the #ClutterActor which emitted the signal
@@ -11733,6 +11769,18 @@ _clutter_actor_get_paint_volume_real (ClutterActor *self,
return FALSE;
}
+ if (priv->content != NULL)
+ {
+ if (!clutter_content_get_paint_volume (priv->content, self, pv))
+ {
+ clutter_paint_volume_free (pv);
+ CLUTTER_NOTE (CLIPPING, "Bail from get_paint_volume (%s): "
+ "Content failed to report a volume",
+ G_OBJECT_TYPE_NAME (self));
+ return FALSE;
+ }
+ }
+
/* since effects can modify the paint volume, we allow them to actually
* do this by making get_paint_volume() "context sensitive"
*/
@@ -12105,3 +12153,41 @@ _clutter_actor_traverse (ClutterActor *actor,
0, /* start depth */
user_data);
}
+
+void
+clutter_actor_set_content (ClutterActor *self,
+ ClutterContent *content)
+{
+ ClutterActorPrivate *priv;
+
+ g_return_if_fail (CLUTTER_IS_ACTOR (self));
+ g_return_if_fail (content == NULL || CLUTTER_IS_CONTENT (content));
+
+ priv = self->priv;
+
+ if (priv->content == content)
+ return;
+
+ if (priv->content != NULL)
+ {
+ _clutter_content_remove_actor (priv->content, self);
+ g_object_unref (priv->content);
+ }
+
+ priv->content = content;
+ if (priv->content != NULL)
+ {
+ g_object_ref (priv->content);
+ _clutter_content_add_actor (priv->content, self);
+ }
+
+ g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_CONTENT]);
+}
+
+ClutterContent *
+clutter_actor_get_content (ClutterActor *self)
+{
+ g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
+
+ return self->priv->content;
+}
diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h
index 6b05d13..7ed6dff 100644
--- a/clutter/clutter-actor.h
+++ b/clutter/clutter-actor.h
@@ -580,6 +580,10 @@ const ClutterPaintVolume *clutter_actor_get_transformed_paint_volume (ClutterAc
gboolean clutter_actor_get_paint_box (ClutterActor *self,
ClutterActorBox *box);
+void clutter_actor_set_content (ClutterActor *self,
+ ClutterContent *content);
+ClutterContent * clutter_actor_get_content (ClutterActor *self);
+
G_END_DECLS
#endif /* __CLUTTER_ACTOR_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]