[NUI] Do not ask DALi to get BackgroundImage url
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 8 May 2024 12:59:46 +0000 (21:59 +0900)
committerbshsqa <32317749+bshsqa@users.noreply.github.com>
Mon, 13 May 2024 07:08:49 +0000 (16:08 +0900)
We don't need to ask DALi side always when we want to get
the url of image.

Instead, just keep it at NUI View side, and use it.

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

index 3d71dab03e2e15bc43bbe13b7904efc5e77a02dc..d78bc4249080be89c350f6372bee40a6c5f9a181 100755 (executable)
@@ -44,13 +44,20 @@ namespace Tizen.NUI.BaseComponents
         private int widthPolicy = LayoutParamPolicies.WrapContent; // Layout width policy
         private int heightPolicy = LayoutParamPolicies.WrapContent; // Layout height policy
         private float weight = 0.0f; // Weighting of child View in a Layout
-        private bool backgroundImageSynchronousLoading = false;
         private bool excludeLayouting = false;
         private LayoutTransition layoutTransition;
         private TransitionOptions transitionOptions = null;
         private ThemeData themeData;
         private bool isThemeChanged = false;
 
+        // Collection of image-sensitive properties, and need to update C# side cache value.
+        private static readonly List<int> cachedNUIViewBackgroundImagePropertyKeyList = new List<int> {
+            ImageVisualProperty.URL,
+            ImageVisualProperty.SynchronousLoading,
+        };
+        private string backgroundImageUrl = null;
+        private bool backgroundImageSynchronousLoading = false;
+
         // List of constraints
         private Constraint widthConstraint = null;
         private Constraint heightConstraint = null;
index e581f729d48097d118d88f690f5e8bb6d4c8a2f9..402bbe3e93f50d838797ec88c88ba7af0b290e62 100755 (executable)
@@ -282,11 +282,8 @@ namespace Tizen.NUI.BaseComponents
         internal static object GetInternalBackgroundImageProperty(BindableObject bindable)
         {
             var view = (View)bindable;
-            string backgroundImage = "";
 
-            Interop.View.InternalRetrievingVisualPropertyString(view.SwigCPtr, Property.BACKGROUND, ImageVisualProperty.URL, out backgroundImage);
-
-            return backgroundImage;
+            return (string)view.backgroundImageUrl;
         }
 
 
@@ -336,21 +333,31 @@ namespace Tizen.NUI.BaseComponents
             var view = (View)bindable;
             if (newValue != null)
             {
-                var propertyValue = new PropertyValue((PropertyMap)newValue);
-                Object.SetProperty(view.SwigCPtr, Property.BACKGROUND, propertyValue);
-
-                view.backgroundExtraData = null;
+                PropertyMap map = (PropertyMap)newValue;
 
                 // Background extra data is not valid anymore. We should ignore lazy UpdateBackgroundExtraData
+                view.backgroundExtraData = null;
                 view.backgroundExtraDataUpdatedFlag = BackgroundExtraDataUpdatedFlag.None;
-                if (view.backgroundExtraDataUpdateProcessAttachedFlag)
+
+                // Update backgroundImageUrl and backgroundImageSynchronousLoading from Map
+                foreach (int key in cachedNUIViewBackgroundImagePropertyKeyList)
                 {
-                    ProcessorController.Instance.ProcessorOnceEvent -= view.UpdateBackgroundExtraData;
-                    view.backgroundExtraDataUpdateProcessAttachedFlag = false;
+                    using PropertyValue propertyValue = map.Find(key);
+                    if (propertyValue != null)
+                    {
+                        if (key == ImageVisualProperty.URL)
+                        {
+                            propertyValue.Get(out view.backgroundImageUrl);
+                        }
+                        else if (key == ImageVisualProperty.SynchronousLoading)
+                        {
+                            propertyValue.Get(out view.backgroundImageSynchronousLoading);
+                        }
+                    }
                 }
 
-                propertyValue.Dispose();
-                propertyValue = null;
+                using var mapValue = new PropertyValue(map);
+                Object.SetProperty(view.SwigCPtr, Property.BACKGROUND, mapValue);
             }
         }
         internal static object GetInternalBackgroundProperty(BindableObject bindable)
@@ -3508,6 +3515,8 @@ namespace Tizen.NUI.BaseComponents
             {
                 backgroundExtraDataUpdatedFlag &= ~BackgroundExtraDataUpdatedFlag.Background;
 
+                backgroundImageUrl = null;
+
                 var empty = new PropertyValue();
                 // Clear background
                 Object.SetProperty(SwigCPtr, Property.BACKGROUND, empty);
@@ -3521,6 +3530,8 @@ namespace Tizen.NUI.BaseComponents
                 value = value.Replace("*Resource*", resource);
             }
 
+            backgroundImageUrl = value;
+
             // Fast return for usual cases.
             if (backgroundExtraData == null && !backgroundImageSynchronousLoading)
             {
@@ -3627,9 +3638,11 @@ namespace Tizen.NUI.BaseComponents
                 return;
             }
 
+            // Background property will be Color after now. Remove background image url information.
+            backgroundImageUrl = null;
+
             if (backgroundExtraData == null)
             {
-
                 Object.InternalSetPropertyVector4(SwigCPtr, View.Property.BACKGROUND, ((Color)value).SwigCPtr);
                 return;
             }