Skip to content

Commit

Permalink
perf: Add DisableFrameReporting binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Apr 24, 2023
1 parent 0f04f79 commit 65ffab1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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.disableFrameReporting")]
internal static partial void DisableFrameReporting(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 @@ -41,7 +41,11 @@ protected override void DisableFrameReporting()
{
if (Handle.IsAlive)
{
#if NET7_0_OR_GREATER
NativeMethods.DisableFrameReporting(Handle.JSHandle);
#else
WebAssemblyRuntime.InvokeJSWithInterop($"{this}.DisableFrameReporting();");
#endif
}
else if (this.Log().IsEnabled(LogLevel.Debug))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
this.scheduleAnimationFrame();
}

public static disableFrameReporting(jsHandle: number) {
RenderingLoopAnimator.getInstance(jsHandle).DisableFrameReporting();
}

public DisableFrameReporting() {
this._isEnabled = false;
this.unscheduleFrame();
Expand Down

0 comments on commit 65ffab1

Please sign in to comment.