OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkTime_DEFINED | 10 #ifndef SkTime_DEFINED |
(...skipping 20 matching lines...) Expand all Loading... |
31 uint8_t fSecond; //!< 0..59 | 31 uint8_t fSecond; //!< 0..59 |
32 | 32 |
33 void toISO8601(SkString* dst) const; | 33 void toISO8601(SkString* dst) const; |
34 }; | 34 }; |
35 static void GetDateTime(DateTime*); | 35 static void GetDateTime(DateTime*); |
36 | 36 |
37 static SkMSec GetMSecs() { return (SkMSec)(GetNSecs() * 1e-6); } | 37 static SkMSec GetMSecs() { return (SkMSec)(GetNSecs() * 1e-6); } |
38 static double GetNSecs(); | 38 static double GetNSecs(); |
39 }; | 39 }; |
40 | 40 |
41 #if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN32) | |
42 extern SkMSec gForceTickCount; | |
43 #endif | |
44 | |
45 #define SK_TIME_FACTOR 1 | 41 #define SK_TIME_FACTOR 1 |
46 | 42 |
47 /////////////////////////////////////////////////////////////////////////////// | 43 /////////////////////////////////////////////////////////////////////////////// |
48 | 44 |
49 class SkAutoTime { | 45 class SkAutoTime { |
50 public: | 46 public: |
51 // The label is not deep-copied, so its address must remain valid for the | 47 // The label is not deep-copied, so its address must remain valid for the |
52 // lifetime of this object | 48 // lifetime of this object |
53 SkAutoTime(const char* label = NULL, SkMSec minToDump = 0) : fLabel(label) | 49 SkAutoTime(const char* label = NULL, SkMSec minToDump = 0) : fLabel(label) |
54 { | 50 { |
55 fNow = SkTime::GetMSecs(); | 51 fNow = SkTime::GetMSecs(); |
56 fMinToDump = minToDump; | 52 fMinToDump = minToDump; |
57 } | 53 } |
58 ~SkAutoTime() | 54 ~SkAutoTime() |
59 { | 55 { |
60 SkMSec dur = SkTime::GetMSecs() - fNow; | 56 SkMSec dur = SkTime::GetMSecs() - fNow; |
61 if (dur >= fMinToDump) { | 57 if (dur >= fMinToDump) { |
62 SkDebugf("%s %d\n", fLabel ? fLabel : "", dur); | 58 SkDebugf("%s %d\n", fLabel ? fLabel : "", dur); |
63 } | 59 } |
64 } | 60 } |
65 private: | 61 private: |
66 const char* fLabel; | 62 const char* fLabel; |
67 SkMSec fNow; | 63 SkMSec fNow; |
68 SkMSec fMinToDump; | 64 SkMSec fMinToDump; |
69 }; | 65 }; |
70 #define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime) | 66 #define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime) |
71 | 67 |
72 #endif | 68 #endif |
OLD | NEW |