5#ifndef TimeUtils_DEFINED
6#define TimeUtils_DEFINED
17 const double msec = nanos * 1
e-6;
19 return static_cast<SkMSec>(msec);
27 static inline float Scaled(
float time,
float speed,
float period = 0) {
42 double value = ::fmod(
time + phase, period);
43 double half = period / 2.0;
44 double diff = ::fabs(
value - half);
45 return (
float)(ends + (1.0 - diff / half) * (mid - ends));
53 if (periodInSecs < 0.f) {
58 float halfAmplitude = (
max -
min) / 2.f;
59 return halfAmplitude * std::sin(t) + halfAmplitude +
min;
constexpr float SK_FloatPI
static constexpr SkMSec SK_MSecMax
static float max(float r, float g, float b)
static float min(float r, float g, float b)
static float PingPong(double time, float period, float phase, float ends, float mid)
static float Scaled(float time, float speed, float period=0)
static float SineWave(double time, float periodInSecs, float phaseInSecs, float min, float max)
static double NanosToSeconds(double nanos)
static SkMSec NanosToMSec(double nanos)
static double time(int loops, Benchmark *bench, Target *target)