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
|
|
|
|
|
|
|
|
#include "SkTypes.h"
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
class SkTime {
|
|
|
|
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*);
|
|
|
|
|
2014-04-24 20:17:24 +00:00
|
|
|
static SkMSec GetMSecs();
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN32)
|
|
|
|
extern SkMSec gForceTickCount;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SK_TIME_FACTOR 1
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class SkAutoTime {
|
|
|
|
public:
|
|
|
|
// The label is not deep-copied, so its address must remain valid for the
|
|
|
|
// lifetime of this object
|
|
|
|
SkAutoTime(const char* label = NULL, SkMSec minToDump = 0) : fLabel(label)
|
|
|
|
{
|
|
|
|
fNow = SkTime::GetMSecs();
|
|
|
|
fMinToDump = minToDump;
|
|
|
|
}
|
|
|
|
~SkAutoTime()
|
|
|
|
{
|
|
|
|
SkMSec dur = SkTime::GetMSecs() - fNow;
|
|
|
|
if (dur >= fMinToDump) {
|
|
|
|
SkDebugf("%s %d\n", fLabel ? fLabel : "", dur);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const char* fLabel;
|
|
|
|
SkMSec fNow;
|
|
|
|
SkMSec fMinToDump;
|
|
|
|
};
|
2013-11-18 16:03:59 +00:00
|
|
|
#define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
#endif
|