OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/sync_control_vsync_provider.h" | 5 #include "ui/gl/sync_control_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 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 | 13 |
14 #if defined(OS_LINUX) | 14 #if defined(OS_LINUX) |
15 // These constants define a reasonable range for a calculated refresh interval. | 15 // These constants define a reasonable range for a calculated refresh interval. |
16 // Calculating refreshes out of this range will be considered a fatal error. | 16 // Calculating refreshes out of this range will be considered a fatal error. |
17 const int64_t kMinVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 400; | 17 const int64_t kMinVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 400; |
18 const int64_t kMaxVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 10; | 18 const int64_t kMaxVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 10; |
19 | 19 |
20 // How much noise we'll tolerate between successive computed intervals before | 20 // How much noise we'll tolerate between successive computed intervals before |
21 // we think the latest computed interval is invalid (noisey due to | 21 // we think the latest computed interval is invalid (noisey due to |
22 // monitor configuration change, moving a window between monitors, etc.). | 22 // monitor configuration change, moving a window between monitors, etc.). |
23 const double kRelativeIntervalDifferenceThreshold = 0.05; | 23 const double kRelativeIntervalDifferenceThreshold = 0.05; |
24 #endif | 24 #endif |
25 | 25 |
26 namespace gfx { | 26 namespace gl { |
27 | 27 |
28 SyncControlVSyncProvider::SyncControlVSyncProvider() : VSyncProvider() { | 28 SyncControlVSyncProvider::SyncControlVSyncProvider() : gfx::VSyncProvider() { |
29 #if defined(OS_LINUX) | 29 #if defined(OS_LINUX) |
30 // On platforms where we can't get an accurate reading on the refresh | 30 // On platforms where we can't get an accurate reading on the refresh |
31 // rate we fall back to the assumption that we're displaying 60 frames | 31 // rate we fall back to the assumption that we're displaying 60 frames |
32 // per second. | 32 // per second. |
33 last_good_interval_ = base::TimeDelta::FromSeconds(1) / 60; | 33 last_good_interval_ = base::TimeDelta::FromSeconds(1) / 60; |
34 #endif | 34 #endif |
35 } | 35 } |
36 | 36 |
37 SyncControlVSyncProvider::~SyncControlVSyncProvider() {} | 37 SyncControlVSyncProvider::~SyncControlVSyncProvider() {} |
38 | 38 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 last_timebase_ = timebase; | 155 last_timebase_ = timebase; |
156 last_media_stream_counter_ = media_stream_counter; | 156 last_media_stream_counter_ = media_stream_counter; |
157 callback.Run(timebase, last_good_interval_); | 157 callback.Run(timebase, last_good_interval_); |
158 #endif // defined(OS_LINUX) | 158 #endif // defined(OS_LINUX) |
159 } | 159 } |
160 | 160 |
161 } // namespace gfx | 161 } // namespace gl |
OLD | NEW |