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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/animator/SkAnimator.h ('k') | include/core/SkTypes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTime.h
diff --git a/include/core/SkTime.h b/include/core/SkTime.h
index 3ff29aa25e1d2f70474975ae1af2a459e5b9564e..8a8224a82a564437c58c3a3b313e53e28cbdf985 100644
--- a/include/core/SkTime.h
+++ b/include/core/SkTime.h
@@ -34,34 +34,27 @@ public:
};
static void GetDateTime(DateTime*);
- static SkMSec GetMSecs() { return (SkMSec)(GetNSecs() * 1e-6); }
+ static double GetSecs() { return GetNSecs() * 1e-9; }
+ static double GetMSecs() { return GetNSecs() * 1e-6; }
static double GetNSecs();
};
-#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);
- }
+ SkAutoTime(const char* label = nullptr)
+ : fLabel(label)
+ , fNow(SkTime::GetMSecs()) {}
+ ~SkAutoTime() {
+ uint64_t dur = static_cast<uint64_t>(SkTime::GetMSecs() - fNow);
+ SkDebugf("%s %ld\n", fLabel ? fLabel : "", dur);
}
private:
const char* fLabel;
- SkMSec fNow;
- SkMSec fMinToDump;
+ double fNow;
};
#define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
« 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