From 0737fe6b8cf2d9dd1fe10ee3c4a0dd36dc54e985 Mon Sep 17 00:00:00 2001 From: sunghyun kim Date: Thu, 30 Nov 2023 12:48:29 +0900 Subject: [PATCH] [NUI] Add EnableFrameCache in LottieAnimationView --- .../public/BaseComponents/LottieAnimationView.cs | 38 ++++++++++++++++++++++ .../LottieAnimationViewBindableProperty.cs | 18 ++++++++++ .../src/public/Visuals/VisualConstants.cs | 11 +++++++ 3 files changed, 67 insertions(+) diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index 1ffaded..7ce0558 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -160,6 +160,7 @@ namespace Tizen.NUI.BaseComponents currentStates.framePlayRangeMin = -1; currentStates.framePlayRangeMax = -1; currentStates.totalFrame = -1; + currentStates.enableFrameCache = false; string ret = (value == null ? "" : value); currentStates.url = ret; @@ -534,6 +535,42 @@ namespace Tizen.NUI.BaseComponents 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 @@ namespace Tizen.NUI.BaseComponents internal bool redrawInScalingDown; internal int desiredWidth, desiredHeight; internal bool synchronousLoading; + internal bool enableFrameCache; internal bool changed; }; private states currentStates; diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs index f4fefd8..e0ffb3d 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs @@ -129,5 +129,23 @@ namespace Tizen.NUI.BaseComponents var instance = (Tizen.NUI.BaseComponents.LottieAnimationView)bindable; return instance.InternalRedrawInScalingDown; }); + + /// + /// EnableFrameCacheProperty + /// + [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; + }); } } diff --git a/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs b/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs index a4100ae..bfbdbd5 100755 --- a/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs @@ -987,6 +987,17 @@ namespace Tizen.NUI /// [EditorBrowsable(EditorBrowsableState.Never)] public static readonly int MarkerInfo = NDalic.ImageVisualOrientationCorrection + 15; + + /// + /// @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 + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly int EnableFrameCache = NDalic.ImageVisualOrientationCorrection + 16; } /// -- 2.7.4