Skip to content

Commit d3e0e5d

Browse files
committed
fix(Avalonia): use SkiaSharp on FreeBSD
Instead of VelloSharp because it is unstable and hasn't seen any new commits since it was unarchived.
1 parent 5793107 commit d3e0e5d

3 files changed

Lines changed: 40 additions & 52 deletions

File tree

SnapX.Avalonia/App.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public override void OnFrameworkInitializationCompleted()
517517
var logoBitmap = new Bitmap(
518518
AssetLoader.Open(new Uri("avares://snapx-ui/SnapX_Logo.png"))
519519
);
520-
if (!OperatingSystem.IsFreeBSD() && SnapX.GetConfiguration().ShowTray)
520+
if (SnapX.GetConfiguration().ShowTray)
521521
{
522522
var trayIcon = new TrayIcon
523523
{

SnapX.Avalonia/Program.cs

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
using System.Reflection;
44
using Avalonia;
55
using SnapX.Avalonia;
6-
#if FREEBSD
7-
using VelloSharp;
8-
using VelloSharp.Avalonia.Vello;
9-
#endif
106
#if BROWSER
117
using Avalonia.Browser;
128
#else
@@ -21,19 +17,21 @@ public static void Main(string[] args)
2117
{
2218
if (args.Length != 0 && (args[0] == "--version" || args[0] == "-v"))
2319
{
24-
var informationalVersion = Assembly.GetExecutingAssembly()
25-
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
26-
.InformationalVersion ?? "Unknown";
20+
var informationalVersion =
21+
Assembly
22+
.GetExecutingAssembly()
23+
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
24+
?.InformationalVersion ?? "Unknown";
2725

2826
Console.WriteLine(informationalVersion);
2927
return;
3028
}
3129

3230
BuildAvaloniaApp()
3331
#if !BROWSER
34-
.StartWithClassicDesktopLifetime(args);
32+
.StartWithClassicDesktopLifetime(args);
3533
#else
36-
.StartBrowserAppAsync("out");
34+
.StartBrowserAppAsync("out");
3735
#endif
3836
}
3937

@@ -46,51 +44,44 @@ public static AppBuilder BuildAvaloniaApp()
4644
#else
4745
if (OperatingSystem.IsLinux() || OperatingSystem.IsFreeBSD())
4846
{
49-
builder = builder.With(new FontManagerOptions
50-
{
51-
FontFallbacks = new List<FontFallback>
47+
builder = builder.With(
48+
new FontManagerOptions
5249
{
53-
new() { FontFamily = "Noto Sans" },
54-
new() { FontFamily = "Roboto" },
55-
new() { FontFamily = "Adwaita Sans" },
56-
new() { FontFamily = "Open Sans" },
57-
new() { FontFamily = "Segoe UI" },
58-
new() { FontFamily = "Inter" }, // kept for compatibility
59-
new() { FontFamily = "Helvetica Neue" },
50+
FontFallbacks = new List<FontFallback>
51+
{
52+
new() { FontFamily = "Noto Sans" },
53+
new() { FontFamily = "Roboto" },
54+
new() { FontFamily = "Adwaita Sans" },
55+
new() { FontFamily = "Open Sans" },
56+
new() { FontFamily = "Segoe UI" },
57+
new() { FontFamily = "Inter" }, // kept for compatibility
58+
new() { FontFamily = "Helvetica Neue" },
59+
},
6060
}
61-
});
61+
);
6262
}
6363

6464
builder = builder.LogToTrace();
6565

6666
var x11Options = new X11PlatformOptions
6767
{
68-
RenderingMode = [X11RenderingMode.Vulkan, X11RenderingMode.Egl, X11RenderingMode.Glx, X11RenderingMode.Software],
68+
RenderingMode =
69+
[
70+
X11RenderingMode.Vulkan,
71+
X11RenderingMode.Egl,
72+
X11RenderingMode.Glx,
73+
X11RenderingMode.Software,
74+
],
6975
UseRetainedFramebuffer = true,
70-
OverlayPopups = true
76+
OverlayPopups = true,
7177
};
7278

73-
if (OperatingSystem.IsFreeBSD() || Environment.GetEnvironmentVariable("SNAPX_PRETEND_FREEBSD") is not null)
74-
{
75-
#if FREEBSD
76-
// Region selector yields a black screen if not using software. Still ULTRA GPU ACCELERATED!
77-
x11Options.RenderingMode = [X11RenderingMode.Software];
78-
builder = builder
79-
.UseSkia()
80-
.UseX11()
81-
.UseVello(new VelloPlatformOptions { FramesPerSecond = 240, PresentMode = PresentMode.Fifo, Antialiasing = AntialiasingMode.Msaa16})
82-
.With(x11Options);
83-
#endif
84-
}
85-
else
86-
{
87-
builder = builder
88-
.UsePlatformDetect()
89-
.UseManagedSystemDialogs()
90-
.With(x11Options)
91-
.With(new AvaloniaNativePlatformOptions { OverlayPopups = true })
92-
.With(new Win32PlatformOptions { OverlayPopups = true });
93-
}
79+
builder = builder
80+
.UsePlatformDetect()
81+
.UseManagedSystemDialogs()
82+
.With(x11Options)
83+
.With(new AvaloniaNativePlatformOptions { OverlayPopups = true })
84+
.With(new Win32PlatformOptions { OverlayPopups = true });
9485

9586
return builder;
9687
#endif

SnapX.Avalonia/SnapX.Avalonia.csproj

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
<HarfBuzzSharpVersion>8.3.1.2</HarfBuzzSharpVersion>
1616
<VelloSharpVersion>0.5.0-alpha.3</VelloSharpVersion>
1717
<ApplicationManifest>app.manifest</ApplicationManifest>
18-
<!-- Packagers: Do not modify the AssemblyName, it will break the compilation of XAML that depends on it being called snapx-ui. Instead create a executable shell script that calls snapx-ui -->
19-
</PropertyGroup>
20-
<PropertyGroup Condition="'$(TargetFreeBSD)' != 'true'">
2118
<ApplicationIcon>Assets\SnapX_Icon.ico</ApplicationIcon>
19+
<!-- Packagers: Do not modify the AssemblyName, it will break the compilation of XAML that depends on it being called snapx-ui. Instead create a executable shell script that calls snapx-ui -->
2220
</PropertyGroup>
2321
<!-- <PropertyGroup Condition="'$(TargetWindows)' == 'true'">-->
2422
<!-- <AvaloniaVersion>11.3.4</AvaloniaVersion>-->
@@ -80,15 +78,14 @@
8078
<PackageReference Remove="Avalonia.X11" />
8179
<PackageReference Include="BrycensRanch.Avalonia.Desktop" Version="$(AvaloniaVersion)" />
8280
<PackageReference Include="BrycensRanch.Avalonia.X11" Version="$(AvaloniaVersion)" />
83-
<PackageReference Include="VelloSharp.Avalonia.Vello" Version="$(VelloSharpVersion)" />
84-
<PackageReference Include="VelloSharp.HarfBuzzSharp" Version="$(VelloSharpVersion)" />
85-
<PackageReference Remove="HarfBuzzSharp" />
81+
<PackageReference Remove="SkiaSharp.NativeAssets.Linux" />
82+
<PackageReference Remove="SkiaSharp.NativeAssets.macOS" />
83+
<PackageReference Remove="SkiaSharp.NativeAssets.Win32" />
84+
<PackageReference Remove="SkiaSharp.NativeAssets.WebAssembly" />
8685
<PackageReference Remove="HarfBuzzSharp.NativeAssets.Linux" />
8786
<PackageReference Remove="HarfBuzzSharp.NativeAssets.macOS" />
8887
<PackageReference Remove="HarfBuzzSharp.NativeAssets.Win32" />
8988
<PackageReference Remove="HarfBuzzSharp.NativeAssets.WebAssembly" />
90-
<PackageReference Include="VelloSharp.Native.Vello" Version="$(VelloSharpVersion)" />
91-
<PackageReference Include="BrycensRanch.VelloSharp.Native.Vello.freebsd-x64" Version="$(VelloSharpVersion)" />
9289
</ItemGroup>
9390
<ItemGroup>
9491
<Folder Include="Controls\" />

0 commit comments

Comments
 (0)