Skip to content

Commit

Permalink
perf(WindowManager): Add SetElementTransformNativeFast binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Jan 10, 2023
1 parent 6c33537 commit 89d6b2b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ internal static void SetElementTransform(IntPtr htmlId, Matrix3x2 matrix)
}
else
{
#if NET7_0_OR_GREATER
NativeMethods.SetElementTransform(htmlId, matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32);
#else
var parms = new WindowManagerSetElementTransformParams
{
HtmlId = htmlId,
Expand All @@ -199,6 +202,7 @@ internal static void SetElementTransform(IntPtr htmlId, Matrix3x2 matrix)
};

TSInteropMarshaller.InvokeJS("Uno:setElementTransformNative", parms);
#endif
}
}

Expand Down Expand Up @@ -1565,6 +1569,9 @@ internal static partial void ArrangeElement(
[JSImport("globalThis.Uno.UI.WindowManager.current.setAttributesNativeFast")]
internal static partial void SetAttributes(IntPtr htmlId, string[] pairs);

[JSImport("globalThis.Uno.UI.WindowManager.current.setElementTransformNativeFast")]
internal static partial void SetElementTransform(IntPtr htmlId, float m11, float m12, float m21, float m22, float m31, float m32);

[JSImport("globalThis.Uno.UI.WindowManager.current.setPointerEventsNativeFast")]
internal static partial void SetPointerEvents(IntPtr htmlId, bool enabled);

Expand Down
22 changes: 16 additions & 6 deletions src/Uno.UI/ts/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,16 +895,26 @@ namespace Uno.UI {
public setElementTransformNative(pParams: number): boolean {

const params = WindowManagerSetElementTransformParams.unmarshal(pParams);
const element = this.getView(params.HtmlId);

const style = element.style;
this.setElementTransformNativeFast(params.HtmlId, params.M11, params.M12, params.M21, params.M22, params.M31, params.M32);

const matrix = `matrix(${params.M11},${params.M12},${params.M21},${params.M22},${params.M31},${params.M32})`;
style.transform = matrix;
return true;
}

this.setAsArranged(element);
public setElementTransformNativeFast(
htmlId: number,
m11: number,
m12: number,
m21: number,
m22: number,
m31: number,
m32: number) {

return true;
const element = this.getView(htmlId);

element.style.transform = `matrix(${m11},${m12},${m21},${m22},${m31},${m32})`;

this.setAsArranged(element);
}

private setPointerEvents(htmlId: number, enabled: boolean) {
Expand Down

0 comments on commit 89d6b2b

Please sign in to comment.