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

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: Elaborate comments and fix pointer formatting 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
« no previous file with comments | « base/time.h ('k') | ui/surface/accelerated_surface_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_));
jar (doing other things) 2012/07/30 21:31:52 nit: only use an indent of 4 beyond the start of t
+ }
+
private:
HighResNowSingleton()
: ticks_per_microsecond_(0.0),
jar (doing other things) 2012/07/30 21:31:52 nit: colon should be indent 4 characters from the
@@ -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);
jar (doing other things) 2012/07/30 21:31:52 nit: 4 character indent off start of "return"
+}
+
+// static
bool TimeTicks::IsHighResClockWorking() {
return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
}
+
+// TimeDelta ------------------------------------------------------------------
+
+// static
+TimeDelta TimeDelta::FromQPCValue(LONGLONG qpcValue) {
+ return HighResNowSingleton::GetInstance()->FromQPCValue(qpcValue);
+}
« no previous file with comments | « base/time.h ('k') | ui/surface/accelerated_surface_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698