michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkTime_DEFINED michael@0: #define SkTime_DEFINED michael@0: michael@0: #include "SkTypes.h" michael@0: michael@0: /** \class SkTime michael@0: Platform-implemented utilities to return time of day, and millisecond counter. michael@0: */ michael@0: class SkTime { michael@0: public: michael@0: struct DateTime { michael@0: uint16_t fYear; //!< e.g. 2005 michael@0: uint8_t fMonth; //!< 1..12 michael@0: uint8_t fDayOfWeek; //!< 0..6, 0==Sunday michael@0: uint8_t fDay; //!< 1..31 michael@0: uint8_t fHour; //!< 0..23 michael@0: uint8_t fMinute; //!< 0..59 michael@0: uint8_t fSecond; //!< 0..59 michael@0: }; michael@0: static void GetDateTime(DateTime*); michael@0: michael@0: static SkMSec GetMSecs(); michael@0: }; michael@0: michael@0: #if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN32) michael@0: extern SkMSec gForceTickCount; michael@0: #endif michael@0: michael@0: #define SK_TIME_FACTOR 1 michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: class SkAutoTime { michael@0: public: michael@0: // The label is not deep-copied, so its address must remain valid for the michael@0: // lifetime of this object michael@0: SkAutoTime(const char* label = NULL, SkMSec minToDump = 0) : fLabel(label) michael@0: { michael@0: fNow = SkTime::GetMSecs(); michael@0: fMinToDump = minToDump; michael@0: } michael@0: ~SkAutoTime() michael@0: { michael@0: SkMSec dur = SkTime::GetMSecs() - fNow; michael@0: if (dur >= fMinToDump) { michael@0: SkDebugf("%s %d\n", fLabel ? fLabel : "", dur); michael@0: } michael@0: } michael@0: private: michael@0: const char* fLabel; michael@0: SkMSec fNow; michael@0: SkMSec fMinToDump; michael@0: }; michael@0: #define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime) michael@0: michael@0: #endif