Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] cache Join and Cap enum values #24248

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions src/Core/src/Graphics/MauiDrawable.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ namespace Microsoft.Maui.Graphics
{
public class MauiDrawable : PaintDrawable
{
static Join? JoinMiter;
static Join? JoinBevel;
static Join? JoinRound;

static Cap? CapButt;
static Cap? CapSquare;
static Cap? CapRound;

readonly AContext? _context;
readonly float _density;

Expand Down Expand Up @@ -298,20 +306,13 @@ public void SetBorderMiterLimit(float strokeMiterLimit)

public void SetBorderLineJoin(LineJoin lineJoin)
{
Join? aLineJoin = Join.Miter;

switch (lineJoin)
Join? aLineJoin = lineJoin switch
{
case LineJoin.Miter:
aLineJoin = Join.Miter;
break;
case LineJoin.Bevel:
aLineJoin = Join.Bevel;
break;
case LineJoin.Round:
aLineJoin = Join.Round;
break;
}
LineJoin.Miter => JoinMiter ??= Join.Miter,
LineJoin.Bevel => JoinBevel ??= Join.Bevel,
LineJoin.Round => JoinRound ??= Join.Round,
_ => JoinMiter ??= Join.Miter,
};

if (_strokeLineJoin == aLineJoin)
return;
Expand All @@ -323,20 +324,13 @@ public void SetBorderLineJoin(LineJoin lineJoin)

public void SetBorderLineCap(LineCap lineCap)
{
Cap? aLineCap = Cap.Butt;

switch (lineCap)
Cap? aLineCap = lineCap switch
{
case LineCap.Butt:
aLineCap = Cap.Butt;
break;
case LineCap.Square:
aLineCap = Cap.Square;
break;
case LineCap.Round:
aLineCap = Cap.Round;
break;
}
LineCap.Butt => CapButt ??= Cap.Butt,
LineCap.Square => CapSquare ??= Cap.Square,
LineCap.Round => CapRound ??= Cap.Round,
_ => CapButt ??= Cap.Butt,
};

if (_strokeLineCap == aLineCap)
return;
Expand Down
Loading