[test-text-perf] Use queue_redraw instead of painting the stage directly

If it doesn't queue a redraw and allow the backend to clear and swap
the buffers then the results will be skewed because it is not
predictable when the driver will actually render the scene.
This commit is contained in:
Neil Roberts 2009-05-28 15:27:09 +01:00
parent 654c26a130
commit d960ce46e5

View File

@ -10,10 +10,9 @@ static int font_size;
static int n_chars; static int n_chars;
static int rows, cols; static int rows, cols;
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;
@ -33,8 +32,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;
} }
@ -91,6 +95,8 @@ 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);
g_signal_connect (stage, "paint", G_CALLBACK (on_paint), NULL);
label = create_label (); label = create_label ();
w = clutter_actor_get_width (label); w = clutter_actor_get_width (label);
h = clutter_actor_get_height (label); h = clutter_actor_get_height (label);
@ -114,7 +120,7 @@ main (int argc, char *argv[])
clutter_actor_show_all (stage); clutter_actor_show_all (stage);
g_idle_add (idle, (gpointer) stage); g_idle_add (queue_redraw, stage);
clutter_main (); clutter_main ();