Use paint nodes to set up the stage
This allows to set a Content on a stage, and consolidates the paint code where it belongs. https://bugzilla.gnome.org/show_bug.cgi?id=704625
This commit is contained in:
parent
1d9e264051
commit
0b6498d655
@ -3563,23 +3563,51 @@ clutter_actor_paint_node (ClutterActor *actor,
|
|||||||
ClutterPaintNode *root)
|
ClutterPaintNode *root)
|
||||||
{
|
{
|
||||||
ClutterActorPrivate *priv = actor->priv;
|
ClutterActorPrivate *priv = actor->priv;
|
||||||
|
ClutterActorBox box;
|
||||||
|
ClutterColor bg_color;
|
||||||
|
|
||||||
if (root == NULL)
|
if (root == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (priv->bg_color_set &&
|
|
||||||
!clutter_color_equal (&priv->bg_color, CLUTTER_COLOR_Transparent))
|
|
||||||
{
|
|
||||||
ClutterPaintNode *node;
|
|
||||||
ClutterColor bg_color;
|
|
||||||
ClutterActorBox box;
|
|
||||||
|
|
||||||
box.x1 = 0.f;
|
box.x1 = 0.f;
|
||||||
box.y1 = 0.f;
|
box.y1 = 0.f;
|
||||||
box.x2 = clutter_actor_box_get_width (&priv->allocation);
|
box.x2 = clutter_actor_box_get_width (&priv->allocation);
|
||||||
box.y2 = clutter_actor_box_get_height (&priv->allocation);
|
box.y2 = clutter_actor_box_get_height (&priv->allocation);
|
||||||
|
|
||||||
bg_color = priv->bg_color;
|
bg_color = priv->bg_color;
|
||||||
|
|
||||||
|
if (CLUTTER_ACTOR_IS_TOPLEVEL (actor))
|
||||||
|
{
|
||||||
|
ClutterPaintNode *node;
|
||||||
|
CoglFramebuffer *fb;
|
||||||
|
CoglBufferBit clear_flags;
|
||||||
|
|
||||||
|
fb = _clutter_stage_get_active_framebuffer (CLUTTER_STAGE (actor));
|
||||||
|
|
||||||
|
if (clutter_stage_get_use_alpha (CLUTTER_STAGE (actor)))
|
||||||
|
{
|
||||||
|
bg_color.alpha = clutter_actor_get_paint_opacity_internal (actor)
|
||||||
|
* priv->bg_color.alpha
|
||||||
|
/ 255;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
bg_color.alpha = 255;
|
||||||
|
|
||||||
|
clear_flags = COGL_BUFFER_BIT_DEPTH;
|
||||||
|
if (!clutter_stage_get_no_clear_hint (CLUTTER_STAGE (actor)))
|
||||||
|
clear_flags |= COGL_BUFFER_BIT_COLOR;
|
||||||
|
|
||||||
|
node = _clutter_root_node_new (fb, &bg_color, clear_flags);
|
||||||
|
clutter_paint_node_set_name (node, "stageClear");
|
||||||
|
clutter_paint_node_add_rectangle (node, &box);
|
||||||
|
clutter_paint_node_add_child (root, node);
|
||||||
|
clutter_paint_node_unref (node);
|
||||||
|
}
|
||||||
|
else if (priv->bg_color_set &&
|
||||||
|
!clutter_color_equal (&priv->bg_color, CLUTTER_COLOR_Transparent))
|
||||||
|
{
|
||||||
|
ClutterPaintNode *node;
|
||||||
|
|
||||||
bg_color.alpha = clutter_actor_get_paint_opacity_internal (actor)
|
bg_color.alpha = clutter_actor_get_paint_opacity_internal (actor)
|
||||||
* priv->bg_color.alpha
|
* priv->bg_color.alpha
|
||||||
/ 255;
|
/ 255;
|
||||||
|
@ -679,6 +679,8 @@ _clutter_stage_do_paint (ClutterStage *stage,
|
|||||||
clutter_stage_invoke_paint_callback (stage);
|
clutter_stage_invoke_paint_callback (stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* the Stage is cleared in clutter_actor_paint_node() */
|
||||||
static void
|
static void
|
||||||
clutter_stage_paint (ClutterActor *self)
|
clutter_stage_paint (ClutterActor *self)
|
||||||
{
|
{
|
||||||
@ -725,6 +727,7 @@ clutter_stage_paint (ClutterActor *self)
|
|||||||
while (clutter_actor_iter_next (&iter, &child))
|
while (clutter_actor_iter_next (&iter, &child))
|
||||||
clutter_actor_paint (child);
|
clutter_actor_paint (child);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_pick (ClutterActor *self,
|
clutter_stage_pick (ClutterActor *self,
|
||||||
@ -1915,7 +1918,6 @@ clutter_stage_class_init (ClutterStageClass *klass)
|
|||||||
actor_class->allocate = clutter_stage_allocate;
|
actor_class->allocate = clutter_stage_allocate;
|
||||||
actor_class->get_preferred_width = clutter_stage_get_preferred_width;
|
actor_class->get_preferred_width = clutter_stage_get_preferred_width;
|
||||||
actor_class->get_preferred_height = clutter_stage_get_preferred_height;
|
actor_class->get_preferred_height = clutter_stage_get_preferred_height;
|
||||||
actor_class->paint = clutter_stage_paint;
|
|
||||||
actor_class->pick = clutter_stage_pick;
|
actor_class->pick = clutter_stage_pick;
|
||||||
actor_class->get_paint_volume = clutter_stage_get_paint_volume;
|
actor_class->get_paint_volume = clutter_stage_get_paint_volume;
|
||||||
actor_class->realize = clutter_stage_realize;
|
actor_class->realize = clutter_stage_realize;
|
||||||
|
@ -49,7 +49,7 @@ on_tap (ClutterTapAction *action,
|
|||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ClutterActor *stage, *box, *text;
|
ClutterActor *stage, *text;
|
||||||
ClutterContent *image;
|
ClutterContent *image;
|
||||||
ClutterAction *action;
|
ClutterAction *action;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
@ -63,17 +63,12 @@ main (int argc, char *argv[])
|
|||||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "Content Box");
|
clutter_stage_set_title (CLUTTER_STAGE (stage), "Content Box");
|
||||||
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
|
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
|
||||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
||||||
|
clutter_actor_set_margin_top (stage, 12);
|
||||||
|
clutter_actor_set_margin_right (stage, 12);
|
||||||
|
clutter_actor_set_margin_bottom (stage, 12);
|
||||||
|
clutter_actor_set_margin_left (stage, 12);
|
||||||
clutter_actor_show (stage);
|
clutter_actor_show (stage);
|
||||||
|
|
||||||
box = clutter_actor_new ();
|
|
||||||
clutter_actor_set_name (box, "Image");
|
|
||||||
clutter_actor_set_margin_top (box, 12);
|
|
||||||
clutter_actor_set_margin_right (box, 12);
|
|
||||||
clutter_actor_set_margin_bottom (box, 12);
|
|
||||||
clutter_actor_set_margin_left (box, 12);
|
|
||||||
clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0));
|
|
||||||
clutter_actor_add_child (stage, box);
|
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_file (TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL);
|
pixbuf = gdk_pixbuf_new_from_file (TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL);
|
||||||
image = clutter_image_new ();
|
image = clutter_image_new ();
|
||||||
clutter_image_set_data (CLUTTER_IMAGE (image),
|
clutter_image_set_data (CLUTTER_IMAGE (image),
|
||||||
@ -87,11 +82,11 @@ main (int argc, char *argv[])
|
|||||||
NULL);
|
NULL);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
clutter_actor_set_content_scaling_filters (box,
|
clutter_actor_set_content_scaling_filters (stage,
|
||||||
CLUTTER_SCALING_FILTER_TRILINEAR,
|
CLUTTER_SCALING_FILTER_TRILINEAR,
|
||||||
CLUTTER_SCALING_FILTER_LINEAR);
|
CLUTTER_SCALING_FILTER_LINEAR);
|
||||||
clutter_actor_set_content_gravity (box, gravities[n_gravities - 1].gravity);
|
clutter_actor_set_content_gravity (stage, gravities[n_gravities - 1].gravity);
|
||||||
clutter_actor_set_content (box, image);
|
clutter_actor_set_content (stage, image);
|
||||||
g_object_unref (image);
|
g_object_unref (image);
|
||||||
|
|
||||||
str = g_strconcat ("Content gravity: ",
|
str = g_strconcat ("Content gravity: ",
|
||||||
@ -107,8 +102,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
action = clutter_tap_action_new ();
|
action = clutter_tap_action_new ();
|
||||||
g_signal_connect (action, "tap", G_CALLBACK (on_tap), text);
|
g_signal_connect (action, "tap", G_CALLBACK (on_tap), text);
|
||||||
clutter_actor_set_reactive (box, TRUE);
|
clutter_actor_add_action (stage, action);
|
||||||
clutter_actor_add_action (box, action);
|
|
||||||
|
|
||||||
clutter_main ();
|
clutter_main ();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user