From 036d5463a6476570798898b46e5372ac576601ed Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 5 Mar 2024 15:06:08 +0600 Subject: [PATCH] Added UI thread rendering mode for fbdev (#14818) --- .../Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs | 6 +++++- .../LinuxFramebufferPlatformOptions.cs | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs index 76e527a39a..f8f6b92b3e 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs @@ -60,9 +60,13 @@ namespace Avalonia.LinuxFramebuffer var opts = AvaloniaLocator.Current.GetService() ?? new LinuxFramebufferPlatformOptions(); + var timer = opts.ShouldRenderOnUIThread + ? new UiThreadRenderTimer(opts.Fps) + : new DefaultRenderTimer(opts.Fps); + AvaloniaLocator.CurrentMutable .Bind().ToConstant(new ManagedDispatcherImpl(new ManualRawEventGrouperDispatchQueueDispatcherInputProvider(EventGrouperDispatchQueue))) - .Bind().ToConstant(new DefaultRenderTimer(opts.Fps)) + .Bind().ToConstant(timer) .Bind().ToTransient() .Bind().ToConstant(new KeyboardDevice()) .Bind().ToSingleton() diff --git a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatformOptions.cs b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatformOptions.cs index bf925bbd75..ec772df57c 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatformOptions.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatformOptions.cs @@ -10,5 +10,12 @@ /// Default 60. /// public int Fps { get; set; } = 60; + + /// + /// Render directly on the UI thread instead of using a dedicated render thread. + /// This can be usable if your device don't have multiple cores to begin with. + /// This setting is false by default. + /// + public bool ShouldRenderOnUIThread { get; set; } } }