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

Unified Diff: base/time_win.cc

Issue 10825053: Use DwmGetCompositionTimingInfo to get vsync info on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change uint32_t to uint32 Created 8 years, 5 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
Index: base/time_win.cc
diff --git a/base/time_win.cc b/base/time_win.cc
index 71c914da29dabe75003d9e83172269d3ac72a717..0e1c67ed65143366361d464f1713fa20a2b67415 100644
--- a/base/time_win.cc
+++ b/base/time_win.cc
@@ -371,6 +371,11 @@ class HighResNowSingleton {
return abs(static_cast<long>((UnreliableNow() - ReliableNow()) - skew_));
}
+ TimeDelta FromQPCValue(LONGLONG qpcValue) {
+ return TimeDelta::FromMicroseconds(
+ static_cast<int64>(qpcValue / ticks_per_microsecond_));
+ }
+
private:
HighResNowSingleton()
: ticks_per_microsecond_(0.0),
@@ -389,8 +394,8 @@ class HighResNowSingleton {
LARGE_INTEGER ticks_per_sec = {0};
if (!QueryPerformanceFrequency(&ticks_per_sec))
return; // Broken, we don't guarantee this function works.
- ticks_per_microsecond_ = static_cast<float>(ticks_per_sec.QuadPart) /
- static_cast<float>(Time::kMicrosecondsPerSecond);
+ ticks_per_microsecond_ = static_cast<double>(ticks_per_sec.QuadPart) /
+ static_cast<double>(Time::kMicrosecondsPerSecond);
skew_ = UnreliableNow() - ReliableNow();
}
@@ -409,7 +414,7 @@ class HighResNowSingleton {
// Cached clock frequency -> microseconds. This assumes that the clock
// frequency is faster than one microsecond (which is 1MHz, should be OK).
- float ticks_per_microsecond_; // 0 indicates QPF failed and we're broken.
+ double ticks_per_microsecond_; // 0 indicates QPF failed and we're broken.
int64 skew_; // Skew between lo-res and hi-res clocks (for debugging).
friend struct DefaultSingletonTraits<HighResNowSingleton>;
@@ -446,6 +451,19 @@ int64 TimeTicks::GetQPCDriftMicroseconds() {
}
// static
+TimeTicks TimeTicks::FromQPCValue(LONGLONG qpcValue) {
+ return TimeTicks() +
+ HighResNowSingleton::GetInstance()->FromQPCValue(qpcValue);
+}
+
+// static
bool TimeTicks::IsHighResClockWorking() {
return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
}
+
+// TimeDelta ------------------------------------------------------------------
+
+// static
+TimeDelta TimeDelta::FromQPCValue(LONGLONG qpcValue) {
+ return HighResNowSingleton::GetInstance()->FromQPCValue(qpcValue);
+}

Powered by Google App Engine
This is Rietveld 408576698