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 #ifndef UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_ | 5 #ifndef UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_ |
6 #define UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_ | 6 #define UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "ui/gfx/vsync_provider.h" | 13 #include "ui/gfx/vsync_provider.h" |
14 #include "ui/gl/gl_export.h" | |
15 | 14 |
16 namespace gl { | 15 namespace gl { |
17 | 16 |
18 // Base class for providers based on extensions like GLX_OML_sync_control and | 17 // Base class for providers based on extensions like GLX_OML_sync_control and |
19 // EGL_CHROMIUM_sync_control. | 18 // EGL_CHROMIUM_sync_control. |
20 class GL_EXPORT SyncControlVSyncProvider : public gfx::VSyncProvider { | 19 class SyncControlVSyncProvider : public gfx::VSyncProvider { |
21 public: | 20 public: |
22 SyncControlVSyncProvider(); | 21 SyncControlVSyncProvider(); |
23 ~SyncControlVSyncProvider() override; | 22 ~SyncControlVSyncProvider() override; |
24 | 23 |
25 void GetVSyncParameters(const UpdateVSyncCallback& callback) override; | 24 void GetVSyncParameters(const UpdateVSyncCallback& callback) override; |
26 | 25 |
27 protected: | 26 protected: |
28 virtual bool GetSyncValues(int64_t* system_time, | 27 virtual bool GetSyncValues(int64_t* system_time, |
29 int64_t* media_stream_counter, | 28 int64_t* media_stream_counter, |
30 int64_t* swap_buffer_counter) = 0; | 29 int64_t* swap_buffer_counter) = 0; |
31 | 30 |
32 virtual bool GetMscRate(int32_t* numerator, int32_t* denominator) = 0; | 31 virtual bool GetMscRate(int32_t* numerator, int32_t* denominator) = 0; |
33 | 32 |
34 private: | 33 private: |
35 #if defined(OS_LINUX) || defined(OS_WIN) | 34 #if defined(OS_LINUX) |
36 bool AdjustSyncValues(int64_t* system_time, int64_t* media_stream_counter); | |
37 | |
38 base::TimeTicks last_timebase_; | 35 base::TimeTicks last_timebase_; |
39 base::TimeDelta last_timebase_diff_; | 36 uint64_t last_media_stream_counter_ = 0; |
40 int64_t last_media_stream_counter_ = 0; | |
41 int64_t last_counter_diff_ = 0; | |
42 base::TimeDelta last_good_interval_; | 37 base::TimeDelta last_good_interval_; |
| 38 bool invalid_msc_ = false; |
43 | 39 |
44 // A short history of the last few computed intervals. | 40 // A short history of the last few computed intervals. |
45 // We use this to filter out the noise in the computation resulting | 41 // We use this to filter out the noise in the computation resulting |
46 // from configuration change (monitor reconfiguration, moving windows | 42 // from configuration change (monitor reconfiguration, moving windows |
47 // between monitors, suspend and resume, etc.). | 43 // between monitors, suspend and resume, etc.). |
48 std::queue<base::TimeDelta> last_computed_intervals_; | 44 std::queue<base::TimeDelta> last_computed_intervals_; |
49 #endif // defined(OS_LINUX) || defined(OS_WIN) | |
50 | |
51 #if defined(OS_LINUX) | |
52 bool invalid_msc_ = false; | |
53 #endif // defined(OS_LINUX) | 45 #endif // defined(OS_LINUX) |
54 | 46 |
55 DISALLOW_COPY_AND_ASSIGN(SyncControlVSyncProvider); | 47 DISALLOW_COPY_AND_ASSIGN(SyncControlVSyncProvider); |
56 }; | 48 }; |
57 | 49 |
58 } // namespace gl | 50 } // namespace gl |
59 | 51 |
60 #endif // UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_ | 52 #endif // UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_ |
OLD | NEW |