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