Skip to content

Commit

Permalink
perf: Generate Brush.Opacity and RelativeTransform DPs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed May 6, 2021
1 parent f0b29e3 commit 516fbb6
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions src/Uno.UI/UI/Xaml/Media/Brush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,12 @@ public Brush()

public double Opacity
{
get => (double)GetValue(OpacityProperty);
set => SetValue(OpacityProperty, value);
get => GetOpacityValue();
set => SetOpacityValue(value);
}

// Using a DependencyProperty as the backing store for Opacity. This enables animation, styling, binding, etc...
public static DependencyProperty OpacityProperty { get ; } =
DependencyProperty.Register(
"Opacity",
typeof(double),
typeof(Brush),
new FrameworkPropertyMetadata(
defaultValue: 1d,
propertyChangedCallback: (s, e) => ((Brush)s).OnOpacityChanged((double)e.OldValue, (double)e.NewValue)
)
);
[GeneratedDependencyProperty(DefaultValue = 1d, ChangedCallback = true)]
public static DependencyProperty OpacityProperty { get ; } = CreateOpacityProperty();

protected virtual void OnOpacityChanged(double oldValue, double newValue)
{
Expand All @@ -60,20 +51,12 @@ public Windows.UI.Xaml.Media.Transform Transform

public Transform RelativeTransform
{
get => (Transform)GetValue(RelativeTransformProperty);
set => SetValue(RelativeTransformProperty, value);
get => GetRelativeTransformValue();
set => SetRelativeTransformValue(value);
}

public static DependencyProperty RelativeTransformProperty { get ; } =
DependencyProperty.Register(
"RelativeTransform",
typeof(Transform),
typeof(Brush),
new FrameworkPropertyMetadata(
null,

propertyChangedCallback: (s, e) =>
((Brush)s).OnRelativeTransformChanged((Transform)e.OldValue, (Transform)e.NewValue)));
[GeneratedDependencyProperty(DefaultValue = null, ChangedCallback = true)]
public static DependencyProperty RelativeTransformProperty { get ; } = CreateRelativeTransformProperty();

protected virtual void OnRelativeTransformChanged(Transform oldValue, Transform newValue)
{
Expand Down

0 comments on commit 516fbb6

Please sign in to comment.