feat(linux): add graphical platform services
This commit is contained in:
parent
1628d9f587
commit
66f114b258
28 changed files with 1328 additions and 155 deletions
38
src/AcDream.App/Rendering/FramePacingWaiterFactory.cs
Normal file
38
src/AcDream.App/Rendering/FramePacingWaiterFactory.cs
Normal 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)),
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue