From 82dc26b4ae9d4422afe0f421514d51a0fa2e0d6f Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 8 May 2024 21:59:46 +0900 Subject: [PATCH] [NUI] Do not ask DALi to get BackgroundImage url 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 --- src/Tizen.NUI/src/public/BaseComponents/View.cs | 9 ++++- .../public/BaseComponents/ViewBindableProperty.cs | 41 ++++++++++++++-------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 3d71dab..d78bc42 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -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 cachedNUIViewBackgroundImagePropertyKeyList = new List { + ImageVisualProperty.URL, + ImageVisualProperty.SynchronousLoading, + }; + private string backgroundImageUrl = null; + private bool backgroundImageSynchronousLoading = false; + // List of constraints private Constraint widthConstraint = null; private Constraint heightConstraint = null; diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index e581f72..402bbe3 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -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; } -- 2.7.4