|
@@ -1,9 +1,7 @@
|
|
using System;
|
|
using System;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
using Avalonia.Animation;
|
|
using Avalonia.Animation;
|
|
-using Avalonia.Animation.Animators;
|
|
|
|
using Avalonia.Media.Immutable;
|
|
using Avalonia.Media.Immutable;
|
|
-using Avalonia.Reactive;
|
|
|
|
using Avalonia.Rendering.Composition;
|
|
using Avalonia.Rendering.Composition;
|
|
using Avalonia.Rendering.Composition.Drawing;
|
|
using Avalonia.Rendering.Composition.Drawing;
|
|
using Avalonia.Rendering.Composition.Server;
|
|
using Avalonia.Rendering.Composition.Server;
|
|
@@ -40,8 +38,8 @@ namespace Avalonia.Media
|
|
/// </summary>
|
|
/// </summary>
|
|
public double Opacity
|
|
public double Opacity
|
|
{
|
|
{
|
|
- get { return GetValue(OpacityProperty); }
|
|
|
|
- set { SetValue(OpacityProperty, value); }
|
|
|
|
|
|
+ get => GetValue(OpacityProperty);
|
|
|
|
+ set => SetValue(OpacityProperty, value);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -49,8 +47,8 @@ namespace Avalonia.Media
|
|
/// </summary>
|
|
/// </summary>
|
|
public ITransform? Transform
|
|
public ITransform? Transform
|
|
{
|
|
{
|
|
- get { return GetValue(TransformProperty); }
|
|
|
|
- set { SetValue(TransformProperty, value); }
|
|
|
|
|
|
+ get => GetValue(TransformProperty);
|
|
|
|
+ set => SetValue(TransformProperty, value);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -73,28 +71,30 @@ namespace Avalonia.Media
|
|
|
|
|
|
if (s.Length > 0)
|
|
if (s.Length > 0)
|
|
{
|
|
{
|
|
- if (s[0] == '#')
|
|
|
|
- {
|
|
|
|
- return new ImmutableSolidColorBrush(Color.Parse(s));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ // Attempt to get a cached known brush first
|
|
|
|
+ // This is a performance optimization for known colors
|
|
var brush = KnownColors.GetKnownBrush(s);
|
|
var brush = KnownColors.GetKnownBrush(s);
|
|
if (brush != null)
|
|
if (brush != null)
|
|
{
|
|
{
|
|
return brush;
|
|
return brush;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (Color.TryParse(s, out Color color))
|
|
|
|
+ {
|
|
|
|
+ return new ImmutableSolidColorBrush(color);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
throw new FormatException($"Invalid brush string: '{s}'.");
|
|
throw new FormatException($"Invalid brush string: '{s}'.");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
{
|
|
{
|
|
if (change.Property == TransformProperty)
|
|
if (change.Property == TransformProperty)
|
|
_resource.ProcessPropertyChangeNotification(change);
|
|
_resource.ProcessPropertyChangeNotification(change);
|
|
|
|
|
|
RegisterForSerialization();
|
|
RegisterForSerialization();
|
|
-
|
|
|
|
|
|
+
|
|
base.OnPropertyChanged(change);
|
|
base.OnPropertyChanged(change);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -126,7 +126,7 @@ namespace Avalonia.Media
|
|
if(_resource.Release(c))
|
|
if(_resource.Release(c))
|
|
OnUnreferencedFromCompositor(c);
|
|
OnUnreferencedFromCompositor(c);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
protected virtual void OnUnreferencedFromCompositor(Compositor c)
|
|
protected virtual void OnUnreferencedFromCompositor(Compositor c)
|
|
{
|
|
{
|
|
if (Transform is ICompositionRenderResource<ITransform> resource)
|
|
if (Transform is ICompositionRenderResource<ITransform> resource)
|
|
@@ -139,7 +139,7 @@ namespace Avalonia.Media
|
|
{
|
|
{
|
|
ServerCompositionSimpleBrush.SerializeAllChanges(writer, Opacity, TransformOrigin, Transform.GetServer(c));
|
|
ServerCompositionSimpleBrush.SerializeAllChanges(writer, Opacity, TransformOrigin, Transform.GetServer(c));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
void ICompositorSerializable.SerializeChanges(Compositor c, BatchStreamWriter writer) => SerializeChanges(c, writer);
|
|
void ICompositorSerializable.SerializeChanges(Compositor c, BatchStreamWriter writer) => SerializeChanges(c, writer);
|
|
}
|
|
}
|
|
}
|
|
}
|