From 86e95a779a87b0d02337c55548152883b6f944aa Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 27 Jan 2009 15:18:45 +0000 Subject: [PATCH] Remove CloneTexture from the API ClutterClone supercedes ClutterCloneTexture, since it can clone every kind of actor -- including composite ones. This is another "brain surgery with a shotgun" kind of commit: it removes CloneTexture and updates every test case using CloneTexture to ClutterClone. The API fallout is minimal, luckily for us. --- clutter/Makefile.am | 2 - clutter/clutter-clone-texture.c | 455 --------------------- clutter/clutter-clone-texture.h | 76 ---- clutter/clutter-clone.c | 14 +- clutter/clutter.h | 1 - doc/reference/clutter/clutter-docs.xml | 9 +- doc/reference/clutter/clutter-sections.txt | 30 +- tests/interactive/test-actors.c | 151 +++---- tests/interactive/test-depth.c | 19 +- tests/interactive/test-fbo.c | 2 +- tests/interactive/test-layout.c | 3 +- tests/interactive/test-paint-wrapper.c | 4 +- 12 files changed, 122 insertions(+), 644 deletions(-) delete mode 100644 clutter/clutter-clone-texture.c delete mode 100644 clutter/clutter-clone-texture.h diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 31155624a..cfe15c121 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -60,7 +60,6 @@ source_h = \ $(srcdir)/clutter-binding-pool.h \ $(srcdir)/clutter-cairo-texture.h \ $(srcdir)/clutter-child-meta.h \ - $(srcdir)/clutter-clone-texture.h \ $(srcdir)/clutter-clone.h \ $(srcdir)/clutter-color.h \ $(srcdir)/clutter-container.h \ @@ -152,7 +151,6 @@ source_c = \ clutter-binding-pool.c \ clutter-cairo-texture.c \ clutter-child-meta.c \ - clutter-clone-texture.c \ clutter-clone.c \ clutter-color.c \ clutter-container.c \ diff --git a/clutter/clutter-clone-texture.c b/clutter/clutter-clone-texture.c deleted file mode 100644 index a2350cbab..000000000 --- a/clutter/clutter-clone-texture.c +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Clutter. - * - * An OpenGL based 'interactive canvas' library. - * - * Authored By Matthew Allum - * - * Copyright (C) 2006 OpenedHand - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/** - * SECTION:clutter-clone-texture - * @short_description: Actor for cloning existing textures in an - * efficient way. - * - * #ClutterCloneTexture allows the cloning of existing #ClutterTexture based - * actors whilst saving underlying graphics resources. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "clutter-clone-texture.h" -#include "clutter-main.h" -#include "clutter-feature.h" -#include "clutter-actor.h" -#include "clutter-util.h" -#include "clutter-enum-types.h" -#include "clutter-private.h" -#include "clutter-debug.h" - -#include "cogl/cogl.h" - -enum -{ - PROP_0, - PROP_PARENT_TEXTURE, - PROP_REPEAT_Y, - PROP_REPEAT_X -}; - -G_DEFINE_TYPE (ClutterCloneTexture, - clutter_clone_texture, - CLUTTER_TYPE_ACTOR); - -#define CLUTTER_CLONE_TEXTURE_GET_PRIVATE(obj) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTexturePrivate)) - -struct _ClutterCloneTexturePrivate -{ - ClutterTexture *parent_texture; - guint repeat_x : 1; - guint repeat_y : 1; -}; - -static void -clutter_clone_texture_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) -{ - ClutterCloneTexturePrivate *priv = CLUTTER_CLONE_TEXTURE (self)->priv; - ClutterActor *parent_texture; - ClutterActorClass *parent_texture_class; - - /* Note that by calling the get_width_request virtual method directly - * and skipping the clutter_actor_get_preferred_width() wrapper, we - * are ignoring any size request override set on the parent texture - * and just getting the normal size of the parent texture. - */ - parent_texture = CLUTTER_ACTOR (priv->parent_texture); - if (!parent_texture) - { - if (min_width_p) - *min_width_p = 0; - - if (natural_width_p) - *natural_width_p = 0; - - return; - } - - parent_texture_class = CLUTTER_ACTOR_GET_CLASS (parent_texture); - parent_texture_class->get_preferred_width (parent_texture, - for_height, - min_width_p, - natural_width_p); -} - -static void -clutter_clone_texture_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) -{ - ClutterCloneTexturePrivate *priv = CLUTTER_CLONE_TEXTURE (self)->priv; - ClutterActor *parent_texture; - ClutterActorClass *parent_texture_class; - - /* Note that by calling the get_height_request virtual method directly - * and skipping the clutter_actor_get_preferred_height() wrapper, we - * are ignoring any size request override set on the parent texture and - * just getting the normal size of the parent texture. - */ - parent_texture = CLUTTER_ACTOR (priv->parent_texture); - if (!parent_texture) - { - if (min_height_p) - *min_height_p = 0; - - if (natural_height_p) - *natural_height_p = 0; - - return; - } - - parent_texture_class = CLUTTER_ACTOR_GET_CLASS (parent_texture); - parent_texture_class->get_preferred_height (parent_texture, - for_width, - min_height_p, - natural_height_p); -} - -static void -clutter_clone_texture_paint (ClutterActor *self) -{ - ClutterCloneTexturePrivate *priv; - ClutterActor *parent_texture; - gint x_1, y_1, x_2, y_2; - CoglHandle cogl_texture; - ClutterFixed t_w, t_h; - guint tex_width, tex_height; - - priv = CLUTTER_CLONE_TEXTURE (self)->priv; - - /* no need to paint stuff if we don't have a texture to clone */ - if (!priv->parent_texture) - return; - - CLUTTER_NOTE (PAINT, - "painting clone texture '%s'", - clutter_actor_get_name (self) ? clutter_actor_get_name (self) - : "unknown"); - - /* parent texture may have been hidden, there for need to make sure its - * realised with resources available. - */ - parent_texture = CLUTTER_ACTOR (priv->parent_texture); - if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture)) - clutter_actor_realize (parent_texture); - - /* If 'parent' texture isn't visible we run its paint to be sure it - * updates. Needed for TFP and likely FBOs. - * Potentially could cause issues - */ - if (!clutter_actor_get_paint_visibility(parent_texture)) - { - CLUTTER_SET_PRIVATE_FLAGS(parent_texture, - CLUTTER_TEXTURE_IN_CLONE_PAINT); - g_signal_emit_by_name (priv->parent_texture, "paint", NULL); - CLUTTER_UNSET_PRIVATE_FLAGS(parent_texture, - CLUTTER_TEXTURE_IN_CLONE_PAINT); - } - - cogl_set_source_color4ub (255, 255, 255, - clutter_actor_get_paint_opacity (self)); - - clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2); - - CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i " - "opacity: %i", - x_1, y_1, x_2, y_2, - clutter_actor_get_opacity (self)); - - cogl_texture = clutter_texture_get_cogl_texture (priv->parent_texture); - - if (cogl_texture == COGL_INVALID_HANDLE) - return; - - tex_width = cogl_texture_get_width (cogl_texture); - tex_height = cogl_texture_get_height (cogl_texture); - - if (priv->repeat_x && tex_width > 0) - t_w = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (x_2 - x_1), - COGL_FIXED_FROM_INT (tex_width)); - else - t_w = COGL_FIXED_1; - if (priv->repeat_y && tex_height > 0) - t_h = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (y_2 - y_1), - COGL_FIXED_FROM_INT (tex_height)); - else - t_h = COGL_FIXED_1; - - /* Parent paint translated us into position */ - cogl_texture_rectangle (cogl_texture, 0, 0, - COGL_FIXED_FROM_INT (x_2 - x_1), - COGL_FIXED_FROM_INT (y_2 - y_1), - 0, 0, t_w, t_h); -} - -static void -set_parent_texture (ClutterCloneTexture *ctexture, - ClutterTexture *texture) -{ - ClutterCloneTexturePrivate *priv = ctexture->priv; - ClutterActor *actor = CLUTTER_ACTOR (ctexture); - gboolean was_visible = CLUTTER_ACTOR_IS_VISIBLE (ctexture); - - if (priv->parent_texture == texture) - return; - - if (priv->parent_texture) - { - g_object_unref (priv->parent_texture); - priv->parent_texture = NULL; - - if (was_visible) - clutter_actor_hide (actor); - } - - if (texture) - { - priv->parent_texture = g_object_ref (texture); - - /* queue a redraw if the cloned texture is already visible */ - if (CLUTTER_ACTOR_IS_VISIBLE (priv->parent_texture) && - was_visible) - { - clutter_actor_show (actor); - clutter_actor_queue_redraw (actor); - } - - clutter_actor_queue_relayout (actor); - } - -} - -static void -clutter_clone_texture_dispose (GObject *object) -{ - ClutterCloneTexture *self = CLUTTER_CLONE_TEXTURE(object); - ClutterCloneTexturePrivate *priv = self->priv; - - if (priv->parent_texture) - g_object_unref (priv->parent_texture); - - priv->parent_texture = NULL; - - G_OBJECT_CLASS (clutter_clone_texture_parent_class)->dispose (object); -} - -static void -clutter_clone_texture_finalize (GObject *object) -{ - G_OBJECT_CLASS (clutter_clone_texture_parent_class)->finalize (object); -} - -static void -clutter_clone_texture_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object); - ClutterCloneTexturePrivate *priv; - - priv = ctexture->priv; - - switch (prop_id) - { - case PROP_PARENT_TEXTURE: - set_parent_texture (ctexture, g_value_get_object (value)); - break; - case PROP_REPEAT_X: - if (priv->repeat_x != g_value_get_boolean (value)) - { - priv->repeat_x = !priv->repeat_x; - clutter_actor_queue_redraw (CLUTTER_ACTOR (ctexture)); - } - break; - case PROP_REPEAT_Y: - if (priv->repeat_y != g_value_get_boolean (value)) - { - priv->repeat_y = !priv->repeat_y; - clutter_actor_queue_redraw (CLUTTER_ACTOR (ctexture)); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -clutter_clone_texture_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object); - ClutterCloneTexturePrivate *priv; - - priv = ctexture->priv; - - switch (prop_id) - { - case PROP_PARENT_TEXTURE: - g_value_set_object (value, ctexture->priv->parent_texture); - break; - case PROP_REPEAT_X: - g_value_set_boolean (value, priv->repeat_x); - break; - case PROP_REPEAT_Y: - g_value_set_boolean (value, priv->repeat_y); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -clutter_clone_texture_class_init (ClutterCloneTextureClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); - - actor_class->paint = - clutter_clone_texture_paint; - actor_class->get_preferred_width = - clutter_clone_texture_get_preferred_width; - actor_class->get_preferred_height = - clutter_clone_texture_get_preferred_height; - - gobject_class->finalize = clutter_clone_texture_finalize; - gobject_class->dispose = clutter_clone_texture_dispose; - gobject_class->set_property = clutter_clone_texture_set_property; - gobject_class->get_property = clutter_clone_texture_get_property; - - g_object_class_install_property - (gobject_class, PROP_PARENT_TEXTURE, - g_param_spec_object ("parent-texture", - "Parent Texture", - "The parent texture to clone", - CLUTTER_TYPE_TEXTURE, - CLUTTER_PARAM_READWRITE)); - - g_object_class_install_property - (gobject_class, PROP_REPEAT_X, - g_param_spec_boolean ("repeat-x", - "Tile underlying pixbuf in x direction", - "Reapeat underlying pixbuf rather than scale " - "in x direction.", - FALSE, - CLUTTER_PARAM_READWRITE)); - - g_object_class_install_property - (gobject_class, PROP_REPEAT_Y, - g_param_spec_boolean ("repeat-y", - "Tile underlying pixbuf in y direction", - "Reapeat underlying pixbuf rather than scale " - "in y direction.", - FALSE, - CLUTTER_PARAM_READWRITE)); - - g_type_class_add_private (gobject_class, sizeof (ClutterCloneTexturePrivate)); -} - -static void -clutter_clone_texture_init (ClutterCloneTexture *self) -{ - ClutterCloneTexturePrivate *priv; - - self->priv = priv = CLUTTER_CLONE_TEXTURE_GET_PRIVATE (self); - priv->parent_texture = NULL; -} - -/** - * clutter_clone_texture_new: - * @texture: a #ClutterTexture, or %NULL - * - * Creates an efficient 'clone' of a pre-existing texture with which it - * shares the underlying pixbuf data. - * - * You can use clutter_clone_texture_set_parent_texture() to change the - * cloned texture. - * - * Return value: the newly created #ClutterCloneTexture - */ -ClutterActor * -clutter_clone_texture_new (ClutterTexture *texture) -{ - g_return_val_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture), NULL); - - return g_object_new (CLUTTER_TYPE_CLONE_TEXTURE, - "parent-texture", texture, - NULL); -} - -/** - * clutter_clone_texture_get_parent_texture: - * @clone: a #ClutterCloneTexture - * - * Retrieves the parent #ClutterTexture used by @clone. - * - * Return value: a #ClutterTexture actor, or %NULL - * - * Since: 0.2 - */ -ClutterTexture * -clutter_clone_texture_get_parent_texture (ClutterCloneTexture *clone) -{ - g_return_val_if_fail (CLUTTER_IS_CLONE_TEXTURE (clone), NULL); - - return clone->priv->parent_texture; -} - -/** - * clutter_clone_texture_set_parent_texture: - * @clone: a #ClutterCloneTexture - * @texture: a #ClutterTexture or %NULL - * - * Sets the parent texture cloned by the #ClutterCloneTexture. - * - * Since: 0.2 - */ -void -clutter_clone_texture_set_parent_texture (ClutterCloneTexture *clone, - ClutterTexture *texture) -{ - g_return_if_fail (CLUTTER_IS_CLONE_TEXTURE (clone)); - g_return_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture)); - - g_object_ref (clone); - - set_parent_texture (clone, texture); - - g_object_notify (G_OBJECT (clone), "parent-texture"); - g_object_unref (clone); -} diff --git a/clutter/clutter-clone-texture.h b/clutter/clutter-clone-texture.h deleted file mode 100644 index 74f297487..000000000 --- a/clutter/clutter-clone-texture.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Clutter. - * - * An OpenGL based 'interactive canvas' library. - * - * Authored By Matthew Allum - * - * Copyright (C) 2006 OpenedHand - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __CLUTTER_CLONE_TEXTURE_H__ -#define __CLUTTER_CLONE_TEXTURE_H__ - -#include -#include - -G_BEGIN_DECLS - -#define CLUTTER_TYPE_CLONE_TEXTURE (clutter_clone_texture_get_type ()) -#define CLUTTER_CLONE_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTexture)) -#define CLUTTER_CLONE_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTextureClass)) -#define CLUTTER_IS_CLONE_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CLONE_TEXTURE)) -#define CLUTTER_IS_CLONE_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CLONE_TEXTURE)) -#define CLUTTER_CLONE_TEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTextureClass)) - -typedef struct _ClutterCloneTexture ClutterCloneTexture; -typedef struct _ClutterCloneTexturePrivate ClutterCloneTexturePrivate; -typedef struct _ClutterCloneTextureClass ClutterCloneTextureClass; - -struct _ClutterCloneTexture -{ - /*< private >*/ - ClutterActor parent; - - ClutterCloneTexturePrivate *priv; -}; - -struct _ClutterCloneTextureClass -{ - /*< private >*/ - ClutterActorClass parent_class; - - /* padding for future expansion */ - void (*_clutter_clone_1) (void); - void (*_clutter_clone_2) (void); - void (*_clutter_clone_3) (void); - void (*_clutter_clone_4) (void); -}; - -GType clutter_clone_texture_get_type (void) G_GNUC_CONST; - -ClutterActor * clutter_clone_texture_new (ClutterTexture *texture); -ClutterTexture *clutter_clone_texture_get_parent_texture (ClutterCloneTexture *clone); -void clutter_clone_texture_set_parent_texture (ClutterCloneTexture *clone, - ClutterTexture *texture); - -G_END_DECLS - -#endif /* __CLUTTER_CLONE_TEXTURE_H__ */ diff --git a/clutter/clutter-clone.c b/clutter/clutter-clone.c index e0dc29c7b..daeec1581 100644 --- a/clutter/clutter-clone.c +++ b/clutter/clutter-clone.c @@ -22,13 +22,21 @@ */ /** - * SECTION:clutter-actor-clone - * @short_description: An actor that displays a scaled clone of another - * actor. + * SECTION:clutterclone + * @short_description: An actor that displays a clone of a source actor * * #ClutterClone is a #ClutterActor which draws with the paint * function of another actor, scaled to fit its own allocation. + * + * #ClutterClone can be used to efficiently clone any other actor. + * + * This is different from clutter_texture_new_from_actor() + * which requires support for FBOs in the underlying GL + * implementation. + * + * #ClutterClone is available since Clutter 1.0 */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/clutter/clutter.h b/clutter/clutter.h index 83f0a3824..125efa8fe 100644 --- a/clutter/clutter.h +++ b/clutter/clutter.h @@ -43,7 +43,6 @@ #include "clutter-binding-pool.h" #include "clutter-cairo-texture.h" #include "clutter-child-meta.h" -#include "clutter-clone-texture.h" #include "clutter-clone.h" #include "clutter-color.h" #include "clutter-container.h" diff --git a/doc/reference/clutter/clutter-docs.xml b/doc/reference/clutter/clutter-docs.xml index a9ecc8a0f..a7bd35d8a 100644 --- a/doc/reference/clutter/clutter-docs.xml +++ b/doc/reference/clutter/clutter-docs.xml @@ -10,10 +10,15 @@ Version &version; - 2008 + 2006,2007,2008 OpenedHand LTD + + 2009 + Intel Corporation + + Permission is granted to copy, distribute and/or modify this @@ -56,7 +61,7 @@ Base actors - + diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index dfc898d0e..b19d63700 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -154,23 +154,23 @@ clutter_alpha_get_type
-clutter-clone-texture -ClutterCloneTexture -ClutterCloneTexture -ClutterCloneTextureClass -clutter_clone_texture_new -clutter_clone_texture_get_parent_texture -clutter_clone_texture_set_parent_texture +clutter-clone +ClutterClone +ClutterClone +ClutterCloneClass +clutter_clone_new +clutter_clone_set_source +clutter_clone_get_source -CLUTTER_CLONE_TEXTURE -CLUTTER_IS_CLONE_TEXTURE -CLUTTER_TYPE_CLONE_TEXTURE -CLUTTER_CLONE_TEXTURE_CLASS -CLUTTER_IS_CLONE_TEXTURE_CLASS -CLUTTER_CLONE_TEXTURE_GET_CLASS +CLUTTER_CLONE +CLUTTER_IS_CLONE +CLUTTER_TYPE_CLONE +CLUTTER_CLONE_CLASS +CLUTTER_IS_CLONE_CLASS +CLUTTER_CLONE_GET_CLASS -ClutterCloneTexturePrivate -clutter_clone_texture_get_type +ClutterClonePrivate +clutter_clone_get_type
diff --git a/tests/interactive/test-actors.c b/tests/interactive/test-actors.c index ded1e1a24..f1edacd2c 100644 --- a/tests/interactive/test-actors.c +++ b/tests/interactive/test-actors.c @@ -1,24 +1,27 @@ #include -#if defined (_MSC_VER) && !defined (_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif - #include #include #include #include #include -#define TRAILS 0 #define NHANDS 6 -#define RADIUS ((CLUTTER_STAGE_WIDTH()+CLUTTER_STAGE_HEIGHT())/NHANDS) typedef struct SuperOH { - ClutterActor **hand, *bgtex; - ClutterActor *group; + ClutterActor **hand, *bgtex; + ClutterActor *real_hand; + ClutterActor *group; + ClutterActor *stage; + gint stage_width; + gint stage_height; + gfloat radius; + + ClutterBehaviour *scaler_1; + ClutterBehaviour *scaler_2; + ClutterTimeline *timeline; } SuperOH; static gint n_hands = NHANDS; @@ -50,12 +53,14 @@ input_cb (ClutterActor *stage, clutter_event_get_coords (event, &x, &y); button_event = (ClutterButtonEvent *) event; - g_print ("*** button press event (button:%d) ***\n", - button_event->button); + g_print ("*** button press event (button:%d) at %d, %d ***\n", + button_event->button, + x, y); e = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage), x, y); - if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE_TEXTURE (e))) + /* only allow hiding the clones */ + if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE (e))) { clutter_actor_hide (e); return TRUE; @@ -95,45 +100,39 @@ frame_cb (ClutterTimeline *timeline, gpointer data) { SuperOH *oh = data; - gint i; + gint i; /* Rotate everything clockwise about stage center*/ - clutter_actor_set_rotation (CLUTTER_ACTOR (oh->group), + clutter_actor_set_rotation (oh->group, CLUTTER_Z_AXIS, frame_num, - CLUTTER_STAGE_WIDTH () / 2, - CLUTTER_STAGE_HEIGHT () / 2, + oh->stage_width / 2, + oh->stage_height / 2, 0); for (i = 0; i < n_hands; i++) { - gdouble scale_x, scale_y; - - clutter_actor_get_scale (oh->hand[i], &scale_x, &scale_y); - /* Rotate each hand around there centers - to get this we need * to take into account any scaling. - * - * FIXME: scaling causes drift so disabled for now. Need rotation - * unit based functions to fix. */ - clutter_actor_set_rotation (oh->hand[i], CLUTTER_Z_AXIS, - - 6.0 * frame_num, 0, 0, 0); + clutter_actor_set_rotation (oh->hand[i], + CLUTTER_Z_AXIS, + -6.0 * frame_num, + 0, 0, 0); } } G_MODULE_EXPORT int test_actors_main (int argc, char *argv[]) { - ClutterTimeline *timeline; - ClutterAlpha *alpha; - ClutterBehaviour *scaler_1, *scaler_2; - ClutterActor *stage; - ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; - SuperOH *oh; - gint i; - GError *error; + ClutterAlpha *alpha; + ClutterActor *stage; + ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; + SuperOH *oh; + gint i; + GError *error; + ClutterActor *real_hand; error = NULL; @@ -148,70 +147,72 @@ test_actors_main (int argc, char *argv[]) error->message); g_error_free (error); - exit (1); + return EXIT_FAILURE; } stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 800, 600); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Actors Test"); - clutter_stage_set_color (CLUTTER_STAGE (stage), - &stage_color); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Clone Test"); + clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); - oh = g_new(SuperOH, 1); + oh = g_new (SuperOH, 1); + oh->stage = stage; /* Create a timeline to manage animation */ - timeline = clutter_timeline_new (360, 60); /* num frames, fps */ - g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ + oh->timeline = clutter_timeline_new (360, 60); + clutter_timeline_set_loop (oh->timeline, TRUE); /* fire a callback for frame change */ - g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh); + g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh); /* Set up some behaviours to handle scaling */ - alpha = clutter_alpha_new_with_func (timeline, clutter_sine_func, + alpha = clutter_alpha_new_with_func (oh->timeline, clutter_sine_func, NULL, NULL); - scaler_1 = clutter_behaviour_scale_new (alpha, - 0.5, 0.5, - 1.0, 1.0); + oh->scaler_1 = clutter_behaviour_scale_new (alpha, 0.5, 0.5, 1.0, 1.0); + oh->scaler_2 = clutter_behaviour_scale_new (alpha, 1.0, 1.0, 0.5, 0.5); - scaler_2 = clutter_behaviour_scale_new (alpha, - 1.0, 1.0, - 0.5, 0.5); + real_hand = clutter_texture_new_from_file ("redhand.png", &error); + if (real_hand == NULL) + { + g_error ("image load failed: %s", error->message); + return EXIT_FAILURE; + } /* create a new group to hold multiple actors in a group */ oh->group = clutter_group_new(); oh->hand = g_new (ClutterActor*, n_hands); + + oh->stage_width = clutter_actor_get_width (stage); + oh->stage_height = clutter_actor_get_height (stage); + oh->radius = (oh->stage_width + oh->stage_height) + / n_hands; + for (i = 0; i < n_hands; i++) { gint x, y, w, h; - /* Create a texture from file, then clone in to same resources */ if (i == 0) - { - if ((oh->hand[i] = clutter_texture_new_from_file ("redhand.png", - &error)) == NULL) - { - g_error ("image load failed: %s", error->message); - exit (1); - } - } + oh->hand[i] = real_hand; else - oh->hand[i] = clutter_clone_texture_new (CLUTTER_TEXTURE(oh->hand[0])); + oh->hand[i] = clutter_clone_new (real_hand); + + clutter_actor_set_size (oh->hand[i], 200, 213); /* Place around a circle */ - w = clutter_actor_get_width (oh->hand[0]); - h = clutter_actor_get_height (oh->hand[0]); + w = clutter_actor_get_width (oh->hand[i]); + h = clutter_actor_get_height (oh->hand[i]); - x = CLUTTER_STAGE_WIDTH () / 2 - + RADIUS - * cos (i * M_PI / (n_hands / 2)) + x = oh->stage_width / 2 + + oh->radius + * cos (i * G_PI / (n_hands / 2)) - w / 2; - y = CLUTTER_STAGE_HEIGHT () / 2 - + RADIUS - * sin (i * M_PI / (n_hands / 2)) + y = oh->stage_height / 2 + + oh->radius + * sin (i * G_PI / (n_hands / 2)) - h / 2; clutter_actor_set_position (oh->hand[i], x, y); @@ -222,22 +223,18 @@ test_actors_main (int argc, char *argv[]) /* Add to our group group */ clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]); -#if 1 /* FIXME: disabled as causes drift? - see comment above */ if (i % 2) - clutter_behaviour_apply (scaler_1, oh->hand[i]); + clutter_behaviour_apply (oh->scaler_1, oh->hand[i]); else - clutter_behaviour_apply (scaler_2, oh->hand[i]); -#endif + clutter_behaviour_apply (oh->scaler_2, oh->hand[i]); } /* Add the group to the stage */ - clutter_container_add_actor (CLUTTER_CONTAINER (stage), - CLUTTER_ACTOR (oh->group)); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), oh->group); - /* Show everying ( and map window ) */ + /* Show everying */ clutter_actor_show (stage); - g_signal_connect (stage, "button-press-event", G_CALLBACK (input_cb), oh); @@ -246,12 +243,16 @@ test_actors_main (int argc, char *argv[]) oh); /* and start it */ - clutter_timeline_start (timeline); + clutter_timeline_start (oh->timeline); clutter_main (); + /* clean up */ + g_object_unref (oh->scaler_1); + g_object_unref (oh->scaler_2); + g_object_unref (oh->timeline); g_free (oh->hand); g_free (oh); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/interactive/test-depth.c b/tests/interactive/test-depth.c index a34ff43b5..ac549c241 100644 --- a/tests/interactive/test-depth.c +++ b/tests/interactive/test-depth.c @@ -24,43 +24,43 @@ raise_top (gpointer ignored) } static ClutterActor * -clone_box (ClutterTexture *original) +clone_box (ClutterActor *original) { guint width, height; ClutterActor *group; ClutterActor *clone; - clutter_actor_get_size (CLUTTER_ACTOR (original), &width, &height); + clutter_actor_get_size (original, &width, &height); group = clutter_group_new (); - clone = clutter_clone_texture_new (original); + clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_depth (clone, width/2); - clone = clutter_clone_texture_new (original); + clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 180, width/2, 0, 0); clutter_actor_set_depth (clone, -(gint)width/2); - clone = clutter_clone_texture_new (original); + clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 90, 0, 0, 0); clutter_actor_set_depth (clone, width/2); clutter_actor_set_position (clone, 0, 0); - clone = clutter_clone_texture_new (original); + clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 90, 0, 0, 0); clutter_actor_set_depth (clone, width/2); clutter_actor_set_position (clone, width, 0); - clone = clutter_clone_texture_new (original); + clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_X_AXIS, 90, 0, 0, 0); clutter_actor_set_depth (clone, -(gint)width/2); clutter_actor_set_position (clone, 0, height); - clone = clutter_clone_texture_new (original); + clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_X_AXIS, 90, 0, 0, 0); clutter_actor_set_depth (clone, -(gint)width/2); @@ -178,9 +178,8 @@ test_depth_main (int argc, char *argv[]) 0, 360); clutter_behaviour_apply (r_behave, janus); - /* add hand box */ - box = clone_box (CLUTTER_TEXTURE (hand)); + box = clone_box (hand); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_set_position (box, 200, 250); clutter_actor_set_scale (box, 0.5, 0.5); diff --git a/tests/interactive/test-fbo.c b/tests/interactive/test-fbo.c index f30cbf049..b3d83b6be 100644 --- a/tests/interactive/test-fbo.c +++ b/tests/interactive/test-fbo.c @@ -149,7 +149,7 @@ test_fbo_main (gint argc, gchar *argv[]) 1.0f / clutter_util_next_p2 (fbo_height)); /* Third from cloning the fbo texture */ - clone = clutter_clone_texture_new (CLUTTER_TEXTURE(fbo)); + clone = clutter_clone_new (fbo); clutter_container_add_actor (CLUTTER_CONTAINER (stage), clone); clutter_actor_set_position (clone, padx*2, 0); diff --git a/tests/interactive/test-layout.c b/tests/interactive/test-layout.c index f446779cc..331eb6976 100644 --- a/tests/interactive/test-layout.c +++ b/tests/interactive/test-layout.c @@ -625,8 +625,7 @@ decrease_property_value (ClutterActor *actor, static ClutterActor * create_item (void) { - ClutterActor *clone = - clutter_clone_texture_new (CLUTTER_TEXTURE (icon)); + ClutterActor *clone = clutter_clone_new (icon); gint32 size = g_random_int_range (MIN_SIZE, MAX_SIZE); diff --git a/tests/interactive/test-paint-wrapper.c b/tests/interactive/test-paint-wrapper.c index 5bc60f018..429813507 100644 --- a/tests/interactive/test-paint-wrapper.c +++ b/tests/interactive/test-paint-wrapper.c @@ -61,7 +61,7 @@ input_cb (ClutterStage *stage, e = clutter_stage_get_actor_at_pos (stage, x, y); - if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE_TEXTURE (e))) + if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE (e))) { clutter_actor_hide (e); return TRUE; @@ -235,7 +235,7 @@ test_paint_wrapper_main (int argc, char *argv[]) } } else - oh->hand[i] = clutter_clone_texture_new (CLUTTER_TEXTURE(oh->hand[0])); + oh->hand[i] = clutter_clone_new (oh->hand[0]); /* paint something before each hand */ g_signal_connect (oh->hand[i],