From 19bf43a38ea9068b1b8687e7c022b82694fcd10a Mon Sep 17 00:00:00 2001 From: sunghyun kim Date: Thu, 30 Nov 2023 12:48:29 +0900 Subject: [PATCH 1/2] [NUI] Add EnableFrameCache in LottieAnimationView --- .../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 1ffadedb57c..7ce05584c65 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -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; diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs index f4fefd828d0..e0ffb3de4b7 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationViewBindableProperty.cs @@ -129,5 +129,23 @@ public partial class LottieAnimationView 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 a4100ae50c4..bfbdbd52672 100755 --- a/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs @@ -987,6 +987,17 @@ public struct ImageVisualProperty /// [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; } /// From d0d034b2d20f45b1718a1c9585fa37ac8eded796 Mon Sep 17 00:00:00 2001 From: Eunki Hong Date: Sun, 31 Dec 2023 10:35:16 +0900 Subject: [PATCH 2/2] [NUI] Support NativeImageQueue creation with queue count Let we allow to create NativeImageQueue with queue count. Previously, we only allow to create the NativeImageQueue based on the environment value "DALI_TBM_SURFACE_QUEUE_SIZE". (This value is 3 as default) It will be useful if some user want to reduce the queue count for some cases, not for whole queue. relative DALi patches : https://review.tizen.org/gerrit/c/platform/core/uifw/dali-adaptor/+/303523 https://review.tizen.org/gerrit/c/platform/core/uifw/dali-csharp-binder/+/303524 Signed-off-by: Eunki Hong --- .../Interop/Interop.NativeImageQueue.cs | 6 ++++ .../src/public/Images/NativeImageQueue.cs | 29 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.NativeImageQueue.cs b/src/Tizen.NUI/src/internal/Interop/Interop.NativeImageQueue.cs index 0ded6365997..a8f786666e2 100644 --- a/src/Tizen.NUI/src/internal/Interop/Interop.NativeImageQueue.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.NativeImageQueue.cs @@ -25,6 +25,9 @@ internal static partial class NativeImageQueue [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_NativeImageQueuePtr")] public static extern IntPtr NewHandle(uint width, uint height, int colorFormat); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_NativeImageQueuePtr_2")] + public static extern IntPtr NewHandle(uint queueCount, uint width, uint height, int colorFormat); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_NativeImageQueue_GetPtr")] public static extern IntPtr Get(IntPtr queue); @@ -41,6 +44,9 @@ internal static partial class NativeImageQueue [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] public static extern bool EnqueueBuffer(IntPtr queue, IntPtr buffer); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_NativeImageQueue_GetQueueCount")] + public static extern uint GetQueueCount(IntPtr queue); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_NativeImageQueue_GenerateUrl")] public static extern IntPtr GenerateUrl(IntPtr queue); } diff --git a/src/Tizen.NUI/src/public/Images/NativeImageQueue.cs b/src/Tizen.NUI/src/public/Images/NativeImageQueue.cs index 4057e45642e..94c3df430a6 100644 --- a/src/Tizen.NUI/src/public/Images/NativeImageQueue.cs +++ b/src/Tizen.NUI/src/public/Images/NativeImageQueue.cs @@ -87,7 +87,22 @@ public enum ColorFormat /// A color format of queue. /// A NativeImageQueue. [EditorBrowsable(EditorBrowsableState.Never)] - public NativeImageQueue(uint width, uint height, ColorFormat colorFormat) : this(Interop.NativeImageQueue.NewHandle(width, height, (int)colorFormat), true) + public NativeImageQueue(uint width, uint height, ColorFormat colorFormat) : this(0, width, height, colorFormat) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Creates an initialized NativeImageQueue with queue count and size and color format. + /// + /// Since queueCount can increase the memory usage, we recommened queueCount value is less or equal than 3. + /// The number of queue count. Use system default value if it is 0. + /// A Width of queue. + /// A Height of queue. + /// A color format of queue. + /// A NativeImageQueue. + [EditorBrowsable(EditorBrowsableState.Never)] + public NativeImageQueue(uint queueCount, uint width, uint height, ColorFormat colorFormat) : this(Interop.NativeImageQueue.NewHandle(queueCount, width, height, (int)colorFormat), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -97,6 +112,18 @@ internal NativeImageQueue(IntPtr cPtr, bool cMemoryOwn) : base(Interop.NativeIma handle = cPtr; } + /// + /// The number of queue. + /// + /// Hidden API: Only for inhouse or developing usage. The behavior and interface can be changed anytime. + [EditorBrowsable(EditorBrowsableState.Never)] + public uint GetQueueCount() + { + uint ret = Interop.NativeImageQueue.GetQueueCount(this.SwigCPtr.Handle); + NDalicPINVOKE.ThrowExceptionIfExists(); + return ret; + } + /// /// Generate Url from native image queue. ///