[NUI] Fast track uploading image
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 17 Jul 2023 03:04:59 +0000 (12:04 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Tue, 25 Jul 2023 08:09:22 +0000 (17:09 +0900)
Add new feature about flag that ImageView's image uploading faster.

Previously, NUI has some operations to support some kind of visual transition,
or calculate natural size for relayout, or etc.

This patch make a way to user that we need to upload image as soon as possible,
don't care about other platform supported features.

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs
src/Tizen.NUI/src/public/Visuals/VisualConstants.cs

index fda30cf..b552ea5 100755 (executable)
@@ -68,6 +68,7 @@ namespace Tizen.NUI.BaseComponents
             ImageVisualProperty.SynchronousLoading,
             Visual.Property.PremultipliedAlpha,
             ImageVisualProperty.OrientationCorrection,
+            ImageVisualProperty.FastTrackUploading,
             NpatchImageVisualProperty.Border,
             NpatchImageVisualProperty.BorderOnly,
         };
@@ -79,6 +80,7 @@ namespace Tizen.NUI.BaseComponents
         private string _resourceUrl = "";
         private int _desired_width = -1;
         private int _desired_height = -1;
+        private bool _fastTrackUploading = false;
         private TriggerableSelector<string> resourceUrlSelector;
         private TriggerableSelector<Rectangle> borderSelector;
 
@@ -611,6 +613,64 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Gets or sets whether to apply fast track uploading or not.<br />
+        /// </summary>
+        /// <remarks>
+        /// If we use fast track uploading feature, It can upload texture without event-thead dependency. But also,<br />
+        ///  - Texture size is invalid until ResourceReady signal comes.<br />
+        ///  - Texture cannot be cached (We always try to load new image).<br />
+        ///  - Seamless visual change didn't supported.<br />
+        ///  - Alpha masking didn't supported. If you try, It will load as normal case.<br />
+        ///  - Synchronous loading didn't supported. If you try, It will load as normal case.<br />
+        ///  - Reload action didn't supported. If you try, It will load as normal case.<br />
+        ///  - Atlas loading didn't supported. If you try, It will load as normal case.<br />
+        ///  - Custom shader didn't supported. If you try, It will load as normal case.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool FastTrackUploading
+        {
+            get
+            {
+                return (bool)GetValue(FastTrackUploadingProperty);
+            }
+            set
+            {
+                SetValue(FastTrackUploadingProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        private bool InternalFastTrackUploading
+        {
+            get
+            {
+                PropertyValue fastTrackUploading = GetCachedImageVisualProperty(ImageVisualProperty.FastTrackUploading);
+                fastTrackUploading?.Get(out _fastTrackUploading);
+                fastTrackUploading?.Dispose();
+
+                return _fastTrackUploading;
+            }
+            set
+            {
+                if (_fastTrackUploading != value)
+                {
+                    _fastTrackUploading = value;
+
+                    PropertyValue setValue = new PropertyValue(_fastTrackUploading);
+                    UpdateImage(ImageVisualProperty.FastTrackUploading, setValue);
+                    setValue?.Dispose();
+
+                    if (_fastTrackUploading && !string.IsNullOrEmpty(_resourceUrl))
+                    {
+                        // Special case. If user set FastTrackUploading mean, user want to upload image As-Soon-As-Possible.
+                        // Create ImageVisual synchronously.
+                        UpdateImage();
+                    }
+                }
+            }
+        }
+
+        /// <summary>
         /// Gets the loading state of the visual resource.
         /// </summary>
         /// <since_tizen> 5 </since_tizen>
@@ -1396,8 +1456,8 @@ namespace Tizen.NUI.BaseComponents
                     {
                         UpdateImage(ImageVisualProperty.URL, setValue);
                     }
-                    // Special case. If we set GeneratedUrl, Create ImageVisual synchronously.
-                    if (value.StartsWith("dali://") || value.StartsWith("enbuf://"))
+                    // Special case. If we set GeneratedUrl, or FastTrackUploading, Create ImageVisual synchronously.
+                    if (value.StartsWith("dali://") || value.StartsWith("enbuf://") || _fastTrackUploading)
                     {
                         UpdateImage();
                     }
@@ -1462,7 +1522,7 @@ namespace Tizen.NUI.BaseComponents
             // Update image property map value as inputed value.
             if (key != 0)
             {
-                if(!HasBody())
+                if (!HasBody())
                 {
                     // Throw exception if ImageView is disposed.
                     throw new global::System.InvalidOperationException("[NUI][ImageVIew] Someone try to change disposed ImageView's property.\n");
index 7534b9d..a312065 100755 (executable)
@@ -349,6 +349,24 @@ namespace Tizen.NUI.BaseComponents
         });
 
         /// <summary>
+        /// FastTrackUploadingProperty
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty FastTrackUploadingProperty = BindableProperty.Create(nameof(FastTrackUploading), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
+            if (newValue != null)
+            {
+                instance.InternalFastTrackUploading = (bool)newValue;
+            }
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
+            return instance.InternalFastTrackUploading;
+        });
+
+        /// <summary>
         /// ImageMapProperty
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -537,7 +555,7 @@ namespace Tizen.NUI.BaseComponents
             var imageView = (Tizen.NUI.BaseComponents.ImageView)bindable;
             if (newValue != null)
             {
-                Object.InternalSetPropertyString(imageView.SwigCPtr, ImageView.Property.PlaceHolderUrl, (string)newValue );
+                Object.InternalSetPropertyString(imageView.SwigCPtr, ImageView.Property.PlaceHolderUrl, (string)newValue);
             }
         },
         defaultValueCreator: (bindable) =>
index 98f7eb3..1d4efb8 100755 (executable)
@@ -969,6 +969,14 @@ namespace Tizen.NUI
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly int MaskingMode = NDalic.ImageVisualOrientationCorrection + 12;
+
+        /// <summary>
+        /// @brief Whether to uploading texture before ResourceReady signal emit or after texture load completed time.
+        /// @details Name "fastTrackUploading", type Property::BOOLEAN.
+        /// @note It is used in the ImageVisual. The default is false.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly int FastTrackUploading = NDalic.ImageVisualOrientationCorrection + 13;
     }
 
     /// <summary>