2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#ifndef SkTime_DEFINED
|
|
|
|
#define SkTime_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
#include "include/private/SkMacros.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2015-05-01 14:06:23 +00:00
|
|
|
class SkString;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** \class SkTime
|
|
|
|
Platform-implemented utilities to return time of day, and millisecond counter.
|
|
|
|
*/
|
2016-05-02 22:04:46 +00:00
|
|
|
class SK_API SkTime {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
|
|
|
struct DateTime {
|
2015-05-01 14:06:23 +00:00
|
|
|
int16_t fTimeZoneMinutes; // The number of minutes that GetDateTime()
|
|
|
|
// is ahead of or behind UTC.
|
2008-12-17 15:59:43 +00:00
|
|
|
uint16_t fYear; //!< e.g. 2005
|
|
|
|
uint8_t fMonth; //!< 1..12
|
|
|
|
uint8_t fDayOfWeek; //!< 0..6, 0==Sunday
|
|
|
|
uint8_t fDay; //!< 1..31
|
|
|
|
uint8_t fHour; //!< 0..23
|
|
|
|
uint8_t fMinute; //!< 0..59
|
|
|
|
uint8_t fSecond; //!< 0..59
|
2015-05-01 14:06:23 +00:00
|
|
|
|
|
|
|
void toISO8601(SkString* dst) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
static void GetDateTime(DateTime*);
|
|
|
|
|
Change SkTime::GetMSecs to double; ensure values stored in SkMSec do not overflow.
The following are currently unused in Android, Google3, Chromium, and Mozilla:
- SkEvent
- SkTime::GetMSecs
- SK_TIME_FACTOR (also unused in Skia)
- SkAutoTime
I left uses of SkMSec more-or-less intact for SkEvent, SkAnimator, and SkInterpolator. SkInterpolator is used in Chromium, so I did not want to change the API. The views/ and animator/ code is crufty, so it didn't seem worthwhile to refactor it. Instead, I added SkEvent::GetMSecsSinceStartup, which is likely to be adequate for use in SampleApp.
I also left SkMSec where it is used to measure a duration rather than a timestamp. With the exception of SkMovie, which is used in Android, all of the uses appear to measure the execution time of a piece of code, which I would hope does not exceed 2^31 milliseconds.
Added skiatest::Timer to support a common idiom in tests where we want to measure the wallclock time in integer milliseconds. (Not used in tests/PathOpsSkpClipTest.cpp because it redefines things in Test.h.)
Removed tabs in tests/StrokerTest.cpp.
BUG=skia:4632
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1811613004
Review URL: https://codereview.chromium.org/1811613004
2016-03-25 19:59:53 +00:00
|
|
|
static double GetSecs() { return GetNSecs() * 1e-9; }
|
|
|
|
static double GetMSecs() { return GetNSecs() * 1e-6; }
|
2015-10-23 14:02:06 +00:00
|
|
|
static double GetNSecs();
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class SkAutoTime {
|
|
|
|
public:
|
|
|
|
// The label is not deep-copied, so its address must remain valid for the
|
|
|
|
// lifetime of this object
|
Change SkTime::GetMSecs to double; ensure values stored in SkMSec do not overflow.
The following are currently unused in Android, Google3, Chromium, and Mozilla:
- SkEvent
- SkTime::GetMSecs
- SK_TIME_FACTOR (also unused in Skia)
- SkAutoTime
I left uses of SkMSec more-or-less intact for SkEvent, SkAnimator, and SkInterpolator. SkInterpolator is used in Chromium, so I did not want to change the API. The views/ and animator/ code is crufty, so it didn't seem worthwhile to refactor it. Instead, I added SkEvent::GetMSecsSinceStartup, which is likely to be adequate for use in SampleApp.
I also left SkMSec where it is used to measure a duration rather than a timestamp. With the exception of SkMovie, which is used in Android, all of the uses appear to measure the execution time of a piece of code, which I would hope does not exceed 2^31 milliseconds.
Added skiatest::Timer to support a common idiom in tests where we want to measure the wallclock time in integer milliseconds. (Not used in tests/PathOpsSkpClipTest.cpp because it redefines things in Test.h.)
Removed tabs in tests/StrokerTest.cpp.
BUG=skia:4632
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1811613004
Review URL: https://codereview.chromium.org/1811613004
2016-03-25 19:59:53 +00:00
|
|
|
SkAutoTime(const char* label = nullptr)
|
|
|
|
: fLabel(label)
|
|
|
|
, fNow(SkTime::GetMSecs()) {}
|
|
|
|
~SkAutoTime() {
|
|
|
|
uint64_t dur = static_cast<uint64_t>(SkTime::GetMSecs() - fNow);
|
|
|
|
SkDebugf("%s %ld\n", fLabel ? fLabel : "", dur);
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
const char* fLabel;
|
Change SkTime::GetMSecs to double; ensure values stored in SkMSec do not overflow.
The following are currently unused in Android, Google3, Chromium, and Mozilla:
- SkEvent
- SkTime::GetMSecs
- SK_TIME_FACTOR (also unused in Skia)
- SkAutoTime
I left uses of SkMSec more-or-less intact for SkEvent, SkAnimator, and SkInterpolator. SkInterpolator is used in Chromium, so I did not want to change the API. The views/ and animator/ code is crufty, so it didn't seem worthwhile to refactor it. Instead, I added SkEvent::GetMSecsSinceStartup, which is likely to be adequate for use in SampleApp.
I also left SkMSec where it is used to measure a duration rather than a timestamp. With the exception of SkMovie, which is used in Android, all of the uses appear to measure the execution time of a piece of code, which I would hope does not exceed 2^31 milliseconds.
Added skiatest::Timer to support a common idiom in tests where we want to measure the wallclock time in integer milliseconds. (Not used in tests/PathOpsSkpClipTest.cpp because it redefines things in Test.h.)
Removed tabs in tests/StrokerTest.cpp.
BUG=skia:4632
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1811613004
Review URL: https://codereview.chromium.org/1811613004
2016-03-25 19:59:53 +00:00
|
|
|
double fNow;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
2013-11-18 16:03:59 +00:00
|
|
|
#define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
#endif
|