diff --git a/src/Avalonia.Animation/IAnimation.cs b/src/Avalonia.Animation/IAnimation.cs
index 34b0a5d769..ff85535d8a 100644
--- a/src/Avalonia.Animation/IAnimation.cs
+++ b/src/Avalonia.Animation/IAnimation.cs
@@ -9,12 +9,12 @@ namespace Avalonia.Animation
public interface IAnimation
{
///
- /// Apply the animation to the specified control
+ /// Apply the animation to the specified control and run it when produces true.
///
IDisposable Apply(Animatable control, IClock clock, IObservable match, Action onComplete = null);
///
- /// Run the animation to the specified control
+ /// Run the animation on the specified control.
///
Task RunAsync(Animatable control, IClock clock);
}
diff --git a/src/Avalonia.Animation/IAnimator.cs b/src/Avalonia.Animation/IAnimator.cs
index 04bad8e112..d0fb173c54 100644
--- a/src/Avalonia.Animation/IAnimator.cs
+++ b/src/Avalonia.Animation/IAnimator.cs
@@ -16,6 +16,6 @@ namespace Avalonia.Animation
///
/// Applies the current KeyFrame group to the specified control.
///
- IDisposable Apply(Animation animation, Animatable control, IClock clock, IObservable obsMatch, Action onComplete);
+ IDisposable Apply(Animation animation, Animatable control, IClock clock, IObservable match, Action onComplete);
}
}
diff --git a/src/Avalonia.Animation/IGlobalClock.cs b/src/Avalonia.Animation/IGlobalClock.cs
new file mode 100644
index 0000000000..b0455e2c80
--- /dev/null
+++ b/src/Avalonia.Animation/IGlobalClock.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Avalonia.Animation
+{
+ public interface IGlobalClock : IClock
+ {
+ }
+}
diff --git a/src/Avalonia.Controls/Application.cs b/src/Avalonia.Controls/Application.cs
index 586a73b75c..37796ff9ba 100644
--- a/src/Avalonia.Controls/Application.cs
+++ b/src/Avalonia.Controls/Application.cs
@@ -340,7 +340,7 @@ namespace Avalonia
var clock = new RenderLoopClock();
AvaloniaLocator.CurrentMutable
- .Bind().ToConstant(clock)
+ .Bind().ToConstant(clock)
.GetService()?.Add(clock);
}
}
diff --git a/src/Avalonia.Controls/Platform/InternalPlatformThreadingInterface.cs b/src/Avalonia.Controls/Platform/InternalPlatformThreadingInterface.cs
index 501e15653a..bb357453ff 100644
--- a/src/Avalonia.Controls/Platform/InternalPlatformThreadingInterface.cs
+++ b/src/Avalonia.Controls/Platform/InternalPlatformThreadingInterface.cs
@@ -14,7 +14,10 @@ namespace Avalonia.Controls.Platform
public InternalPlatformThreadingInterface()
{
TlsCurrentThreadIsLoopThread = true;
- StartTimer(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 0, 66), () => Tick?.Invoke(Environment.TickCount));
+ StartTimer(
+ DispatcherPriority.Render,
+ new TimeSpan(0, 0, 0, 0, 66),
+ () => Tick?.Invoke(TimeSpan.FromMilliseconds(Environment.TickCount)));
}
private readonly AutoResetEvent _signaled = new AutoResetEvent(false);
@@ -105,7 +108,7 @@ namespace Avalonia.Controls.Platform
public bool CurrentThreadIsLoopThread => TlsCurrentThreadIsLoopThread;
public event Action Signaled;
- public event Action Tick;
+ public event Action Tick;
}
-}
\ No newline at end of file
+}
diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs
index fb5b932fd8..630753396f 100644
--- a/src/Avalonia.Controls/TopLevel.cs
+++ b/src/Avalonia.Controls/TopLevel.cs
@@ -96,7 +96,6 @@ namespace Avalonia.Controls
_applicationLifecycle = TryGetService(dependencyResolver);
_renderInterface = TryGetService(dependencyResolver);
- var renderLoop = TryGetService(dependencyResolver);
Renderer = impl.CreateRenderer(this);
impl.SetInputRoot(this);
diff --git a/src/Avalonia.Visuals/Animation/RenderLoopClock.cs b/src/Avalonia.Visuals/Animation/RenderLoopClock.cs
index e59b3aac0d..504caef461 100644
--- a/src/Avalonia.Visuals/Animation/RenderLoopClock.cs
+++ b/src/Avalonia.Visuals/Animation/RenderLoopClock.cs
@@ -5,7 +5,7 @@ using Avalonia.Rendering;
namespace Avalonia.Animation
{
- public class RenderLoopClock : ClockBase, IRenderLoopTask
+ public class RenderLoopClock : ClockBase, IRenderLoopTask, IGlobalClock
{
protected override void Stop()
{
@@ -18,9 +18,9 @@ namespace Avalonia.Animation
{
}
- void IRenderLoopTask.Update(long tickCount)
+ void IRenderLoopTask.Update(TimeSpan time)
{
- Pulse(TimeSpan.FromMilliseconds(tickCount));
+ Pulse(time);
}
}
}
diff --git a/src/Avalonia.Visuals/Rendering/DefaultRenderTimer.cs b/src/Avalonia.Visuals/Rendering/DefaultRenderTimer.cs
index a83334ff5e..d0eb181c65 100644
--- a/src/Avalonia.Visuals/Rendering/DefaultRenderTimer.cs
+++ b/src/Avalonia.Visuals/Rendering/DefaultRenderTimer.cs
@@ -19,7 +19,7 @@ namespace Avalonia.Rendering
{
private IRuntimePlatform _runtime;
private int _subscriberCount;
- private Action _tick;
+ private Action _tick;
private IDisposable _subscription;
///
@@ -39,7 +39,7 @@ namespace Avalonia.Rendering
public int FramesPerSecond { get; }
///
- public event Action Tick
+ public event Action Tick
{
add
{
@@ -78,14 +78,16 @@ namespace Avalonia.Rendering
/// This can be overridden by platform implementations to use a specialized timer
/// implementation.
///
- protected virtual IDisposable StartCore(Action tick)
+ protected virtual IDisposable StartCore(Action tick)
{
if (_runtime == null)
{
_runtime = AvaloniaLocator.Current.GetService();
}
- return _runtime.StartSystemTimer(TimeSpan.FromSeconds(1.0 / FramesPerSecond), () => tick(Environment.TickCount));
+ return _runtime.StartSystemTimer(
+ TimeSpan.FromSeconds(1.0 / FramesPerSecond),
+ () => tick(TimeSpan.FromMilliseconds(Environment.TickCount)));
}
///
@@ -97,7 +99,7 @@ namespace Avalonia.Rendering
_subscription = null;
}
- private void InternalTick(long tickCount)
+ private void InternalTick(TimeSpan tickCount)
{
_tick(tickCount);
}
diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs
index 3221dd85c6..fc67b5c461 100644
--- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs
+++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs
@@ -166,7 +166,7 @@ namespace Avalonia.Rendering
bool IRenderLoopTask.NeedsUpdate => _dirty == null || _dirty.Count > 0;
- void IRenderLoopTask.Update(long tickCount) => UpdateScene();
+ void IRenderLoopTask.Update(TimeSpan time) => UpdateScene();
void IRenderLoopTask.Render()
{
diff --git a/src/Avalonia.Visuals/Rendering/IRenderLoopTask.cs b/src/Avalonia.Visuals/Rendering/IRenderLoopTask.cs
index b031bf00df..15f0afc797 100644
--- a/src/Avalonia.Visuals/Rendering/IRenderLoopTask.cs
+++ b/src/Avalonia.Visuals/Rendering/IRenderLoopTask.cs
@@ -6,20 +6,7 @@ namespace Avalonia.Rendering
public interface IRenderLoopTask
{
bool NeedsUpdate { get; }
- void Update(long tickCount);
+ void Update(TimeSpan time);
void Render();
}
-
- public class MockRenderLoopTask : IRenderLoopTask
- {
- public bool NeedsUpdate => true;
-
- public void Render()
- {
- }
-
- public void Update(long tickCount)
- {
- }
- }
}
diff --git a/src/Avalonia.Visuals/Rendering/IRenderTimer.cs b/src/Avalonia.Visuals/Rendering/IRenderTimer.cs
index 78f6183994..d333e928a0 100644
--- a/src/Avalonia.Visuals/Rendering/IRenderTimer.cs
+++ b/src/Avalonia.Visuals/Rendering/IRenderTimer.cs
@@ -15,6 +15,6 @@ namespace Avalonia.Rendering
/// This event can be raised on any thread; it is the responsibility of the subscriber to
/// switch execution to the right thread.
///
- event Action Tick;
+ event Action Tick;
}
-}
\ No newline at end of file
+}
diff --git a/src/Avalonia.Visuals/Rendering/RenderLoop.cs b/src/Avalonia.Visuals/Rendering/RenderLoop.cs
index d920be2706..d0d5b2250d 100644
--- a/src/Avalonia.Visuals/Rendering/RenderLoop.cs
+++ b/src/Avalonia.Visuals/Rendering/RenderLoop.cs
@@ -84,7 +84,7 @@ namespace Avalonia.Rendering
}
}
- private async void TimerTick(long tickCount)
+ private async void TimerTick(TimeSpan time)
{
if (Interlocked.CompareExchange(ref inTick, 1, 0) == 0)
{
@@ -96,7 +96,7 @@ namespace Avalonia.Rendering
{
foreach (var i in _items)
{
- i.Update(tickCount);
+ i.Update(time);
}
}, DispatcherPriority.Render).ConfigureAwait(false);
}
diff --git a/tests/Avalonia.Visuals.UnitTests/Rendering/RenderLoopTests.cs b/tests/Avalonia.Visuals.UnitTests/Rendering/RenderLoopTests.cs
index 30ef35a2bb..bf992f4027 100644
--- a/tests/Avalonia.Visuals.UnitTests/Rendering/RenderLoopTests.cs
+++ b/tests/Avalonia.Visuals.UnitTests/Rendering/RenderLoopTests.cs
@@ -35,14 +35,14 @@ namespace Avalonia.Visuals.UnitTests.Rendering
var renderTask = new Mock();
renderTask.Setup(t => t.NeedsUpdate).Returns(true);
- renderTask.Setup(t => t.Update(It.IsAny()))
+ renderTask.Setup(t => t.Update(It.IsAny()))
.Callback((long _) => Assert.True(inDispatcher));
loop.Add(renderTask.Object);
timer.Raise(t => t.Tick += null, 0L);
- renderTask.Verify(t => t.Update(It.IsAny()), Times.Once());
+ renderTask.Verify(t => t.Update(It.IsAny()), Times.Once());
}
[Fact]
@@ -62,7 +62,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering
loop.Add(renderTask.Object);
timer.Raise(t => t.Tick += null, 0L);
- renderTask.Verify(t => t.Update(It.IsAny()), Times.Never());
+ renderTask.Verify(t => t.Update(It.IsAny()), Times.Never());
}
[Fact]
@@ -92,7 +92,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering
loop.Add(renderTask.Object);
timer.Raise(t => t.Tick += null, 0L);
- renderTask.Verify(t => t.Update(It.IsAny()), Times.Once());
+ renderTask.Verify(t => t.Update(It.IsAny()), Times.Once());
}
[Fact]
@@ -110,10 +110,10 @@ namespace Avalonia.Visuals.UnitTests.Rendering
renderTask.Setup(t => t.NeedsUpdate).Returns(true);
loop.Add(renderTask.Object);
- var tickCount = 12345L;
- timer.Raise(t => t.Tick += null, tickCount);
+ var time = new TimeSpan(123456789L);
+ timer.Raise(t => t.Tick += null, time);
- renderTask.Verify(t => t.Update(tickCount), Times.Once());
+ renderTask.Verify(t => t.Update(time), Times.Once());
}
}
}