Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / ozone / platform / drm / gpu / drm_vsync_provider.cc
blobe3c39252569aef74b263691e2f89151e886670ae
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.
5 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h"
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"
11 namespace ui {
13 DrmVSyncProvider::DrmVSyncProvider(DrmWindow* window) : window_(window) {
16 DrmVSyncProvider::~DrmVSyncProvider() {
19 void DrmVSyncProvider::GetVSyncParameters(const UpdateVSyncCallback& callback) {
20 HardwareDisplayController* controller = window_->GetController();
21 if (!controller)
22 return;
24 // The value is invalid, so we can't update the parameters.
25 if (controller->GetTimeOfLastFlip() == 0 ||
26 controller->get_mode().vrefresh == 0)
27 return;
29 // Stores the time of the last refresh.
30 base::TimeTicks timebase =
31 base::TimeTicks::FromInternalValue(controller->GetTimeOfLastFlip());
32 // Stores the refresh rate.
33 base::TimeDelta interval =
34 base::TimeDelta::FromSeconds(1) / controller->get_mode().vrefresh;
36 callback.Run(timebase, interval);
39 } // namespace ui