OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ozone/platform/drm/gpu/drm_vsync_provider.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" |
8 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 9 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
9 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | 10 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" |
10 | 11 |
11 namespace ui { | 12 namespace ui { |
12 | 13 |
13 DrmVSyncProvider::DrmVSyncProvider(DrmWindow* window) : window_(window) { | 14 DrmVSyncProvider::DrmVSyncProvider(DrmWindow* window) : window_(window) { |
14 } | 15 } |
15 | 16 |
16 DrmVSyncProvider::~DrmVSyncProvider() { | 17 DrmVSyncProvider::~DrmVSyncProvider() { |
17 } | 18 } |
18 | 19 |
19 void DrmVSyncProvider::GetVSyncParameters(const UpdateVSyncCallback& callback) { | 20 void DrmVSyncProvider::GetVSyncParameters(const UpdateVSyncCallback& callback) { |
20 HardwareDisplayController* controller = window_->GetController(); | 21 HardwareDisplayController* controller = window_->GetController(); |
21 if (!controller) | 22 if (!controller) |
22 return; | 23 return; |
23 | 24 |
| 25 // If we're in mirror mode the 2 CRTCs should have similar modes with the same |
| 26 // refresh rates. |
| 27 CrtcController* crtc = controller->crtc_controllers()[0]; |
24 // The value is invalid, so we can't update the parameters. | 28 // The value is invalid, so we can't update the parameters. |
25 if (controller->GetTimeOfLastFlip() == 0 || | 29 if (controller->GetTimeOfLastFlip() == 0 || crtc->mode().vrefresh == 0) |
26 controller->get_mode().vrefresh == 0) | |
27 return; | 30 return; |
28 | 31 |
29 // Stores the time of the last refresh. | 32 // Stores the time of the last refresh. |
30 base::TimeTicks timebase = | 33 base::TimeTicks timebase = |
31 base::TimeTicks::FromInternalValue(controller->GetTimeOfLastFlip()); | 34 base::TimeTicks::FromInternalValue(controller->GetTimeOfLastFlip()); |
32 // Stores the refresh rate. | 35 // Stores the refresh rate. |
33 base::TimeDelta interval = | 36 base::TimeDelta interval = |
34 base::TimeDelta::FromSeconds(1) / controller->get_mode().vrefresh; | 37 base::TimeDelta::FromSeconds(1) / crtc->mode().vrefresh; |
35 | 38 |
36 callback.Run(timebase, interval); | 39 callback.Run(timebase, interval); |
37 } | 40 } |
38 | 41 |
39 } // namespace ui | 42 } // namespace ui |
OLD | NEW |