Skip to content

Commit bb71491

Browse files
committed
perf: Remove use of generic delegate in Brush.AssignAndObserveBrush
1 parent 05bb15d commit bb71491

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/Uno.UI/UI/Xaml/Media/Brush.Android.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace Windows.UI.Xaml.Media
1616
//Android partial for Brush
1717
public partial class Brush
1818
{
19+
internal delegate void ColorSetterHandler(Android.Graphics.Color color);
20+
1921
/// <summary>
2022
/// Return a paint with Fill style
2123
/// </summary>
@@ -42,7 +44,7 @@ internal Paint GetStrokePaint(Windows.Foundation.Rect destinationRect)
4244

4345
protected virtual Paint GetPaintInner(Rect destinationRect) => throw new InvalidOperationException();
4446

45-
internal static IDisposable AssignAndObserveBrush(Brush b, Action<Android.Graphics.Color> colorSetter, Action imageBrushCallback = null)
47+
internal static IDisposable AssignAndObserveBrush(Brush b, ColorSetterHandler colorSetter, Action imageBrushCallback = null)
4648
{
4749
if (b is SolidColorBrush colorBrush)
4850
{

src/Uno.UI/UI/Xaml/Media/Brush.Skia.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ namespace Windows.UI.Xaml.Media
99
{
1010
public abstract partial class Brush
1111
{
12-
internal static IDisposable AssignAndObserveBrush(Brush b, Action<Color> colorSetter, Action imageBrushCallback = null)
12+
internal delegate void ColorSetterHandler(Color color);
13+
14+
internal static IDisposable AssignAndObserveBrush(Brush b, ColorSetterHandler colorSetter, Action imageBrushCallback = null)
1315
{
1416
var disposables = new CompositeDisposable();
1517

src/Uno.UI/UI/Xaml/Media/Brush.iOSmacOS.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ namespace Windows.UI.Xaml.Media
1919
// iOS partial for SolidColorBrush
2020
public partial class Brush
2121
{
22-
internal static IDisposable AssignAndObserveBrush(Brush b, Action<CGColor> colorSetter, Action imageBrushCallback = null)
22+
internal delegate void ColorSetterHandler(CGColor color);
23+
24+
internal static IDisposable AssignAndObserveBrush(Brush b, ColorSetterHandler colorSetter, Action imageBrushCallback = null)
2325
{
2426
if (b is SolidColorBrush colorBrush)
2527
{

src/Uno.UI/UI/Xaml/Media/Brush.wasm.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@
33
using System.Text;
44
using Uno.Extensions;
55
using Uno.Disposables;
6+
using Windows.UI; // Required for WinUI 3+ Color
67

78
namespace Windows.UI.Xaml.Media
89
{
910
public abstract partial class Brush
1011
{
11-
internal static IDisposable AssignAndObserveBrush(Brush b, Action<Windows.UI.Color> colorSetter, Action imageBrushCallback = null)
12+
/// <summary>
13+
/// Color action handler
14+
/// </summary>
15+
/// <remarks>
16+
/// This delegate is not an <see cref="Action{T}"/> to account for https://github.com/dotnet/runtime/issues/50757
17+
/// </remarks>
18+
internal delegate void ColorSetterHandler(Color color);
19+
20+
internal static IDisposable AssignAndObserveBrush(Brush b, ColorSetterHandler colorSetter, Action imageBrushCallback = null)
1221
{
1322
if (b is SolidColorBrush colorBrush)
1423
{

0 commit comments

Comments
 (0)