mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
Deprecate ges_layer_set_priority
Keep old behaviour but deprecate the method and property as ges_timeline_move_layer should be used instead.
This commit is contained in:
parent
11b24922a1
commit
136456e180
4 changed files with 44 additions and 34 deletions
|
@ -354,6 +354,7 @@ G_GNUC_INTERNAL GList* ges_clip_create_track_elements (GESClip *clip
|
|||
* GESLayer *
|
||||
****************************************************/
|
||||
G_GNUC_INTERNAL gboolean ges_layer_resync_priorities (GESLayer * layer);
|
||||
G_GNUC_INTERNAL void layer_set_priority (GESLayer * layer, guint priority, gboolean emit);
|
||||
|
||||
/****************************************************
|
||||
* GESTrackElement *
|
||||
|
|
|
@ -105,7 +105,8 @@ ges_layer_set_property (GObject * object, guint property_id,
|
|||
|
||||
switch (property_id) {
|
||||
case PROP_PRIORITY:
|
||||
ges_layer_set_priority (layer, g_value_get_uint (value));
|
||||
GST_FIXME ("Deprecated, use ges_timeline_move_layer instead");
|
||||
layer_set_priority (layer, g_value_get_uint (value), FALSE);
|
||||
break;
|
||||
case PROP_AUTO_TRANSITION:
|
||||
ges_layer_set_auto_transition (layer, g_value_get_boolean (value));
|
||||
|
@ -165,6 +166,10 @@ ges_layer_class_init (GESLayerClass * klass)
|
|||
*
|
||||
* Note that the timeline needs to be commited (with #ges_timeline_commit)
|
||||
* for the change to be taken into account.
|
||||
*
|
||||
* Deprecated:1.16.0: use #ges_timeline_move_layer instead. This deprecation means
|
||||
* that you will not need to handle layer priorities at all yourself, GES
|
||||
* will make sure there is never 'gaps' between layer priorities.
|
||||
*/
|
||||
g_object_class_install_property (object_class, PROP_PRIORITY,
|
||||
g_param_spec_uint ("priority", "Priority",
|
||||
|
@ -282,6 +287,23 @@ ges_layer_resync_priorities (GESLayer * layer)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
layer_set_priority (GESLayer * layer, guint priority, gboolean emit)
|
||||
{
|
||||
GST_DEBUG ("layer:%p, priority:%d", layer, priority);
|
||||
|
||||
if (priority != layer->priv->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);
|
||||
}
|
||||
|
||||
if (emit)
|
||||
g_object_notify (G_OBJECT (layer), "priority");
|
||||
}
|
||||
|
||||
static void
|
||||
new_asset_cb (GESAsset * source, GAsyncResult * res, NewAssetUData * udata)
|
||||
{
|
||||
|
@ -413,23 +435,19 @@ ges_layer_remove_clip (GESLayer * layer, GESClip * clip)
|
|||
*
|
||||
* Sets the layer to the given @priority. See the documentation of the
|
||||
* priority property for more information.
|
||||
*
|
||||
* Deprecated:1.16.0: use #ges_timeline_move_layer instead. This deprecation means
|
||||
* that you will not need to handle layer priorities at all yourself, GES
|
||||
* will make sure there is never 'gaps' between layer priorities.
|
||||
*/
|
||||
void
|
||||
ges_layer_set_priority (GESLayer * layer, guint priority)
|
||||
{
|
||||
g_return_if_fail (GES_IS_LAYER (layer));
|
||||
|
||||
GST_DEBUG ("layer:%p, priority:%d", layer, priority);
|
||||
GST_FIXME ("Deprecated, use ges_timeline_move_layer instead");
|
||||
|
||||
if (priority != layer->priv->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);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (layer), "priority");
|
||||
layer_set_priority (layer, priority, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -744,9 +744,7 @@ _resync_layers (GESTimeline * timeline)
|
|||
|
||||
timeline->priv->resyncing_layers = TRUE;
|
||||
for (tmp = timeline->layers; tmp; tmp = tmp->next) {
|
||||
GST_ERROR_OBJECT (tmp->data, "New index: %d", i);
|
||||
ges_layer_set_priority (tmp->data, i);
|
||||
|
||||
layer_set_priority (tmp->data, i, TRUE);
|
||||
i++;
|
||||
}
|
||||
timeline->priv->resyncing_layers = FALSE;
|
||||
|
@ -2540,6 +2538,9 @@ static void
|
|||
layer_priority_changed_cb (GESLayer * layer,
|
||||
GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
|
||||
{
|
||||
if (timeline->priv->resyncing_layers)
|
||||
return;
|
||||
|
||||
timeline->layers = g_list_sort (timeline->layers, (GCompareFunc)
|
||||
sort_layers);
|
||||
}
|
||||
|
|
|
@ -26,24 +26,23 @@
|
|||
GST_START_TEST (test_layer_properties)
|
||||
{
|
||||
GESTimeline *timeline;
|
||||
GESLayer *layer;
|
||||
GESLayer *layer, *layer1;
|
||||
GESTrack *track;
|
||||
GESTrackElement *trackelement;
|
||||
GESClip *clip;
|
||||
|
||||
/* Timeline and 1 Layer */
|
||||
timeline = ges_timeline_new ();
|
||||
layer = (GESLayer *) ges_layer_new ();
|
||||
|
||||
/* The default priority is 0 */
|
||||
fail_unless ((layer = ges_timeline_append_layer (timeline)));
|
||||
fail_unless_equals_int (ges_layer_get_priority (layer), 0);
|
||||
|
||||
/* Layers are initially floating, once we add them to the timeline,
|
||||
* the timeline will take that reference. */
|
||||
fail_unless (g_object_is_floating (layer));
|
||||
fail_unless (ges_timeline_add_layer (timeline, layer));
|
||||
fail_if (g_object_is_floating (layer));
|
||||
|
||||
fail_unless ((layer1 = ges_timeline_append_layer (timeline)));
|
||||
fail_unless_equals_int (ges_layer_get_priority (layer1), 1);
|
||||
|
||||
track = GES_TRACK (ges_video_track_new ());
|
||||
fail_unless (track != NULL);
|
||||
fail_unless (ges_timeline_add_track (timeline, track));
|
||||
|
@ -92,7 +91,7 @@ GST_START_TEST (test_layer_properties)
|
|||
51, MIN_NLE_PRIO + TRANSITIONS_HEIGHT + LAYER_HEIGHT * 31, TRUE);
|
||||
|
||||
/* and back to 0 */
|
||||
g_object_set (layer, "priority", 0, NULL);
|
||||
fail_unless (ges_timeline_move_layer (timeline, layer, 0));
|
||||
assert_equals_int (ges_layer_get_priority (layer), 0);
|
||||
assert_equals_uint64 (_PRIORITY (clip), 1);
|
||||
ges_timeline_commit (timeline);
|
||||
|
@ -121,16 +120,9 @@ GST_START_TEST (test_layer_priorities)
|
|||
|
||||
/* Timeline and 3 Layer */
|
||||
timeline = ges_timeline_new ();
|
||||
layer1 = (GESLayer *) ges_layer_new ();
|
||||
layer2 = (GESLayer *) ges_layer_new ();
|
||||
layer3 = (GESLayer *) ges_layer_new ();
|
||||
|
||||
ges_layer_set_priority (layer2, 1);
|
||||
ges_layer_set_priority (layer3, 2);
|
||||
|
||||
fail_unless (ges_timeline_add_layer (timeline, layer1));
|
||||
fail_unless (ges_timeline_add_layer (timeline, layer2));
|
||||
fail_unless (ges_timeline_add_layer (timeline, layer3));
|
||||
fail_unless ((layer1 = ges_timeline_append_layer (timeline)));
|
||||
fail_unless ((layer2 = ges_timeline_append_layer (timeline)));
|
||||
fail_unless ((layer3 = ges_timeline_append_layer (timeline)));
|
||||
fail_unless_equals_int (ges_layer_get_priority (layer1), 0);
|
||||
fail_unless_equals_int (ges_layer_get_priority (layer2), 1);
|
||||
fail_unless_equals_int (ges_layer_get_priority (layer3), 2);
|
||||
|
@ -189,9 +181,7 @@ GST_START_TEST (test_layer_priorities)
|
|||
assert_equals_int (prio3, 1 + MIN_NLE_PRIO + LAYER_HEIGHT * 2);
|
||||
|
||||
/* Move layers around */
|
||||
g_object_set (layer1, "priority", 2, NULL);
|
||||
g_object_set (layer2, "priority", 0, NULL);
|
||||
g_object_set (layer3, "priority", 1, NULL);
|
||||
fail_unless (ges_timeline_move_layer (timeline, layer1, 2));
|
||||
ges_timeline_commit (timeline);
|
||||
|
||||
/* And check the new priorities */
|
||||
|
|
Loading…
Reference in a new issue