-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NUI] Make FrameUpdateCallback could use UIVector2 and UIColor #6590
Conversation
Internal API ChangedAdded: 8, Removed: 0, Changed: 0Added+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::BakeColor(System.UInt32,Tizen.NUI.UIColor)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::BakePosition(System.UInt32,Tizen.NUI.UIVector2)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::BakeScale(System.UInt32,Tizen.NUI.UIVector2)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::BakeSize(System.UInt32,Tizen.NUI.UIVector2)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::GetColor(System.UInt32,Tizen.NUI.UIColor&)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::GetPosition(System.UInt32,Tizen.NUI.UIVector2&)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::GetScale(System.UInt32,Tizen.NUI.UIVector2&)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::GetSize(System.UInt32,Tizen.NUI.UIVector2&)
|
Let we allow to use FrameUpdateCallbackInterface could use UIVector2 and UIColor so we can reduce GC call at render thread. Require dali patch : https://review.tizen.org/gerrit/c/platform/core/uifw/dali-csharp-binder/+/318520 Signed-off-by: Eunki, Hong <[email protected]>
870a9d1
to
7cee53f
Compare
Internal API ChangedAdded: 8, Removed: 0, Changed: 0Added+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::BakeColor(System.UInt32,Tizen.NUI.UIColor)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::BakePosition(System.UInt32,Tizen.NUI.UIVector2)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::BakeScale(System.UInt32,Tizen.NUI.UIVector2)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::BakeSize(System.UInt32,Tizen.NUI.UIVector2)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::GetColor(System.UInt32,Tizen.NUI.UIColor&)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::GetPosition(System.UInt32,Tizen.NUI.UIVector2&)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::GetScale(System.UInt32,Tizen.NUI.UIVector2&)
+ /// <since_tizen>none</since_tizen
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ System.Boolean Tizen.NUI.FrameUpdateCallbackInterface::GetSize(System.UInt32,Tizen.NUI.UIVector2&)
|
{ | ||
return false; | ||
} | ||
bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceBakePositionVector2Componentwise(proxyIntPtr, id, position.X, position.Y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, there is a ReusablePool<T>
that reuses object for PInvoke.
For example,
TizenFX/src/Tizen.NUI/src/internal/Common/Object.cs
Lines 331 to 344 in 9258291
internal static void InternalSetPropertyColor(HandleRef actor, int propertyType, UIColor color) | |
{ | |
if (actor.Handle == System.IntPtr.Zero) | |
{ | |
throw new System.InvalidOperationException("Error! NUI's native dali object is already disposed. OR the native dali object handle of NUI becomes null!"); | |
} | |
ReusablePool<Vector4>.GetOne((vector4, actor, propertyType, color) => | |
{ | |
vector4.Reset(color); | |
_ = Interop.Actor.InternalSetPropertyVector4(actor, propertyType, vector4.SwigCPtr); | |
NDalicPINVOKE.ThrowExceptionIfExists(); | |
}, actor, propertyType, color); | |
} |
This code gets
Vector4
object from the pool and use it for PInvoke and return it back to the pool.By using this, you can avoid to create bindings for every struct cases.
protected bool BakePosition(uint id, UIVector2 position)
{
if (proxyIntPtr == IntPtr.Zero)
{
return false;
}
return ReusablePool<Vector3>.GetOne((vector3, proxyIntPtr, id, position) =>
{
vector3.Reset(position.X, position.Y, 0); // I am not sure there's a Reset for Vector3
bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceBakePosition(proxyIntPtr, id, position);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}, proxyIntPtr, id, position);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I know, ReusablePool
is not thread safe. This API will be called at RenderThread, so I think we cannot use this pool here :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my.. It need to be thread safe! since current resuable pool is not thread safe you would not use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve.
And if it requires cost to use Vector2 in NUI.
How do you think about to deprecate previous apis.
Because the FrameUpdateCallback is called in every frame so it looks be better to guide for VD to use new API.
Let we allow to use FrameUpdateCallbackInterface could use UIVector2 and UIColor so we can reduce GC call at render thread.
Require dali patch :
https://review.tizen.org/gerrit/c/platform/core/uifw/dali-csharp-binder/+/318520