Skip to content

Commit

Permalink
[NUI] Allow to call FrameUpdate callback return value
Browse files Browse the repository at this point in the history
DALi's FrameUpdateCallback have interface whether we need to update scene or not.
Previously, we always return it as false.
It might make some render / update timing issue when App is paused.

To make ensure whether we need to update scene or not,
Let we override the new API that app can control the return value.

Signed-off-by: Eunki, Hong <[email protected]>
  • Loading branch information
Eunki, Hong authored and dongsug-song committed Jan 16, 2024
1 parent e2e6b78 commit 870b5c0
Show file tree
Hide file tree
Showing 3 changed files with 729 additions and 673 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ internal static partial class FrameUpdateCallbackInterface
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_FrameCallbackInterface")]
public static extern global::System.IntPtr newFrameUpdateCallbackInterface();

[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FrameCallbackInterface_director_connect")]
public static extern void FrameUpdateCallbackInterfaceDirectorConnect(global::System.Runtime.InteropServices.HandleRef jarg1, Tizen.NUI.FrameUpdateCallbackInterface.DelegateFrameUpdateCallbackInterface delegate0);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FrameCallbackInterface_director_connect_with_return")]
public static extern void FrameUpdateCallbackInterfaceDirectorConnectV1(global::System.Runtime.InteropServices.HandleRef jarg1, Tizen.NUI.FrameUpdateCallbackInterface.DelegateFrameUpdateCallbackInterfaceV1 delegate1);

[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FrameCallbackInterface_GetPosition")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
Expand Down
55 changes: 44 additions & 11 deletions src/Tizen.NUI/src/public/Common/FrameUpdateCallbackInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,76 @@ namespace Tizen.NUI
[EditorBrowsable(EditorBrowsableState.Never)]
public class FrameUpdateCallbackInterface : Disposable
{
private uint onUpdateCallbackVersion = 0u;

/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
internal FrameUpdateCallbackInterface(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public FrameUpdateCallbackInterface() : this(Interop.FrameUpdateCallbackInterface.newFrameUpdateCallbackInterface(), true)
public FrameUpdateCallbackInterface() : this(0u)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public FrameUpdateCallbackInterface(uint updateCallbackVersion) : this(Interop.FrameUpdateCallbackInterface.newFrameUpdateCallbackInterface(), true)
{
onUpdateCallbackVersion = updateCallbackVersion;
DirectorConnect();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public uint UpdateCallbackVersion => onUpdateCallbackVersion;

private void DirectorConnect()
{
Delegate0 = new DelegateFrameUpdateCallbackInterface(DirectorOnUpdate);
Interop.FrameUpdateCallbackInterface.FrameUpdateCallbackInterfaceDirectorConnect(SwigCPtr, Delegate0);
Delegate1 = new DelegateFrameUpdateCallbackInterfaceV1(DirectorOnUpdate);
Interop.FrameUpdateCallbackInterface.FrameUpdateCallbackInterfaceDirectorConnectV1(SwigCPtr, Delegate1);
}

private global::System.IntPtr proxyIntPtr;
private void DirectorOnUpdate(global::System.IntPtr proxy, float elapsedSeconds)
private global::System.IntPtr proxyIntPtr = global::System.IntPtr.Zero;

private bool DirectorOnUpdate(global::System.IntPtr proxy, float elapsedSeconds)
{
bool ret = false;

proxyIntPtr = proxy;
OnUpdate(elapsedSeconds);
return;
}
if (onUpdateCallbackVersion == 0u)
{
OnUpdate(elapsedSeconds);
}
else if (onUpdateCallbackVersion == 1u)
{
ret = OnUpdate(this, elapsedSeconds);
}
proxyIntPtr = global::System.IntPtr.Zero;

internal delegate void DelegateFrameUpdateCallbackInterface(global::System.IntPtr proxy, float elapsedSeconds);
private DelegateFrameUpdateCallbackInterface Delegate0;
return ret;
}

internal delegate bool DelegateFrameUpdateCallbackInterfaceV1(global::System.IntPtr proxy, float elapsedSeconds);
private DelegateFrameUpdateCallbackInterfaceV1 Delegate1;

/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void OnUpdate(float elapsedSeconds)
{
}

/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnUpdate(FrameUpdateCallbackInterface obj, float elapsedSeconds)
{
// Let we call Versoin 0 API. To keep backward capability.
OnUpdate(elapsedSeconds);
return false;
}

/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
Expand Down
Loading

0 comments on commit 870b5c0

Please sign in to comment.