skia2/include/core/SkTime.h
mtklein 33eefcd58b SkTime::GetNSecs()
- Move high-precision wall timers from tools/timer to SkTime.
   - Implement SkTime::GetMSecs() in terms of SkTime::GetNSecs().
   - Delete unused tools/timer code.

I have no idea what's going on there in src/animator.
I don't intend to investigate.

BUG=skia:

Committed: https://skia.googlesource.com/skia/+/70084cbc16ee8162649f2601377feb6e49de0217

CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Debug-CrOS_Link-Trybot

Committed: https://skia.googlesource.com/skia/+/a1840d50e29fd95e4df2d1168fe54c34c2a5c30c

Committed: https://skia.googlesource.com/skia/+/38a88e4c0c28a7be981aac7bb4a198ad95a62a63

Review URL: https://codereview.chromium.org/1422513003
2015-10-23 07:02:06 -07:00

73 lines
1.9 KiB
C++

/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkTime_DEFINED
#define SkTime_DEFINED
#include "SkTypes.h"
class SkString;
/** \class SkTime
Platform-implemented utilities to return time of day, and millisecond counter.
*/
class SkTime {
public:
struct DateTime {
int16_t fTimeZoneMinutes; // The number of minutes that GetDateTime()
// is ahead of or behind UTC.
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
void toISO8601(SkString* dst) const;
};
static void GetDateTime(DateTime*);
static SkMSec GetMSecs() { return (SkMSec)(GetNSecs() * 1e-6); }
static double GetNSecs();
};
#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;
};
#define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
#endif