From 6090b70e4856ff9d7e55dcf6c9f48f436a685153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20S=CC=8Colte=CC=81s?= Date: Fri, 26 Jan 2024 19:22:00 +0100 Subject: [PATCH] Move reload invalidation --- src/Avalonia.Svg.Skia/SvgImage.cs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Svg.Skia/SvgImage.cs b/src/Avalonia.Svg.Skia/SvgImage.cs index 2bbc326a..4c26370f 100644 --- a/src/Avalonia.Svg.Skia/SvgImage.cs +++ b/src/Avalonia.Svg.Skia/SvgImage.cs @@ -64,12 +64,6 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect) { var source = Source; - var style = string.Concat(Style, ' ', CurrentStyle); - if (source?.Parameters?.Style != style) - { - source?.ReLoad(new SvgParameters(null, style)); - } - if (source?.Picture is null) { return; @@ -101,9 +95,30 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect) protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { base.OnPropertyChanged(change); + if (change.Property == SourceProperty) { // TODO: Invalidate IImage } + + if (change.Property == StyleProperty) + { + var style = string.Concat(Style, ' ', CurrentStyle); + + if (Source?.Parameters?.Style != style) + { + Source?.ReLoad(new SvgParameters(null, style)); + } + } + + if (change.Property == CurrentStyleProperty) + { + var style = string.Concat(Style, ' ', CurrentStyle); + + if (Source?.Parameters?.Style != style) + { + Source?.ReLoad(new SvgParameters(null, style)); + } + } } }