| 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/dri/dri_vsync_provider.h" | 5 #include "ui/ozone/platform/dri/dri_vsync_provider.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "ui/ozone/platform/dri/dri_window_delegate.h" |
| 8 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 9 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 9 | 10 |
| 10 namespace ui { | 11 namespace ui { |
| 11 | 12 |
| 12 DriVSyncProvider::DriVSyncProvider( | 13 DriVSyncProvider::DriVSyncProvider(DriWindowDelegate* window_delegate) |
| 13 const base::WeakPtr<HardwareDisplayController>& controller) | 14 : window_delegate_(window_delegate) { |
| 14 : controller_(controller) { | |
| 15 } | 15 } |
| 16 | 16 |
| 17 DriVSyncProvider::~DriVSyncProvider() {} | 17 DriVSyncProvider::~DriVSyncProvider() {} |
| 18 | 18 |
| 19 void DriVSyncProvider::GetVSyncParameters(const UpdateVSyncCallback& callback) { | 19 void DriVSyncProvider::GetVSyncParameters(const UpdateVSyncCallback& callback) { |
| 20 if (!controller_) | 20 HardwareDisplayController* controller = window_delegate_->GetController(); |
| 21 if (!controller) |
| 21 return; | 22 return; |
| 22 | 23 |
| 23 // The value is invalid, so we can't update the parameters. | 24 // The value is invalid, so we can't update the parameters. |
| 24 if (controller_->get_time_of_last_flip() == 0 || | 25 if (controller->get_time_of_last_flip() == 0 || |
| 25 controller_->get_mode().vrefresh == 0) | 26 controller->get_mode().vrefresh == 0) |
| 26 return; | 27 return; |
| 27 | 28 |
| 28 // Stores the time of the last refresh. | 29 // Stores the time of the last refresh. |
| 29 base::TimeTicks timebase = | 30 base::TimeTicks timebase = |
| 30 base::TimeTicks::FromInternalValue(controller_->get_time_of_last_flip()); | 31 base::TimeTicks::FromInternalValue(controller->get_time_of_last_flip()); |
| 31 // Stores the refresh rate. | 32 // Stores the refresh rate. |
| 32 base::TimeDelta interval = | 33 base::TimeDelta interval = |
| 33 base::TimeDelta::FromSeconds(1) / controller_->get_mode().vrefresh; | 34 base::TimeDelta::FromSeconds(1) / controller->get_mode().vrefresh; |
| 34 | 35 |
| 35 callback.Run(timebase, interval); | 36 callback.Run(timebase, interval); |
| 36 } | 37 } |
| 37 | 38 |
| 38 } // namespace ui | 39 } // namespace ui |
| OLD | NEW |