OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 // Windows Timer Primer | 6 // Windows Timer Primer |
7 // | 7 // |
8 // A good article: http://www.ddj.com/windows/184416651 | 8 // A good article: http://www.ddj.com/windows/184416651 |
9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 | 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 |
10 // | 10 // |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 high_resolution_timer_enabled_ = enable; | 175 high_resolution_timer_enabled_ = enable; |
176 } | 176 } |
177 | 177 |
178 // static | 178 // static |
179 bool Time::ActivateHighResolutionTimer(bool activating) { | 179 bool Time::ActivateHighResolutionTimer(bool activating) { |
180 if (!high_resolution_timer_enabled_ && activating) | 180 if (!high_resolution_timer_enabled_ && activating) |
181 return false; | 181 return false; |
182 | 182 |
183 // Using anything other than 1ms makes timers granular | 183 // Using anything other than 1ms makes timers granular |
184 // to that interval. | 184 // to that interval. |
185 const int kMinTimerIntervalMs = 1; | 185 const int kMinTimerIntervalMs = 4; |
186 MMRESULT result; | 186 MMRESULT result; |
187 if (activating) { | 187 if (activating) { |
188 result = timeBeginPeriod(kMinTimerIntervalMs); | 188 result = timeBeginPeriod(kMinTimerIntervalMs); |
189 high_resolution_timer_activated_++; | 189 high_resolution_timer_activated_++; |
190 } else { | 190 } else { |
191 result = timeEndPeriod(kMinTimerIntervalMs); | 191 result = timeEndPeriod(kMinTimerIntervalMs); |
192 high_resolution_timer_activated_--; | 192 high_resolution_timer_activated_--; |
193 } | 193 } |
194 return result == TIMERR_NOERROR; | 194 return result == TIMERR_NOERROR; |
195 } | 195 } |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 return TimeTicks() + TimeDelta::FromMilliseconds(timeGetTime()); | 527 return TimeTicks() + TimeDelta::FromMilliseconds(timeGetTime()); |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 // TimeDelta ------------------------------------------------------------------ | 531 // TimeDelta ------------------------------------------------------------------ |
532 | 532 |
533 // static | 533 // static |
534 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 534 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
535 return TimeDelta(GetHighResNowSingleton()->QPCValueToMicroseconds(qpc_value)); | 535 return TimeDelta(GetHighResNowSingleton()->QPCValueToMicroseconds(qpc_value)); |
536 } | 536 } |
OLD | NEW |