Skip to content

Commit

Permalink
perf: Add EnableFrameReporting binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Apr 24, 2023
1 parent 5ec71ed commit 0f04f79
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ private JSObjectHandle(object target, IJSObjectMetadata metadata)
/// </summary>
public bool IsAlive { get; private set; }

internal long JSHandle => _jsHandle;

internal nint ManagedHandle => _managedHandle;

/// <summary>
/// Metadata about the marshaled object
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ internal static partial class NativeMethods

[JSImport("globalThis.Windows.UI.Xaml.Media.Animation.RenderingLoopAnimator.destroyInstance")]
internal static partial void DestroyInstance(double jsHandle);

[JSImport("globalThis.Windows.UI.Xaml.Media.Animation.RenderingLoopAnimator.enableFrameReporting")]
internal static partial void EnableFrameReporting(double jsHandle);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ protected override void EnableFrameReporting()
{
if (Handle.IsAlive)
{
#if NET7_0_OR_GREATER
NativeMethods.EnableFrameReporting(Handle.JSHandle);
#else
WebAssemblyRuntime.InvokeJSWithInterop($"{this}.EnableFrameReporting();");
#endif
}
else if (this.Log().IsEnabled(LogLevel.Debug))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
}
}

public static enableFrameReporting(jsHandle: number) {
RenderingLoopAnimator.getInstance(jsHandle).EnableFrameReporting();
}

public EnableFrameReporting() {
if (this._isEnabled) {
return;
Expand Down

0 comments on commit 0f04f79

Please sign in to comment.