| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "ui/gl/vsync_provider.h" | 5 #include "ui/gl/vsync_provider.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 | 11 |
| 12 namespace { | 12 #if defined(OS_LINUX) |
| 13 | |
| 14 // These constants define a reasonable range for a calculated refresh interval. | 13 // These constants define a reasonable range for a calculated refresh interval. |
| 15 // Calculating refreshes out of this range will be considered a fatal error. | 14 // Calculating refreshes out of this range will be considered a fatal error. |
| 16 const int64 kMinVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 400; | 15 const int64 kMinVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 400; |
| 17 const int64 kMaxVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 10; | 16 const int64 kMaxVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 10; |
| 18 | 17 |
| 19 // How much noise we'll tolerate between successive computed intervals before | 18 // How much noise we'll tolerate between successive computed intervals before |
| 20 // we think the latest computed interval is invalid (noisey due to | 19 // we think the latest computed interval is invalid (noisey due to |
| 21 // monitor configuration change, moving a window between monitors, etc.). | 20 // monitor configuration change, moving a window between monitors, etc.). |
| 22 const double kRelativeIntervalDifferenceThreshold = 0.05; | 21 const double kRelativeIntervalDifferenceThreshold = 0.05; |
| 23 | 22 #endif |
| 24 } // namespace | |
| 25 | 23 |
| 26 namespace gfx { | 24 namespace gfx { |
| 27 | 25 |
| 28 VSyncProvider::VSyncProvider() { | 26 VSyncProvider::VSyncProvider() { |
| 29 } | 27 } |
| 30 | 28 |
| 31 VSyncProvider::~VSyncProvider() { | 29 VSyncProvider::~VSyncProvider() { |
| 32 } | 30 } |
| 33 | 31 |
| 34 SyncControlVSyncProvider::SyncControlVSyncProvider() | 32 SyncControlVSyncProvider::SyncControlVSyncProvider() |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 150 } |
| 153 } | 151 } |
| 154 | 152 |
| 155 last_timebase_ = timebase; | 153 last_timebase_ = timebase; |
| 156 last_media_stream_counter_ = media_stream_counter; | 154 last_media_stream_counter_ = media_stream_counter; |
| 157 callback.Run(timebase, last_good_interval_); | 155 callback.Run(timebase, last_good_interval_); |
| 158 #endif // defined(OS_LINUX) | 156 #endif // defined(OS_LINUX) |
| 159 } | 157 } |
| 160 | 158 |
| 161 } // namespace gfx | 159 } // namespace gfx |
| OLD | NEW |