Flutter Engine
fml::TimeDelta Class Reference

#include <time_delta.h>

Public Member Functions

constexpr TimeDelta ()=default
 
constexpr int64_t ToNanoseconds () const
 
constexpr int64_t ToMicroseconds () const
 
constexpr int64_t ToMilliseconds () const
 
constexpr int64_t ToSeconds () const
 
constexpr double ToNanosecondsF () const
 
constexpr double ToMicrosecondsF () const
 
constexpr double ToMillisecondsF () const
 
constexpr double ToSecondsF () const
 
constexpr TimeDelta operator- (TimeDelta other) const
 
constexpr TimeDelta operator+ (TimeDelta other) const
 
constexpr TimeDelta operator/ (int64_t divisor) const
 
constexpr int64_t operator/ (TimeDelta other) const
 
constexpr TimeDelta operator* (int64_t multiplier) const
 
constexpr TimeDelta operator% (TimeDelta other) const
 
bool operator== (TimeDelta other) const
 
bool operator!= (TimeDelta other) const
 
bool operator< (TimeDelta other) const
 
bool operator<= (TimeDelta other) const
 
bool operator> (TimeDelta other) const
 
bool operator>= (TimeDelta other) const
 
struct timespec ToTimespec ()
 

Static Public Member Functions

static constexpr TimeDelta Zero ()
 
static constexpr TimeDelta Min ()
 
static constexpr TimeDelta Max ()
 
static constexpr TimeDelta FromNanoseconds (int64_t nanos)
 
static constexpr TimeDelta FromMicroseconds (int64_t micros)
 
static constexpr TimeDelta FromMilliseconds (int64_t millis)
 
static constexpr TimeDelta FromSeconds (int64_t seconds)
 
static constexpr TimeDelta FromSecondsF (double seconds)
 
static constexpr TimeDelta FromMillisecondsF (double millis)
 
static constexpr TimeDelta FromTimespec (struct timespec ts)
 

Detailed Description

Definition at line 29 of file time_delta.h.

Constructor & Destructor Documentation

◆ TimeDelta()

constexpr fml::TimeDelta::TimeDelta ( )
default

Member Function Documentation

◆ FromMicroseconds()

static constexpr TimeDelta fml::TimeDelta::FromMicroseconds ( int64_t  micros)
inlinestatic

◆ FromMilliseconds()

static constexpr TimeDelta fml::TimeDelta::FromMilliseconds ( int64_t  millis)
inlinestatic

◆ FromMillisecondsF()

static constexpr TimeDelta fml::TimeDelta::FromMillisecondsF ( double  millis)
inlinestatic

Definition at line 57 of file time_delta.h.

Referenced by flutter::Rasterizer::Draw().

57  {
58  return FromNanoseconds(millis * (1000.0 * 1000.0));
59  }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ FromNanoseconds()

◆ FromSeconds()

static constexpr TimeDelta fml::TimeDelta::FromSeconds ( int64_t  seconds)
inlinestatic

◆ FromSecondsF()

static constexpr TimeDelta fml::TimeDelta::FromSecondsF ( double  seconds)
inlinestatic

Definition at line 53 of file time_delta.h.

Referenced by VSyncClient::await, flutter::SamplingProfiler::Start(), and flutter::VsyncWaiterFallback::VsyncWaiterFallback().

53  {
54  return FromNanoseconds(seconds * (1000.0 * 1000.0 * 1000.0));
55  }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ FromTimespec()

static constexpr TimeDelta fml::TimeDelta::FromTimespec ( struct timespec  ts)
inlinestatic

Definition at line 106 of file time_delta.h.

References FromNanoseconds(), and FromSeconds().

106  {
107  return TimeDelta::FromSeconds(ts.tv_sec) +
108  TimeDelta::FromNanoseconds(ts.tv_nsec);
109  }
static constexpr TimeDelta FromSeconds(int64_t seconds)
Definition: time_delta.h:49
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ Max()

static constexpr TimeDelta fml::TimeDelta::Max ( )
inlinestatic

Definition at line 37 of file time_delta.h.

37  {
38  return TimeDelta(std::numeric_limits<int64_t>::max());
39  }
constexpr TimeDelta()=default

◆ Min()

static constexpr TimeDelta fml::TimeDelta::Min ( )
inlinestatic

Definition at line 34 of file time_delta.h.

34  {
35  return TimeDelta(std::numeric_limits<int64_t>::min());
36  }
constexpr TimeDelta()=default

◆ operator!=()

bool fml::TimeDelta::operator!= ( TimeDelta  other) const
inline

Definition at line 100 of file time_delta.h.

100 { return delta_ != other.delta_; }

◆ operator%()

constexpr TimeDelta fml::TimeDelta::operator% ( TimeDelta  other) const
inline

Definition at line 95 of file time_delta.h.

References FromNanoseconds().

95  {
96  return TimeDelta::FromNanoseconds(delta_ % other.delta_);
97  }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ operator*()

constexpr TimeDelta fml::TimeDelta::operator* ( int64_t  multiplier) const
inline

Definition at line 91 of file time_delta.h.

References FromNanoseconds().

91  {
92  return TimeDelta::FromNanoseconds(delta_ * multiplier);
93  }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ operator+()

constexpr TimeDelta fml::TimeDelta::operator+ ( TimeDelta  other) const
inline

Definition at line 79 of file time_delta.h.

References FromNanoseconds().

79  {
80  return TimeDelta::FromNanoseconds(delta_ + other.delta_);
81  }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ operator-()

constexpr TimeDelta fml::TimeDelta::operator- ( TimeDelta  other) const
inline

Definition at line 75 of file time_delta.h.

References FromNanoseconds().

75  {
76  return TimeDelta::FromNanoseconds(delta_ - other.delta_);
77  }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ operator/() [1/2]

constexpr TimeDelta fml::TimeDelta::operator/ ( int64_t  divisor) const
inline

Definition at line 83 of file time_delta.h.

References FromNanoseconds().

83  {
84  return TimeDelta::FromNanoseconds(delta_ / divisor);
85  }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ operator/() [2/2]

constexpr int64_t fml::TimeDelta::operator/ ( TimeDelta  other) const
inline

Definition at line 87 of file time_delta.h.

87  {
88  return delta_ / other.delta_;
89  }

◆ operator<()

bool fml::TimeDelta::operator< ( TimeDelta  other) const
inline

Definition at line 101 of file time_delta.h.

101 { return delta_ < other.delta_; }

◆ operator<=()

bool fml::TimeDelta::operator<= ( TimeDelta  other) const
inline

Definition at line 102 of file time_delta.h.

102 { return delta_ <= other.delta_; }

◆ operator==()

bool fml::TimeDelta::operator== ( TimeDelta  other) const
inline

Definition at line 99 of file time_delta.h.

99 { return delta_ == other.delta_; }

◆ operator>()

bool fml::TimeDelta::operator> ( TimeDelta  other) const
inline

Definition at line 103 of file time_delta.h.

103 { return delta_ > other.delta_; }

◆ operator>=()

bool fml::TimeDelta::operator>= ( TimeDelta  other) const
inline

Definition at line 104 of file time_delta.h.

104 { return delta_ >= other.delta_; }

◆ ToMicroseconds()

constexpr int64_t fml::TimeDelta::ToMicroseconds ( ) const
inline

◆ ToMicrosecondsF()

constexpr double fml::TimeDelta::ToMicrosecondsF ( ) const
inline

Definition at line 67 of file time_delta.h.

67 { return delta_ / 1000.0; }

◆ ToMilliseconds()

constexpr int64_t fml::TimeDelta::ToMilliseconds ( ) const
inline

Definition at line 63 of file time_delta.h.

Referenced by flutter_runner::VsyncWaiter::SnapToNextPhase(), flutter_runner::VsyncWaiter::VsyncWaiter(), and flutter::Shell::WaitForFirstFrame().

63 { return ToMicroseconds() / 1000; }
constexpr int64_t ToMicroseconds() const
Definition: time_delta.h:62

◆ ToMillisecondsF()

constexpr double fml::TimeDelta::ToMillisecondsF ( ) const
inline

Definition at line 68 of file time_delta.h.

Referenced by flutter::PerformanceOverlayLayer::MakeStatisticsText().

68  {
69  return delta_ / (1000.0 * 1000.0);
70  }

◆ ToNanoseconds()

◆ ToNanosecondsF()

constexpr double fml::TimeDelta::ToNanosecondsF ( ) const
inline

Definition at line 66 of file time_delta.h.

66 { return delta_; }

◆ ToSeconds()

constexpr int64_t fml::TimeDelta::ToSeconds ( ) const
inline

Definition at line 64 of file time_delta.h.

Referenced by flutter::testing::PendingTests::CheckTimedOutTests(), and flutter::testing::TestTimeoutListener::TestTimeoutListener().

64 { return ToMilliseconds() / 1000; }
constexpr int64_t ToMilliseconds() const
Definition: time_delta.h:63

◆ ToSecondsF()

constexpr double fml::TimeDelta::ToSecondsF ( ) const
inline

Definition at line 71 of file time_delta.h.

71  {
72  return delta_ / (1000.0 * 1000.0 * 1000.0);
73  }

◆ ToTimespec()

struct timespec fml::TimeDelta::ToTimespec ( )
inline

Definition at line 110 of file time_delta.h.

110  {
111  struct timespec ts;
112  constexpr int64_t kNanosecondsPerSecond = 1000000000ll;
113  ts.tv_sec = static_cast<time_t>(ToSeconds());
114  ts.tv_nsec = delta_ % kNanosecondsPerSecond;
115  return ts;
116  }
constexpr int64_t ToSeconds() const
Definition: time_delta.h:64

◆ Zero()


The documentation for this class was generated from the following file: