Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Adjust IsLayoutRequested interop on arrange #10426

Merged
merged 2 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions build/PackageDiffIgnore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9028,6 +9028,27 @@
<Properties>
</Properties>
</IgnoreSet>

<IgnoreSet baseVersion="4.6">
<Types>
</Types>

<Events>
</Events>

<Fields>
</Fields>

<Properties>
</Properties>

<Methods>
<Member fullName="System.Void Uno.UI.UnoViewGroup.OnLayoutCore(System.Boolean p0, System.Int32 p1, System.Int32 p2, System.Int32 p3, System.Int32 p4)"
reason="Externally unused API for android layouting" />
</Methods>
</IgnoreSet>


<!--
Supported nodes (please keep at the bottom of this file):
<IgnoreSet baseVersion="0.0">
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI.BindingHelper.Android/Uno/UI/UnoViewGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ public final void nativeFinishLayoutOverride(){
_unoLayoutOverride = false;
}

protected abstract void onLayoutCore(boolean changed, int left, int top, int right, int bottom);
protected abstract void onLayoutCore(boolean changed, int left, int top, int right, int bottom, boolean isLayoutRequested);

protected final void onLayout(boolean changed, int left, int top, int right, int bottom)
{
if(!_unoLayoutOverride)
{
onLayoutCore(changed, left, top, right, bottom);
onLayoutCore(changed, left, top, right, bottom, isLayoutRequested());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/Controls/BindableView.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void Initialize()
InitializeBinder();
}

protected override void OnLayoutCore(bool changed, int l, int t, int r, int b)
protected override void OnLayoutCore(bool changed, int l, int t, int r, int b, bool localIsLayoutRequested)
{

}
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/Border/Border.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ private protected override void OnUnloaded()
_borderRenderer.Clear();
}

protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom)
protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom, bool localIsLayoutRequested)
{
base.OnLayoutCore(changed, left, top, right, bottom);
base.OnLayoutCore(changed, left, top, right, bottom, localIsLayoutRequested);

UpdateBorder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public ContentPresenter()
IFrameworkElementHelper.Initialize(this);
}

protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom)
protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom, bool localIsLayoutRequested)
{
base.OnLayoutCore(changed, left, top, right, bottom);
base.OnLayoutCore(changed, left, top, right, bottom, localIsLayoutRequested);

UpdateBorder();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/Panel/Panel.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ private void UpdateBorder(bool willUpdateMeasures)
}
}

protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom)
protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom, bool localIsLayoutRequested)
{
base.OnLayoutCore(changed, left, top, right, bottom);
base.OnLayoutCore(changed, left, top, right, bottom, localIsLayoutRequested);

UpdateBorder(changed);
}
Expand Down
9 changes: 5 additions & 4 deletions src/Uno.UI/UI/Xaml/FrameworkElement.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ void ILayouterElement.SetMeasuredDimensionInternal(int width, int height)
SetMeasuredDimension(width, height);
}

protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom)
protected override void OnLayoutCore(bool changed, int left, int top, int right, int bottom, bool localIsLayoutRequested)
{
try
{
base.OnLayoutCore(changed, left, top, right, bottom);
base.OnLayoutCore(changed, left, top, right, bottom, localIsLayoutRequested);

Rect finalRect;
if (TransientArrangeFinalRect is Rect tafr)
Expand Down Expand Up @@ -244,7 +244,8 @@ protected override void OnLayoutCore(bool changed, int left, int top, int right,
(changed && _lastLayoutSize != finalRect.Size)

// Even if nothing changed, but a layout was requested, arrange the children.
|| IsLayoutRequested
// Use the copy grabbed from the native invocation to avoid an additional interop call
|| localIsLayoutRequested
)
{
_lastLayoutSize = finalRect.Size;
Expand Down Expand Up @@ -281,7 +282,7 @@ internal void FastLayout(bool changed, int left, int top, int right, int bottom)
NativeStartLayoutOverride(left, top, right, bottom);

// Invoke our own layouting without going back and fort with Java.
OnLayoutCore(changed, left, top, right, bottom);
OnLayoutCore(changed, left, top, right, bottom, IsLayoutRequested);
}
finally
{
Expand Down