Browse Source

Added UI thread rendering mode for X11. (#14856)

Allows using UI thread render timer for X11. Makes sense for low-end X11 devices that previously used immediate renderer.
pull/14866/head
Steven Kirk 2 years ago
committed by GitHub
parent
commit
7dd77c56b1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      src/Avalonia.X11/X11Platform.cs

15
src/Avalonia.X11/X11Platform.cs

@ -70,10 +70,14 @@ namespace Avalonia.X11
if (options.UseDBusMenu) if (options.UseDBusMenu)
DBusHelper.TryInitialize(); DBusHelper.TryInitialize();
IRenderTimer timer = options.ShouldRenderOnUIThread
? new UiThreadRenderTimer(60)
: new SleepLoopRenderTimer(60);
AvaloniaLocator.CurrentMutable.BindToSelf(this) AvaloniaLocator.CurrentMutable.BindToSelf(this)
.Bind<IWindowingPlatform>().ToConstant(this) .Bind<IWindowingPlatform>().ToConstant(this)
.Bind<IDispatcherImpl>().ToConstant(new X11PlatformThreading(this)) .Bind<IDispatcherImpl>().ToConstant(new X11PlatformThreading(this))
.Bind<IRenderTimer>().ToConstant(new SleepLoopRenderTimer(60)) .Bind<IRenderTimer>().ToConstant(timer)
.Bind<PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Control)) .Bind<PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Control))
.Bind<IKeyboardDevice>().ToFunc(() => KeyboardDevice) .Bind<IKeyboardDevice>().ToFunc(() => KeyboardDevice)
.Bind<ICursorFactory>().ToConstant(new X11CursorFactory(Display)) .Bind<ICursorFactory>().ToConstant(new X11CursorFactory(Display))
@ -303,7 +307,14 @@ namespace Avalonia
/// </remarks> /// </remarks>
public bool EnableSessionManagement { get; set; } = public bool EnableSessionManagement { get; set; } =
Environment.GetEnvironmentVariable("AVALONIA_X11_USE_SESSION_MANAGEMENT") != "0"; Environment.GetEnvironmentVariable("AVALONIA_X11_USE_SESSION_MANAGEMENT") != "0";
/// <summary>
/// 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.
/// </summary>
public bool ShouldRenderOnUIThread { get; set; }
public IList<GlVersion> GlProfiles { get; set; } = new List<GlVersion> public IList<GlVersion> GlProfiles { get; set; } = new List<GlVersion>
{ {
new GlVersion(GlProfileType.OpenGL, 4, 0), new GlVersion(GlProfileType.OpenGL, 4, 0),

Loading…
Cancel
Save