[test-paint-wrapper] Use a separate paint guard for each actor
authorNeil Roberts <neil@linux.intel.com>
Mon, 15 Dec 2008 16:32:21 +0000 (16:32 +0000)
committerNeil Roberts <neil@linux.intel.com>
Mon, 15 Dec 2008 16:33:45 +0000 (16:33 +0000)
Since commit c7c5cf9b ClutterCloneTexture causes an extra paint of the
source actor during the paint run of the cloned texture if the source
is not yet visible. When the stage is first shown it is redrawn
immediatly before it is mapped which means get_paint_visibility will
fail on the source actor so the inner paint will be run. The paint
guards were a global variable so they didn't cope with a second actor
being painted.

The breakage didn't occur until commit d510a4b0 because
get_paint_visibility was also broken.

tests/interactive/test-paint-wrapper.c

index ab8b8a3..27448b8 100644 (file)
@@ -19,6 +19,8 @@ typedef struct SuperOH
   ClutterActor   **hand, *bgtex;
   ClutterActor    *group;
 
+  gboolean        *paint_guards;
+
 } SuperOH;
 
 static gint n_hands = NHANDS;
@@ -118,38 +120,44 @@ frame_cb (ClutterTimeline *timeline,
     }
 }
 
-static gboolean hand_pre_paint_guard = FALSE;
-
 static void
 hand_pre_paint (ClutterActor *actor,
                 gpointer      user_data)
 {
+  SuperOH *oh = (SuperOH *) user_data;
   guint w, h;
+  int actor_num;
+
+  for (actor_num = 0; oh->hand[actor_num] != actor; actor_num++);
 
-  g_assert (hand_pre_paint_guard == FALSE);
+  g_assert (oh->paint_guards[actor_num] == FALSE);
 
   clutter_actor_get_size (actor, &w, &h);
 
   cogl_set_source_color4ub (255, 0, 0, 128);
   cogl_rectangle (0, 0, w / 2, h / 2);
 
-  hand_pre_paint_guard = TRUE;
+  oh->paint_guards[actor_num] = TRUE;
 }
 
 static void
 hand_post_paint (ClutterActor *actor,
                  gpointer      user_data)
 {
+  SuperOH *oh = (SuperOH *) user_data;
   guint w, h;
+  int actor_num;
 
-  g_assert (hand_pre_paint_guard == TRUE);
+  for (actor_num = 0; oh->hand[actor_num] != actor; actor_num++);
+
+  g_assert (oh->paint_guards[actor_num] == TRUE);
 
   clutter_actor_get_size (actor, &w, &h);
 
   cogl_set_source_color4ub (0, 255, 0, 128);
   cogl_rectangle (w / 2, h / 2, w / 2, h / 2);
 
-  hand_pre_paint_guard = FALSE;
+  oh->paint_guards[actor_num] = FALSE;
 }
 
 G_MODULE_EXPORT int
@@ -232,12 +240,12 @@ test_paint_wrapper_main (int argc, char *argv[])
       /* paint something before each hand */
       g_signal_connect (oh->hand[i],
                         "paint", G_CALLBACK (hand_pre_paint),
-                        NULL);
+                        oh);
 
       /* paint something after each hand */
       g_signal_connect_after (oh->hand[i],
                               "paint", G_CALLBACK (hand_post_paint),
-                              NULL);
+                              oh);
 
       /* Place around a circle */
       w = clutter_actor_get_width (oh->hand[0]);
@@ -269,6 +277,8 @@ test_paint_wrapper_main (int argc, char *argv[])
 #endif
     }
 
+  oh->paint_guards = g_malloc0 (sizeof (gboolean) * n_hands);
+
   /* Add the group to the stage */
   clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                                CLUTTER_ACTOR (oh->group));
@@ -290,6 +300,7 @@ test_paint_wrapper_main (int argc, char *argv[])
   clutter_main ();
 
   g_free (oh->hand);
+  g_free (oh->paint_guards);
   g_free (oh);
 
   return 0;