Skip to content

Commit

Permalink
perf: Add CreateInstance binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Apr 4, 2023
1 parent 2f3a3e8 commit 75f0bbc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#if NET7_0_OR_GREATER
using System;
using System.Runtime.InteropServices.JavaScript;

namespace __Windows.UI.Xaml.Media.Animation
{
internal partial class RenderingLoopAnimator
{
internal static partial class NativeMethods
{
[JSImport("globalThis.Windows.UI.Xaml.Media.Animation.RenderingLoopAnimator.createInstance")]
internal static partial void CreateInstance(IntPtr managedHandle, double id);
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
using Uno.Foundation.Interop;
using Uno.Foundation.Logging;

#if NET7_0_OR_GREATER
using NativeMethods = __Windows.UI.Xaml.Media.Animation.RenderingLoopAnimator.NativeMethods;
#endif

namespace Windows.UI.Xaml.Media.Animation
{
internal abstract class RenderingLoopAnimator<T> : CPUBoundAnimator<T>, IJSObject where T : struct
Expand Down Expand Up @@ -94,7 +98,12 @@ private Metadata() { }
public long CreateNativeInstance(IntPtr managedHandle)
{
var id = RenderingLoopAnimatorMetadataIdProvider.Next();

#if NET7_0_OR_GREATER
NativeMethods.CreateInstance(managedHandle, id);
#else
WebAssemblyRuntime.InvokeJS($"Windows.UI.Xaml.Media.Animation.RenderingLoopAnimator.createInstance(\"{managedHandle}\", \"{id}\")");
#endif

return id;
}
Expand Down

0 comments on commit 75f0bbc

Please sign in to comment.