[NUI] Preload some static values
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 24 Oct 2023 01:47:09 +0000 (10:47 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 25 Oct 2023 12:48:44 +0000 (21:48 +0900)
Since C# initialize static values when that namespace / class access first time,
We need to access some static values at static Preload() timing.

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/internal/Common/Disposable.cs
src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs
src/Tizen.NUI/src/public/Animation/Animatable.cs
src/Tizen.NUI/src/public/Application/NUIApplication.cs
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/Common/BaseHandle.cs
src/Tizen.NUI/src/public/Common/Container.cs

index 7884c303e288c7d129b7dd258af439a2ac0577e8..72d1dc8ef47e0c8b845b43c364a00709bf5b094e 100644 (file)
@@ -25,6 +25,11 @@ namespace Tizen.NUI
     /// <since_tizen> 6 </since_tizen>
     public class Disposable : global::System.IDisposable
     {
+        static internal void Preload()
+        {
+            // Do nothing. Just call for load static values.
+        }
+
         /// <summary>
         /// The flag to check if it is already disposed of.
         /// </summary>
index a55f62275341e66e194e0835ddd90deed73b1d16..560684c28b56dccba57946e2a8b94ab31e18a143 100755 (executable)
@@ -245,6 +245,14 @@ namespace Tizen.NUI
         {
         }
 
+        static internal void Preload()
+        {
+            // Do nothing. Just call for load static values.
+            var temporalSwigExceptionHelper = swigExceptionHelper;
+            var temporalSwigStringHelper = swigStringHelper;
+            ThrowExceptionIfExists();
+        }
+
         [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_BaseHandle")]
         public static extern void DeleteBaseHandle(global::System.Runtime.InteropServices.HandleRef jarg1);
 
index 91233e65d708e263c0234c50d2cc8ab40d1a9413..b587488e575bc8cc17666e64111d9ed30dc37347 100755 (executable)
@@ -26,6 +26,11 @@ namespace Tizen.NUI
     /// <since_tizen> 3 </since_tizen>
     public class Animatable : BaseHandle
     {
+        static internal new void Preload()
+        {
+            BaseHandle.Preload();
+            // Do nothing. Just call for load static values.
+        }
 
         /// <summary>
         /// Create an instance of animatable.
index 457b5916e093fa07e304a19959b31646dceeb13e..eabcdef9ef485eddda0975e4bb306ceaebe0f2b9 100755 (executable)
@@ -640,6 +640,22 @@ namespace Tizen.NUI
         static public void Preload()
         {
             Interop.Application.PreInitialize();
+
+            // Initialize some static utility
+            var disposalbeQueue = DisposeQueue.Instance;
+            var registry = Registry.Instance;
+
+            // Initialize some BaseComponent static variables now
+            BaseComponents.View.Preload();
+            BaseComponents.ImageView.Preload();
+            BaseComponents.TextLabel.Preload();
+            BaseComponents.TextEditor.Preload();
+            BaseComponents.TextField.Preload();
+            Disposable.Preload();
+
+            // Initialize exception tasks. It must be called end of Preload()
+            NDalicPINVOKE.Preload();
+
             IsPreload = true;
         }
 
index dd9f625486e3894439f933165fea8066a2a494ad..407d042d46b75060de907a338009391ca9469023 100755 (executable)
@@ -32,6 +32,15 @@ namespace Tizen.NUI.BaseComponents
     {
         static ImageView() { }
 
+        static internal new void Preload()
+        {
+            // Do not call View.Preload(), since we already call it
+
+            Property.Preload();
+            // Do nothing. Just call for load static values.
+            var temporalCachedImagePropertyKeyList = cachedImagePropertyKeyList;
+        }
+
         private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
         private ResourceReadyEventCallbackType _resourceReadyEventCallback;
         private EventHandler<ResourceLoadedEventArgs> _resourceLoadedEventHandler;
@@ -1882,6 +1891,11 @@ namespace Tizen.NUI.BaseComponents
             internal static readonly int PixelArea = Interop.ImageView.PixelAreaGet();
             internal static readonly int PlaceHolderUrl = Interop.ImageView.PlaceHolderImageGet();
             internal static readonly int TransitionEffect = Interop.ImageView.TransitionEffectGet();
+
+            internal static void Preload()
+            {
+                // Do nothing. Just call for load static values.
+            }
         }
 
         private enum ImageType
index 85f6d988080c0bd1a8f62ef8b39b69f730c5018c..61b415983414d2a642219302bb60b981ca3e7de0 100755 (executable)
@@ -57,6 +57,14 @@ namespace Tizen.NUI.BaseComponents
 
         static TextEditor() { }
 
+        static internal new void Preload()
+        {
+            // Do not call View.Preload(), since we already call it
+
+            Property.Preload();
+            // Do nothing. Just call for load static values.
+        }
+
         /// <summary>
         /// Creates the TextEditor control.
         /// </summary>
@@ -2767,6 +2775,11 @@ namespace Tizen.NUI.BaseComponents
             internal static readonly int InputFilter = Interop.TextEditor.InputFilterGet();
             internal static readonly int Strikethrough = Interop.TextEditor.StrikethroughGet();
             internal static readonly int CharacterSpacing = Interop.TextEditor.CharacterSpacingGet();
+
+            internal static void Preload()
+            {
+                // Do nothing. Just call for load static values.
+            }
         }
 
         internal class InputStyle
index 36f50b05b27dbac422791f3830d29a19246c6fd1..e2506a78f7a8c966511bdba93d290f7dcbacf204 100755 (executable)
@@ -57,6 +57,14 @@ namespace Tizen.NUI.BaseComponents
 
         static TextField() { }
 
+        static internal new void Preload()
+        {
+            // Do not call View.Preload(), since we already call it
+
+            Property.Preload();
+            // Do nothing. Just call for load static values.
+        }
+
         /// <summary>
         /// Creates the TextField control.
         /// </summary>
@@ -2765,6 +2773,11 @@ namespace Tizen.NUI.BaseComponents
             internal static readonly int InputFilter = Interop.TextField.InputFilterGet();
             internal static readonly int Strikethrough = Interop.TextField.StrikethroughGet();
             internal static readonly int CharacterSpacing = Interop.TextField.CharacterSpacingGet();
+
+            internal static void Preload()
+            {
+                // Do nothing. Just call for load static values.
+            }
         }
 
         internal class InputStyle
index 1c979212c114a16412fc48e4e6e16494b125f87b..98474f4e8a7c61af16398f6966be5b3e229a7c6e 100755 (executable)
@@ -84,6 +84,14 @@ namespace Tizen.NUI.BaseComponents
 
         static TextLabel() { }
 
+        static internal new void Preload()
+        {
+            // Do not call View.Preload(), since we already call it
+
+            Property.Preload();
+            // Do nothing. Just call for load static values.
+        }
+
         private static SystemFontTypeChanged systemFontTypeChanged = new SystemFontTypeChanged();
         private static SystemLocaleLanguageChanged systemLocaleLanguageChanged = new SystemLocaleLanguageChanged();
         static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextLabel";
@@ -1847,6 +1855,11 @@ namespace Tizen.NUI.BaseComponents
             internal static readonly int EllipsisPosition = Interop.TextLabel.EllipsisPositionGet();
             internal static readonly int Strikethrough = Interop.TextLabel.StrikethroughGet();
             internal static readonly int CharacterSpacing = Interop.TextLabel.CharacterSpacingGet();
+
+            internal static void Preload()
+            {
+                // Do nothing. Just call for load static values.
+            }
         }
 
         private void OnShadowColorChanged(float x, float y, float z, float w)
index 059284387b0e3779674a1b8571a1290b89f80591..a2ca0546522a149320afff549a393166c8ab0c37 100755 (executable)
@@ -105,6 +105,16 @@ namespace Tizen.NUI.BaseComponents
             RegisterAccessibilityDelegate();
         }
 
+        static internal new void Preload()
+        {
+            Container.Preload();
+
+            // Do nothing. Just call for load static values.
+            var temporalPositionPropertyGroup = positionPropertyGroup;
+            var temporalSizePropertyGroup = sizePropertyGroup;
+            var temporalScalePropertyGroup = scalePropertyGroup;
+        }
+
         /// <summary>
         /// Accessibility mode for controlling View's Accessible implementation.
         /// It is only relevant when deriving custom controls from View directly,
index 5f85509181bd69bf7ce7a82a68baffbca3379074..b8e7eb3ce760e3af1843d8a6c50cdf22fd9068ab 100755 (executable)
@@ -28,6 +28,11 @@ namespace Tizen.NUI
     /// <since_tizen> 3 </since_tizen>
     public class BaseHandle : Element, global::System.IDisposable
     {
+        static internal void Preload()
+        {
+            // Do nothing. Just call for load static values.
+        }
+
         /// <summary>
         /// swigCMemOwn
         /// </summary>
index 13577bf0c79d13a34251da079cdbce41627f0a99..fdfbf2c9c814ad2c3a667c33b355558cdebcd49a 100755 (executable)
@@ -41,6 +41,14 @@ namespace Tizen.NUI
         ResourceDictionary _resources;
         bool IResourcesProvider.IsResourcesCreated => _resources != null;
 
+        static internal new void Preload()
+        {
+            Animatable.Preload();
+
+            // Do nothing. Just call for load static values.
+            var temporalXamlStyleProperty = XamlStyleProperty;
+        }
+
         internal Container(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
             // No un-managed data hence no need to store a native ptr