Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: include/core/SkTime.h

Issue 1811613004: Change SkTime::GetMSecs to double; ensure values stored in SkMSec do not overflow. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Rebase. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/animator/SkAnimator.h ('k') | include/core/SkTypes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 uint8_t fDayOfWeek; //!< 0..6, 0==Sunday 27 uint8_t fDayOfWeek; //!< 0..6, 0==Sunday
28 uint8_t fDay; //!< 1..31 28 uint8_t fDay; //!< 1..31
29 uint8_t fHour; //!< 0..23 29 uint8_t fHour; //!< 0..23
30 uint8_t fMinute; //!< 0..59 30 uint8_t fMinute; //!< 0..59
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 double GetSecs() { return GetNSecs() * 1e-9; }
38 static double GetMSecs() { return GetNSecs() * 1e-6; }
38 static double GetNSecs(); 39 static double GetNSecs();
39 }; 40 };
40 41
41 #define SK_TIME_FACTOR 1
42
43 /////////////////////////////////////////////////////////////////////////////// 42 ///////////////////////////////////////////////////////////////////////////////
44 43
45 class SkAutoTime { 44 class SkAutoTime {
46 public: 45 public:
47 // The label is not deep-copied, so its address must remain valid for the 46 // The label is not deep-copied, so its address must remain valid for the
48 // lifetime of this object 47 // lifetime of this object
49 SkAutoTime(const char* label = NULL, SkMSec minToDump = 0) : fLabel(label) 48 SkAutoTime(const char* label = nullptr)
50 { 49 : fLabel(label)
51 fNow = SkTime::GetMSecs(); 50 , fNow(SkTime::GetMSecs()) {}
52 fMinToDump = minToDump; 51 ~SkAutoTime() {
53 } 52 uint64_t dur = static_cast<uint64_t>(SkTime::GetMSecs() - fNow);
54 ~SkAutoTime() 53 SkDebugf("%s %ld\n", fLabel ? fLabel : "", dur);
55 {
56 SkMSec dur = SkTime::GetMSecs() - fNow;
57 if (dur >= fMinToDump) {
58 SkDebugf("%s %d\n", fLabel ? fLabel : "", dur);
59 }
60 } 54 }
61 private: 55 private:
62 const char* fLabel; 56 const char* fLabel;
63 SkMSec fNow; 57 double fNow;
64 SkMSec fMinToDump;
65 }; 58 };
66 #define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime) 59 #define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
67 60
68 #endif 61 #endif
OLDNEW
« no previous file with comments | « include/animator/SkAnimator.h ('k') | include/core/SkTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698