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