From f79c73789f81ffeedc860229c91956016f96863d Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 11 Aug 2016 10:36:44 -0400 Subject: [PATCH] layer: Handle operation priorities All operations should have higher priorites and sources should be on top of those. We now first set the operations priorities in a first pass and then stack sources on top of those. Differential Revision: https://phabricator.freedesktop.org/D1279 --- ges/ges-layer.c | 53 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/ges/ges-layer.c b/ges/ges-layer.c index 81602945f3..f7e984421a 100644 --- a/ges/ges-layer.c +++ b/ges/ges-layer.c @@ -218,36 +218,28 @@ ges_layer_init (GESLayer * self) _register_metas (self); } -/** - * ges_layer_resync_priorities: - * @layer: a #GESLayer - * - * Resyncs the priorities of the clips controlled by @layer. - * This method - */ -gboolean -ges_layer_resync_priorities (GESLayer * layer) +static gint +ges_layer_resync_priorities_by_type (GESLayer * layer, + gint starting_priority, GType type) { GstClockTime next_reset = 0; - gint priority = 1; + gint priority = starting_priority, max_priority = priority; GList *tmp; GESTimelineElement *element; - GST_INFO_OBJECT (layer, "Resync priorities (prio: %d)", - layer->priv->priority); - for (tmp = layer->priv->clips_start; tmp; tmp = tmp->next) { element = GES_TIMELINE_ELEMENT (tmp->data); if (GES_IS_TRANSITION_CLIP (element)) { + /* Blindly set transitions priorities to 0 */ _set_priority0 (element, 0); - continue; - } + } else if (!g_type_is_a (G_OBJECT_TYPE (element), type)) + continue; if (element->start > next_reset) { - priority = 1; + priority = starting_priority; next_reset = 0; } @@ -256,8 +248,34 @@ ges_layer_resync_priorities (GESLayer * layer) _set_priority0 (element, priority); priority = priority + GES_CONTAINER_HEIGHT (element); + + if (priority > max_priority) + max_priority = priority; } + return max_priority; +} + +/** + * ges_layer_resync_priorities: + * @layer: a #GESLayer + * + * Resyncs the priorities of the clips controlled by @layer. + */ +gboolean +ges_layer_resync_priorities (GESLayer * layer) +{ + gint min_source_prios; + + GST_INFO_OBJECT (layer, "Resync priorities (prio: %d)", + layer->priv->priority); + + min_source_prios = ges_layer_resync_priorities_by_type (layer, 1, + GES_TYPE_OPERATION_CLIP); + + ges_layer_resync_priorities_by_type (layer, min_source_prios, + GES_TYPE_SOURCE_CLIP); + return TRUE; } @@ -398,6 +416,7 @@ ges_layer_set_priority (GESLayer * layer, guint priority) layer->priv->priority = priority; layer->min_nle_priority = (priority * LAYER_HEIGHT) + MIN_NLE_PRIO; layer->max_nle_priority = ((priority + 1) * LAYER_HEIGHT) + MIN_NLE_PRIO; + ges_layer_resync_priorities (layer); } @@ -530,7 +549,7 @@ ges_layer_add_clip (GESLayer * layer, GESClip * clip) g_return_val_if_fail (GES_IS_LAYER (layer), FALSE); g_return_val_if_fail (GES_IS_CLIP (clip), FALSE); - GST_DEBUG_OBJECT (layer, "adding clip: %s", GES_TIMELINE_ELEMENT_NAME (clip)); + GST_DEBUG_OBJECT (layer, "adding clip:%p", clip); priv = layer->priv; current_layer = ges_clip_get_layer (clip);