[gnome-games] gnometris: Speed up keypress handler even more for smoother move animations



commit 0b0b181cd9a6a4fe22de2ca10c70dbf862c5ef86
Author: Jason D. Clinton <me jasonclinton com>
Date:   Sat Aug 29 19:24:18 2009 -0500

    gnometris: Speed up keypress handler even more for smoother move animations
    
    This is accomplished by avoiding creating a new GObject in the middle of the key
    press handler which is relatively expensive operation.

 gnometris/blockops.cpp |    8 +++-----
 gnometris/blocks.cpp   |    8 +++++---
 gnometris/blocks.h     |    1 +
 3 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gnometris/blockops.cpp b/gnometris/blockops.cpp
index 4669351..b8c0b8d 100644
--- a/gnometris/blockops.cpp
+++ b/gnometris/blockops.cpp
@@ -632,11 +632,9 @@ BlockOps::moveBlockInField (gint x_trans, gint y_trans)
 				if (animate) {
 					gfloat cur_x, cur_y = 0.0;
 					g_object_get (G_OBJECT (cell->actor), "x", &cur_x, "y", &cur_y, NULL);
-					ClutterPath *path_line = clutter_path_new ();
-					clutter_path_add_move_to (path_line, cur_x, cur_y);
-					clutter_path_add_line_to (path_line, cell->x, cell->y);
-					clutter_behaviour_path_set_path (CLUTTER_BEHAVIOUR_PATH(cell->move_behaviour),
-					                                 CLUTTER_PATH(path_line));
+					clutter_path_clear (CLUTTER_PATH(cell->move_path));
+					clutter_path_add_move_to (cell->move_path, cur_x, cur_y);
+					clutter_path_add_line_to (cell->move_path, cell->x, cell->y);
 					clutter_behaviour_remove_all (CLUTTER_BEHAVIOUR(cell->move_behaviour));
 					clutter_behaviour_apply (cell->move_behaviour, cell->actor);
 				}
diff --git a/gnometris/blocks.cpp b/gnometris/blocks.cpp
index 693a1dd..b96f442 100644
--- a/gnometris/blocks.cpp
+++ b/gnometris/blocks.cpp
@@ -29,7 +29,8 @@ Block::Block ():
 	y(0),
 	move_behaviour(NULL),
 	fall_behaviour(NULL),
-	explode_move_behaviour(NULL)
+	explode_move_behaviour(NULL),
+	move_path(NULL)
 {}
 
 Block::~Block ()
@@ -72,8 +73,9 @@ Block::createActor (ClutterActor *chamber, CoglHandle texture_source, gint pxwid
 void
 Block::bindAnimations (BlockOps *f)
 {
-	move_behaviour = clutter_behaviour_path_new_with_knots (f->move_alpha,
-								NULL, 0);
+	move_path = clutter_path_new ();
+	move_behaviour = clutter_behaviour_path_new (f->move_alpha,
+	                                             move_path);
 	fall_behaviour = clutter_behaviour_path_new_with_knots (f->fall_alpha,
 								NULL, 0);
 	explode_move_behaviour = clutter_behaviour_path_new_with_knots (f->explode_alpha,
diff --git a/gnometris/blocks.h b/gnometris/blocks.h
index b2cbd23..3b27027 100644
--- a/gnometris/blocks.h
+++ b/gnometris/blocks.h
@@ -58,6 +58,7 @@ public:
 	ClutterBehaviour *move_behaviour;
 	ClutterBehaviour *fall_behaviour;
 	ClutterBehaviour *explode_move_behaviour;
+	ClutterPath *move_path;
 };
 
 extern int blockTable[][4][4][4];



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]