Bug 1849470 - Update in-tree zlib to version 1.3. r=aosmond
[gecko.git] / gfx / layers / SampleTime.h
bloba32f758eb7ec541b2510e85495422e76c5d24451
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"
12 namespace mozilla {
13 namespace layers {
15 /**
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.
21 class SampleTime {
22 public:
23 enum TimeType {
24 // Uninitialized sample time.
25 eNull,
26 // Time comes from a vsync tick, possibly adjusted by a vsync interval.
27 eVsync,
28 // Time comes from a "now" timestamp
29 eNow,
30 // Time is set by a test
31 eTest,
34 SampleTime();
35 static SampleTime FromVsync(const TimeStamp& aTime);
36 static SampleTime FromNow();
37 static SampleTime FromTest(const TimeStamp& aTime);
39 bool IsNull() const;
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,
55 // ignoring the type.
56 TimeDuration operator-(const SampleTime& aOther) const;
58 private:
59 // Private constructor; use one of the static FromXXX methods instead.
60 SampleTime(TimeType aType, const TimeStamp& aTime);
62 TimeType mType;
63 TimeStamp mTime;
66 } // namespace layers
67 } // namespace mozilla
69 #endif // mozilla_layers_SampleTime_h