mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
[test-paint-wrapper] Use a separate paint guard for each actor
Since commitc7c5cf9b
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 commitd510a4b0
because get_paint_visibility was also broken.
This commit is contained in:
parent
f6feed4386
commit
c68cf3564e
@ -19,6 +19,8 @@ typedef struct SuperOH
|
|||||||
ClutterActor **hand, *bgtex;
|
ClutterActor **hand, *bgtex;
|
||||||
ClutterActor *group;
|
ClutterActor *group;
|
||||||
|
|
||||||
|
gboolean *paint_guards;
|
||||||
|
|
||||||
} SuperOH;
|
} SuperOH;
|
||||||
|
|
||||||
static gint n_hands = NHANDS;
|
static gint n_hands = NHANDS;
|
||||||
@ -118,38 +120,44 @@ frame_cb (ClutterTimeline *timeline,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean hand_pre_paint_guard = FALSE;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hand_pre_paint (ClutterActor *actor,
|
hand_pre_paint (ClutterActor *actor,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
SuperOH *oh = (SuperOH *) user_data;
|
||||||
guint w, h;
|
guint w, h;
|
||||||
|
int actor_num;
|
||||||
|
|
||||||
g_assert (hand_pre_paint_guard == FALSE);
|
for (actor_num = 0; oh->hand[actor_num] != actor; actor_num++);
|
||||||
|
|
||||||
|
g_assert (oh->paint_guards[actor_num] == FALSE);
|
||||||
|
|
||||||
clutter_actor_get_size (actor, &w, &h);
|
clutter_actor_get_size (actor, &w, &h);
|
||||||
|
|
||||||
cogl_set_source_color4ub (255, 0, 0, 128);
|
cogl_set_source_color4ub (255, 0, 0, 128);
|
||||||
cogl_rectangle (0, 0, w / 2, h / 2);
|
cogl_rectangle (0, 0, w / 2, h / 2);
|
||||||
|
|
||||||
hand_pre_paint_guard = TRUE;
|
oh->paint_guards[actor_num] = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hand_post_paint (ClutterActor *actor,
|
hand_post_paint (ClutterActor *actor,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
SuperOH *oh = (SuperOH *) user_data;
|
||||||
guint w, h;
|
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);
|
clutter_actor_get_size (actor, &w, &h);
|
||||||
|
|
||||||
cogl_set_source_color4ub (0, 255, 0, 128);
|
cogl_set_source_color4ub (0, 255, 0, 128);
|
||||||
cogl_rectangle (w / 2, h / 2, w / 2, h / 2);
|
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
|
G_MODULE_EXPORT int
|
||||||
@ -232,12 +240,12 @@ test_paint_wrapper_main (int argc, char *argv[])
|
|||||||
/* paint something before each hand */
|
/* paint something before each hand */
|
||||||
g_signal_connect (oh->hand[i],
|
g_signal_connect (oh->hand[i],
|
||||||
"paint", G_CALLBACK (hand_pre_paint),
|
"paint", G_CALLBACK (hand_pre_paint),
|
||||||
NULL);
|
oh);
|
||||||
|
|
||||||
/* paint something after each hand */
|
/* paint something after each hand */
|
||||||
g_signal_connect_after (oh->hand[i],
|
g_signal_connect_after (oh->hand[i],
|
||||||
"paint", G_CALLBACK (hand_post_paint),
|
"paint", G_CALLBACK (hand_post_paint),
|
||||||
NULL);
|
oh);
|
||||||
|
|
||||||
/* Place around a circle */
|
/* Place around a circle */
|
||||||
w = clutter_actor_get_width (oh->hand[0]);
|
w = clutter_actor_get_width (oh->hand[0]);
|
||||||
@ -269,6 +277,8 @@ test_paint_wrapper_main (int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oh->paint_guards = g_malloc0 (sizeof (gboolean) * n_hands);
|
||||||
|
|
||||||
/* Add the group to the stage */
|
/* Add the group to the stage */
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
||||||
CLUTTER_ACTOR (oh->group));
|
CLUTTER_ACTOR (oh->group));
|
||||||
@ -290,6 +300,7 @@ test_paint_wrapper_main (int argc, char *argv[])
|
|||||||
clutter_main ();
|
clutter_main ();
|
||||||
|
|
||||||
g_free (oh->hand);
|
g_free (oh->hand);
|
||||||
|
g_free (oh->paint_guards);
|
||||||
g_free (oh);
|
g_free (oh);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user