From b5a7fe4b233ca80c998cb1f0a27fed495e1d13d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 21 Nov 2020 11:26:42 +0100 Subject: [PATCH] clutter/actor: Handle clips correctly when building paint volume clutter_actor_paint() implements a clear preference for custom clips over clip_to_allocation: If a custom clip is set, clip_to_allocation is ignored. Since the paint volume reflects what Clutter is going to paint, we should handle it the same when putting together our paint volume: So first handle custom clips, and if one is set, use that. Then handle clip_to_allocation, and if that's set, use that. And finally, if both aren't set, union our allocation with the children paint volumes to get the building volume. clutter_actor_paint() also doesn't check whether the custom clip is empty: If that's the case, it will simply not paint anything. Given that that's allowed by clutter_actor_paint(), the paint volume should also follow here and return an empty paint volume in case the custom clip is empty. Part-of: --- clutter/clutter/clutter-actor.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 9ba0050a8..cabd95f8f 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -5701,6 +5701,21 @@ clutter_actor_update_default_paint_volume (ClutterActor *self, if (priv->needs_allocation) return FALSE; + if (priv->has_clip) + { + graphene_point3d_t origin; + + origin.x = priv->clip.origin.x; + origin.y = priv->clip.origin.y; + origin.z = 0; + + clutter_paint_volume_set_origin (volume, &origin); + clutter_paint_volume_set_width (volume, priv->clip.size.width); + clutter_paint_volume_set_height (volume, priv->clip.size.height); + + return TRUE; + } + /* we start from the allocation */ clutter_paint_volume_set_width (volume, priv->allocation.x2 - priv->allocation.x1); @@ -5722,23 +5737,6 @@ clutter_actor_update_default_paint_volume (ClutterActor *self, { ClutterActor *child; - if (priv->has_clip && - priv->clip.size.width >= 0 && - priv->clip.size.height >= 0) - { - graphene_point3d_t origin; - - origin.x = priv->clip.origin.x; - origin.y = priv->clip.origin.y; - origin.z = 0; - - clutter_paint_volume_set_origin (volume, &origin); - clutter_paint_volume_set_width (volume, priv->clip.size.width); - clutter_paint_volume_set_height (volume, priv->clip.size.height); - - return TRUE; - } - /* if we don't have children we just bail out here... */ if (priv->n_children == 0) return res;