feat(linux): add graphical platform services

This commit is contained in:
Erik 2026-07-27 11:54:59 +02:00
parent 1628d9f587
commit 66f114b258
28 changed files with 1328 additions and 155 deletions

View file

@ -0,0 +1,38 @@
using AcDream.App.Platform;
namespace AcDream.App.Rendering;
internal interface IFramePacingWaiterFactory
{
IFramePacingWaiter Create();
}
/// <summary>
/// The sole startup-time platform selector for software frame waits.
/// Frame policy and deadline behavior remain platform-neutral.
/// </summary>
internal sealed class PlatformFramePacingWaiterFactory
: IFramePacingWaiterFactory
{
private readonly GraphicalHostOperatingSystem _operatingSystem;
internal PlatformFramePacingWaiterFactory(
GraphicalHostOperatingSystem operatingSystem)
{
_operatingSystem = operatingSystem;
}
internal static PlatformFramePacingWaiterFactory ForCurrentProcess() =>
new(GraphicalHostPlatformServices.DetectOperatingSystem());
public IFramePacingWaiter Create() =>
_operatingSystem switch
{
GraphicalHostOperatingSystem.Windows =>
WindowsHighResolutionFramePacingWaiter.Create(),
GraphicalHostOperatingSystem.Linux =>
LinuxMonotonicFramePacingWaiter.Create(),
_ => throw new ArgumentOutOfRangeException(
nameof(_operatingSystem)),
};
}