[cairo-commit] goocanvas/demo mv-scalability-demo.c, 1.2,
1.3 scalability-demo.c, 1.8, 1.9
Damon Chaplin
commit at pdx.freedesktop.org
Wed Apr 25 04:08:35 PDT 2007
Committed by: damon
Update of /cvs/cairo/goocanvas/demo
In directory kemper:/tmp/cvs-serv5405/demo
Modified Files:
mv-scalability-demo.c scalability-demo.c
Log Message:
2007-04-25 Damon Chaplin <damon at gnome.org>
* demo/mv-scalability-demo.c:
* demo/scalability-demo.c: instead of connecting signals to all items
we just use a handler on the root item. Also added a switch to turn
off the text items, to see the difference in performance (a lot).
Without text items we can startup with 100,000 items in 1 second
for a simple canvas, or 4 seconds for model-view (compared to 4 seconds
and 7 seconds with text items).
* src/goocanvasitemsimple.c (goo_canvas_item_simple_set_model): only
setup the accessibility stuff if accessibility is enabled (as it is
quite slow if you have lots of items).
Index: mv-scalability-demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/mv-scalability-demo.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mv-scalability-demo.c 24 Feb 2007 11:16:36 -0000 1.2
+++ mv-scalability-demo.c 25 Apr 2007 11:08:25 -0000 1.3
@@ -10,6 +10,10 @@
#endif
#define N_COLS 10
#define N_ROWS 10
+#define ITEM_WIDTH 400
+
+#define ROTATE
+
#define N_TOTAL_ID_ITEMS (N_GROUP_COLS * N_GROUP_ROWS) * (N_COLS * N_ROWS)
/* The maximum length of a string identifying an item (i.e. its coords). */
@@ -17,6 +21,10 @@
#define PADDING 10
+#if 1
+#define USE_TEXT
+#endif
+
#if 0
#define USE_PIXMAP
#endif
@@ -37,11 +45,22 @@
GdkEventMotion *event,
gpointer data)
{
- gchar *id = g_object_get_data (G_OBJECT (item), "id");
+ GooCanvasItem *ancestor = target;
+ gchar *id;
- g_print ("%s item received 'motion-notify' signal\n", id ? id : "Unknown");
+ while (ancestor)
+ {
+ id = g_object_get_data (G_OBJECT (ancestor), "id");
+ if (id)
+ {
+ g_print ("%s item received 'motion-notify' signal\n", id);
+ return TRUE;
+ }
- return FALSE;
+ ancestor = goo_canvas_item_get_parent (ancestor);
+ }
+
+ return TRUE;
}
@@ -67,6 +86,10 @@
goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);
g_object_unref (root);
+ item = goo_canvas_get_item (GOO_CANVAS (canvas), root);
+ g_signal_connect (item, "motion_notify_event",
+ (GtkSignalFunc) on_motion_notify, NULL);
+
#ifdef USE_PIXMAP
pixbuf = gdk_pixbuf_new_from_file("toroid.png", NULL);
item_width = gdk_pixbuf_get_width (pixbuf);
@@ -74,7 +97,7 @@
pattern = goo_canvas_cairo_pattern_from_pixbuf (pixbuf);
#else
pixbuf = NULL;
- item_width = 400/*80*/;
+ item_width = ITEM_WIDTH;
item_height = 19;
#endif
@@ -128,9 +151,11 @@
{
double item_x = (i * cell_width) + PADDING;
double item_y = (j * cell_height) + PADDING;
+#ifdef ROTATE
double rotation = i % 10 * 2;
double rotation_x = item_x + item_width / 2;
double rotation_y = item_y + item_height / 2;
+#endif
sprintf (ids[id_item_num], "%g, %g",
group_x + item_x, group_y + item_y);
@@ -147,23 +172,39 @@
item_width, item_height,
NULL);
goo_canvas_item_model_set_style (model, (j % 2) ? style : style2);
+#ifdef ROTATE
goo_canvas_item_model_rotate (model, rotation, rotation_x, rotation_y);
#endif
+#endif
item = goo_canvas_get_item (GOO_CANVAS (canvas), model);
g_object_set_data (G_OBJECT (item), "id",
ids[id_item_num]);
+
+#if 0
g_signal_connect (item, "motion_notify_event",
(GtkSignalFunc) on_motion_notify, NULL);
+#endif
+#ifdef USE_TEXT
model = goo_canvas_text_model_new (group, ids[id_item_num],
item_x + item_width / 2,
item_y + item_height / 2,
-1, GTK_ANCHOR_CENTER,
NULL);
+#else
+ model = goo_canvas_rect_model_new (group,
+ item_x + 20,
+ item_y + 4,
+ item_width - 40,
+ item_height - 8,
+ NULL);
+#endif
+
+#ifdef ROTATE
goo_canvas_item_model_rotate (model, rotation, rotation_x,
rotation_y);
-
+#endif
id_item_num++;
total_items += 2;
Index: scalability-demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/scalability-demo.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- scalability-demo.c 25 Feb 2007 17:37:57 -0000 1.8
+++ scalability-demo.c 25 Apr 2007 11:08:25 -0000 1.9
@@ -25,6 +25,10 @@
/* The maximum length of a string identifying an item (i.e. its coords). */
#define MAX_ID_LEN 20
+#if 1
+#define USE_TEXT
+#endif
+
#if 0
#define USE_PIXMAP
#endif
@@ -45,11 +49,22 @@
GdkEventMotion *event,
gpointer data)
{
- gchar *id = g_object_get_data (G_OBJECT (item), "id");
+ GooCanvasItem *ancestor = target;
+ gchar *id;
- g_print ("%s item received 'motion-notify' signal\n", id ? id : "Unknown");
+ while (ancestor)
+ {
+ id = g_object_get_data (G_OBJECT (ancestor), "id");
+ if (id)
+ {
+ g_print ("%s item received 'motion-notify' signal\n", id);
+ return TRUE;
+ }
- return FALSE;
+ ancestor = goo_canvas_item_get_parent (ancestor);
+ }
+
+ return TRUE;
}
@@ -70,6 +85,9 @@
root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
+ g_signal_connect (root, "motion_notify_event",
+ (GtkSignalFunc) on_motion_notify, NULL);
+
g_object_set (G_OBJECT (root),
"font", "Sans 8",
NULL);
@@ -141,7 +159,7 @@
double rotation_y = item_y + item_height / 2;
#endif
- sprintf (ids[id_item_num], "%g, %g",
+ sprintf (ids[id_item_num], "%.10g, %.10g",
group_x + item_x, group_y + item_y);
#ifdef USE_PIXMAP
@@ -162,14 +180,23 @@
g_object_set_data (G_OBJECT (item), "id",
ids[id_item_num]);
+#if 0
g_signal_connect (item, "motion_notify_event",
(GtkSignalFunc) on_motion_notify, NULL);
+#endif
+#ifdef USE_TEXT
item = goo_canvas_text_new (group, ids[id_item_num],
item_x + item_width / 2,
item_y + item_height / 2,
-1, GTK_ANCHOR_CENTER,
NULL);
+#else
+ item = goo_canvas_rect_new (group, item_x + 20, item_y + 4,
+ item_width - 40, item_height - 8,
+ NULL);
+#endif
+
#ifdef ROTATE
goo_canvas_item_rotate (item, rotation, rotation_x,
rotation_y);
More information about the cairo-commit
mailing list