[clutter/deprecate-default-stage: 3/14] micro-bench/*: Do not use clutter_stage_get_default()



commit 93eb0bfe328598fe37a6469cd43ba8fa59ae147e
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Nov 8 17:23:52 2011 +0000

    micro-bench/*: Do not use clutter_stage_get_default()

 tests/micro-bench/test-cogl-perf.c   |   14 ++++++--------
 tests/micro-bench/test-picking.c     |   10 ++++++----
 tests/micro-bench/test-random-text.c |    5 ++++-
 tests/micro-bench/test-text-perf.c   |    6 +++---
 tests/micro-bench/test-text.c        |   11 ++++++-----
 5 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/tests/micro-bench/test-cogl-perf.c b/tests/micro-bench/test-cogl-perf.c
index 0f97a95..5f594e1 100644
--- a/tests/micro-bench/test-cogl-perf.c
+++ b/tests/micro-bench/test-cogl-perf.c
@@ -23,6 +23,7 @@ static GOptionEntry entries[] = {
 
 typedef struct _TestState
 {
+  ClutterActor *stage;
   int current_test;
 } TestState;
 
@@ -89,8 +90,6 @@ test_rectangles (TestState *state)
           cogl_pop_matrix ();
         }
     }
-
-
 }
 
 TestCallback tests[] =
@@ -117,8 +116,6 @@ main (int argc, char *argv[])
 {
   TestState state;
   ClutterActor *stage;
-  ClutterColor stage_clr = {0x0, 0x0, 0x0, 0xff};
-  guint idle_source;
   GError *error = NULL;
 
   g_setenv ("CLUTTER_VBLANK", "none", FALSE);
@@ -139,13 +136,14 @@ main (int argc, char *argv[])
 
   state.current_test = 0;
 
-  stage = clutter_stage_get_default ();
+  state.stage = stage = clutter_stage_new ();
 
   clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
-  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr);
+  clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White);
+  clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Performance Test");
 
   /* We want continuous redrawing of the stage... */
-  idle_source = g_idle_add (queue_redraw, stage);
+  clutter_threads_add_idle (queue_redraw, stage);
 
   g_signal_connect_after (stage, "paint", G_CALLBACK (on_paint), &state);
 
@@ -153,7 +151,7 @@ main (int argc, char *argv[])
 
   clutter_main ();
 
-  g_source_remove (idle_source);
+  clutter_actor_destroy (stage);
 
   return 0;
 }
diff --git a/tests/micro-bench/test-picking.c b/tests/micro-bench/test-picking.c
index f661729..094b657 100644
--- a/tests/micro-bench/test-picking.c
+++ b/tests/micro-bench/test-picking.c
@@ -72,7 +72,6 @@ main (int argc, char **argv)
 {
   glong i;
   gdouble angle;
-  const ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
   ClutterColor color = { 0x00, 0x00, 0x00, 0xff };
   ClutterActor *stage, *rect;
   GError *error = NULL;
@@ -88,9 +87,10 @@ main (int argc, char **argv)
                               &error) != CLUTTER_INIT_SUCCESS)
     return 1;
 
-  stage = clutter_stage_get_default ();
+  stage = clutter_stage_new ();
   clutter_actor_set_size (stage, 512, 512);
-  clutter_stage_set_color (CLUTTER_STAGE (stage), &black);
+  clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black);
+  clutter_stage_set_title (CLUTTER_STAGE (stage), "Picking");
 
   printf ("Picking performance test with "
           "%d actors and %d events per frame\n",
@@ -126,12 +126,14 @@ main (int argc, char **argv)
 
   clutter_actor_show (stage);
 
-  g_idle_add (queue_redraw, stage);
+  clutter_threads_add_idle (queue_redraw, stage);
 
   g_signal_connect (stage, "paint", G_CALLBACK (on_paint), NULL);
 
   clutter_main ();
 
+  clutter_actor_destroy (stage);
+
   return 0;
 }
 
diff --git a/tests/micro-bench/test-random-text.c b/tests/micro-bench/test-random-text.c
index b1f710d..69eb6d0 100644
--- a/tests/micro-bench/test-random-text.c
+++ b/tests/micro-bench/test-random-text.c
@@ -90,7 +90,8 @@ main (int argc, char *argv[])
   if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
     return 1;
 
-  stage = clutter_stage_get_default ();
+  stage = clutter_stage_new ();
+  clutter_stage_set_title (CLUTTER_STAGE (stage), "Random Text");
 
   clutter_actor_show (stage);
 
@@ -98,5 +99,7 @@ main (int argc, char *argv[])
 
   clutter_main ();
 
+  clutter_actor_destroy (stage);
+
   return 0;
 }
diff --git a/tests/micro-bench/test-text-perf.c b/tests/micro-bench/test-text-perf.c
index e21939c..5e70ba7 100644
--- a/tests/micro-bench/test-text-perf.c
+++ b/tests/micro-bench/test-text-perf.c
@@ -105,7 +105,6 @@ int
 main (int argc, char *argv[])
 {
   ClutterActor    *stage;
-  ClutterColor     stage_color = { 0x00, 0x00, 0x00, 0xff };
   ClutterActor    *label;
   int              w, h;
   int              row, col;
@@ -128,9 +127,10 @@ main (int argc, char *argv[])
 
   g_print ("Monospace %dpx, string length = %d\n", font_size, n_chars);
 
-  stage = clutter_stage_get_default ();
+  stage = clutter_stage_new ();
   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), CLUTTER_COLOR_Black);
+  clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Performance");
 
   g_signal_connect (stage, "paint", G_CALLBACK (on_paint), NULL);
 
diff --git a/tests/micro-bench/test-text.c b/tests/micro-bench/test-text.c
index 93a8f55..18cd775 100644
--- a/tests/micro-bench/test-text.c
+++ b/tests/micro-bench/test-text.c
@@ -43,8 +43,6 @@ int
 main (int argc, char *argv[])
 {
   ClutterActor    *stage;
-  ClutterColor     stage_color = { 0x00, 0x00, 0x00, 0xff };
-  ClutterColor     label_color = { 0xff, 0xff, 0xff, 0xff };
   ClutterActor    *group;
 
   g_setenv ("CLUTTER_VBLANK", "none", FALSE);
@@ -53,9 +51,10 @@ main (int argc, char *argv[])
   if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
     return 1;
 
-  stage = clutter_stage_get_default ();
+  stage = clutter_stage_new ();
   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), CLUTTER_COLOR_Black);
+  clutter_stage_set_title (CLUTTER_STAGE (stage), "Text");
 
   group = clutter_group_new ();
   clutter_actor_set_size (group, STAGE_WIDTH, STAGE_WIDTH);
@@ -98,7 +97,7 @@ main (int argc, char *argv[])
             }
 
           label = clutter_text_new_with_text (font_name, text);
-          clutter_text_set_color (CLUTTER_TEXT (label), &label_color);
+          clutter_text_set_color (CLUTTER_TEXT (label), CLUTTER_COLOR_White);
           clutter_actor_set_position (label, (1.0*STAGE_WIDTH/COLS)*col,
                                              (1.0*STAGE_HEIGHT/ROWS)*row);
           /*clutter_actor_set_clip (label, 0,0, (1.0*STAGE_WIDTH/COLS),
@@ -115,5 +114,7 @@ main (int argc, char *argv[])
 
   clutter_main();
 
+  clutter_actor_destroy (stage);
+
   return 0;
 }



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