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<int> cachedNUIViewBackgroundImagePropertyKeyList = new List<int> {
+ ImageVisualProperty.URL,
+ ImageVisualProperty.SynchronousLoading,
+ };
+ private string backgroundImageUrl = null;
+ private bool backgroundImageSynchronousLoading = false;
+
// List of constraints
private Constraint widthConstraint = null;
private Constraint heightConstraint = null;
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;
}
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)
{
backgroundExtraDataUpdatedFlag &= ~BackgroundExtraDataUpdatedFlag.Background;
+ backgroundImageUrl = null;
+
var empty = new PropertyValue();
// Clear background
Object.SetProperty(SwigCPtr, Property.BACKGROUND, empty);
value = value.Replace("*Resource*", resource);
}
+ backgroundImageUrl = value;
+
// Fast return for usual cases.
if (backgroundExtraData == null && !backgroundImageSynchronousLoading)
{
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;
}