Browse Source

Add the global frame count to AnimationStateTimer.

pull/1793/head
Jumar Macato 8 years ago
parent
commit
b3ebfa5748
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 9
      src/Avalonia.Animation/Timing.cs

9
src/Avalonia.Animation/Timing.cs

@ -16,6 +16,7 @@ namespace Avalonia.Animation
public static class Timing public static class Timing
{ {
static ulong _transitionsFrameCount; static ulong _transitionsFrameCount;
static long _tickStartTimeStamp;
static PlayState _globalState = PlayState.Run; static PlayState _globalState = PlayState.Run;
/// <summary> /// <summary>
@ -33,12 +34,16 @@ namespace Avalonia.Animation
/// </summary> /// </summary>
static Timing() static Timing()
{ {
_tickStartTimeStamp = Stopwatch.GetTimestamp();
var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance); var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance);
AnimationStateTimer = globalTimer AnimationStateTimer = globalTimer
.Select(_ => .Select(_ =>
{ {
return _globalState; return (_globalState, (Stopwatch.GetTimestamp() - _tickStartTimeStamp)
/ (Stopwatch.Frequency / FramesPerSecond));
}) })
.Publish() .Publish()
.RefCount(); .RefCount();
@ -76,7 +81,7 @@ namespace Avalonia.Animation
/// defined in <see cref="FramesPerSecond"/>. /// defined in <see cref="FramesPerSecond"/>.
/// The parameter passed to a subsciber is the current playstate of the animation. /// The parameter passed to a subsciber is the current playstate of the animation.
/// </remarks> /// </remarks>
internal static IObservable<PlayState> AnimationStateTimer internal static IObservable<(PlayState, long)> AnimationStateTimer
{ {
get; get;
} }

Loading…
Cancel
Save