1
0
mirror of https://github.com/brl/mutter.git synced 2025-03-11 13:55:05 +00:00

[test-text-perf] Small fix-ups

- Fix a typo in a for loop in create_label which left 'i'
  uninitialised and caused a crash if you're unlucky.

- Set the CLUTTER_VBLANK=none environment variable.

- Don't quit on a keypress.

- Trailing whitespace tidy up.
This commit is contained in:
Neil Roberts 2009-05-21 17:43:41 +01:00
parent 8724a16452
commit a1b0160da7

@ -13,16 +13,16 @@ static int rows, cols;
gboolean idle (gpointer data) gboolean idle (gpointer data)
{ {
ClutterActor *stage = CLUTTER_ACTOR (data); ClutterActor *stage = CLUTTER_ACTOR (data);
static GTimer *timer = NULL; static GTimer *timer = NULL;
static int fps = 0; static int fps = 0;
if (!timer) if (!timer)
{ {
timer = g_timer_new (); timer = g_timer_new ();
g_timer_start (timer); g_timer_start (timer);
} }
if (g_timer_elapsed (timer, NULL) >= 1) if (g_timer_elapsed (timer, NULL) >= 1)
{ {
printf ("fps=%d, strings/sec=%d, chars/sec=%d\n", printf ("fps=%d, strings/sec=%d, chars/sec=%d\n",
@ -32,7 +32,7 @@ gboolean idle (gpointer data)
g_timer_start (timer); g_timer_start (timer);
fps = 0; fps = 0;
} }
clutter_actor_paint (stage); clutter_actor_paint (stage);
++fps; ++fps;
@ -40,7 +40,7 @@ gboolean idle (gpointer data)
} }
static ClutterActor * static ClutterActor *
create_label() create_label ()
{ {
ClutterColor label_color = { 0xff, 0xff, 0xff, 0xff }; ClutterColor label_color = { 0xff, 0xff, 0xff, 0xff };
ClutterActor *label; ClutterActor *label;
@ -51,7 +51,7 @@ create_label()
font_name = g_strdup_printf ("Monospace %dpx", font_size); font_name = g_strdup_printf ("Monospace %dpx", font_size);
str = g_string_new (NULL); str = g_string_new (NULL);
for (i < 0; i < n_chars; i++) for (i = 0; i < n_chars; i++)
g_string_append_c (str, 'A' + (i % 26)); g_string_append_c (str, 'A' + (i % 26));
label = clutter_text_new_with_text (font_name, str->str); label = clutter_text_new_with_text (font_name, str->str);
@ -72,6 +72,8 @@ main (int argc, char *argv[])
int w, h; int w, h;
int row, col; int row, col;
g_setenv ("CLUTTER_VBLANK", "none", FALSE);
clutter_init (&argc, &argv); clutter_init (&argc, &argv);
if (argc != 3) if (argc != 3)
@ -112,12 +114,9 @@ main (int argc, char *argv[])
clutter_actor_show_all (stage); clutter_actor_show_all (stage);
g_signal_connect (stage, "key-press-event",
G_CALLBACK (clutter_main_quit), NULL);
g_idle_add (idle, (gpointer) stage); g_idle_add (idle, (gpointer) stage);
clutter_main(); clutter_main ();
return 0; return 0;
} }