From 447d8627313037168965e0691196f1343dea3093 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Mon, 17 Jul 2023 12:04:59 +0900 Subject: [PATCH] [NUI] Fast track uploading image 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 --- .../src/public/BaseComponents/ImageView.cs | 66 ++++++++++++++++++- .../ImageViewBindableProperty.cs | 20 +++++- .../src/public/Visuals/VisualConstants.cs | 8 +++ 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index fda30cf9f9b..b552ea54f7f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -68,6 +68,7 @@ private static string ConvertResourceUrl(ref string value) ImageVisualProperty.SynchronousLoading, Visual.Property.PremultipliedAlpha, ImageVisualProperty.OrientationCorrection, + ImageVisualProperty.FastTrackUploading, NpatchImageVisualProperty.Border, NpatchImageVisualProperty.BorderOnly, }; @@ -79,6 +80,7 @@ private static string ConvertResourceUrl(ref string value) private string _resourceUrl = ""; private int _desired_width = -1; private int _desired_height = -1; + private bool _fastTrackUploading = false; private TriggerableSelector resourceUrlSelector; private TriggerableSelector borderSelector; @@ -610,6 +612,64 @@ private MaskingModeType InternalMaskingMode } } + /// + /// Gets or sets whether to apply fast track uploading or not.
+ ///
+ /// + /// If we use fast track uploading feature, It can upload texture without event-thead dependency. But also,
+ /// - Texture size is invalid until ResourceReady signal comes.
+ /// - Texture cannot be cached (We always try to load new image).
+ /// - Seamless visual change didn't supported.
+ /// - Alpha masking didn't supported. If you try, It will load as normal case.
+ /// - Synchronous loading didn't supported. If you try, It will load as normal case.
+ /// - Reload action didn't supported. If you try, It will load as normal case.
+ /// - Atlas loading didn't supported. If you try, It will load as normal case.
+ /// - Custom shader didn't supported. If you try, It will load as normal case. + ///
+ [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(); + } + } + } + } + /// /// Gets the loading state of the visual resource. /// @@ -1396,8 +1456,8 @@ private void SetResourceUrl(string value) { 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 @@ protected virtual void UpdateImage(int key, PropertyValue value, bool requiredVi // 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"); diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs index 7534b9d9b1c..a31206529b4 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs @@ -348,6 +348,24 @@ public partial class ImageView return instance.InternalMaskingMode; }); + /// + /// FastTrackUploadingProperty + /// + [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; + }); + /// /// ImageMapProperty /// @@ -537,7 +555,7 @@ public partial class ImageView 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) => diff --git a/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs b/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs index 98f7eb36a97..1d4efb8ba6b 100755 --- a/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualConstants.cs @@ -969,6 +969,14 @@ public struct ImageVisualProperty /// [EditorBrowsable(EditorBrowsableState.Never)] public static readonly int MaskingMode = NDalic.ImageVisualOrientationCorrection + 12; + + /// + /// @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. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly int FastTrackUploading = NDalic.ImageVisualOrientationCorrection + 13; } ///