gfx/skia/trunk/include/core/SkTime.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/core/SkTime.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,65 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2006 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#ifndef SkTime_DEFINED
    1.14 +#define SkTime_DEFINED
    1.15 +
    1.16 +#include "SkTypes.h"
    1.17 +
    1.18 +/** \class SkTime
    1.19 +    Platform-implemented utilities to return time of day, and millisecond counter.
    1.20 +*/
    1.21 +class SkTime {
    1.22 +public:
    1.23 +    struct DateTime {
    1.24 +        uint16_t fYear;          //!< e.g. 2005
    1.25 +        uint8_t  fMonth;         //!< 1..12
    1.26 +        uint8_t  fDayOfWeek;     //!< 0..6, 0==Sunday
    1.27 +        uint8_t  fDay;           //!< 1..31
    1.28 +        uint8_t  fHour;          //!< 0..23
    1.29 +        uint8_t  fMinute;        //!< 0..59
    1.30 +        uint8_t  fSecond;        //!< 0..59
    1.31 +    };
    1.32 +    static void GetDateTime(DateTime*);
    1.33 +
    1.34 +    static SkMSec GetMSecs();
    1.35 +};
    1.36 +
    1.37 +#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN32)
    1.38 +    extern SkMSec gForceTickCount;
    1.39 +#endif
    1.40 +
    1.41 +#define SK_TIME_FACTOR      1
    1.42 +
    1.43 +///////////////////////////////////////////////////////////////////////////////
    1.44 +
    1.45 +class SkAutoTime {
    1.46 +public:
    1.47 +    // The label is not deep-copied, so its address must remain valid for the
    1.48 +    // lifetime of this object
    1.49 +    SkAutoTime(const char* label = NULL, SkMSec minToDump = 0) : fLabel(label)
    1.50 +    {
    1.51 +        fNow = SkTime::GetMSecs();
    1.52 +        fMinToDump = minToDump;
    1.53 +    }
    1.54 +    ~SkAutoTime()
    1.55 +    {
    1.56 +        SkMSec dur = SkTime::GetMSecs() - fNow;
    1.57 +        if (dur >= fMinToDump) {
    1.58 +            SkDebugf("%s %d\n", fLabel ? fLabel : "", dur);
    1.59 +        }
    1.60 +    }
    1.61 +private:
    1.62 +    const char* fLabel;
    1.63 +    SkMSec      fNow;
    1.64 +    SkMSec      fMinToDump;
    1.65 +};
    1.66 +#define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
    1.67 +
    1.68 +#endif

mercurial