Skip to content

Commit

Permalink
[NUI] Add EnableFrameCache in LottieAnimationView
Browse files Browse the repository at this point in the history
  • Loading branch information
tscholb authored and everLEEst committed Jan 2, 2024
1 parent 018d97a commit 0737fe6
Showing 3 changed files with 67 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs
Original file line number Diff line number Diff line change
@@ -160,6 +160,7 @@ private string InternalURL
currentStates.framePlayRangeMin = -1;
currentStates.framePlayRangeMax = -1;
currentStates.totalFrame = -1;
currentStates.enableFrameCache = false;

string ret = (value == null ? "" : value);
currentStates.url = ret;
@@ -534,6 +535,42 @@ private bool InternalRedrawInScalingDown
return currentStates.redrawInScalingDown;
}
}


[EditorBrowsable(EditorBrowsableState.Never)]
public bool EnableFrameCache
{
get
{
return (bool)GetValue(EnableFrameCacheProperty);
}
set
{
SetValue(EnableFrameCacheProperty, value);
NotifyPropertyChanged();
}
}

private bool InternalEnableFrameCache
{
set
{
if (currentStates.enableFrameCache != value)
{
currentStates.changed = true;
currentStates.enableFrameCache = value;

NUILog.Debug($"<[{GetId()}]SET currentStates.EnableFrameCache={currentStates.enableFrameCache}>");

Interop.View.InternalUpdateVisualPropertyBool(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.EnableFrameCache, currentStates.enableFrameCache);
}
}
get
{
NUILog.Debug($"EnableFrameCache get! {currentStates.enableFrameCache}");
return currentStates.enableFrameCache;
}
}
#endregion Property


@@ -1252,6 +1289,7 @@ private struct states
internal bool redrawInScalingDown;
internal int desiredWidth, desiredHeight;
internal bool synchronousLoading;
internal bool enableFrameCache;
internal bool changed;
};
private states currentStates;
Original file line number Diff line number Diff line change
@@ -129,5 +129,23 @@ public partial class LottieAnimationView
var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable;
return instance.InternalRedrawInScalingDown;
});

/// <summary>
/// EnableFrameCacheProperty
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty EnableFrameCacheProperty = BindableProperty.Create(nameof(EnableFrameCache), typeof(bool), typeof(Tizen.NUI.BaseComponents.LottieAnimationView), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable;
if (newValue != null)
{
instance.InternalEnableFrameCache = (bool)newValue;
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable;
return instance.InternalEnableFrameCache;
});
}
}
11 changes: 11 additions & 0 deletions src/Tizen.NUI/src/public/Visuals/VisualConstants.cs
Original file line number Diff line number Diff line change
@@ -987,6 +987,17 @@ public struct ImageVisualProperty
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly int MarkerInfo = NDalic.ImageVisualOrientationCorrection + 15;

/// <summary>
/// @brief Whether to animated image visual uses fixed cache or not.
/// @details type Property::BOOLEAN.
/// If this property is true, animated image visual uses fixed cache for loading and keeps loaded frame
/// until the visual is removed. It reduces CPU cost when the animated image will be looping.
/// But it can spend a lot of memory if the resource has high resolution image or many frame count.
/// @note It is used in the AnimatedImageVisual. The default is false
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly int EnableFrameCache = NDalic.ImageVisualOrientationCorrection + 16;
}

/// <summary>

0 comments on commit 0737fe6

Please sign in to comment.