|
|
|
@ -6,26 +6,23 @@ using MonoMac.Foundation; |
|
|
|
namespace Avalonia.MonoMac |
|
|
|
{ |
|
|
|
//TODO: Switch to using CVDisplayLink
|
|
|
|
public class RenderTimer : IRenderTimer |
|
|
|
public class RenderTimer : DefaultRenderTimer |
|
|
|
{ |
|
|
|
private readonly object _lock = new object(); |
|
|
|
private readonly IDisposable _timer; |
|
|
|
public RenderTimer(int framesPerSecond) : base(framesPerSecond) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
public RenderTimer() |
|
|
|
protected override IDisposable StartCore(Action<long> tick) |
|
|
|
{ |
|
|
|
_timer = AvaloniaLocator.Current.GetService<IRuntimePlatform>().StartSystemTimer(new TimeSpan(0, 0, 0, 0, 1000 / 60), |
|
|
|
return AvaloniaLocator.Current.GetService<IRuntimePlatform>().StartSystemTimer( |
|
|
|
TimeSpan.FromSeconds(1.0 / FramesPerSecond), |
|
|
|
() => |
|
|
|
{ |
|
|
|
lock (_lock) |
|
|
|
using (new NSAutoreleasePool()) |
|
|
|
{ |
|
|
|
using (new NSAutoreleasePool()) |
|
|
|
{ |
|
|
|
Tick?.Invoke(Environment.TickCount); |
|
|
|
} |
|
|
|
tick?.Invoke(Environment.TickCount); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public event Action<long> Tick; |
|
|
|
} |
|
|
|
} |
|
|
|
|