[NUI][API10] Let LottieAnimationView use InternalVisual API
authorEunki Hong <eunkiki.hong@samsung.com>
Tue, 16 May 2023 16:49:39 +0000 (01:49 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 17 May 2023 02:03:23 +0000 (11:03 +0900)
To avoid useless PropertyValue class creation, let we change
to visual use InternalVisual APIs.

Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/internal/Interop/Interop.View.cs
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs

index 3d58662..36c0b28 100755 (executable)
@@ -95,12 +95,27 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_DoActionWithEmptyAttributes")]
             public static extern void DoActionWithEmptyAttributes(HandleRef control, int visualIndex, int actionId);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_DoActionWithSingleIntAttributes")]
+            public static extern void DoActionWithSingleIntAttributes(HandleRef control, int visualIndex, int actionId, int actionValue);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_InternalUpdateVisualPropertyBool")]
+            public static extern int InternalUpdateVisualPropertyBool(HandleRef control, int visualIndex, int visualPropertyIndex, bool valBool);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_InternalUpdateVisualPropertyFloat")]
             public static extern int InternalUpdateVisualPropertyFloat(HandleRef control, int visualIndex, int visualPropertyIndex, float valFloat);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_InternalUpdateVisualPropertyInt")]
             public static extern int InternalUpdateVisualPropertyInt(HandleRef control, int visualIndex, int visualPropertyIndex, int valInt);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_InternalUpdateVisualPropertyIntPair")]
+            public static extern int InternalUpdateVisualPropertyIntPair(HandleRef control, int visualIndex, int visualPropertyIndex, int valInt1, int valInt2);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_InternalUpdateVisualPropertyString")]
+            public static extern int InternalUpdateVisualPropertyString(HandleRef control, int visualIndex, int visualPropertyIndex, string valString);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_InternalUpdateVisualPropertyStringPair")]
+            public static extern int InternalUpdateVisualPropertyStringPair(HandleRef control, int visualIndex, int visualPropertyIndex, string valString1, string valString2);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_InternalUpdateVisualPropertyVector4")]
             public static extern int InternalUpdateVisualPropertyVector4(HandleRef control, int visualIndex, int visualPropertyIndex, HandleRef vector4);
 
index 36820c1..20ffb89 100755 (executable)
@@ -178,24 +178,13 @@ namespace Tizen.NUI.BaseComponents
             get
             {
                 NUILog.Debug($"< Get!");
-                using PropertyMap map = base.Image;
-                var ret = 0;
-                if (map != null)
-                {
-                    using PropertyValue val = map.Find(ImageVisualProperty.PlayState);
-                    if (val != null)
-                    {
-                        if (val.Get(out ret))
-                        {
-                            currentStates.playState = (PlayStateType)ret;
-                            NUILog.Debug($"gotten play state={ret} >");
-                        }
-                    }
-                }
-                else
-                {
-                    Tizen.Log.Error(tag, $"<[ERROR][{GetId()}]Fail to get PlayState from dali currentStates.playState={currentStates.playState}>");
-                }
+
+                int ret = 0;
+                Interop.View.InternalRetrievingVisualPropertyInt(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.PlayState, out ret);
+
+                currentStates.playState = (PlayStateType)ret;
+                NUILog.Debug($"gotten play state={currentStates.playState} >");
+
                 return currentStates.playState;
             }
         }
@@ -211,22 +200,10 @@ namespace Tizen.NUI.BaseComponents
                 int ret = currentStates.totalFrame;
                 if (ret == -1)
                 {
-                    // TODO : Could we get this value without base.Image?
-                    using PropertyMap map = base.Image;
-                    if (map != null)
-                    {
-                        using PropertyValue val = map.Find(ImageVisualProperty.TotalFrameNumber);
-                        if (val != null)
-                        {
-                            if (val.Get(out ret))
-                            {
-                                NUILog.Debug($"TotalFrameNumber get! ret={ret}");
-                                currentStates.totalFrame = ret;
-                                return ret;
-                            }
-                        }
-                    }
-                    Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get TotalFrameNumber from dali>");
+                    Interop.View.InternalRetrievingVisualPropertyInt(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.TotalFrameNumber, out ret);
+
+                    currentStates.totalFrame = ret;
+                    NUILog.Debug($"TotalFrameNumber get! ret={ret}");
                 }
                 return ret;
             }
@@ -269,27 +246,16 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 NUILog.Debug($"<[{GetId()}]SET frame={value}>");
-                using PropertyValue attribute = new PropertyValue(value);
-                DoAction(ImageView.Property.IMAGE, ActionJumpTo, attribute);
+
+                Interop.View.DoActionWithSingleIntAttributes(this.SwigCPtr, ImageView.Property.IMAGE, ActionJumpTo, value);
             }
             get
             {
-                // TODO : Could we get this value without base.Image?
                 int ret = 0;
-                using PropertyMap map = base.Image;
-                if (map != null)
-                {
-                    using PropertyValue val = map.Find(ImageVisualProperty.CurrentFrameNumber);
-                    if (val != null)
-                    {
-                        if (val.Get(out ret))
-                        {
-                            NUILog.Debug($"CurrentFrameNumber get! val={ret}");
-                            return ret;
-                        }
-                    }
-                }
-                Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get CurrentFrameNumber from dali!! ret={ret}>");
+
+                Interop.View.InternalRetrievingVisualPropertyInt(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.CurrentFrameNumber, out ret);
+
+                NUILog.Debug($"CurrentFrameNumber get! val={ret}");
                 return ret;
             }
         }
@@ -321,11 +287,8 @@ namespace Tizen.NUI.BaseComponents
                     currentStates.loopMode = (LoopingModeType)value;
 
                     NUILog.Debug($"<[{GetId()}] SET loopMode={currentStates.loopMode}>");
-                    using PropertyMap map = new PropertyMap();
-                    using PropertyValue loopMode = new PropertyValue((int)currentStates.loopMode);
-                    map.Add(ImageVisualProperty.LoopingMode, loopMode);
-                    using PropertyValue attribute = new PropertyValue(map);
-                    DoAction(ImageView.Property.IMAGE, ActionUpdateProperty, attribute);
+
+                    Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.LoopingMode, (int)currentStates.loopMode);
                 }
             }
             get
@@ -377,11 +340,8 @@ namespace Tizen.NUI.BaseComponents
                     currentStates.loopCount = value;
 
                     NUILog.Debug($"<[{GetId()}]SET currentStates.loopCount={currentStates.loopCount}>");
-                    using PropertyMap map = new PropertyMap();
-                    using PropertyValue loopCnt = new PropertyValue(currentStates.loopCount);
-                    map.Add(ImageVisualProperty.LoopCount, loopCnt);
-                    using PropertyValue attribute = new PropertyValue(map);
-                    DoAction(ImageView.Property.IMAGE, ActionUpdateProperty, attribute);
+
+                    Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.LoopCount, currentStates.loopCount);
                 }
             }
             get
@@ -418,11 +378,8 @@ namespace Tizen.NUI.BaseComponents
                     currentStates.stopEndAction = (StopBehaviorType)value;
 
                     NUILog.Debug($"<[{GetId()}]SET val={currentStates.stopEndAction}>");
-                    using PropertyMap map = new PropertyMap();
-                    using PropertyValue stopAction = new PropertyValue((int)currentStates.stopEndAction);
-                    map.Add(ImageVisualProperty.StopBehavior, stopAction);
-                    using PropertyValue attribute = new PropertyValue(map);
-                    DoAction(ImageView.Property.IMAGE, ActionUpdateProperty, attribute);
+
+                    Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.StopBehavior, (int)currentStates.stopEndAction);
                 }
             }
             get
@@ -463,11 +420,8 @@ namespace Tizen.NUI.BaseComponents
                     currentStates.redrawInScalingDown = value;
 
                     NUILog.Debug($"<[{GetId()}]SET currentStates.redrawInScalingDown={currentStates.redrawInScalingDown}>");
-                    using PropertyMap map = new PropertyMap();
-                    using PropertyValue redraw = new PropertyValue(currentStates.redrawInScalingDown);
-                    map.Add(ImageVisualProperty.RedrawInScalingDown, redraw);
-                    using PropertyValue action = new PropertyValue(map);
-                    DoAction(ImageView.Property.IMAGE, ActionUpdateProperty, action);
+
+                    Interop.View.InternalUpdateVisualPropertyBool(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.RedrawInScalingDown, currentStates.redrawInScalingDown);
                 }
             }
             get
@@ -507,17 +461,8 @@ namespace Tizen.NUI.BaseComponents
                 currentStates.framePlayRangeMin = minFrame;
                 currentStates.framePlayRangeMax = maxFrame;
 
-                using PropertyArray array = new PropertyArray();
-                using PropertyValue min = new PropertyValue(currentStates.framePlayRangeMin);
-                using PropertyValue max = new PropertyValue(currentStates.framePlayRangeMax);
-                array.PushBack(min);
-                array.PushBack(max);
+                Interop.View.InternalUpdateVisualPropertyIntPair(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.PlayRange, currentStates.framePlayRangeMin, currentStates.framePlayRangeMax);
 
-                using PropertyMap map = new PropertyMap();
-                using PropertyValue range = new PropertyValue(array);
-                map.Add(ImageVisualProperty.PlayRange, range);
-                using PropertyValue action = new PropertyValue(map);
-                DoAction(ImageView.Property.IMAGE, ActionUpdateProperty, action);
                 NUILog.Debug($"  [{GetId()}] currentStates.min:({currentStates.framePlayRangeMin}, max:{currentStates.framePlayRangeMax})>");
             }
         }
@@ -632,20 +577,15 @@ namespace Tizen.NUI.BaseComponents
                 currentStates.mark1 = marker1;
                 currentStates.mark2 = marker2;
 
-                using PropertyArray array = new PropertyArray();
-                using PropertyValue mark1 = new PropertyValue(currentStates.mark1);
-                array.PushBack(mark1);
-                using PropertyValue mark2 = new PropertyValue(currentStates.mark2);
-                if (marker2 != null)
+                if (string.IsNullOrEmpty(currentStates.mark2))
                 {
-                    array.PushBack(mark2);
+                    Interop.View.InternalUpdateVisualPropertyString(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.PlayRange, currentStates.mark1);
+                }
+                else
+                {
+                    Interop.View.InternalUpdateVisualPropertyStringPair(this.SwigCPtr, ImageView.Property.IMAGE, ImageVisualProperty.PlayRange, currentStates.mark1, currentStates.mark2);
                 }
 
-                using PropertyMap map = new PropertyMap();
-                using PropertyValue range = new PropertyValue(array);
-                map.Add(ImageVisualProperty.PlayRange, range);
-                using PropertyValue actionProperty = new PropertyValue(map);
-                DoAction(ImageView.Property.IMAGE, ActionUpdateProperty, actionProperty);
                 NUILog.Debug($"  [{GetId()}] currentStates.mark1:{currentStates.mark1}, mark2:{currentStates.mark2} >");
             }
         }