Skip to content

Commit

Permalink
fix: Background image should not adjust area
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Feb 8, 2024
1 parent bd09142 commit 84f8575
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,15 @@ partial void UpdatePlatform()

if (!newState.Equals(previousLayoutState))
{
if (
newState.Background != null ||
_layerDisposable.Disposable = null;

if (newState.Background != null ||
newState.CornerRadius != CornerRadius.None ||
(newState.BorderThickness != Thickness.Empty && newState.BorderBrush != null)
)
(newState.BorderThickness != Thickness.Empty && newState.BorderBrush != null))
{

_layerDisposable.Disposable = null;
_layerDisposable.Disposable = InnerCreateLayer(_owner, newState);
}
else
{
_layerDisposable.Disposable = null;
}

_currentState = newState;
}
Expand Down Expand Up @@ -112,10 +107,9 @@ private static IDisposable InnerCreateLayer(UIElement owner, BorderLayerState st
{
var backgroundShape = compositor.CreateSpriteShape();

// First we set the brush as it might alter the adjustedArea
if (background is ImageBrush imgBackground)
{
adjustedArea = CreateImageLayer(compositor, disposables, borderThickness, adjustedArea, backgroundShape, adjustedArea, imgBackground);
CreateImageLayer(compositor, disposables, borderThickness, adjustedArea, backgroundShape, adjustedArea, imgBackground);
}
else
{
Expand Down Expand Up @@ -283,7 +277,7 @@ void CreateLayer(Action<CompositionSpriteShape, SKPath> builder, string name)
return disposables;
}

private static Rect CreateImageLayer(Compositor compositor, CompositeDisposable disposables, Thickness borderThickness, Rect adjustedArea, CompositionSpriteShape backgroundShape, Rect backgroundArea, ImageBrush imgBackground)
private static void CreateImageLayer(Compositor compositor, CompositeDisposable disposables, Thickness borderThickness, Rect adjustedArea, CompositionSpriteShape backgroundShape, Rect backgroundArea, ImageBrush imgBackground)
{
Action onInvalidateRender = () =>
{
Expand Down Expand Up @@ -325,7 +319,6 @@ private static Rect CreateImageLayer(Compositor compositor, CompositeDisposable
onInvalidateRender();
imgBackground.InvalidateRender += onInvalidateRender;
new DisposableAction(() => imgBackground.InvalidateRender -= onInvalidateRender).DisposeWith(disposables);
return backgroundArea;
}

private static CompositionPath GetBackgroundPath(SKPoint[] radii, Rect area)
Expand Down

0 comments on commit 84f8575

Please sign in to comment.