[NUI] Add EnableFrameCache in LottieAnimationView
authorsunghyun kim <scholb.kim@samsung.com>
Thu, 30 Nov 2023 03:48:29 +0000 (12:48 +0900)
committertscholb <scholb.kim@samsung.com>
Mon, 4 Dec 2023 04:05:59 +0000 (13:05 +0900)
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs
src/Tizen.NUI/src/public/Visuals/VisualConstants.cs

index bf94e9f..65cb53b 100755 (executable)
@@ -135,6 +135,7 @@ namespace Tizen.NUI.BaseComponents
                 currentStates.url = ret;
                 currentStates.changed = true;
                 currentStates.totalFrame = -1; // Reset cached totalFrame value;
+                currentStates.enableFrameCache = false;
 
                 NUILog.Debug($"<[{GetId()}]SET url={currentStates.url}");
 
@@ -443,6 +444,40 @@ namespace Tizen.NUI.BaseComponents
         // This is used for internal purpose. hidden API.
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected int SetDynamicProperty => ActionJumpTo + 1;
+        [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
 
 
@@ -1010,6 +1045,7 @@ namespace Tizen.NUI.BaseComponents
             internal List<Tuple<string, int, int>> contentInfo;
             internal string mark1, mark2;
             internal bool redrawInScalingDown;
+            internal bool enableFrameCache;
         };
         private states currentStates;
 
index f4fefd8..e0ffb3d 100755 (executable)
@@ -129,5 +129,23 @@ namespace Tizen.NUI.BaseComponents
             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;
+        });
     }
 }
index 23df9ca..c3afb75 100755 (executable)
@@ -959,6 +959,18 @@ namespace Tizen.NUI
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly int MaskingMode = NDalic.ImageVisualOrientationCorrection + 12;
+
+
+        /// <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 + 13;
     }
 
     /// <summary>