Skip to content

Commit

Permalink
perf: Bundle Paint reset steps in Java
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Sep 7, 2023
1 parent c94ddc0 commit 9e168b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 15 additions & 0 deletions src/Uno.UI.BindingHelper.Android/Uno/UI/BrushNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,19 @@ public static void buildBackgroundCornerRadius(
paint.setColor(fillPaint.getColor());
paint.setShader(fillPaint.getShader());
}


public static void resetPaintForStroke(Paint paint)
{
paint.reset();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.STROKE);
}

public static void resetPaintForFill(Paint paint)
{
paint.reset();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
}
}
8 changes: 2 additions & 6 deletions src/Uno.UI/UI/Xaml/Media/Brush.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ internal void ApplyToFillPaint(Windows.Foundation.Rect destinationRect, Paint pa
throw new ArgumentNullException(nameof(paint));
}

paint.Reset();
paint.AntiAlias = true;
BrushNative.ResetPaintForFill(paint);
ApplyToPaintInner(destinationRect, paint);
paint.SetStyle(SystemFill);
}

/// <summary>
Expand All @@ -57,10 +55,8 @@ internal void ApplyToStrokePaint(Windows.Foundation.Rect destinationRect, Paint
throw new ArgumentNullException(nameof(paint));
}

paint.Reset();
paint.AntiAlias = true;
BrushNative.ResetPaintForStroke(paint);
ApplyToPaintInner(destinationRect, paint);
paint.SetStyle(SystemStroke);
}

private protected virtual void ApplyToPaintInner(Rect destinationRect, Paint paint) => throw new InvalidOperationException();
Expand Down

0 comments on commit 9e168b4

Please sign in to comment.