Previously, we don't cache Url infomation at cached property map when we use
SetImage API instead of ResourceUrl property.
Now, let we keep this cache information.
And also, add parameter that we dont want to create new visual when we change
this property.
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
using PropertyValue arrayProperty = new PropertyValue(indexPropertyArray);
// Trigger the ImageView so that we have something update
using PropertyValue arrayProperty = new PropertyValue(indexPropertyArray);
// Trigger the ImageView so that we have something update
- UpdateImage(ImageVisualProperty.URL, arrayProperty);
+ UpdateImage(ImageVisualProperty.URL, arrayProperty, false);
}
}
using PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedImage);
}
}
using PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedImage);
- UpdateImage(Visual.Property.Type, animatiedImage);
+ UpdateImage(Visual.Property.Type, animatiedImage, false);
public ImageView(string url) : this(Interop.ImageView.New(ConvertResourceUrl(ref url)), true)
{
_resourceUrl = url;
public ImageView(string url) : this(Interop.ImageView.New(ConvertResourceUrl(ref url)), true)
{
_resourceUrl = url;
+
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
public ImageView(string url, bool shown) : this(Interop.ImageView.New(ConvertResourceUrl(ref url)), true)
{
_resourceUrl = url;
public ImageView(string url, bool shown) : this(Interop.ImageView.New(ConvertResourceUrl(ref url)), true)
{
_resourceUrl = url;
+
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
SetVisible(shown);
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
SetVisible(shown);
}
_resourceUrl = url;
_desired_width = size?.GetWidth() ?? -1;
_desired_height = size?.GetHeight() ?? -1;
_resourceUrl = url;
_desired_width = size?.GetWidth() ?? -1;
_desired_height = size?.GetHeight() ?? -1;
+
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
+ using (PropertyValue desiredWidthValue = new PropertyValue(_desired_width))
+ {
+ UpdateImage(ImageVisualProperty.DesiredWidth, desiredWidthValue, false);
+ }
+ using (PropertyValue desiredHeightValue = new PropertyValue(_desired_height))
+ {
+ UpdateImage(ImageVisualProperty.DesiredWidth, desiredHeightValue, false);
+ }
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
if (!shown)
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
if (!shown)
image?.Dispose();
// Update cached property map
image?.Dispose();
// Update cached property map
- if(returnValue != null)
+ if (returnValue != null)
{
MergeCachedImageVisualProperty(returnValue);
}
{
MergeCachedImageVisualProperty(returnValue);
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
_resourceUrl = url;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
_resourceUrl = url;
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
+ imagePropertyUpdatedFlag = false;
PropertyValue setValue = new PropertyValue(value ?? "");
UpdateImage(ImageVisualProperty.AlphaMaskURL, setValue);
// When we never set CropToMask property before, we should set default value as true.
PropertyValue setValue = new PropertyValue(value ?? "");
UpdateImage(ImageVisualProperty.AlphaMaskURL, setValue);
// When we never set CropToMask property before, we should set default value as true.
- using(PropertyValue cropToMask = GetCachedImageVisualProperty(ImageVisualProperty.CropToMask))
+ using (PropertyValue cropToMask = GetCachedImageVisualProperty(ImageVisualProperty.CropToMask))
+ if (cropToMask == null)
{
using PropertyValue setCropValue = new PropertyValue(true);
UpdateImage(ImageVisualProperty.CropToMask, setCropValue);
{
using PropertyValue setCropValue = new PropertyValue(true);
UpdateImage(ImageVisualProperty.CropToMask, setCropValue);
get
{
// Sync as current properties only if both _desired_width and _desired_height are setuped.
get
{
// Sync as current properties only if both _desired_width and _desired_height are setuped.
- if(_desired_width != -1 && _desired_height != -1)
+ if (_desired_width != -1 && _desired_height != -1)
{
_desired_width = value;
PropertyValue setValue = new PropertyValue(value);
{
_desired_width = value;
PropertyValue setValue = new PropertyValue(value);
- UpdateImage(ImageVisualProperty.DesiredWidth, setValue);
+ UpdateImage(ImageVisualProperty.DesiredWidth, setValue, false);
get
{
// Sync as current properties only if both _desired_width and _desired_height are setuped.
get
{
// Sync as current properties only if both _desired_width and _desired_height are setuped.
- if(_desired_width != -1 && _desired_height != -1)
+ if (_desired_width != -1 && _desired_height != -1)
{
_desired_height = value;
PropertyValue setValue = new PropertyValue(value);
{
_desired_height = value;
PropertyValue setValue = new PropertyValue(value);
- UpdateImage(ImageVisualProperty.DesiredHeight, setValue);
+ UpdateImage(ImageVisualProperty.DesiredHeight, setValue, false);
NotifyPropertyChanged();
}
}
NotifyPropertyChanged();
}
}
private ReleasePolicyType InternalReleasePolicy
{
get
private ReleasePolicyType InternalReleasePolicy
{
get
_resourceUrl = url;
_desired_width = size?.GetWidth() ?? -1;
_desired_height = size?.GetHeight() ?? -1;
_resourceUrl = url;
_desired_width = size?.GetWidth() ?? -1;
_desired_height = size?.GetHeight() ?? -1;
+
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
+ using (PropertyValue desiredWidthValue = new PropertyValue(_desired_width))
+ {
+ UpdateImage(ImageVisualProperty.DesiredWidth, desiredWidthValue, false);
+ }
+ using (PropertyValue desiredHeightValue = new PropertyValue(_desired_height))
+ {
+ UpdateImage(ImageVisualProperty.DesiredWidth, desiredHeightValue, false);
+ }
+ imagePropertyUpdatedFlag = false;
}
internal ViewResourceReadySignal ResourceReadySignal(View view)
}
internal ViewResourceReadySignal ResourceReadySignal(View view)
// Callback for View ResourceReady signal
private void OnResourceReady(IntPtr data)
{
// Callback for View ResourceReady signal
private void OnResourceReady(IntPtr data)
{
- if(!CheckResourceReady())
+ if (!CheckResourceReady())
private void SetResourceUrl(string value)
{
private void SetResourceUrl(string value)
{
- if(_resourceUrl != ConvertResourceUrl(ref value))
+ if (_resourceUrl != ConvertResourceUrl(ref value))
- if(string.IsNullOrEmpty(_resourceUrl))
+ if (string.IsNullOrEmpty(_resourceUrl))
{
// Special case. If we set ResourceUrl as empty, Unregist visual.
RemoveImage();
}
else
{
{
// Special case. If we set ResourceUrl as empty, Unregist visual.
RemoveImage();
}
else
{
- using(PropertyValue setValue = new PropertyValue(value))
+ using (PropertyValue setValue = new PropertyValue(value))
{
UpdateImage(ImageVisualProperty.URL, setValue);
}
// Special case. If we set GeneratedUrl, Create ImageVisual synchronously.
{
UpdateImage(ImageVisualProperty.URL, setValue);
}
// Special case. If we set GeneratedUrl, Create ImageVisual synchronously.
- if(value.StartsWith("dali://") || value.StartsWith("enbuf://"))
+ if (value.StartsWith("dali://") || value.StartsWith("enbuf://"))
{
_border = new Rectangle(value);
UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(_border));
{
_border = new Rectangle(value);
UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(_border));
// Unregist and detach process only if previous resourceUrl was not empty
string currentResourceUrl = "";
PropertyValue currentResourceUrlValue = GetCachedImageVisualProperty(ImageVisualProperty.URL);
// Unregist and detach process only if previous resourceUrl was not empty
string currentResourceUrl = "";
PropertyValue currentResourceUrlValue = GetCachedImageVisualProperty(ImageVisualProperty.URL);
- if((currentResourceUrlValue?.Get(out currentResourceUrl) ?? false) && !string.IsNullOrEmpty(currentResourceUrl))
+ if ((currentResourceUrlValue?.Get(out currentResourceUrl) ?? false) && !string.IsNullOrEmpty(currentResourceUrl))
{
PropertyValue emptyValue = new PropertyValue();
{
PropertyValue emptyValue = new PropertyValue();
// Image visual is not exist anymore. We should ignore lazy UpdateImage
imagePropertyUpdatedFlag = false;
// Image visual is not exist anymore. We should ignore lazy UpdateImage
imagePropertyUpdatedFlag = false;
- if(imagePropertyUpdateProcessAttachedFlag)
+ if (imagePropertyUpdateProcessAttachedFlag)
{
ProcessorController.Instance.ProcessorOnceEvent -= UpdateImage;
imagePropertyUpdateProcessAttachedFlag = false;
{
ProcessorController.Instance.ProcessorOnceEvent -= UpdateImage;
imagePropertyUpdateProcessAttachedFlag = false;
/// <summary>
/// Lazy call to UpdateImage.
/// Collect Properties need to be update, and set properties that starts the Processing.
/// <summary>
/// Lazy call to UpdateImage.
/// Collect Properties need to be update, and set properties that starts the Processing.
+ ///
+ /// If you want to update cachedImagePropertyMap, but don't want to request new visual creation, make requiredVisualCreation value as false.
+ /// (Example : if we change SynchronousLoading property from 'true' to 'false', or if we call this function during UpdateImage)
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual void UpdateImage(int key, PropertyValue value)
+ protected virtual void UpdateImage(int key, PropertyValue value, bool requiredVisualCreation = true)
{
// Update image property map value as inputed value.
if (key != 0)
{
// Update image property map value as inputed value.
if (key != 0)
imagePropertyUpdatedFlag = true;
cachedImagePropertyMap[key] = value;
imagePropertyUpdatedFlag = true;
cachedImagePropertyMap[key] = value;
- // Lazy update only if _resourceUrl is not empty and ProcessAttachedFlag is false.
- if (!string.IsNullOrEmpty(_resourceUrl) && !imagePropertyUpdateProcessAttachedFlag)
+ // Lazy update only if visual creation required, and _resourceUrl is not empty, and ProcessAttachedFlag is false.
+ if (requiredVisualCreation && !string.IsNullOrEmpty(_resourceUrl) && !imagePropertyUpdateProcessAttachedFlag)
{
imagePropertyUpdateProcessAttachedFlag = true;
ProcessorController.Instance.ProcessorOnceEvent += UpdateImage;
{
imagePropertyUpdateProcessAttachedFlag = true;
ProcessorController.Instance.ProcessorOnceEvent += UpdateImage;
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void UpdateImage()
{
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void UpdateImage()
{
- if(!imagePropertyUpdatedFlag) return;
+ if (!imagePropertyUpdatedFlag) return;
imagePropertyUpdatedFlag = false;
imagePropertyUpdatedFlag = false;
- if(cachedImagePropertyMap == null)
+ if (cachedImagePropertyMap == null)
{
cachedImagePropertyMap = new PropertyMap();
}
{
cachedImagePropertyMap = new PropertyMap();
}
// Checkup the cached visual type is AnimatedImage.
// It is trick to know that this code is running on AnimatedImageView.UpdateImage() / LottieAnimationView.UpdateImage() or not.
int visualType = (int)Visual.Type.Invalid;
// Checkup the cached visual type is AnimatedImage.
// It is trick to know that this code is running on AnimatedImageView.UpdateImage() / LottieAnimationView.UpdateImage() or not.
int visualType = (int)Visual.Type.Invalid;
- if(!((GetCachedImageVisualProperty(Visual.Property.Type)?.Get(out visualType) ?? false) && (visualType == (int)Visual.Type.AnimatedImage || visualType == (int)Visual.Type.AnimatedVectorImage)))
+ if (!((GetCachedImageVisualProperty(Visual.Property.Type)?.Get(out visualType) ?? false) && (visualType == (int)Visual.Type.AnimatedImage || visualType == (int)Visual.Type.AnimatedVectorImage)))
{
// If ResourceUrl is not setuped, don't set property. fast return.
{
// If ResourceUrl is not setuped, don't set property. fast return.
- if(string.IsNullOrEmpty(_resourceUrl))
+ if (string.IsNullOrEmpty(_resourceUrl))
if (_resourceUrl != null)
{
Size2D imageSize = ImageLoader.GetOriginalImageSize(_resourceUrl, true);
if (_resourceUrl != null)
{
Size2D imageSize = ImageLoader.GetOriginalImageSize(_resourceUrl, true);
- if( imageSize.Height > 0 && imageSize.Width > 0 && _desired_width > 0 && _desired_height > 0 )
+ if (imageSize.Height > 0 && imageSize.Width > 0 && _desired_width > 0 && _desired_height > 0)
{
int adjustedDesiredWidth, adjustedDesiredHeight;
float aspectOfDesiredSize = (float)_desired_height / (float)_desired_width;
{
int adjustedDesiredWidth, adjustedDesiredHeight;
float aspectOfDesiredSize = (float)_desired_height / (float)_desired_width;
private void UpdateImageMap()
{
// Note : We can't use ImageView.Image property here. Because That property call UpdateImage internally.
private void UpdateImageMap()
{
// Note : We can't use ImageView.Image property here. Because That property call UpdateImage internally.
- using(PropertyMap imageMap = new PropertyMap())
+ using (PropertyMap imageMap = new PropertyMap())
- using(PropertyValue returnValue = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE))
+ using (PropertyValue returnValue = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE))
{
returnValue?.Get(imageMap);
}
{
returnValue?.Get(imageMap);
}
- if(cachedImagePropertyMap != null)
+ if (cachedImagePropertyMap != null)
{
imageMap?.Merge(cachedImagePropertyMap);
}
{
imageMap?.Merge(cachedImagePropertyMap);
}
- using(PropertyValue setValue = new PropertyValue(imageMap))
+ using (PropertyValue setValue = new PropertyValue(imageMap))
{
SetProperty(ImageView.Property.IMAGE, setValue);
}
{
SetProperty(ImageView.Property.IMAGE, setValue);
}
protected virtual PropertyValue GetImageVisualProperty(int key)
{
PropertyValue ret = GetCachedImageVisualProperty(key);
protected virtual PropertyValue GetImageVisualProperty(int key)
{
PropertyValue ret = GetCachedImageVisualProperty(key);
{
// If we cannot find result form cached map, Get value from native engine.
ret = Image?.Find(key);
{
// If we cannot find result form cached map, Get value from native engine.
ret = Image?.Find(key);
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void MergeCachedImageVisualProperty(PropertyMap map)
{
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void MergeCachedImageVisualProperty(PropertyMap map)
{
- if(map == null) return;
- if(cachedImagePropertyMap == null)
+ if (map == null) return;
+ if (cachedImagePropertyMap == null)
{
cachedImagePropertyMap = new PropertyMap();
}
{
cachedImagePropertyMap = new PropertyMap();
}
- foreach(var key in cachedImagePropertyKeyList)
+ foreach (var key in cachedImagePropertyKeyList)
{
PropertyValue value = map.Find(key);
{
PropertyValue value = map.Find(key);
{
// Update-or-Insert new value
cachedImagePropertyMap[key] = value;
{
// Update-or-Insert new value
cachedImagePropertyMap[key] = value;
private void OnResourceLoaded(IntPtr view)
{
private void OnResourceLoaded(IntPtr view)
{
- if(!CheckResourceReady())
+ if (!CheckResourceReady())
- imageView.UpdateImage(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
+ // Note : We need to create new visual if previous visual was async, and now we set value as sync.
+ imageView.UpdateImage(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue), (bool)newValue);
}
},
defaultValueCreator: (bindable) =>
}
},
defaultValueCreator: (bindable) =>
- imageView.UpdateImage(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
+ // Note : We need to create new visual if previous visual was async, and now we set value as sync.
+ imageView.UpdateImage(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue), (bool)newValue);
}
},
defaultValueCreator: (bindable) =>
}
},
defaultValueCreator: (bindable) =>
// Update currentStates properties to cachedImagePropertyMap
if(currentStates.changed)
{
// Update currentStates properties to cachedImagePropertyMap
if(currentStates.changed)
{
- UpdateImage(ImageVisualProperty.LoopCount, new PropertyValue(currentStates.loopCount));
- UpdateImage(ImageVisualProperty.StopBehavior, new PropertyValue((int)currentStates.stopEndAction));
- UpdateImage(ImageVisualProperty.LoopingMode, new PropertyValue((int)currentStates.loopMode));
- UpdateImage(ImageVisualProperty.RedrawInScalingDown, new PropertyValue(currentStates.redrawInScalingDown));
+ UpdateImage(ImageVisualProperty.LoopCount, new PropertyValue(currentStates.loopCount), false);
+ UpdateImage(ImageVisualProperty.StopBehavior, new PropertyValue((int)currentStates.stopEndAction), false);
+ UpdateImage(ImageVisualProperty.LoopingMode, new PropertyValue((int)currentStates.loopMode), false);
+ UpdateImage(ImageVisualProperty.RedrawInScalingDown, new PropertyValue(currentStates.redrawInScalingDown), false);
// Do not cache PlayRange and TotalFrameNumber into cachedImagePropertyMap.
// (To keep legacy implements behaviour)
// Do not cache PlayRange and TotalFrameNumber into cachedImagePropertyMap.
// (To keep legacy implements behaviour)
}
using PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedVectorImage);
}
using PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedVectorImage);
- UpdateImage(Visual.Property.Type, animatiedImage);
+ UpdateImage(Visual.Property.Type, animatiedImage, false);