From 84f8575e45e7bbac272dd6edb0b823c2cd23ee90 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 7 Feb 2024 16:34:04 +0100 Subject: [PATCH] fix: Background image should not adjust area --- .../Border/BorderLayerRenderer.skia.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.skia.cs b/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.skia.cs index 10fb94fa6edf..8c4ec110fb06 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.skia.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.skia.cs @@ -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; } @@ -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 { @@ -283,7 +277,7 @@ void CreateLayer(Action 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 = () => { @@ -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)