[test-text] queue redraws instead of calling clutter_actor_paint directly

Directly calling clutter_actor_paint skips out quite a bit code such as the
backend swap buffer call.

Since we are interested in the highest fps possible, and it now goes through
to the backend swap buffer call we now do a setenv (CLUTTER_VBLANK, none, 0)
before calling clutter_init.
This commit is contained in:
Robert Bragg 2009-01-15 13:58:31 +00:00
parent 22183c7a8f
commit 642617b7a0

View File

@ -9,10 +9,9 @@
#define COLS 18 #define COLS 18
#define ROWS 20 #define ROWS 20
gboolean idle (gpointer data) static void
on_paint (ClutterActor *actor, gconstpointer *data)
{ {
ClutterActor *stage = CLUTTER_ACTOR (data);
static GTimer *timer = NULL; static GTimer *timer = NULL;
static int fps = 0; static int fps = 0;
@ -29,8 +28,13 @@ gboolean idle (gpointer data)
fps = 0; fps = 0;
} }
clutter_actor_paint (stage);
++fps; ++fps;
}
static gboolean
queue_redraw (gpointer stage)
{
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
return TRUE; return TRUE;
} }
@ -41,6 +45,9 @@ main (int argc, char *argv[])
ClutterActor *stage; ClutterActor *stage;
ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff }; ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
ClutterColor label_color = { 0xff, 0xff, 0xff, 0xff }; ClutterColor label_color = { 0xff, 0xff, 0xff, 0xff };
ClutterActor *group;
setenv ("CLUTTER_VBLANK", "none", 0);
clutter_init (&argc, &argv); clutter_init (&argc, &argv);
@ -48,6 +55,14 @@ main (int argc, char *argv[])
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
group = clutter_group_new ();
clutter_actor_set_size (group, STAGE_WIDTH, STAGE_WIDTH);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
g_idle_add (queue_redraw, stage);
g_signal_connect (group, "paint", G_CALLBACK (on_paint), NULL);
{ {
gint row, col; gint row, col;
@ -88,15 +103,13 @@ main (int argc, char *argv[])
(1.0*STAGE_HEIGHT/ROWS));*/ (1.0*STAGE_HEIGHT/ROWS));*/
clutter_actor_set_scale (label, scale, scale); clutter_actor_set_scale (label, scale, scale);
clutter_text_set_line_wrap (CLUTTER_TEXT (label), FALSE); clutter_text_set_line_wrap (CLUTTER_TEXT (label), FALSE);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label); clutter_container_add_actor (CLUTTER_CONTAINER (group), label);
} }
} }
clutter_actor_show_all (stage); clutter_actor_show_all (stage);
g_signal_connect (stage, "key-press-event", g_signal_connect (stage, "key-press-event",
G_CALLBACK (clutter_main_quit), NULL); G_CALLBACK (clutter_main_quit), NULL);
g_idle_add (idle, (gpointer) stage);
clutter_main(); clutter_main();