Skip to content

Commit

Permalink
[Optimization][Issue 23] Set int/float/string/vector/rectangle to pro…
Browse files Browse the repository at this point in the history
…pertyMap directly.
  • Loading branch information
AdunFang authored and dongsug-song committed Feb 11, 2025
1 parent 6bad862 commit 032700e
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 110 deletions.
48 changes: 48 additions & 0 deletions src/Tizen.NUI/src/internal/Interop/Interop.PropertyMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,63 @@ internal static partial class PropertyMap
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_None")]
public static extern IntPtr AddNone(HandleRef propertyMap, int key);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Str_None")]
public static extern IntPtr AddNone(HandleRef propertyMap, string key);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Int_None")]
public static extern IntPtr SetNone(HandleRef propertyMap, int key);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Str_None")]
public static extern IntPtr SetNone(HandleRef propertyMap, string key);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_Bool")]
public static extern IntPtr AddBool(HandleRef propertyMap, int key, bool value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Str_Bool")]
public static extern IntPtr AddBool(HandleRef propertyMap, string key, bool value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Int_Bool")]
public static extern IntPtr SetBool(HandleRef propertyMap, int key, bool value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Str_Bool")]
public static extern IntPtr SetBool(HandleRef propertyMap, string key, bool value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_Int")]
public static extern IntPtr AddInt(HandleRef propertyMap, int key, int value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Str_Int")]
public static extern IntPtr AddInt(HandleRef propertyMap, string key, int value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Int_Int")]
public static extern IntPtr SetInt(HandleRef propertyMap, int key, int value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Str_Int")]
public static extern IntPtr SetInt(HandleRef propertyMap, string key, int value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_Float")]
public static extern IntPtr AddFloat(HandleRef propertyMap, int key, float value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Str_Float")]
public static extern IntPtr AddFloat(HandleRef propertyMap, string key, float value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Int_Float")]
public static extern IntPtr SetFloat(HandleRef propertyMap, int key, float value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Str_Float")]
public static extern IntPtr SetFloat(HandleRef propertyMap, string key, float value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_Str")]
public static extern IntPtr AddString(HandleRef propertyMap, int key, string value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Str_Str")]
public static extern IntPtr AddString(HandleRef propertyMap, string key, string value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Int_Str")]
public static extern IntPtr SetString(HandleRef propertyMap, int key, string value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Str_Str")]
public static extern IntPtr SetString(HandleRef propertyMap, string key, string value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_Vector2")]
public static extern IntPtr AddVector2(HandleRef propertyMap, int key, HandleRef value);

Expand All @@ -131,6 +164,12 @@ internal static partial class PropertyMap
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Str_NVector2")]
public static extern IntPtr AddVector2(HandleRef propertyMap, string key, float x, float y);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Int_NVector2")]
public static extern IntPtr SetVector2(HandleRef propertyMap, int key, float x, float y);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Str_NVector2")]
public static extern IntPtr SetVector2(HandleRef propertyMap, string key, float x, float y);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_Vector3")]
public static extern IntPtr AddVector3(HandleRef propertyMap, int key, HandleRef value);

Expand All @@ -143,9 +182,18 @@ internal static partial class PropertyMap
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Str_NVector4")]
public static extern IntPtr AddVector4(HandleRef propertyMap, string key, float x, float y, float z, float w);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Int_NVector4")]
public static extern IntPtr SetVector4(HandleRef propertyMap, int key, float x, float y, float z, float w);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Str_NVector4")]
public static extern IntPtr SetVector4(HandleRef propertyMap, string key, float x, float y, float z, float w);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_Rectangle")]
public static extern IntPtr AddRectangle(HandleRef propertyMap, int key, HandleRef value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Set_Int_Rectangle")]
public static extern IntPtr SetRectangle(HandleRef propertyMap, int key, HandleRef value);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_Map")]
public static extern IntPtr AddPropertyMap(HandleRef propertyMap, int key, HandleRef value);
}
Expand Down
39 changes: 11 additions & 28 deletions src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ private void RemoveImage()
_resourceUrl = "";
if (cachedImagePropertyMap != null)
{
cachedImagePropertyMap[ImageVisualProperty.URL] = emptyValue;
cachedImagePropertyMap.SetNone(ImageVisualProperty.URL);
}
}
}
Expand Down Expand Up @@ -2278,48 +2278,31 @@ protected virtual void UpdateImage()
}
if (_border == null)
{
PropertyValue image = new PropertyValue((int)Visual.Type.Image);
cachedImagePropertyMap[Visual.Property.Type] = image;
image?.Dispose();
cachedImagePropertyMap.Set(Visual.Property.Type, (int)Visual.Type.Image);
}
else
{
PropertyValue nPatch = new PropertyValue((int)Visual.Type.NPatch);
cachedImagePropertyMap[Visual.Property.Type] = nPatch;
nPatch?.Dispose();
PropertyValue border = new PropertyValue(_border);
cachedImagePropertyMap[NpatchImageVisualProperty.Border] = border;
border?.Dispose();
cachedImagePropertyMap.Set(Visual.Property.Type, (int)Visual.Type.NPatch);
cachedImagePropertyMap.Set(NpatchImageVisualProperty.Border, _border);
}
}

if (backgroundExtraData != null && backgroundExtraData.CornerRadius != null)
{
using (var cornerRadius = new PropertyValue(backgroundExtraData.CornerRadius))
using (var cornerRadiusPolicy = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy))
{
cachedImagePropertyMap[Visual.Property.CornerRadius] = cornerRadius;
cachedImagePropertyMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)(backgroundExtraData.CornerRadiusPolicy));
}
cachedImagePropertyMap.Set(Visual.Property.CornerRadius, backgroundExtraData.CornerRadius);
cachedImagePropertyMap.Set(Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);

if (backgroundExtraData.CornerSquareness != null)
{
using (var cornerSquareness = new PropertyValue(backgroundExtraData.CornerSquareness))
{
cachedImagePropertyMap[Visual.Property.CornerSquareness] = cornerSquareness;
}
cachedImagePropertyMap.Set(Visual.Property.CornerSquareness, backgroundExtraData.CornerSquareness);
}
}

if (backgroundExtraData != null && backgroundExtraData.BorderlineWidth > 0.0f)
{
using (var borderlineWidth = new PropertyValue(backgroundExtraData.BorderlineWidth))
using (var borderlineColor = new PropertyValue(backgroundExtraData.BorderlineColor))
using (var borderlineOffset = new PropertyValue(backgroundExtraData.BorderlineOffset))
{
cachedImagePropertyMap[Visual.Property.BorderlineWidth] = borderlineWidth;
cachedImagePropertyMap[Visual.Property.BorderlineColor] = borderlineColor;
cachedImagePropertyMap[Visual.Property.BorderlineOffset] = borderlineOffset;
}
cachedImagePropertyMap.Set(Visual.Property.BorderlineWidth, backgroundExtraData.BorderlineWidth);
cachedImagePropertyMap.Set(Visual.Property.BorderlineColor, backgroundExtraData.BorderlineColor);
cachedImagePropertyMap.Set(Visual.Property.BorderlineOffset, backgroundExtraData.BorderlineOffset);
}

// We already applied background extra data now.
Expand Down
4 changes: 1 addition & 3 deletions src/Tizen.NUI/src/public/BaseComponents/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5402,9 +5402,7 @@ private bool InternalBackgroundImageSynchronousLoading
if (!string.IsNullOrEmpty(BackgroundImage))
{
PropertyMap bgMap = this.Background;
var temp = new PropertyValue(backgroundImageSynchronousLoading);
bgMap[ImageVisualProperty.SynchronousLoading] = temp;
temp.Dispose();
bgMap.Set(ImageVisualProperty.SynchronousLoading, backgroundImageSynchronousLoading);
Background = bgMap;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2705,15 +2705,15 @@ private void SetBackgroundImageBorder(Rectangle value)
return;
}

map[NpatchImageVisualProperty.Border] = new PropertyValue(backgroundImageBorder);
map.Set(NpatchImageVisualProperty.Border, backgroundImageBorder);

int visualType = 0;

map.Find(Visual.Property.Type)?.Get(out visualType);

if (visualType == (int)Visual.Type.Image)
{
map[Visual.Property.Type] = new PropertyValue((int)Visual.Type.NPatch);
map.Set(Visual.Property.Type, (int)Visual.Type.NPatch);
}

// Background extra data flag is not meanful anymore.
Expand Down
Loading

0 comments on commit 032700e

Please sign in to comment.