Skip to content

Commit

Permalink
[Optimization] Add int/float/vector to PropertyMap directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdunFang authored and dongsug-song committed Feb 10, 2025
1 parent 1b238af commit b48cb82
Show file tree
Hide file tree
Showing 29 changed files with 526 additions and 602 deletions.
4 changes: 1 addition & 3 deletions src/Tizen.NUI/src/internal/FrameBroker/FrameBrokerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,8 @@ private struct TexturedQuadVertex
private PropertyBuffer CreateQuadPropertyBuffer()
{
/* Create Property buffer */
PropertyValue value = new PropertyValue((int)PropertyType.Vector2);
PropertyMap vertexFormat = new PropertyMap();
vertexFormat.Add("aPosition", value);
vertexFormat.Add("aPosition", (int)PropertyType.Vector2);

PropertyBuffer vertexBuffer = new PropertyBuffer(vertexFormat);

Expand Down Expand Up @@ -335,7 +334,6 @@ private PropertyBuffer CreateQuadPropertyBuffer()
Marshal.FreeHGlobal(pA);
}

value.Dispose();
vertexFormat.Dispose();

return vertexBuffer;
Expand Down
21 changes: 21 additions & 0 deletions src/Tizen.NUI/src/internal/Interop/Interop.PropertyMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,39 @@ internal static partial class PropertyMap
[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_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_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_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_Add_Int_Vector2")]
public static extern IntPtr AddVector2(HandleRef propertyMap, int key, HandleRef value);

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

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

[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_Add_Int_Vector3")]
public static extern IntPtr AddVector3(HandleRef propertyMap, int key, HandleRef value);

Expand All @@ -122,6 +140,9 @@ internal static partial class PropertyMap
[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Property_Map_Add_Int_NVector4")]
public static extern IntPtr AddVector4(HandleRef propertyMap, int key, float x, float y, float z, float w);

[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_Add_Int_Rectangle")]
public static extern IntPtr AddRectangle(HandleRef propertyMap, int key, HandleRef value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ public bool AddResponseHeaders(IDictionary<string, string> headers)
PropertyMap headerMap = new PropertyMap();
foreach (KeyValuePair<string, string> kvp in headers)
{
using (PropertyValue value = new PropertyValue(kvp.Value))
{
headerMap.Add(kvp.Key, value);
}
headerMap.Add(kvp.Key, kvp.Value);
}
bool result = Interop.WebHttpRequestInterceptor.AddResponseHeaders(interceptorHandle, PropertyMap.getCPtr(headerMap));
headerMap.Dispose();
Expand Down
32 changes: 8 additions & 24 deletions src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,39 +1365,23 @@ public void SetTransitionEffectOption(object initialImageAlpha,object destinatio
using (PropertyMap timePeriod = new PropertyMap())
using (PropertyValue initValue = PropertyValue.CreateFromObject(initialImageAlpha))
using (PropertyValue destValue = PropertyValue.CreateFromObject(destinationImageAlpha))
using (PropertyValue pvDelay = new PropertyValue(delay))
using (PropertyValue pvSpeed = new PropertyValue(speed))
using (PropertyValue pvProperty = new PropertyValue("opacity"))
using (PropertyValue pvAnimationType = new PropertyValue("BETWEEN"))
using (PropertyMap transition = new PropertyMap())
{
if (alphaFunction != null)
{
using (PropertyValue pvAlpha = new PropertyValue(AlphaFunction.BuiltinToPropertyKey(alphaFunction)))
{
animator.Add("alphaFunction", pvAlpha);
}
animator.Add("alphaFunction", AlphaFunction.BuiltinToPropertyKey(alphaFunction));
}

timePeriod.Add("duration", pvSpeed);
timePeriod.Add("delay", pvDelay);
using (PropertyValue pvTimePeriod = new PropertyValue(timePeriod))
{
animator.Add("timePeriod", pvTimePeriod);
}
timePeriod.Add("duration", speed);
timePeriod.Add("delay", delay);
animator.Add("timePeriod", timePeriod);

animator.Add("animationType", pvAnimationType);
animator.Add("animationType", "BETWEEN");

using (PropertyValue pvAnimator = new PropertyValue(animator))
{
transition.Add("animator", pvAnimator);
}
using(PropertyValue pvTarget = new PropertyValue("image"))
{
transition.Add("target", pvTarget);
}
transition.Add("animator", animator);

transition.Add("property", pvProperty);
transition.Add("target", "image");
transition.Add("property", "opacity");
transition.Add("initialValue", initValue);
transition.Add("targetValue", destValue);

Expand Down
38 changes: 13 additions & 25 deletions src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,37 +217,25 @@ private string InternalURL

// TODO : Could create new Image without additional creation?
using PropertyMap map = new PropertyMap();
using PropertyValue type = new PropertyValue((int)Visual.Type.AnimatedVectorImage);
using PropertyValue url = new PropertyValue(currentStates.url);
using PropertyValue loopCnt = new PropertyValue(currentStates.loopCount);
using PropertyValue stopAction = new PropertyValue((int)currentStates.stopEndAction);
using PropertyValue loopMode = new PropertyValue((int)currentStates.loopMode);
using PropertyValue redrawInScalingDown = new PropertyValue(currentStates.redrawInScalingDown);
using PropertyValue synchronousLoading = new PropertyValue(currentStates.synchronousLoading);
using PropertyValue enableFrameCache = new PropertyValue(currentStates.enableFrameCache);
using PropertyValue notifyAfterRasterization = new PropertyValue(currentStates.notifyAfterRasterization);
using PropertyValue frameSpeedFactor = new PropertyValue(currentStates.frameSpeedFactor);

map.Add(Visual.Property.Type, type)
.Add(ImageVisualProperty.URL, url)
.Add(ImageVisualProperty.LoopCount, loopCnt)
.Add(ImageVisualProperty.StopBehavior, stopAction)
.Add(ImageVisualProperty.LoopingMode, loopMode)
.Add(ImageVisualProperty.RedrawInScalingDown, redrawInScalingDown)
.Add(ImageVisualProperty.SynchronousLoading, synchronousLoading)
.Add(ImageVisualProperty.EnableFrameCache, enableFrameCache)
.Add(ImageVisualProperty.NotifyAfterRasterization, notifyAfterRasterization)
.Add(ImageVisualProperty.FrameSpeedFactor, frameSpeedFactor);

map.Add(Visual.Property.Type, (int)Visual.Type.AnimatedVectorImage)
.Add(ImageVisualProperty.URL, currentStates.url)
.Add(ImageVisualProperty.LoopCount, currentStates.loopCount)
.Add(ImageVisualProperty.StopBehavior, (int)currentStates.stopEndAction)
.Add(ImageVisualProperty.LoopingMode, (int)currentStates.loopMode)
.Add(ImageVisualProperty.RedrawInScalingDown, currentStates.redrawInScalingDown)
.Add(ImageVisualProperty.SynchronousLoading, currentStates.synchronousLoading)
.Add(ImageVisualProperty.EnableFrameCache, currentStates.enableFrameCache)
.Add(ImageVisualProperty.NotifyAfterRasterization, currentStates.notifyAfterRasterization)
.Add(ImageVisualProperty.FrameSpeedFactor, currentStates.frameSpeedFactor);

if (currentStates.desiredWidth > 0)
{
using PropertyValue desiredWidth = new PropertyValue((int)currentStates.desiredWidth);
map.Add(ImageVisualProperty.DesiredWidth, desiredWidth);
map.Add(ImageVisualProperty.DesiredWidth, currentStates.desiredWidth);
}
if (currentStates.desiredHeight > 0)
{
using PropertyValue desiredHeight = new PropertyValue((int)currentStates.desiredHeight);
map.Add(ImageVisualProperty.DesiredHeight, desiredHeight);
map.Add(ImageVisualProperty.DesiredHeight, currentStates.desiredHeight);
}

Image = map;
Expand Down
5 changes: 1 addition & 4 deletions src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3087,10 +3087,7 @@ public Tizen.NUI.PropertyMap Placeholder
using (var fontStyle = new PropertyMap())
{
properyValue.Get(fontStyle);
using (var fontStyleValue = new PropertyValue(fontStyle))
{
map.Add("fontStyle", fontStyleValue);
}
map.Add("fontStyle", fontStyle);
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/Tizen.NUI/src/public/BaseComponents/TextField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3362,10 +3362,7 @@ public Tizen.NUI.PropertyMap Placeholder
using (var fontStyle = new PropertyMap())
{
properyValue.Get(fontStyle);
using (var fontStyleValue = new PropertyValue(fontStyle))
{
map.Add("fontStyle", fontStyleValue);
}
map.Add("fontStyle", fontStyle);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,8 @@ public static PropertyMap GetPlaceholderMap(Placeholder placeholder)
if (placeholder.FontStyle != null)
{
using (var fontStyleMap = GetFontStyleMap((FontStyle)placeholder.FontStyle))
using (var fontStyleValue = new PropertyValue(fontStyleMap))
{
map.Add("fontStyle", fontStyleValue);
map.Add("fontStyle", fontStyleMap);
}
}

Expand Down
66 changes: 20 additions & 46 deletions src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2649,43 +2649,28 @@ private void SetBackgroundImage(string value)
}

using var map = new PropertyMap();
using var url = new PropertyValue(value);
using var synchronousLoading = new PropertyValue(backgroundImageSynchronousLoading);

map.Add(ImageVisualProperty.URL, url)
.Add(ImageVisualProperty.SynchronousLoading, synchronousLoading);
map.Add(ImageVisualProperty.URL, value)
.Add(ImageVisualProperty.SynchronousLoading, backgroundImageSynchronousLoading);

if ((backgroundExtraData?.BackgroundImageBorder) != null)
{
using var npatchType = new PropertyValue((int)Visual.Type.NPatch);
using var border = new PropertyValue(backgroundExtraData.BackgroundImageBorder);
map.Add(Visual.Property.Type, npatchType)
.Add(NpatchImageVisualProperty.Border, border);
map.Add(Visual.Property.Type, (int)Visual.Type.NPatch)
.Add(NpatchImageVisualProperty.Border, backgroundExtraData.BackgroundImageBorder);
}
else
{
using var imageType = new PropertyValue((int)Visual.Type.Image);
map.Add(Visual.Property.Type, imageType);
map.Add(Visual.Property.Type, (int)Visual.Type.Image);
}

if (backgroundExtraData != null)
{
using var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
using var cornerRadius = new PropertyValue(cornerRadiusValue);
using var cornerSquarenessValue = backgroundExtraData.CornerSquareness == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerSquareness);
using var cornerSquareness = new PropertyValue(cornerSquarenessValue);
using var cornerRadiusPolicy = new PropertyValue((int)(backgroundExtraData.CornerRadiusPolicy));
using var borderlineWidth = new PropertyValue(backgroundExtraData.BorderlineWidth);
using var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
using var borderlineColor = new PropertyValue(borderlineColorValue);
using var borderlineOffset = new PropertyValue(backgroundExtraData.BorderlineOffset);

map.Add(Visual.Property.CornerRadius, cornerRadius)
.Add(Visual.Property.CornerSquareness, cornerSquareness)
.Add(Visual.Property.CornerRadiusPolicy, cornerRadiusPolicy)
.Add(Visual.Property.BorderlineWidth, borderlineWidth)
.Add(Visual.Property.BorderlineColor, borderlineColor)
.Add(Visual.Property.BorderlineOffset, borderlineOffset);
map.Add(Visual.Property.CornerRadius, backgroundExtraData.CornerRadius)
.Add(Visual.Property.CornerSquareness, backgroundExtraData.CornerSquareness)
.Add(Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy)
.Add(Visual.Property.BorderlineWidth, backgroundExtraData.BorderlineWidth)
.Add(Visual.Property.BorderlineColor, backgroundExtraData.BorderlineColor == null ? Color.Black : backgroundExtraData.BorderlineColor)
.Add(Visual.Property.BorderlineOffset, backgroundExtraData.BorderlineOffset);
}

backgroundExtraDataUpdatedFlag &= ~BackgroundExtraDataUpdatedFlag.Background;
Expand Down Expand Up @@ -2760,26 +2745,15 @@ private void SetBackgroundColor(Color value)
}

using var map = new PropertyMap();
using var colorType = new PropertyValue((int)Visual.Type.Color);
using var mixColor = new PropertyValue(value);
using var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
using var cornerRadius = new PropertyValue(cornerRadiusValue);
using var cornerSquarenessValue = backgroundExtraData.CornerSquareness == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerSquareness);
using var cornerSquareness = new PropertyValue(cornerSquarenessValue);
using var cornerRadiusPolicy = new PropertyValue((int)(backgroundExtraData.CornerRadiusPolicy));
using var borderlineWidth = new PropertyValue(backgroundExtraData.BorderlineWidth);
using var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
using var borderlineColor = new PropertyValue(borderlineColorValue);
using var borderlineOffset = new PropertyValue(backgroundExtraData.BorderlineOffset);

map.Add(Visual.Property.Type, colorType)
.Add(ColorVisualProperty.MixColor, mixColor)
.Add(Visual.Property.CornerRadius, cornerRadius)
.Add(Visual.Property.CornerSquareness, cornerSquareness)
.Add(Visual.Property.CornerRadiusPolicy, cornerRadiusPolicy)
.Add(Visual.Property.BorderlineWidth, borderlineWidth)
.Add(Visual.Property.BorderlineColor, borderlineColor)
.Add(Visual.Property.BorderlineOffset, borderlineOffset);

map.Add(Visual.Property.Type, (int)Visual.Type.Color)
.Add(ColorVisualProperty.MixColor, value)
.Add(Visual.Property.CornerRadius, backgroundExtraData.CornerRadius)
.Add(Visual.Property.CornerSquareness, backgroundExtraData.CornerSquareness)
.Add(Visual.Property.CornerRadiusPolicy, (int)(backgroundExtraData.CornerRadiusPolicy))
.Add(Visual.Property.BorderlineWidth, backgroundExtraData.BorderlineWidth)
.Add(Visual.Property.BorderlineColor, backgroundExtraData.BorderlineColor == null ? Color.Black : backgroundExtraData.BorderlineColor)
.Add(Visual.Property.BorderlineOffset, backgroundExtraData.BorderlineOffset);

backgroundExtraDataUpdatedFlag &= ~BackgroundExtraDataUpdatedFlag.Background;

Expand Down
Loading

0 comments on commit b48cb82

Please sign in to comment.