1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_layers_SampleTime_h
8 #define mozilla_layers_SampleTime_h
10 #include "mozilla/TimeStamp.h"
16 * When compositing frames, there is usually a "sample time" associated
17 * with the frame, which may be derived from vsync or controlled by a test.
18 * This class encapsulates that and tracks where the sample time comes from,
19 * as the desired behaviour may vary based on the time source.
24 // Uninitialized sample time.
26 // Time comes from a vsync tick, possibly adjusted by a vsync interval.
28 // Time comes from a "now" timestamp
30 // Time is set by a test
35 static SampleTime
FromVsync(const TimeStamp
& aTime
);
36 static SampleTime
FromNow();
37 static SampleTime
FromTest(const TimeStamp
& aTime
);
40 TimeType
Type() const;
41 const TimeStamp
& Time() const;
43 // These operators just compare the timestamps
44 bool operator==(const SampleTime
& aOther
) const;
45 bool operator!=(const SampleTime
& aOther
) const;
46 bool operator<(const SampleTime
& aOther
) const;
47 bool operator<=(const SampleTime
& aOther
) const;
48 bool operator>(const SampleTime
& aOther
) const;
49 bool operator>=(const SampleTime
& aOther
) const;
50 // These return a new SampleTime with the same type as this one, but the
51 // time adjusted by the provided TimeDuration
52 SampleTime
operator+(const TimeDuration
& aDuration
) const;
53 SampleTime
operator-(const TimeDuration
& aDuration
) const;
54 // This just produces the time difference between the two SampleTimes,
56 TimeDuration
operator-(const SampleTime
& aOther
) const;
59 // Private constructor; use one of the static FromXXX methods instead.
60 SampleTime(TimeType aType
, const TimeStamp
& aTime
);
67 } // namespace mozilla
69 #endif // mozilla_layers_SampleTime_h