static void clutter_clone_paint (ClutterActor *self) { ClutterClone *clone = CLUTTER_CLONE (self); ClutterClonePrivate *priv = clone->priv; ClutterGeometry geom, clone_geom; gfloat x_scale, y_scale; gboolean was_unmapped = FALSE; if (G_UNLIKELY (priv->clone_source == NULL)) return; CLUTTER_NOTE (PAINT, "painting clone actor '%s'", clutter_actor_get_name (self) ? clutter_actor_get_name (self) : "unknown"); /* get our allocated size */ clutter_actor_get_allocation_geometry (self, &geom); /* and get the allocated size of the source */ clutter_actor_get_allocation_geometry (priv->clone_source, &clone_geom); /* We need to scale what the clone-source actor paints to fill our own * allocation... */ x_scale = (gfloat) geom.width / clone_geom.width; y_scale = (gfloat) geom.height / clone_geom.height; cogl_scale (x_scale, y_scale, 1.0); /* The final bits of magic: * - We need to make sure that when the clone-source actor's paint * method calls clutter_actor_get_paint_opacity, it traverses to * us and our parent not it's real parent. * - We need to stop clutter_actor_paint applying the model view matrix of * the clone source actor. */ _clutter_actor_set_opacity_parent (priv->clone_source, self); _clutter_actor_set_enable_model_view_transform (priv->clone_source, FALSE); if (!CLUTTER_ACTOR_IS_MAPPED (priv->clone_source)) { _clutter_actor_set_enable_paint_unmapped (priv->clone_source, TRUE); was_unmapped = TRUE; } clutter_actor_paint (priv->clone_source); if (was_unmapped) _clutter_actor_set_enable_paint_unmapped (priv->clone_source, FALSE); _clutter_actor_set_enable_model_view_transform (priv->clone_source, TRUE); _clutter_actor_set_opacity_parent (priv->clone_source, NULL); }
static void clutter_clone_paint (ClutterActor *actor) { ClutterClone *self = CLUTTER_CLONE (actor); ClutterClonePrivate *priv = self->priv; gboolean was_unmapped = FALSE; if (priv->clone_source == NULL) return; CLUTTER_NOTE (PAINT, "painting clone actor '%s'", _clutter_actor_get_debug_name (actor)); /* The final bits of magic: * - We need to override the paint opacity of the actor with our own * opacity. * - We need to inform the actor that it's in a clone paint (for the function * clutter_actor_is_in_clone_paint()) * - We need to stop clutter_actor_paint applying the model view matrix of * the clone source actor. */ _clutter_actor_set_in_clone_paint (priv->clone_source, TRUE); _clutter_actor_set_opacity_override (priv->clone_source, clutter_actor_get_paint_opacity (actor)); _clutter_actor_set_enable_model_view_transform (priv->clone_source, FALSE); if (!CLUTTER_ACTOR_IS_MAPPED (priv->clone_source)) { _clutter_actor_set_enable_paint_unmapped (priv->clone_source, TRUE); was_unmapped = TRUE; } _clutter_actor_push_clone_paint (); clutter_actor_paint (priv->clone_source); _clutter_actor_pop_clone_paint (); if (was_unmapped) _clutter_actor_set_enable_paint_unmapped (priv->clone_source, FALSE); _clutter_actor_set_enable_model_view_transform (priv->clone_source, TRUE); _clutter_actor_set_opacity_override (priv->clone_source, -1); _clutter_actor_set_in_clone_paint (priv->clone_source, FALSE); }